From 7afe6f52e4448d7523877f652e567542f02b974e Mon Sep 17 00:00:00 2001 From: The8472 Date: Wed, 3 Nov 2021 20:47:00 +0100 Subject: [PATCH 1/7] Make RawVec private to alloc RawVec was previously exposed for compiler-internal use (libarena specifically) in 1acbb0a9350560d951359cc359361b87992a6f2b Since it is unstable, doc-hidden and has no associated tracking issue it was never meant for public use. And since it is no longer used outside alloc itself it can be made private again. Also remove some functions that are dead due to lack of internal users. --- library/alloc/src/lib.rs | 3 +- library/alloc/src/raw_vec.rs | 61 +++--------------------------------- 2 files changed, 6 insertions(+), 58 deletions(-) diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 34d2cfc8e2c5b..2614c221042e5 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -173,6 +173,8 @@ extern crate test; #[macro_use] mod macros; +mod raw_vec; + // Heaps provided for low-level allocation strategies pub mod alloc; @@ -191,7 +193,6 @@ mod boxed { pub mod borrow; pub mod collections; pub mod fmt; -pub mod raw_vec; pub mod rc; pub mod slice; pub mod str; diff --git a/library/alloc/src/raw_vec.rs b/library/alloc/src/raw_vec.rs index 75dbd4678bb47..4ab38c802a159 100644 --- a/library/alloc/src/raw_vec.rs +++ b/library/alloc/src/raw_vec.rs @@ -1,5 +1,4 @@ -#![unstable(feature = "raw_vec_internals", reason = "implementation detail", issue = "none")] -#![doc(hidden)] +#![unstable(feature = "raw_vec_internals", reason = "unstable const warnings", issue = "none")] use core::alloc::LayoutError; use core::cmp; @@ -50,7 +49,7 @@ enum AllocInit { /// `usize::MAX`. This means that you need to be careful when round-tripping this type with a /// `Box<[T]>`, since `capacity()` won't yield the length. #[allow(missing_debug_implementations)] -pub struct RawVec { +pub(crate) struct RawVec { ptr: Unique, cap: usize, alloc: A, @@ -87,7 +86,7 @@ impl RawVec { /// # Aborts /// /// Aborts on OOM. - #[cfg(not(no_global_oom_handling))] + #[cfg(not(any(no_global_oom_handling, test)))] #[must_use] #[inline] pub fn with_capacity(capacity: usize) -> Self { @@ -95,25 +94,12 @@ impl RawVec { } /// Like `with_capacity`, but guarantees the buffer is zeroed. - #[cfg(not(no_global_oom_handling))] + #[cfg(not(any(no_global_oom_handling, test)))] #[must_use] #[inline] pub fn with_capacity_zeroed(capacity: usize) -> Self { Self::with_capacity_zeroed_in(capacity, Global) } - - /// Reconstitutes a `RawVec` from a pointer and capacity. - /// - /// # Safety - /// - /// The `ptr` must be allocated (on the system heap), and with the given `capacity`. - /// The `capacity` cannot exceed `isize::MAX` for sized types. (only a concern on 32-bit - /// systems). ZST vectors may have a capacity up to `usize::MAX`. - /// If the `ptr` and `capacity` come from a `RawVec`, then this is guaranteed. - #[inline] - pub unsafe fn from_raw_parts(ptr: *mut T, capacity: usize) -> Self { - unsafe { Self::from_raw_parts_in(ptr, capacity, Global) } - } } impl RawVec { @@ -154,14 +140,6 @@ impl RawVec { Self::allocate_in(capacity, AllocInit::Zeroed, alloc) } - /// Converts a `Box<[T]>` into a `RawVec`. - pub fn from_box(slice: Box<[T], A>) -> Self { - unsafe { - let (slice, alloc) = Box::into_raw_with_allocator(slice); - RawVec::from_raw_parts_in(slice.as_mut_ptr(), slice.len(), alloc) - } - } - /// Converts the entire buffer into `Box<[MaybeUninit]>` with the specified `len`. /// /// Note that this will correctly reconstitute any `cap` changes @@ -290,37 +268,6 @@ impl RawVec { /// # Aborts /// /// Aborts on OOM. - /// - /// # Examples - /// - /// ``` - /// # #![feature(raw_vec_internals)] - /// # extern crate alloc; - /// # use std::ptr; - /// # use alloc::raw_vec::RawVec; - /// struct MyVec { - /// buf: RawVec, - /// len: usize, - /// } - /// - /// impl MyVec { - /// pub fn push_all(&mut self, elems: &[T]) { - /// self.buf.reserve(self.len, elems.len()); - /// // reserve would have aborted or panicked if the len exceeded - /// // `isize::MAX` so this is safe to do unchecked now. - /// for x in elems { - /// unsafe { - /// ptr::write(self.buf.ptr().add(self.len), x.clone()); - /// } - /// self.len += 1; - /// } - /// } - /// } - /// # fn main() { - /// # let mut vector = MyVec { buf: RawVec::new(), len: 0 }; - /// # vector.push_all(&[1, 3, 5, 7, 9]); - /// # } - /// ``` #[cfg(not(no_global_oom_handling))] #[inline] pub fn reserve(&mut self, len: usize, additional: usize) { From 6234a5694936cb0f7c9a3fb456ae4c0aeee69f11 Mon Sep 17 00:00:00 2001 From: Augie Fackler Date: Thu, 4 Nov 2021 17:16:16 -0400 Subject: [PATCH 2/7] rustc_llvm: update PassWrapper for recent LLVM Now AddressSanitizerOptions is a struct, but at least the change was tiny. r? nikic --- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index ddbc3c5912836..94dce9f46fbc1 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -889,15 +889,18 @@ LLVMRustOptimizeWithNewPassManager( OptimizerLastEPCallbacks.push_back( [SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) { MPM.addPass(RequireAnalysisPass()); - MPM.addPass(ModuleAddressSanitizerPass( - /*CompileKernel=*/false, SanitizerOptions->SanitizeAddressRecover)); #if LLVM_VERSION_GE(14, 0) - AddressSanitizerOptions opts(/*CompileKernel=*/false, - SanitizerOptions->SanitizeAddressRecover, - /*UseAfterScope=*/true, - AsanDetectStackUseAfterReturnMode::Runtime); + AddressSanitizerOptions opts = AddressSanitizerOptions{ + /*CompileKernel=*/false, + SanitizerOptions->SanitizeAddressRecover, + /*UseAfterScope=*/false, + AsanDetectStackUseAfterReturnMode::Runtime, + }; + MPM.addPass(ModuleAddressSanitizerPass(opts)); MPM.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass(opts))); #else + MPM.addPass(ModuleAddressSanitizerPass( + /*CompileKernel=*/false, SanitizerOptions->SanitizeAddressRecover)); MPM.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass( /*CompileKernel=*/false, SanitizerOptions->SanitizeAddressRecover, /*UseAfterScope=*/true))); From d440ce6a9f6d8cfa532007add77754d956038407 Mon Sep 17 00:00:00 2001 From: Augie Fackler Date: Thu, 4 Nov 2021 18:08:32 -0400 Subject: [PATCH 3/7] Didn't mean to invert this boolean. --- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 94dce9f46fbc1..baeb17ed1cb6d 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -893,7 +893,7 @@ LLVMRustOptimizeWithNewPassManager( AddressSanitizerOptions opts = AddressSanitizerOptions{ /*CompileKernel=*/false, SanitizerOptions->SanitizeAddressRecover, - /*UseAfterScope=*/false, + /*UseAfterScope=*/true, AsanDetectStackUseAfterReturnMode::Runtime, }; MPM.addPass(ModuleAddressSanitizerPass(opts)); From 6f13bdbd7332ae586502ff141fa33c2b96dbc262 Mon Sep 17 00:00:00 2001 From: pierwill Date: Tue, 9 Nov 2021 10:58:11 -0600 Subject: [PATCH 4/7] Remove `rustc_incremental::persist::fs::dep_graph_path_from` --- compiler/rustc_incremental/src/persist/fs.rs | 3 --- compiler/rustc_incremental/src/persist/load.rs | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/compiler/rustc_incremental/src/persist/fs.rs b/compiler/rustc_incremental/src/persist/fs.rs index 38cbf5314ef31..c0137fc7a5ac8 100644 --- a/compiler/rustc_incremental/src/persist/fs.rs +++ b/compiler/rustc_incremental/src/persist/fs.rs @@ -139,9 +139,6 @@ pub fn dep_graph_path(sess: &Session) -> PathBuf { pub fn staging_dep_graph_path(sess: &Session) -> PathBuf { in_incr_comp_dir_sess(sess, STAGING_DEP_GRAPH_FILENAME) } -pub fn dep_graph_path_from(incr_comp_session_dir: &Path) -> PathBuf { - in_incr_comp_dir(incr_comp_session_dir, DEP_GRAPH_FILENAME) -} pub fn work_products_path(sess: &Session) -> PathBuf { in_incr_comp_dir_sess(sess, WORK_PRODUCTS_FILENAME) diff --git a/compiler/rustc_incremental/src/persist/load.rs b/compiler/rustc_incremental/src/persist/load.rs index 4d38556e5d214..5f5e83774dad8 100644 --- a/compiler/rustc_incremental/src/persist/load.rs +++ b/compiler/rustc_incremental/src/persist/load.rs @@ -105,7 +105,7 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture { // Calling `sess.incr_comp_session_dir()` will panic if `sess.opts.incremental.is_none()`. // Fortunately, we just checked that this isn't the case. - let path = dep_graph_path_from(&sess.incr_comp_session_dir()); + let path = dep_graph_path(&sess); let report_incremental_info = sess.opts.debugging_opts.incremental_info; let expected_hash = sess.opts.dep_tracking_hash(false); From fc9624c6738c57f32e6811ed93b3085415e61ccd Mon Sep 17 00:00:00 2001 From: Jimmy Envall Date: Wed, 10 Nov 2021 18:49:30 +0100 Subject: [PATCH 5/7] Fix trait object error code --- compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs | 2 +- src/test/ui/editions/dyn-trait-sugg-2021.stderr | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs index 93b2a59525972..aae59eee99142 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs @@ -952,7 +952,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut err = rustc_errors::struct_span_err!( self.sess(), self_ty.span, - E0783, + E0782, "{}", msg, ); diff --git a/src/test/ui/editions/dyn-trait-sugg-2021.stderr b/src/test/ui/editions/dyn-trait-sugg-2021.stderr index f6e9fa96a15b5..a7119b073abfa 100644 --- a/src/test/ui/editions/dyn-trait-sugg-2021.stderr +++ b/src/test/ui/editions/dyn-trait-sugg-2021.stderr @@ -1,4 +1,4 @@ -error[E0783]: trait objects without an explicit `dyn` are deprecated +error[E0782]: trait objects without an explicit `dyn` are deprecated --> $DIR/dyn-trait-sugg-2021.rs:10:5 | LL | Foo::hi(123); @@ -6,4 +6,4 @@ LL | Foo::hi(123); error: aborting due to previous error -For more information about this error, try `rustc --explain E0783`. +For more information about this error, try `rustc --explain E0782`. From 33663274934b356c352e0967e2a5b18fc3ee494e Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 8 Nov 2021 04:37:28 +0000 Subject: [PATCH 6/7] Change paths for `dist` command to match the components they generate Before, you could have the confusing situation where the command to generate a component had no relation to the name of that component (e.g. the `rustc` component was generated with `src/librustc`). This changes the name to make them match up. --- src/bootstrap/CHANGELOG.md | 1 + src/bootstrap/dist.rs | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/bootstrap/CHANGELOG.md b/src/bootstrap/CHANGELOG.md index 2f99e36aef219..2bc7ffb0c50c7 100644 --- a/src/bootstrap/CHANGELOG.md +++ b/src/bootstrap/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - `llvm-libunwind` now accepts `in-tree` (formerly true), `system` or `no` (formerly false) [#77703](https://github.com/rust-lang/rust/pull/77703) - The options `infodir`, `localstatedir`, and `gpg-password-file` are no longer allowed in config.toml. Previously, they were ignored without warning. Note that `infodir` and `localstatedir` are still accepted by `./configure`, with a warning. [#82451](https://github.com/rust-lang/rust/pull/82451) - Add options for enabling overflow checks, one for std (`overflow-checks-std`) and one for everything else (`overflow-checks`). Both default to false. +- Change the names for `dist` commmands to match the component they generate. [#90684](https://github.com/rust-lang/rust/pull/90684) ### Non-breaking changes diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index a799732adde9d..09ea84a083eb2 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -64,7 +64,7 @@ impl Step for Docs { fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let default = run.builder.config.docs; - run.path("src/doc").default_condition(default) + run.path("rust-docs").default_condition(default) } fn make_run(run: RunConfig<'_>) { @@ -275,7 +275,7 @@ impl Step for Mingw { const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.never() + run.path("rust-mingw") } fn make_run(run: RunConfig<'_>) { @@ -316,7 +316,7 @@ impl Step for Rustc { const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.path("src/librustc") + run.path("rustc") } fn make_run(run: RunConfig<'_>) { @@ -572,7 +572,7 @@ impl Step for Std { const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.path("library/std") + run.path("rust-std") } fn make_run(run: RunConfig<'_>) { @@ -686,7 +686,7 @@ impl Step for Analysis { fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let default = should_build_extended_tool(&run.builder, "analysis"); - run.path("analysis").default_condition(default) + run.path("rust-analysis").default_condition(default) } fn make_run(run: RunConfig<'_>) { @@ -821,7 +821,7 @@ impl Step for Src { const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.path("src") + run.path("rust-src") } fn make_run(run: RunConfig<'_>) { @@ -874,7 +874,7 @@ impl Step for PlainSourceTarball { fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let builder = run.builder; - run.path("src").default_condition(builder.config.rust_dist_src) + run.path("rustc-src").default_condition(builder.config.rust_dist_src) } fn make_run(run: RunConfig<'_>) { @@ -2120,7 +2120,7 @@ impl Step for BuildManifest { const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.path("src/tools/build-manifest") + run.path("build-manifest") } fn make_run(run: RunConfig<'_>) { @@ -2152,7 +2152,7 @@ impl Step for ReproducibleArtifacts { const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.path("reproducible") + run.path("reproducible-artifacts") } fn make_run(run: RunConfig<'_>) { From d9f2d5f0e9c55f440d043c3614b164d7c9fa70ce Mon Sep 17 00:00:00 2001 From: Krasimir Georgiev Date: Thu, 11 Nov 2021 09:03:23 -0500 Subject: [PATCH 7/7] PassWrapper: additional sanitizer update to match clang This happened later in the stream than the other changes, but the fix is overlapping. Fix taken from a55c4ec1cee7683d9095327d9d33e7137ec25292 in LLVM. --- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index baeb17ed1cb6d..4f77db8a24dc4 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -897,7 +897,6 @@ LLVMRustOptimizeWithNewPassManager( AsanDetectStackUseAfterReturnMode::Runtime, }; MPM.addPass(ModuleAddressSanitizerPass(opts)); - MPM.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass(opts))); #else MPM.addPass(ModuleAddressSanitizerPass( /*CompileKernel=*/false, SanitizerOptions->SanitizeAddressRecover));