Skip to content

Commit

Permalink
Auto merge of #67828 - JohnTitor:rollup-qmswkkl, r=JohnTitor
Browse files Browse the repository at this point in the history
Rollup of 10 pull requests

Successful merges:

 - #67450 (Allow for setting a ThinLTO import limit during bootstrap)
 - #67595 (Suggest adding a lifetime constraint for opaque type)
 - #67636 (allow rustfmt key in [build] section)
 - #67736 (Less-than is asymmetric, not antisymmetric)
 - #67762 (Add missing links for insecure_time)
 - #67783 (Warn for bindings named same as variants when matching against a borrow)
 - #67796 (Ensure that we process projections during MIR inlining)
 - #67807 (Use drop instead of the toilet closure `|_| ()`)
 - #67816 (Clean up err codes)
 - #67825 (Minor: change take() docs grammar to match other docs)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Jan 3, 2020
2 parents 4877e16 + 14c96ce commit 30ddb5a
Show file tree
Hide file tree
Showing 52 changed files with 269 additions and 68 deletions.
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

0 comments on commit 30ddb5a

Please sign in to comment.