Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 10 pull requests #67828

Merged
merged 28 commits into from
Jan 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b817a68
allow rustfmt key in [build] section
semarie Dec 27, 2019
98d8326
add comment for rustfmt in config.toml.example
semarie Dec 27, 2019
d4fbb55
Suggest adding a lifetime constraint when opaque type is responsible …
ohadravid Dec 24, 2019
d935a26
Less-than is asymmetric, not antisymmetric
taralx Dec 30, 2019
1a4f6b8
Change wording for lifetime suggestion for opaque types from `constra…
ohadravid Dec 25, 2019
0970f3d
Add missing links for insecure_time
tesuji Dec 31, 2019
4f63985
Warn for bindings named same as variants when matching against a borrow
LeSeulArtichaut Jan 1, 2020
f474c00
Added test
LeSeulArtichaut Jan 1, 2020
e8e53b5
Ensure that we process projections during MIR inlining
Aaron1011 Jan 2, 2020
dd8f072
Use drop instead of the toilet closure `|_| ()`
tesuji Jan 2, 2020
1b7c404
bootstrap: Allow for setting the ThinLTO import limit used for compil…
michaelwoerister Dec 20, 2019
6f57bad
Set a lower ThinLTO import limit for PR CI image.
michaelwoerister Dec 20, 2019
d202b59
Clean up E0130 error explanation
GuillaumeGomez Jan 2, 2020
3182805
Move test
LeSeulArtichaut Jan 2, 2020
dc19b48
Enhance test
LeSeulArtichaut Jan 2, 2020
5cc9f6b
Reformulate test description
LeSeulArtichaut Jan 2, 2020
8341a9a
Clean up E0131 error explanation
GuillaumeGomez Jan 2, 2020
4a48818
Minor: change take() docs grammar to match other docs
petertodd Jan 3, 2020
7c404ce
Rollup merge of #67450 - michaelwoerister:bootstrap-import-limit, r=M…
JohnTitor Jan 3, 2020
76c1454
Rollup merge of #67595 - ohadravid:impl-trait-does-not-live-long-enou…
JohnTitor Jan 3, 2020
9dd2c9e
Rollup merge of #67636 - semarie:bootstrap-rustfmt, r=Mark-Simulacrum
JohnTitor Jan 3, 2020
ed80f49
Rollup merge of #67736 - taralx:patch-1, r=sfackler
JohnTitor Jan 3, 2020
aefc3cd
Rollup merge of #67762 - lzutao:systemtime-links, r=joshtriplett
JohnTitor Jan 3, 2020
7affcd5
Rollup merge of #67783 - LeSeulArtichaut:pattern-ref-warning, r=Centril
JohnTitor Jan 3, 2020
09c7a9b
Rollup merge of #67796 - Aaron1011:fix/mir-inline-proj, r=wesleywiser
JohnTitor Jan 3, 2020
b0649c0
Rollup merge of #67807 - lzutao:toilet-closure, r=Centril
JohnTitor Jan 3, 2020
39a68a1
Rollup merge of #67816 - GuillaumeGomez:clean-up-err-codes, r=Dylan-DPC
JohnTitor Jan 3, 2020
14c96ce
Rollup merge of #67825 - petertodd:2020-mem-take-grammar, r=steveklabnik
JohnTitor Jan 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@
# specified, use this rustc binary instead as the stage0 snapshot compiler.
#rustc = "/path/to/bin/rustc"

# Instead of download the src/stage0.txt version of rustfmt specified,
# use this rustfmt binary instead as the stage0 snapshot rustfmt.
#rustfmt = "/path/to/bin/rustfmt"

# Flag to specify whether any documentation is built. If false, rustdoc and
# friends will still be compiled but they will not be used to generate any
# documentation.
Expand Down Expand Up @@ -406,6 +410,13 @@
# Whether to verify generated LLVM IR
#verify-llvm-ir = false

# Compile the compiler with a non-default ThinLTO import limit. This import
# limit controls the maximum size of functions imported by ThinLTO. Decreasing
# will make code compile faster at the expense of lower runtime performance.
# If `incremental` is set to true above, the import limit will default to 10
# instead of LLVM's default of 100.
#thin-lto-import-instr-limit = 100

# Map all debuginfo paths for libstd and crates to `/rust/$sha/$crate/...`,
# generally only set for releases
#remap-debuginfo = false
Expand Down
15 changes: 15 additions & 0 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,21 @@ impl<'a> Builder<'a> {
rustflags.arg("-Cprefer-dynamic");
}

// When building incrementally we default to a lower ThinLTO import limit
// (unless explicitly specified otherwise). This will produce a somewhat
// slower code but give way better compile times.
{
let limit = match self.config.rust_thin_lto_import_instr_limit {
Some(limit) => Some(limit),
None if self.config.incremental => Some(10),
_ => None,
};

if let Some(limit) = limit {
rustflags.arg(&format!("-Cllvm-args=-import-instr-limit={}", limit));
}
}

Cargo { command: cargo, rustflags }
}

Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ pub struct Config {
pub rust_dist_src: bool,
pub rust_codegen_backends: Vec<Interned<String>>,
pub rust_verify_llvm_ir: bool,
pub rust_thin_lto_import_instr_limit: Option<u32>,
pub rust_remap_debuginfo: bool,

pub build: Interned<String>,
Expand Down Expand Up @@ -202,6 +203,7 @@ struct Build {
target: Vec<String>,
cargo: Option<String>,
rustc: Option<String>,
rustfmt: Option<String>, /* allow bootstrap.py to use rustfmt key */
docs: Option<bool>,
compiler_docs: Option<bool>,
submodules: Option<bool>,
Expand Down Expand Up @@ -325,6 +327,7 @@ struct Rust {
deny_warnings: Option<bool>,
backtrace_on_ice: Option<bool>,
verify_llvm_ir: Option<bool>,
thin_lto_import_instr_limit: Option<u32>,
remap_debuginfo: Option<bool>,
jemalloc: Option<bool>,
test_compare_mode: Option<bool>,
Expand Down Expand Up @@ -569,6 +572,7 @@ impl Config {
set(&mut config.deny_warnings, flags.deny_warnings.or(rust.deny_warnings));
set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
set(&mut config.rust_verify_llvm_ir, rust.verify_llvm_ir);
config.rust_thin_lto_import_instr_limit = rust.thin_lto_import_instr_limit;
set(&mut config.rust_remap_debuginfo, rust.remap_debuginfo);

if let Some(ref backends) = rust.codegen_backends {
Expand Down
4 changes: 3 additions & 1 deletion src/ci/docker/x86_64-gnu-llvm-7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ RUN sh /scripts/sccache.sh
ENV RUST_CONFIGURE_ARGS \
--build=x86_64-unknown-linux-gnu \
--llvm-root=/usr/lib/llvm-7 \
--enable-llvm-link-shared
--enable-llvm-link-shared \
--set rust.thin-lto-import-instr-limit=10

ENV SCRIPT python2.7 ../x.py test src/tools/tidy && python2.7 ../x.py test

# The purpose of this container isn't to test with debug assertions and
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/tests/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ fn shared_from_iter_trustedlen_normal() {

// Try a ZST to make sure it is handled well.
{
let iter = (0..SHARED_ITER_MAX).map(|_| ());
let iter = (0..SHARED_ITER_MAX).map(drop);
let vec = iter.clone().collect::<Vec<_>>();
let rc = iter.collect::<Rc<[_]>>();
assert_eq!(&*vec, &*rc);
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/tests/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ fn shared_from_iter_trustedlen_normal() {

// Try a ZST to make sure it is handled well.
{
let iter = (0..SHARED_ITER_MAX).map(|_| ());
let iter = (0..SHARED_ITER_MAX).map(drop);
let vec = iter.clone().collect::<Vec<_>>();
let rc = iter.collect::<Rc<[_]>>();
assert_eq!(&*vec, &*rc);
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ impl<T: Ord> Ord for Reverse<T> {
///
/// An order is a total order if it is (for all `a`, `b` and `c`):
///
/// - total and antisymmetric: exactly one of `a < b`, `a == b` or `a > b` is true; and
/// - total and asymmetric: exactly one of `a < b`, `a == b` or `a > b` is true; and
/// - transitive, `a < b` and `b < c` implies `a < c`. The same must hold for both `==` and `>`.
///
/// ## Derivable
Expand Down Expand Up @@ -674,7 +674,7 @@ impl PartialOrd for Ordering {
///
/// The comparison must satisfy, for all `a`, `b` and `c`:
///
/// - antisymmetry: if `a < b` then `!(a > b)`, as well as `a > b` implying `!(a < b)`; and
/// - asymmetry: if `a < b` then `!(a > b)`, as well as `a > b` implying `!(a < b)`; and
/// - transitivity: `a < b` and `b < c` implies `a < c`. The same must hold for both `==` and `>`.
///
/// Note that these requirements mean that the trait itself must be implemented symmetrically and
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
}
}

/// Replace `dest` with the default value of `T`, and return the previous `dest` value.
/// Replaces `dest` with the default value of `T`, returning the previous `dest` value.
///
/// # Examples
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
err.span_suggestion(
fn_return_span,
&format!(
"you can add a constraint to the return type to make it last \
"you can add a bound to the return type to make it last \
less than `'static` and match {}",
lifetime,
),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_error_codes/error_codes/E0130.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
You declared a pattern as an argument in a foreign function declaration.
A pattern was declared as an argument in a foreign function declaration.

Erroneous code example:

Expand All @@ -9,7 +9,7 @@ extern {
}
```

Please replace the pattern argument with a regular one. Example:
To fix this error, replace the pattern argument with a regular one. Example:

```
struct SomeStruct {
Expand Down
7 changes: 5 additions & 2 deletions src/librustc_error_codes/error_codes/E0131.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
It is not possible to define `main` with generic parameters.
When `main` is present, it must take no arguments and return `()`.
The `main` function was defined with generic parameters.

Erroneous code example:

```compile_fail,E0131
fn main<T>() { // error: main function is not allowed to have generic parameters
}
```

It is not possible to define the `main` function with generic parameters.
It must not take any arguments.
43 changes: 42 additions & 1 deletion src/librustc_mir/borrow_check/diagnostics/explain_borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc::mir::{
use rustc::ty::adjustment::PointerCast;
use rustc::ty::{self, TyCtxt};
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::DiagnosticBuilder;
use rustc_errors::{Applicability, DiagnosticBuilder};
use rustc_index::vec::IndexVec;
use rustc_span::symbol::Symbol;
use rustc_span::Span;
Expand Down Expand Up @@ -206,6 +206,47 @@ impl BorrowExplanation {
),
);
};

self.add_lifetime_bound_suggestion_to_diagnostic(
tcx,
err,
&category,
span,
region_name,
);
}
_ => {}
}
}
pub(in crate::borrow_check) fn add_lifetime_bound_suggestion_to_diagnostic<'tcx>(
&self,
tcx: TyCtxt<'tcx>,
err: &mut DiagnosticBuilder<'_>,
category: &ConstraintCategory,
span: Span,
region_name: &RegionName,
) {
match category {
ConstraintCategory::OpaqueType => {
if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(span) {
let suggestable_name = if region_name.was_named() {
region_name.to_string()
} else {
"'_".to_string()
};

err.span_suggestion(
span,
&format!(
"you can add a bound to the {}to make it last less than \
`'static` and match `{}`",
category.description(),
region_name,
),
format!("{} + {}", snippet, suggestable_name),
Applicability::Unspecified,
);
}
}
_ => {}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
span,
&format!(
"to allow this `impl Trait` to capture borrowed data with lifetime \
`{}`, add `{}` as a constraint",
`{}`, add `{}` as a bound",
fr_name, suggestable_fr_name,
),
format!("{} + {}", snippet, suggestable_fr_name),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/hair/pattern/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ fn check_for_bindings_named_same_as_variants(cx: &MatchVisitor<'_, '_>, pat: &Pa
if let Some(ty::BindByValue(hir::Mutability::Not)) =
cx.tables.extract_binding_mode(cx.tcx.sess, p.hir_id, p.span)
{
let pat_ty = cx.tables.pat_ty(p);
let pat_ty = cx.tables.pat_ty(p).peel_refs();
if let ty::Adt(edef, _) = pat_ty.kind {
if edef.is_enum()
&& edef.variants.iter().any(|variant| {
Expand Down
12 changes: 4 additions & 8 deletions src/librustc_mir/transform/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,12 +671,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
*local = self.make_integrate_local(local);
}

fn visit_place(
&mut self,
place: &mut Place<'tcx>,
_context: PlaceContext,
_location: Location,
) {
fn visit_place(&mut self, place: &mut Place<'tcx>, context: PlaceContext, location: Location) {
match &mut place.base {
PlaceBase::Static(_) => {}
PlaceBase::Local(l) => {
Expand All @@ -689,10 +684,11 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {

place.projection = self.tcx.intern_place_elems(&*projs);
}

*l = self.make_integrate_local(l);
}
}
// Handles integrating any locals that occur in the base
// or projections
self.super_place(place, context, location)
}

fn process_projection_elem(&mut self, elem: &PlaceElem<'tcx>) -> Option<PlaceElem<'tcx>> {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_parse/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ impl<'a> Parser<'a> {
let appl = Applicability::MachineApplicable;
if self.token.span == DUMMY_SP || self.prev_span == DUMMY_SP {
// Likely inside a macro, can't provide meaninful suggestions.
return self.expect(&token::Semi).map(|_| ());
return self.expect(&token::Semi).map(drop);
} else if !sm.is_multiline(self.prev_span.until(self.token.span)) {
// The current token is in the same line as the prior token, not recoverable.
} else if self.look_ahead(1, |t| {
Expand Down Expand Up @@ -887,7 +887,7 @@ impl<'a> Parser<'a> {
.emit();
return Ok(());
}
self.expect(&token::Semi).map(|_| ()) // Error unconditionally
self.expect(&token::Semi).map(drop) // Error unconditionally
}

pub(super) fn parse_semi_or_incorrect_foreign_fn_body(
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/io/buffered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl<R: Seek> BufReader<R> {
}
}
}
self.seek(SeekFrom::Current(offset)).map(|_| ())
self.seek(SeekFrom::Current(offset)).map(drop)
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/libstd/sys/unix/android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ pub fn ftruncate64(fd: c_int, size: u64) -> io::Result<()> {

unsafe {
match ftruncate64.get() {
Some(f) => cvt_r(|| f(fd, size as i64)).map(|_| ()),
Some(f) => cvt_r(|| f(fd, size as i64)).map(drop),
None => {
if size > i32::max_value() as u64 {
Err(io::Error::new(io::ErrorKind::InvalidInput, "cannot truncate >2GB"))
} else {
cvt_r(|| ftruncate(fd, size as i32)).map(|_| ())
cvt_r(|| ftruncate(fd, size as i32)).map(drop)
}
}
}
Expand All @@ -107,7 +107,7 @@ pub fn ftruncate64(fd: c_int, size: u64) -> io::Result<()> {

#[cfg(target_pointer_width = "64")]
pub fn ftruncate64(fd: c_int, size: u64) -> io::Result<()> {
unsafe { cvt_r(|| ftruncate(fd, size as i64)).map(|_| ()) }
unsafe { cvt_r(|| ftruncate(fd, size as i64)).map(drop) }
}

#[cfg(target_pointer_width = "32")]
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ impl File {
use crate::convert::TryInto;
let size: off64_t =
size.try_into().map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))?;
cvt_r(|| unsafe { ftruncate64(self.0.raw(), size) }).map(|_| ())
cvt_r(|| unsafe { ftruncate64(self.0.raw(), size) }).map(drop)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/unix/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ impl Socket {

pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
let mut nonblocking = nonblocking as libc::c_int;
cvt(unsafe { libc::ioctl(*self.as_inner(), libc::FIONBIO, &mut nonblocking) }).map(|_| ())
cvt(unsafe { libc::ioctl(*self.as_inner(), libc::FIONBIO, &mut nonblocking) }).map(drop)
}

pub fn take_error(&self) -> io::Result<Option<io::Error>> {
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/sys/unix/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ pub fn setenv(k: &OsStr, v: &OsStr) -> io::Result<()> {

unsafe {
let _guard = env_lock();
cvt(libc::setenv(k.as_ptr(), v.as_ptr(), 1)).map(|_| ())
cvt(libc::setenv(k.as_ptr(), v.as_ptr(), 1)).map(drop)
}
}

Expand All @@ -538,7 +538,7 @@ pub fn unsetenv(n: &OsStr) -> io::Result<()> {

unsafe {
let _guard = env_lock();
cvt(libc::unsetenv(nbuf.as_ptr())).map(|_| ())
cvt(libc::unsetenv(nbuf.as_ptr())).map(drop)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/libstd/sys/unix/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ pub fn read2(p1: AnonPipe, v1: &mut Vec<u8>, p2: AnonPipe, v2: &mut Vec<u8>) ->

if fds[0].revents != 0 && read(&p1, v1)? {
p2.set_nonblocking(false)?;
return p2.read_to_end(v2).map(|_| ());
return p2.read_to_end(v2).map(drop);
}
if fds[1].revents != 0 && read(&p2, v2)? {
p1.set_nonblocking(false)?;
return p1.read_to_end(v1).map(|_| ());
return p1.read_to_end(v1).map(drop);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/unix/process/process_unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ impl Process {
"invalid argument: can't kill an exited process",
))
} else {
cvt(unsafe { libc::kill(self.pid, libc::SIGKILL) }).map(|_| ())
cvt(unsafe { libc::kill(self.pid, libc::SIGKILL) }).map(drop)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/vxworks/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ impl File {
}

pub fn truncate(&self, size: u64) -> io::Result<()> {
return cvt_r(|| unsafe { ftruncate(self.0.raw(), size as off_t) }).map(|_| ());
return cvt_r(|| unsafe { ftruncate(self.0.raw(), size as off_t) }).map(drop);
}

pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> {
Expand Down
Loading