Skip to content

Commit 30ddb5a

Browse files
committed
Auto merge of #67828 - JohnTitor:rollup-qmswkkl, r=JohnTitor
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
2 parents 4877e16 + 14c96ce commit 30ddb5a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+269
-68
lines changed

config.toml.example

+11
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@
138138
# specified, use this rustc binary instead as the stage0 snapshot compiler.
139139
#rustc = "/path/to/bin/rustc"
140140

141+
# Instead of download the src/stage0.txt version of rustfmt specified,
142+
# use this rustfmt binary instead as the stage0 snapshot rustfmt.
143+
#rustfmt = "/path/to/bin/rustfmt"
144+
141145
# Flag to specify whether any documentation is built. If false, rustdoc and
142146
# friends will still be compiled but they will not be used to generate any
143147
# documentation.
@@ -406,6 +410,13 @@
406410
# Whether to verify generated LLVM IR
407411
#verify-llvm-ir = false
408412

413+
# Compile the compiler with a non-default ThinLTO import limit. This import
414+
# limit controls the maximum size of functions imported by ThinLTO. Decreasing
415+
# will make code compile faster at the expense of lower runtime performance.
416+
# If `incremental` is set to true above, the import limit will default to 10
417+
# instead of LLVM's default of 100.
418+
#thin-lto-import-instr-limit = 100
419+
409420
# Map all debuginfo paths for libstd and crates to `/rust/$sha/$crate/...`,
410421
# generally only set for releases
411422
#remap-debuginfo = false

src/bootstrap/builder.rs

+15
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,21 @@ impl<'a> Builder<'a> {
11831183
rustflags.arg("-Cprefer-dynamic");
11841184
}
11851185

1186+
// When building incrementally we default to a lower ThinLTO import limit
1187+
// (unless explicitly specified otherwise). This will produce a somewhat
1188+
// slower code but give way better compile times.
1189+
{
1190+
let limit = match self.config.rust_thin_lto_import_instr_limit {
1191+
Some(limit) => Some(limit),
1192+
None if self.config.incremental => Some(10),
1193+
_ => None,
1194+
};
1195+
1196+
if let Some(limit) = limit {
1197+
rustflags.arg(&format!("-Cllvm-args=-import-instr-limit={}", limit));
1198+
}
1199+
}
1200+
11861201
Cargo { command: cargo, rustflags }
11871202
}
11881203

src/bootstrap/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ pub struct Config {
108108
pub rust_dist_src: bool,
109109
pub rust_codegen_backends: Vec<Interned<String>>,
110110
pub rust_verify_llvm_ir: bool,
111+
pub rust_thin_lto_import_instr_limit: Option<u32>,
111112
pub rust_remap_debuginfo: bool,
112113

113114
pub build: Interned<String>,
@@ -202,6 +203,7 @@ struct Build {
202203
target: Vec<String>,
203204
cargo: Option<String>,
204205
rustc: Option<String>,
206+
rustfmt: Option<String>, /* allow bootstrap.py to use rustfmt key */
205207
docs: Option<bool>,
206208
compiler_docs: Option<bool>,
207209
submodules: Option<bool>,
@@ -325,6 +327,7 @@ struct Rust {
325327
deny_warnings: Option<bool>,
326328
backtrace_on_ice: Option<bool>,
327329
verify_llvm_ir: Option<bool>,
330+
thin_lto_import_instr_limit: Option<u32>,
328331
remap_debuginfo: Option<bool>,
329332
jemalloc: Option<bool>,
330333
test_compare_mode: Option<bool>,
@@ -569,6 +572,7 @@ impl Config {
569572
set(&mut config.deny_warnings, flags.deny_warnings.or(rust.deny_warnings));
570573
set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
571574
set(&mut config.rust_verify_llvm_ir, rust.verify_llvm_ir);
575+
config.rust_thin_lto_import_instr_limit = rust.thin_lto_import_instr_limit;
572576
set(&mut config.rust_remap_debuginfo, rust.remap_debuginfo);
573577

574578
if let Some(ref backends) = rust.codegen_backends {

src/ci/docker/x86_64-gnu-llvm-7/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ RUN sh /scripts/sccache.sh
2525
ENV RUST_CONFIGURE_ARGS \
2626
--build=x86_64-unknown-linux-gnu \
2727
--llvm-root=/usr/lib/llvm-7 \
28-
--enable-llvm-link-shared
28+
--enable-llvm-link-shared \
29+
--set rust.thin-lto-import-instr-limit=10
30+
2931
ENV SCRIPT python2.7 ../x.py test src/tools/tidy && python2.7 ../x.py test
3032

3133
# The purpose of this container isn't to test with debug assertions and

src/liballoc/tests/arc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ fn shared_from_iter_trustedlen_normal() {
142142

143143
// Try a ZST to make sure it is handled well.
144144
{
145-
let iter = (0..SHARED_ITER_MAX).map(|_| ());
145+
let iter = (0..SHARED_ITER_MAX).map(drop);
146146
let vec = iter.clone().collect::<Vec<_>>();
147147
let rc = iter.collect::<Rc<[_]>>();
148148
assert_eq!(&*vec, &*rc);

src/liballoc/tests/rc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ fn shared_from_iter_trustedlen_normal() {
138138

139139
// Try a ZST to make sure it is handled well.
140140
{
141-
let iter = (0..SHARED_ITER_MAX).map(|_| ());
141+
let iter = (0..SHARED_ITER_MAX).map(drop);
142142
let vec = iter.clone().collect::<Vec<_>>();
143143
let rc = iter.collect::<Rc<[_]>>();
144144
assert_eq!(&*vec, &*rc);

src/libcore/cmp.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ impl<T: Ord> Ord for Reverse<T> {
495495
///
496496
/// An order is a total order if it is (for all `a`, `b` and `c`):
497497
///
498-
/// - total and antisymmetric: exactly one of `a < b`, `a == b` or `a > b` is true; and
498+
/// - total and asymmetric: exactly one of `a < b`, `a == b` or `a > b` is true; and
499499
/// - transitive, `a < b` and `b < c` implies `a < c`. The same must hold for both `==` and `>`.
500500
///
501501
/// ## Derivable
@@ -674,7 +674,7 @@ impl PartialOrd for Ordering {
674674
///
675675
/// The comparison must satisfy, for all `a`, `b` and `c`:
676676
///
677-
/// - antisymmetry: if `a < b` then `!(a > b)`, as well as `a > b` implying `!(a < b)`; and
677+
/// - asymmetry: if `a < b` then `!(a > b)`, as well as `a > b` implying `!(a < b)`; and
678678
/// - transitivity: `a < b` and `b < c` implies `a < c`. The same must hold for both `==` and `>`.
679679
///
680680
/// Note that these requirements mean that the trait itself must be implemented symmetrically and

src/libcore/mem/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
557557
}
558558
}
559559

560-
/// Replace `dest` with the default value of `T`, and return the previous `dest` value.
560+
/// Replaces `dest` with the default value of `T`, returning the previous `dest` value.
561561
///
562562
/// # Examples
563563
///

src/librustc/infer/error_reporting/nice_region_error/static_impl_trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
5454
err.span_suggestion(
5555
fn_return_span,
5656
&format!(
57-
"you can add a constraint to the return type to make it last \
57+
"you can add a bound to the return type to make it last \
5858
less than `'static` and match {}",
5959
lifetime,
6060
),

src/librustc_error_codes/error_codes/E0130.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
You declared a pattern as an argument in a foreign function declaration.
1+
A pattern was declared as an argument in a foreign function declaration.
22

33
Erroneous code example:
44

@@ -9,7 +9,7 @@ extern {
99
}
1010
```
1111

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

1414
```
1515
struct SomeStruct {
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
It is not possible to define `main` with generic parameters.
2-
When `main` is present, it must take no arguments and return `()`.
1+
The `main` function was defined with generic parameters.
2+
33
Erroneous code example:
44

55
```compile_fail,E0131
66
fn main<T>() { // error: main function is not allowed to have generic parameters
77
}
88
```
9+
10+
It is not possible to define the `main` function with generic parameters.
11+
It must not take any arguments.

src/librustc_mir/borrow_check/diagnostics/explain_borrow.rs

+42-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc::mir::{
99
use rustc::ty::adjustment::PointerCast;
1010
use rustc::ty::{self, TyCtxt};
1111
use rustc_data_structures::fx::FxHashSet;
12-
use rustc_errors::DiagnosticBuilder;
12+
use rustc_errors::{Applicability, DiagnosticBuilder};
1313
use rustc_index::vec::IndexVec;
1414
use rustc_span::symbol::Symbol;
1515
use rustc_span::Span;
@@ -206,6 +206,47 @@ impl BorrowExplanation {
206206
),
207207
);
208208
};
209+
210+
self.add_lifetime_bound_suggestion_to_diagnostic(
211+
tcx,
212+
err,
213+
&category,
214+
span,
215+
region_name,
216+
);
217+
}
218+
_ => {}
219+
}
220+
}
221+
pub(in crate::borrow_check) fn add_lifetime_bound_suggestion_to_diagnostic<'tcx>(
222+
&self,
223+
tcx: TyCtxt<'tcx>,
224+
err: &mut DiagnosticBuilder<'_>,
225+
category: &ConstraintCategory,
226+
span: Span,
227+
region_name: &RegionName,
228+
) {
229+
match category {
230+
ConstraintCategory::OpaqueType => {
231+
if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(span) {
232+
let suggestable_name = if region_name.was_named() {
233+
region_name.to_string()
234+
} else {
235+
"'_".to_string()
236+
};
237+
238+
err.span_suggestion(
239+
span,
240+
&format!(
241+
"you can add a bound to the {}to make it last less than \
242+
`'static` and match `{}`",
243+
category.description(),
244+
region_name,
245+
),
246+
format!("{} + {}", snippet, suggestable_name),
247+
Applicability::Unspecified,
248+
);
249+
}
209250
}
210251
_ => {}
211252
}

src/librustc_mir/borrow_check/diagnostics/region_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
815815
span,
816816
&format!(
817817
"to allow this `impl Trait` to capture borrowed data with lifetime \
818-
`{}`, add `{}` as a constraint",
818+
`{}`, add `{}` as a bound",
819819
fr_name, suggestable_fr_name,
820820
),
821821
format!("{} + {}", snippet, suggestable_fr_name),

src/librustc_mir/hair/pattern/check_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ fn check_for_bindings_named_same_as_variants(cx: &MatchVisitor<'_, '_>, pat: &Pa
284284
if let Some(ty::BindByValue(hir::Mutability::Not)) =
285285
cx.tables.extract_binding_mode(cx.tcx.sess, p.hir_id, p.span)
286286
{
287-
let pat_ty = cx.tables.pat_ty(p);
287+
let pat_ty = cx.tables.pat_ty(p).peel_refs();
288288
if let ty::Adt(edef, _) = pat_ty.kind {
289289
if edef.is_enum()
290290
&& edef.variants.iter().any(|variant| {

src/librustc_mir/transform/inline.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -671,12 +671,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
671671
*local = self.make_integrate_local(local);
672672
}
673673

674-
fn visit_place(
675-
&mut self,
676-
place: &mut Place<'tcx>,
677-
_context: PlaceContext,
678-
_location: Location,
679-
) {
674+
fn visit_place(&mut self, place: &mut Place<'tcx>, context: PlaceContext, location: Location) {
680675
match &mut place.base {
681676
PlaceBase::Static(_) => {}
682677
PlaceBase::Local(l) => {
@@ -689,10 +684,11 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
689684

690685
place.projection = self.tcx.intern_place_elems(&*projs);
691686
}
692-
693-
*l = self.make_integrate_local(l);
694687
}
695688
}
689+
// Handles integrating any locals that occur in the base
690+
// or projections
691+
self.super_place(place, context, location)
696692
}
697693

698694
fn process_projection_elem(&mut self, elem: &PlaceElem<'tcx>) -> Option<PlaceElem<'tcx>> {

src/librustc_parse/parser/diagnostics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ impl<'a> Parser<'a> {
848848
let appl = Applicability::MachineApplicable;
849849
if self.token.span == DUMMY_SP || self.prev_span == DUMMY_SP {
850850
// Likely inside a macro, can't provide meaninful suggestions.
851-
return self.expect(&token::Semi).map(|_| ());
851+
return self.expect(&token::Semi).map(drop);
852852
} else if !sm.is_multiline(self.prev_span.until(self.token.span)) {
853853
// The current token is in the same line as the prior token, not recoverable.
854854
} else if self.look_ahead(1, |t| {
@@ -887,7 +887,7 @@ impl<'a> Parser<'a> {
887887
.emit();
888888
return Ok(());
889889
}
890-
self.expect(&token::Semi).map(|_| ()) // Error unconditionally
890+
self.expect(&token::Semi).map(drop) // Error unconditionally
891891
}
892892

893893
pub(super) fn parse_semi_or_incorrect_foreign_fn_body(

src/libstd/io/buffered.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ impl<R: Seek> BufReader<R> {
232232
}
233233
}
234234
}
235-
self.seek(SeekFrom::Current(offset)).map(|_| ())
235+
self.seek(SeekFrom::Current(offset)).map(drop)
236236
}
237237
}
238238

src/libstd/sys/unix/android.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ pub fn ftruncate64(fd: c_int, size: u64) -> io::Result<()> {
9393

9494
unsafe {
9595
match ftruncate64.get() {
96-
Some(f) => cvt_r(|| f(fd, size as i64)).map(|_| ()),
96+
Some(f) => cvt_r(|| f(fd, size as i64)).map(drop),
9797
None => {
9898
if size > i32::max_value() as u64 {
9999
Err(io::Error::new(io::ErrorKind::InvalidInput, "cannot truncate >2GB"))
100100
} else {
101-
cvt_r(|| ftruncate(fd, size as i32)).map(|_| ())
101+
cvt_r(|| ftruncate(fd, size as i32)).map(drop)
102102
}
103103
}
104104
}
@@ -107,7 +107,7 @@ pub fn ftruncate64(fd: c_int, size: u64) -> io::Result<()> {
107107

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

113113
#[cfg(target_pointer_width = "32")]

src/libstd/sys/unix/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ impl File {
814814
use crate::convert::TryInto;
815815
let size: off64_t =
816816
size.try_into().map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))?;
817-
cvt_r(|| unsafe { ftruncate64(self.0.raw(), size) }).map(|_| ())
817+
cvt_r(|| unsafe { ftruncate64(self.0.raw(), size) }).map(drop)
818818
}
819819
}
820820

src/libstd/sys/unix/net.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ impl Socket {
324324

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

330330
pub fn take_error(&self) -> io::Result<Option<io::Error>> {

src/libstd/sys/unix/os.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ pub fn setenv(k: &OsStr, v: &OsStr) -> io::Result<()> {
529529

530530
unsafe {
531531
let _guard = env_lock();
532-
cvt(libc::setenv(k.as_ptr(), v.as_ptr(), 1)).map(|_| ())
532+
cvt(libc::setenv(k.as_ptr(), v.as_ptr(), 1)).map(drop)
533533
}
534534
}
535535

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

539539
unsafe {
540540
let _guard = env_lock();
541-
cvt(libc::unsetenv(nbuf.as_ptr())).map(|_| ())
541+
cvt(libc::unsetenv(nbuf.as_ptr())).map(drop)
542542
}
543543
}
544544

src/libstd/sys/unix/pipe.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ pub fn read2(p1: AnonPipe, v1: &mut Vec<u8>, p2: AnonPipe, v2: &mut Vec<u8>) ->
9999

100100
if fds[0].revents != 0 && read(&p1, v1)? {
101101
p2.set_nonblocking(false)?;
102-
return p2.read_to_end(v2).map(|_| ());
102+
return p2.read_to_end(v2).map(drop);
103103
}
104104
if fds[1].revents != 0 && read(&p2, v2)? {
105105
p1.set_nonblocking(false)?;
106-
return p1.read_to_end(v1).map(|_| ());
106+
return p1.read_to_end(v1).map(drop);
107107
}
108108
}
109109

src/libstd/sys/unix/process/process_unix.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ impl Process {
425425
"invalid argument: can't kill an exited process",
426426
))
427427
} else {
428-
cvt(unsafe { libc::kill(self.pid, libc::SIGKILL) }).map(|_| ())
428+
cvt(unsafe { libc::kill(self.pid, libc::SIGKILL) }).map(drop)
429429
}
430430
}
431431

src/libstd/sys/vxworks/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ impl File {
340340
}
341341

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

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

0 commit comments

Comments
 (0)