From 55ba9e4755eb47555417c311b867bce6196da462 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Tue, 29 Sep 2020 21:39:24 +0800 Subject: [PATCH 01/12] Reorder benches const variable Move LEN so it is is read in order. --- library/alloc/benches/vec.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/alloc/benches/vec.rs b/library/alloc/benches/vec.rs index 789ae3a20eabf..89893b6209c0a 100644 --- a/library/alloc/benches/vec.rs +++ b/library/alloc/benches/vec.rs @@ -570,6 +570,8 @@ fn bench_in_place_collect_droppable(b: &mut Bencher) { }) } +const LEN: usize = 16384; + #[bench] fn bench_chain_collect(b: &mut Bencher) { let data = black_box([0; LEN]); @@ -613,8 +615,6 @@ pub fn map_fast(l: &[(u32, u32)]) -> Vec { result } -const LEN: usize = 16384; - #[bench] fn bench_range_map_collect(b: &mut Bencher) { b.iter(|| (0..LEN).map(|_| u32::default()).collect::>()); From 096722ff7647c42fe221c0d99892a72e596b6a56 Mon Sep 17 00:00:00 2001 From: wcampbell Date: Tue, 13 Oct 2020 17:50:10 -0400 Subject: [PATCH 02/12] Refactor collapsible_if Signed-off-by: wcampbell --- library/std/src/f64.rs | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/library/std/src/f64.rs b/library/std/src/f64.rs index bd094bdb55dc3..2ecb0f44d001b 100644 --- a/library/std/src/f64.rs +++ b/library/std/src/f64.rs @@ -920,22 +920,20 @@ impl f64 { fn log_wrapper f64>(self, log_fn: F) -> f64 { if !cfg!(any(target_os = "solaris", target_os = "illumos")) { log_fn(self) - } else { - if self.is_finite() { - if self > 0.0 { - log_fn(self) - } else if self == 0.0 { - Self::NEG_INFINITY // log(0) = -Inf - } else { - Self::NAN // log(-n) = NaN - } - } else if self.is_nan() { - self // log(NaN) = NaN - } else if self > 0.0 { - self // log(Inf) = Inf + } else if self.is_finite() { + if self > 0.0 { + log_fn(self) + } else if self == 0.0 { + Self::NEG_INFINITY // log(0) = -Inf } else { - Self::NAN // log(-Inf) = NaN + Self::NAN // log(-n) = NaN } + } else if self.is_nan() { + self // log(NaN) = NaN + } else if self > 0.0 { + self // log(Inf) = Inf + } else { + Self::NAN // log(-Inf) = NaN } } } From fcec76bde4026afcb47ef814aeccfd8cc1f1b28f Mon Sep 17 00:00:00 2001 From: LingMan Date: Mon, 12 Oct 2020 23:51:35 +0200 Subject: [PATCH 03/12] Simplify a nested bool match Logically this first eliminates the innermost match by merging the patterns. Then, in a second step, turns the newly innermost match into a `matches!` call. --- compiler/rustc_ast_pretty/src/pprust/state.rs | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index 9aa066370bb5b..969ff522f6142 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -156,24 +156,13 @@ fn tt_prepend_space(tt: &TokenTree, prev: &TokenTree) -> bool { } } match tt { - TokenTree::Token(token) => match token.kind { - token::Comma => false, - _ => true, - }, - TokenTree::Delimited(_, DelimToken::Paren, _) => match prev { - TokenTree::Token(token) => match token.kind { - token::Ident(_, _) => false, - _ => true, - }, - _ => true, - }, - TokenTree::Delimited(_, DelimToken::Bracket, _) => match prev { - TokenTree::Token(token) => match token.kind { - token::Pound => false, - _ => true, - }, - _ => true, - }, + TokenTree::Token(token) => token.kind != token::Comma, + TokenTree::Delimited(_, DelimToken::Paren, _) => { + !matches!(prev, TokenTree::Token(Token { kind: token::Ident(..), .. })) + } + TokenTree::Delimited(_, DelimToken::Bracket, _) => { + !matches!(prev, TokenTree::Token(Token { kind: token::Pound, .. })) + } TokenTree::Delimited(..) => true, } } From 2661a4edb90773b22bab3af31fa12a25963c1b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Thu, 29 Oct 2020 00:00:00 +0000 Subject: [PATCH 04/12] Avoid BorrowMutError with RUSTC_LOG=debug $ touch empty.rs $ env RUSTC_LOG=debug rustc +stage1 --crate-type=lib empty.rs Fails with a `BorrowMutError` because source map files are already borrowed while `features_query` attempts to format a log message containing a span. Release the borrow before the query to avoid the issue. --- compiler/rustc_metadata/src/rmeta/encoder.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 7e33a479228ba..2a81737e168d4 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -2042,6 +2042,10 @@ fn encode_metadata_impl(tcx: TyCtxt<'_>) -> EncodedMetadata { encoder.emit_raw_bytes(&[0, 0, 0, 0]); let source_map_files = tcx.sess.source_map().files(); + let source_file_cache = (source_map_files[0].clone(), 0); + let required_source_files = Some(GrowableBitSet::with_capacity(source_map_files.len())); + drop(source_map_files); + let hygiene_ctxt = HygieneEncodeContext::default(); let mut ecx = EncodeContext { @@ -2052,13 +2056,12 @@ fn encode_metadata_impl(tcx: TyCtxt<'_>) -> EncodedMetadata { lazy_state: LazyState::NoNode, type_shorthands: Default::default(), predicate_shorthands: Default::default(), - source_file_cache: (source_map_files[0].clone(), 0), + source_file_cache, interpret_allocs: Default::default(), - required_source_files: Some(GrowableBitSet::with_capacity(source_map_files.len())), + required_source_files, is_proc_macro: tcx.sess.crate_types().contains(&CrateType::ProcMacro), hygiene_ctxt: &hygiene_ctxt, }; - drop(source_map_files); // Encode the rustc version string in a predictable location. rustc_version().encode(&mut ecx).unwrap(); From 79cc5099b1825dae5507e74a09b6f6eb913667c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Thu, 29 Oct 2020 00:00:00 +0000 Subject: [PATCH 05/12] Use RwLock instead of Lock for SourceMap::files --- compiler/rustc_data_structures/src/sync.rs | 2 +- compiler/rustc_span/src/source_map.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_data_structures/src/sync.rs b/compiler/rustc_data_structures/src/sync.rs index d22f3adfb016d..26706cd2b1b77 100644 --- a/compiler/rustc_data_structures/src/sync.rs +++ b/compiler/rustc_data_structures/src/sync.rs @@ -512,7 +512,7 @@ impl Clone for Lock { } } -#[derive(Debug)] +#[derive(Debug, Default)] pub struct RwLock(InnerRwLock); impl RwLock { diff --git a/compiler/rustc_span/src/source_map.rs b/compiler/rustc_span/src/source_map.rs index 3b929c4acb902..f067cdb730864 100644 --- a/compiler/rustc_span/src/source_map.rs +++ b/compiler/rustc_span/src/source_map.rs @@ -12,7 +12,7 @@ pub use crate::*; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::stable_hasher::StableHasher; -use rustc_data_structures::sync::{AtomicU32, Lock, LockGuard, Lrc, MappedLockGuard}; +use rustc_data_structures::sync::{AtomicU32, Lrc, MappedReadGuard, ReadGuard, RwLock}; use std::cmp; use std::convert::TryFrom; use std::hash::Hash; @@ -168,7 +168,7 @@ pub struct SourceMap { /// The address space below this value is currently used by the files in the source map. used_address_space: AtomicU32, - files: Lock, + files: RwLock, file_loader: Box, // This is used to apply the file path remapping as specified via // `--remap-path-prefix` to all `SourceFile`s allocated within this `SourceMap`. @@ -236,8 +236,8 @@ impl SourceMap { // By returning a `MonotonicVec`, we ensure that consumers cannot invalidate // any existing indices pointing into `files`. - pub fn files(&self) -> MappedLockGuard<'_, monotonic::MonotonicVec>> { - LockGuard::map(self.files.borrow(), |files| &mut files.source_files) + pub fn files(&self) -> MappedReadGuard<'_, monotonic::MonotonicVec>> { + ReadGuard::map(self.files.borrow(), |files| &files.source_files) } pub fn source_file_by_stable_id( From 4fc21689d8cfd43a9c5d8a682f54906d326eb5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Thu, 29 Oct 2020 00:00:00 +0000 Subject: [PATCH 06/12] Add support for rustc-env and unset-rustc-env for aux-builds --- src/tools/compiletest/src/runtest.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index d85558ea2f5f0..666e5d402ef1e 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1775,6 +1775,11 @@ impl<'test> TestCx<'test> { let mut aux_rustc = aux_cx.make_compile_args(input_file, aux_output, EmitMetadata::No, AllowUnused::No); + for key in &aux_props.unset_rustc_env { + aux_rustc.env_remove(key); + } + aux_rustc.envs(aux_props.rustc_env.clone()); + let (dylib, crate_type) = if aux_props.no_prefer_dynamic { (true, None) } else if self.config.target.contains("cloudabi") From a15e0dc4991a6c06dd5108d72163fb9809db2b07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Thu, 29 Oct 2020 00:00:00 +0000 Subject: [PATCH 07/12] Test building of libraries with rustc logging enabled --- src/test/ui/auxiliary/rustc-rust-log-aux.rs | 1 + src/test/ui/rustc-rust-log.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/auxiliary/rustc-rust-log-aux.rs diff --git a/src/test/ui/auxiliary/rustc-rust-log-aux.rs b/src/test/ui/auxiliary/rustc-rust-log-aux.rs new file mode 100644 index 0000000000000..daa8e9f495e06 --- /dev/null +++ b/src/test/ui/auxiliary/rustc-rust-log-aux.rs @@ -0,0 +1 @@ +// rustc-env:RUSTC_LOG=debug diff --git a/src/test/ui/rustc-rust-log.rs b/src/test/ui/rustc-rust-log.rs index 1c4252b23ea26..8ceb24dd2afd2 100644 --- a/src/test/ui/rustc-rust-log.rs +++ b/src/test/ui/rustc-rust-log.rs @@ -8,7 +8,7 @@ // dont-check-compiler-stdout // dont-check-compiler-stderr // compile-flags: --error-format human - +// aux-build: rustc-rust-log-aux.rs // rustc-env:RUSTC_LOG=debug fn main() {} From f9a26643ecd72cf75d0d5b87c40979816fdaef22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Thu, 29 Oct 2020 08:26:42 -0700 Subject: [PATCH 08/12] Revert invalid `fn` return type parsing change Fix #78507. --- compiler/rustc_parse/src/parser/item.rs | 17 ++++------------- src/test/ui/parser/issue-24780.rs | 4 ++-- src/test/ui/parser/issue-24780.stderr | 4 ++-- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 39d4875f37b1d..26492d92a77e9 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -1666,19 +1666,10 @@ impl<'a> Parser<'a> { req_name: ReqName, ret_allow_plus: AllowPlus, ) -> PResult<'a, P> { - let inputs = self.parse_fn_params(req_name)?; - let output = self.parse_ret_ty(ret_allow_plus, RecoverQPath::Yes)?; - - if let ast::FnRetTy::Ty(ty) = &output { - if let TyKind::Path(_, Path { segments, .. }) = &ty.kind { - if let [.., last] = &segments[..] { - // Detect and recover `fn foo() -> Vec> {}` - self.check_trailing_angle_brackets(last, &[&token::OpenDelim(token::Brace)]); - } - } - } - - Ok(P(FnDecl { inputs, output })) + Ok(P(FnDecl { + inputs: self.parse_fn_params(req_name)?, + output: self.parse_ret_ty(ret_allow_plus, RecoverQPath::Yes)?, + })) } /// Parses the parameter list of a function, including the `(` and `)` delimiters. diff --git a/src/test/ui/parser/issue-24780.rs b/src/test/ui/parser/issue-24780.rs index 20665b549d257..480d9bc2bade0 100644 --- a/src/test/ui/parser/issue-24780.rs +++ b/src/test/ui/parser/issue-24780.rs @@ -1,8 +1,8 @@ // Verify that '>' is not both expected and found at the same time, as it used // to happen in #24780. For example, following should be an error: -// expected one of ..., `>`, ... found `>`. No longer exactly this, but keeping for posterity. +// expected one of ..., `>`, ... found `>`. -fn foo() -> Vec> { //~ ERROR unmatched angle bracket +fn foo() -> Vec> { //~ ERROR expected one of `!`, `+`, `::`, `;`, `where`, or `{`, found `>` Vec::new() } diff --git a/src/test/ui/parser/issue-24780.stderr b/src/test/ui/parser/issue-24780.stderr index d12b13d35f8ad..bdd089bb7a139 100644 --- a/src/test/ui/parser/issue-24780.stderr +++ b/src/test/ui/parser/issue-24780.stderr @@ -1,8 +1,8 @@ -error: unmatched angle bracket +error: expected one of `!`, `+`, `::`, `;`, `where`, or `{`, found `>` --> $DIR/issue-24780.rs:5:23 | LL | fn foo() -> Vec> { - | ^^ help: remove extra angle bracket + | ^ expected one of `!`, `+`, `::`, `;`, `where`, or `{` error: aborting due to previous error From 9ae713057aa79c7f582bd9f7e6aac0032b6e2ea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Thu, 29 Oct 2020 08:32:13 -0700 Subject: [PATCH 09/12] Add regression test --- src/test/ui/parser/fn-returns-fn-pointer.rs | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/test/ui/parser/fn-returns-fn-pointer.rs diff --git a/src/test/ui/parser/fn-returns-fn-pointer.rs b/src/test/ui/parser/fn-returns-fn-pointer.rs new file mode 100644 index 0000000000000..15590e324861c --- /dev/null +++ b/src/test/ui/parser/fn-returns-fn-pointer.rs @@ -0,0 +1,6 @@ +// check-pass +// Regression test for #78507. +fn foo() -> Option Option> { + Some(|| Some(true)) +} +fn main() {} From 41ce3979902a1b1f02679b224b968c6c4cf12554 Mon Sep 17 00:00:00 2001 From: Jack Huey Date: Thu, 29 Oct 2020 18:42:31 -0400 Subject: [PATCH 10/12] Make anonymous binders start at 0 --- compiler/rustc_middle/src/ty/fold.rs | 5 +++-- compiler/rustc_symbol_mangling/src/v0.rs | 16 +++------------- .../rustc_typeck/src/check/generator_interior.rs | 3 ++- .../expect-fn-supply-fn.stderr | 4 ++-- .../expect-region-supply-region-2.stderr | 4 ++-- src/test/ui/issues/issue-10291.stderr | 2 +- src/test/ui/issues/issue-52533-1.stderr | 4 ++-- src/test/ui/issues/issue-52533.stderr | 4 ++-- src/test/ui/regions/regions-nested-fns.stderr | 6 +++--- .../ui/regions/regions-ret-borrowed-1.stderr | 2 +- src/test/ui/regions/regions-ret-borrowed.stderr | 2 +- ...fer-argument-types-two-region-pointers.stderr | 4 ++-- 12 files changed, 24 insertions(+), 32 deletions(-) diff --git a/compiler/rustc_middle/src/ty/fold.rs b/compiler/rustc_middle/src/ty/fold.rs index 0e5e22dcaae9f..13bf24bf8cffb 100644 --- a/compiler/rustc_middle/src/ty/fold.rs +++ b/compiler/rustc_middle/src/ty/fold.rs @@ -684,7 +684,7 @@ impl<'tcx> TyCtxt<'tcx> { } /// Rewrite any late-bound regions so that they are anonymous. Region numbers are - /// assigned starting at 1 and increasing monotonically in the order traversed + /// assigned starting at 0 and increasing monotonically in the order traversed /// by the fold operation. /// /// The chief purpose of this function is to canonicalize regions so that two @@ -698,8 +698,9 @@ impl<'tcx> TyCtxt<'tcx> { let mut counter = 0; Binder::bind( self.replace_late_bound_regions(sig, |_| { + let r = self.mk_region(ty::ReLateBound(ty::INNERMOST, ty::BrAnon(counter))); counter += 1; - self.mk_region(ty::ReLateBound(ty::INNERMOST, ty::BrAnon(counter))) + r }) .0, ) diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index 7833385cbc996..1ff043ae91ffb 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -200,15 +200,9 @@ impl SymbolMangler<'tcx> { let lifetimes = regions .into_iter() - .map(|br| { - match br { - ty::BrAnon(i) => { - // FIXME(eddyb) for some reason, `anonymize_late_bound_regions` starts at `1`. - assert_ne!(i, 0); - i - 1 - } - _ => bug!("symbol_names: non-anonymized region `{:?}` in `{:?}`", br, value), - } + .map(|br| match br { + ty::BrAnon(i) => i, + _ => bug!("symbol_names: non-anonymized region `{:?}` in `{:?}`", br, value), }) .max() .map_or(0, |max| max + 1); @@ -327,10 +321,6 @@ impl Printer<'tcx> for SymbolMangler<'tcx> { // Late-bound lifetimes use indices starting at 1, // see `BinderLevel` for more details. ty::ReLateBound(debruijn, ty::BrAnon(i)) => { - // FIXME(eddyb) for some reason, `anonymize_late_bound_regions` starts at `1`. - assert_ne!(i, 0); - let i = i - 1; - let binder = &self.binders[self.binders.len() - 1 - debruijn.index()]; let depth = binder.lifetime_depths.start + i; diff --git a/compiler/rustc_typeck/src/check/generator_interior.rs b/compiler/rustc_typeck/src/check/generator_interior.rs index 4473aa2081f23..5bd8ff6cde7bd 100644 --- a/compiler/rustc_typeck/src/check/generator_interior.rs +++ b/compiler/rustc_typeck/src/check/generator_interior.rs @@ -186,8 +186,9 @@ pub fn resolve_interior<'a, 'tcx>( // which means that none of the regions inside relate to any other, even if // typeck had previously found constraints that would cause them to be related. let folded = fcx.tcx.fold_regions(&erased, &mut false, |_, current_depth| { + let r = fcx.tcx.mk_region(ty::ReLateBound(current_depth, ty::BrAnon(counter))); counter += 1; - fcx.tcx.mk_region(ty::ReLateBound(current_depth, ty::BrAnon(counter))) + r }); cause.ty = folded; diff --git a/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr b/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr index 0de15dfa7357d..7a4ff77941052 100644 --- a/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr +++ b/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr @@ -6,7 +6,7 @@ LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); | = note: expected fn pointer `fn(&u32)` found fn pointer `fn(&'x u32)` -note: the anonymous lifetime #2 defined on the body at 16:48... +note: the anonymous lifetime #1 defined on the body at 16:48... --> $DIR/expect-fn-supply-fn.rs:16:48 | LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); @@ -30,7 +30,7 @@ note: the lifetime `'x` as defined on the function body at 13:36... | LL | fn expect_free_supply_free_from_fn<'x>(x: &'x u32) { | ^^ -note: ...does not necessarily outlive the anonymous lifetime #2 defined on the body at 16:48 +note: ...does not necessarily outlive the anonymous lifetime #1 defined on the body at 16:48 --> $DIR/expect-fn-supply-fn.rs:16:48 | LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); diff --git a/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.stderr b/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.stderr index 7f527904a69e5..07a67a6183462 100644 --- a/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.stderr +++ b/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.stderr @@ -6,7 +6,7 @@ LL | closure_expecting_bound(|x: &'x u32| { | = note: expected reference `&u32` found reference `&'x u32` -note: the anonymous lifetime #2 defined on the body at 14:29... +note: the anonymous lifetime #1 defined on the body at 14:29... --> $DIR/expect-region-supply-region-2.rs:14:29 | LL | closure_expecting_bound(|x: &'x u32| { @@ -37,7 +37,7 @@ note: the lifetime `'x` as defined on the function body at 9:30... | LL | fn expect_bound_supply_named<'x>() { | ^^ -note: ...does not necessarily outlive the anonymous lifetime #2 defined on the body at 14:29 +note: ...does not necessarily outlive the anonymous lifetime #1 defined on the body at 14:29 --> $DIR/expect-region-supply-region-2.rs:14:29 | LL | closure_expecting_bound(|x: &'x u32| { diff --git a/src/test/ui/issues/issue-10291.stderr b/src/test/ui/issues/issue-10291.stderr index 4fff4ee866c39..ff51aa3acf4d4 100644 --- a/src/test/ui/issues/issue-10291.stderr +++ b/src/test/ui/issues/issue-10291.stderr @@ -4,7 +4,7 @@ error[E0312]: lifetime of reference outlives lifetime of borrowed content... LL | x | ^ | -note: ...the reference is valid for the anonymous lifetime #2 defined on the body at 2:69... +note: ...the reference is valid for the anonymous lifetime #1 defined on the body at 2:69... --> $DIR/issue-10291.rs:2:69 | LL | drop:: FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { diff --git a/src/test/ui/issues/issue-52533-1.stderr b/src/test/ui/issues/issue-52533-1.stderr index dd37d3e559381..4247d551565c8 100644 --- a/src/test/ui/issues/issue-52533-1.stderr +++ b/src/test/ui/issues/issue-52533-1.stderr @@ -6,12 +6,12 @@ LL | gimme(|x, y| y) | = note: expected reference `&Foo<'_, '_, u32>` found reference `&Foo<'_, '_, u32>` -note: the anonymous lifetime #4 defined on the body at 9:11... +note: the anonymous lifetime #3 defined on the body at 9:11... --> $DIR/issue-52533-1.rs:9:11 | LL | gimme(|x, y| y) | ^^^^^^^^ -note: ...does not necessarily outlive the anonymous lifetime #3 defined on the body at 9:11 +note: ...does not necessarily outlive the anonymous lifetime #2 defined on the body at 9:11 --> $DIR/issue-52533-1.rs:9:11 | LL | gimme(|x, y| y) diff --git a/src/test/ui/issues/issue-52533.stderr b/src/test/ui/issues/issue-52533.stderr index 586548002072e..4e41620eecfdd 100644 --- a/src/test/ui/issues/issue-52533.stderr +++ b/src/test/ui/issues/issue-52533.stderr @@ -4,12 +4,12 @@ error[E0312]: lifetime of reference outlives lifetime of borrowed content... LL | foo(|a, b| b) | ^ | -note: ...the reference is valid for the anonymous lifetime #2 defined on the body at 5:9... +note: ...the reference is valid for the anonymous lifetime #1 defined on the body at 5:9... --> $DIR/issue-52533.rs:5:9 | LL | foo(|a, b| b) | ^^^^^^^^ -note: ...but the borrowed content is only valid for the anonymous lifetime #3 defined on the body at 5:9 +note: ...but the borrowed content is only valid for the anonymous lifetime #2 defined on the body at 5:9 --> $DIR/issue-52533.rs:5:9 | LL | foo(|a, b| b) diff --git a/src/test/ui/regions/regions-nested-fns.stderr b/src/test/ui/regions/regions-nested-fns.stderr index 9e405d83140d8..eeec0cc786267 100644 --- a/src/test/ui/regions/regions-nested-fns.stderr +++ b/src/test/ui/regions/regions-nested-fns.stderr @@ -4,7 +4,7 @@ error[E0495]: cannot infer an appropriate lifetime due to conflicting requiremen LL | let mut ay = &y; | ^^ | -note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 7:58... +note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the body at 7:58... --> $DIR/regions-nested-fns.rs:7:58 | LL | ignore:: FnMut(&'z isize)>>(Box::new(|z| { @@ -19,7 +19,7 @@ note: ...so that reference does not outlive borrowed content | LL | ay = z; | ^ -note: but, the lifetime must be valid for the anonymous lifetime #2 defined on the body at 13:72... +note: but, the lifetime must be valid for the anonymous lifetime #1 defined on the body at 13:72... --> $DIR/regions-nested-fns.rs:13:72 | LL | ignore::< Box FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { @@ -48,7 +48,7 @@ error[E0312]: lifetime of reference outlives lifetime of borrowed content... LL | if false { return x; } | ^ | -note: ...the reference is valid for the anonymous lifetime #2 defined on the body at 13:72... +note: ...the reference is valid for the anonymous lifetime #1 defined on the body at 13:72... --> $DIR/regions-nested-fns.rs:13:72 | LL | ignore::< Box FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { diff --git a/src/test/ui/regions/regions-ret-borrowed-1.stderr b/src/test/ui/regions/regions-ret-borrowed-1.stderr index 2c4769d8e3751..bba968cfde43c 100644 --- a/src/test/ui/regions/regions-ret-borrowed-1.stderr +++ b/src/test/ui/regions/regions-ret-borrowed-1.stderr @@ -4,7 +4,7 @@ error[E0495]: cannot infer an appropriate lifetime due to conflicting requiremen LL | with(|o| o) | ^ | -note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 10:10... +note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the body at 10:10... --> $DIR/regions-ret-borrowed-1.rs:10:10 | LL | with(|o| o) diff --git a/src/test/ui/regions/regions-ret-borrowed.stderr b/src/test/ui/regions/regions-ret-borrowed.stderr index da560107cea99..4b93ca0ae6734 100644 --- a/src/test/ui/regions/regions-ret-borrowed.stderr +++ b/src/test/ui/regions/regions-ret-borrowed.stderr @@ -4,7 +4,7 @@ error[E0495]: cannot infer an appropriate lifetime due to conflicting requiremen LL | with(|o| o) | ^ | -note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 13:10... +note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the body at 13:10... --> $DIR/regions-ret-borrowed.rs:13:10 | LL | with(|o| o) diff --git a/src/test/ui/unboxed-closures/unboxed-closures-infer-argument-types-two-region-pointers.stderr b/src/test/ui/unboxed-closures/unboxed-closures-infer-argument-types-two-region-pointers.stderr index 526055ba04b65..bd20fd26180cb 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-infer-argument-types-two-region-pointers.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-infer-argument-types-two-region-pointers.stderr @@ -4,7 +4,7 @@ error[E0312]: lifetime of reference outlives lifetime of borrowed content... LL | x.set(y); | ^ | -note: ...the reference is valid for the anonymous lifetime #3 defined on the body at 16:14... +note: ...the reference is valid for the anonymous lifetime #2 defined on the body at 16:14... --> $DIR/unboxed-closures-infer-argument-types-two-region-pointers.rs:16:14 | LL | doit(0, &|x, y| { @@ -12,7 +12,7 @@ LL | doit(0, &|x, y| { LL | | x.set(y); LL | | }); | |_____^ -note: ...but the borrowed content is only valid for the anonymous lifetime #4 defined on the body at 16:14 +note: ...but the borrowed content is only valid for the anonymous lifetime #3 defined on the body at 16:14 --> $DIR/unboxed-closures-infer-argument-types-two-region-pointers.rs:16:14 | LL | doit(0, &|x, y| { From fee4f8feb04385e743c55d61682176ae95f235ce Mon Sep 17 00:00:00 2001 From: Camelid Date: Thu, 29 Oct 2020 20:09:29 -0700 Subject: [PATCH 11/12] Improve wording of `core::ptr::drop_in_place` docs And two small intra-doc link conversions in `std::{f32, f64}`. --- library/core/src/ptr/mod.rs | 6 +++--- library/std/src/f32.rs | 2 +- library/std/src/f64.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index 39117b1890ef6..9de2758767e3e 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -99,9 +99,9 @@ mod mut_ptr; /// dropped normally. /// /// * It is friendlier to the optimizer to do this over [`ptr::read`] when -/// dropping manually allocated memory (e.g., when writing Box/Rc/Vec), -/// as the compiler doesn't need to prove that it's sound to elide the -/// copy. +/// dropping manually allocated memory (e.g., in the implementations of +/// `Box`/`Rc`/`Vec`), as the compiler doesn't need to prove that it's +/// sound to elide the copy. /// /// * It can be used to drop [pinned] data when `T` is not `repr(packed)` /// (pinned data must not be moved before it is dropped). diff --git a/library/std/src/f32.rs b/library/std/src/f32.rs index 59c2da5273bde..db6255de90634 100644 --- a/library/std/src/f32.rs +++ b/library/std/src/f32.rs @@ -1,7 +1,7 @@ //! This module provides constants which are specific to the implementation //! of the `f32` floating point data type. //! -//! *[See also the `f32` primitive type](../../std/primitive.f32.html).* +//! *[See also the `f32` primitive type](primitive@f32).* //! //! Mathematically significant numbers are provided in the `consts` sub-module. //! diff --git a/library/std/src/f64.rs b/library/std/src/f64.rs index bd094bdb55dc3..2c25ed9ead9aa 100644 --- a/library/std/src/f64.rs +++ b/library/std/src/f64.rs @@ -1,7 +1,7 @@ //! This module provides constants which are specific to the implementation //! of the `f64` floating point data type. //! -//! *[See also the `f64` primitive type](../../std/primitive.f64.html).* +//! *[See also the `f64` primitive type](primitive@f64).* //! //! Mathematically significant numbers are provided in the `consts` sub-module. //! From f558d96253648f0c07145c90d4f5244fa1ae56fd Mon Sep 17 00:00:00 2001 From: Camelid Date: Thu, 29 Oct 2020 23:05:45 -0700 Subject: [PATCH 12/12] Link to pass docs from NRVO module docs --- compiler/rustc_mir/src/transform/nrvo.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/rustc_mir/src/transform/nrvo.rs b/compiler/rustc_mir/src/transform/nrvo.rs index 7e05d66074bb1..45b906bf542d5 100644 --- a/compiler/rustc_mir/src/transform/nrvo.rs +++ b/compiler/rustc_mir/src/transform/nrvo.rs @@ -1,3 +1,5 @@ +//! See the docs for [`RenameReturnPlace`]. + use rustc_hir::Mutability; use rustc_index::bit_set::HybridBitSet; use rustc_middle::mir::visit::{MutVisitor, NonUseContext, PlaceContext, Visitor};