From aca631fb9b444fbce3e52a092289518363c0af50 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 8 Jan 2024 13:14:30 -0500 Subject: [PATCH 01/14] Increase visibility of `join_path` and `split_paths` Add some crosslinking among `std::env` pages. Also add aliases to help anyone searching for `PATH`. --- library/std/src/env.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/library/std/src/env.rs b/library/std/src/env.rs index 30ac0512348ca..e662b26316b75 100644 --- a/library/std/src/env.rs +++ b/library/std/src/env.rs @@ -258,6 +258,9 @@ fn _var(key: &OsStr) -> Result { /// None => println!("{key} is not defined in the environment.") /// } /// ``` +/// +/// If expecting a delimited variable (such as `PATH`), [`split_paths`] +/// can be used to separate items. #[must_use] #[stable(feature = "env", since = "1.0.0")] pub fn var_os>(key: K) -> Option { @@ -441,6 +444,16 @@ pub struct SplitPaths<'a> { /// Returns an iterator over the paths contained in `unparsed`. The iterator /// element type is [`PathBuf`]. /// +/// On most Unix platforms, the separator is `:` and on Windows it is `;`. This +/// also performs unquoting on Windows. +/// +/// [`join_paths`] can be used to recombine elements. +/// +/// # Panics +/// +/// This will panic on systems where theere is no delimited `PATH` variable, +/// such as UEFI. +/// /// # Examples /// /// ``` @@ -456,6 +469,7 @@ pub struct SplitPaths<'a> { /// None => println!("{key} is not defined in the environment.") /// } /// ``` +#[doc(alias = "PATH")] #[stable(feature = "env", since = "1.0.0")] pub fn split_paths + ?Sized>(unparsed: &T) -> SplitPaths<'_> { SplitPaths { inner: os_imp::split_paths(unparsed.as_ref()) } @@ -496,7 +510,8 @@ pub struct JoinPathsError { /// /// Returns an [`Err`] (containing an error message) if one of the input /// [`Path`]s contains an invalid character for constructing the `PATH` -/// variable (a double quote on Windows or a colon on Unix). +/// variable (a double quote on Windows or a colon on Unix), or if the system +/// does not have a `PATH`-like variable (e.g. UEFI or WASI). /// /// # Examples /// @@ -550,6 +565,7 @@ pub struct JoinPathsError { /// ``` /// /// [`env::split_paths()`]: split_paths +#[doc(alias = "PATH")] #[stable(feature = "env", since = "1.0.0")] pub fn join_paths(paths: I) -> Result where From 0de367748c41af843b4989d4039269ac2092c903 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sat, 10 Feb 2024 18:59:47 -0800 Subject: [PATCH 02/14] Fix typo Co-authored-by: Benjamin Peter <145429680+benjamin-nw@users.noreply.github.com> --- library/std/src/env.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/env.rs b/library/std/src/env.rs index e662b26316b75..a46ddfd949170 100644 --- a/library/std/src/env.rs +++ b/library/std/src/env.rs @@ -451,7 +451,7 @@ pub struct SplitPaths<'a> { /// /// # Panics /// -/// This will panic on systems where theere is no delimited `PATH` variable, +/// This will panic on systems where there is no delimited `PATH` variable, /// such as UEFI. /// /// # Examples From 5d59d0c7d725fe259b652bb9e9d17e6cbe1919af Mon Sep 17 00:00:00 2001 From: Peter Jaszkowiak Date: Tue, 23 Jan 2024 19:00:10 -0700 Subject: [PATCH 03/14] have `String` use `SliceIndex` impls from `str` --- library/alloc/src/lib.rs | 1 + library/alloc/src/string.rs | 102 +++++------------------------------- 2 files changed, 15 insertions(+), 88 deletions(-) diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 45e93feb6c5b3..28695ade5bf55 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -152,6 +152,7 @@ #![feature(set_ptr_value)] #![feature(sized_type_properties)] #![feature(slice_from_ptr_range)] +#![feature(slice_index_methods)] #![feature(slice_ptr_get)] #![feature(slice_ptr_len)] #![feature(slice_range)] diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 6dadbc8e36428..25991a91498f1 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -54,7 +54,7 @@ use core::ops::Add; use core::ops::AddAssign; #[cfg(not(no_global_oom_handling))] use core::ops::Bound::{Excluded, Included, Unbounded}; -use core::ops::{self, Index, IndexMut, Range, RangeBounds}; +use core::ops::{self, Range, RangeBounds}; use core::ptr; use core::slice; use core::str::pattern::Pattern; @@ -2433,100 +2433,26 @@ impl AddAssign<&str> for String { } #[stable(feature = "rust1", since = "1.0.0")] -impl ops::Index> for String { - type Output = str; +impl ops::Index for String +where + I: slice::SliceIndex, +{ + type Output = I::Output; #[inline] - fn index(&self, index: ops::Range) -> &str { - &self[..][index] + fn index(&self, index: I) -> &I::Output { + index.index(self.as_str()) } } -#[stable(feature = "rust1", since = "1.0.0")] -impl ops::Index> for String { - type Output = str; - #[inline] - fn index(&self, index: ops::RangeTo) -> &str { - &self[..][index] - } -} #[stable(feature = "rust1", since = "1.0.0")] -impl ops::Index> for String { - type Output = str; - - #[inline] - fn index(&self, index: ops::RangeFrom) -> &str { - &self[..][index] - } -} -#[stable(feature = "rust1", since = "1.0.0")] -impl ops::Index for String { - type Output = str; - - #[inline] - fn index(&self, _index: ops::RangeFull) -> &str { - unsafe { str::from_utf8_unchecked(&self.vec) } - } -} -#[stable(feature = "inclusive_range", since = "1.26.0")] -impl ops::Index> for String { - type Output = str; - - #[inline] - fn index(&self, index: ops::RangeInclusive) -> &str { - Index::index(&**self, index) - } -} -#[stable(feature = "inclusive_range", since = "1.26.0")] -impl ops::Index> for String { - type Output = str; - - #[inline] - fn index(&self, index: ops::RangeToInclusive) -> &str { - Index::index(&**self, index) - } -} - -#[stable(feature = "derefmut_for_string", since = "1.3.0")] -impl ops::IndexMut> for String { - #[inline] - fn index_mut(&mut self, index: ops::Range) -> &mut str { - &mut self[..][index] - } -} -#[stable(feature = "derefmut_for_string", since = "1.3.0")] -impl ops::IndexMut> for String { - #[inline] - fn index_mut(&mut self, index: ops::RangeTo) -> &mut str { - &mut self[..][index] - } -} -#[stable(feature = "derefmut_for_string", since = "1.3.0")] -impl ops::IndexMut> for String { - #[inline] - fn index_mut(&mut self, index: ops::RangeFrom) -> &mut str { - &mut self[..][index] - } -} -#[stable(feature = "derefmut_for_string", since = "1.3.0")] -impl ops::IndexMut for String { - #[inline] - fn index_mut(&mut self, _index: ops::RangeFull) -> &mut str { - unsafe { str::from_utf8_unchecked_mut(&mut *self.vec) } - } -} -#[stable(feature = "inclusive_range", since = "1.26.0")] -impl ops::IndexMut> for String { - #[inline] - fn index_mut(&mut self, index: ops::RangeInclusive) -> &mut str { - IndexMut::index_mut(&mut **self, index) - } -} -#[stable(feature = "inclusive_range", since = "1.26.0")] -impl ops::IndexMut> for String { +impl ops::IndexMut for String +where + I: slice::SliceIndex, +{ #[inline] - fn index_mut(&mut self, index: ops::RangeToInclusive) -> &mut str { - IndexMut::index_mut(&mut **self, index) + fn index_mut(&mut self, index: I) -> &mut I::Output { + index.index_mut(self.as_mut_str()) } } From 11f948952f6f268bc41ab10b7dd4c43624fd1774 Mon Sep 17 00:00:00 2001 From: surechen Date: Wed, 28 Feb 2024 22:45:43 +0800 Subject: [PATCH 04/14] Changing some attributes to only_local. Modified according to https://github.com/rust-lang/compiler-team/issues/505. --- compiler/rustc_feature/src/builtin_attrs.rs | 63 +++++++++++++++------ 1 file changed, 45 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 682363ed19d87..d423beade40c6 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -536,16 +536,19 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ ), gated!( rustc_allow_const_fn_unstable, Normal, - template!(Word, List: "feat1, feat2, ..."), DuplicatesOk, + template!(Word, List: "feat1, feat2, ..."), DuplicatesOk, @only_local: true, "rustc_allow_const_fn_unstable side-steps feature gating and stability checks" ), gated!( allow_internal_unsafe, Normal, template!(Word), WarnFollowing, - "allow_internal_unsafe side-steps the unsafe_code lint", + @only_local: true, "allow_internal_unsafe side-steps the unsafe_code lint", + ), + rustc_attr!( + rustc_allowed_through_unstable_modules, Normal, template!(Word), + WarnFollowing, @only_local: true, + "rustc_allowed_through_unstable_modules special cases accidental stabilizations of stable items \ + through unstable paths" ), - rustc_attr!(rustc_allowed_through_unstable_modules, Normal, template!(Word), WarnFollowing, - "rustc_allowed_through_unstable_modules special cases accidental stabilizations of stable items \ - through unstable paths"), // ========================================================================== // Internal attributes: Type system related: @@ -553,7 +556,8 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ gated!(fundamental, Normal, template!(Word), WarnFollowing, experimental!(fundamental)), gated!( - may_dangle, Normal, template!(Word), WarnFollowing, dropck_eyepatch, + may_dangle, Normal, template!(Word), WarnFollowing, + @only_local: true, dropck_eyepatch, "`may_dangle` has unstable semantics and may be removed in the future", ), @@ -561,31 +565,51 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ // Internal attributes: Runtime related: // ========================================================================== - rustc_attr!(rustc_allocator, Normal, template!(Word), WarnFollowing, IMPL_DETAIL), - rustc_attr!(rustc_nounwind, Normal, template!(Word), WarnFollowing, IMPL_DETAIL), - rustc_attr!(rustc_reallocator, Normal, template!(Word), WarnFollowing, IMPL_DETAIL), - rustc_attr!(rustc_deallocator, Normal, template!(Word), WarnFollowing, IMPL_DETAIL), - rustc_attr!(rustc_allocator_zeroed, Normal, template!(Word), WarnFollowing, IMPL_DETAIL), + rustc_attr!( + rustc_allocator, Normal, template!(Word), WarnFollowing, + @only_local: true, IMPL_DETAIL + ), + rustc_attr!( + rustc_nounwind, Normal, template!(Word), WarnFollowing, + @only_local: true, IMPL_DETAIL + ), + rustc_attr!( + rustc_reallocator, Normal, template!(Word), WarnFollowing, + @only_local: true, IMPL_DETAIL + ), + rustc_attr!( + rustc_deallocator, Normal, template!(Word), WarnFollowing, + @only_local: true, IMPL_DETAIL + ), + rustc_attr!( + rustc_allocator_zeroed, Normal, template!(Word), WarnFollowing, + @only_local: true, IMPL_DETAIL + ), + gated!( + default_lib_allocator, Normal, template!(Word), WarnFollowing, + @only_local: true, allocator_internals, experimental!(default_lib_allocator), + ), gated!( - default_lib_allocator, Normal, template!(Word), WarnFollowing, allocator_internals, - experimental!(default_lib_allocator), + needs_allocator, Normal, template!(Word), WarnFollowing, + @only_local: true, allocator_internals, experimental!(needs_allocator), ), gated!( - needs_allocator, Normal, template!(Word), WarnFollowing, allocator_internals, - experimental!(needs_allocator), + panic_runtime, Normal, template!(Word), WarnFollowing, + @only_local: true, experimental!(panic_runtime) ), - gated!(panic_runtime, Normal, template!(Word), WarnFollowing, experimental!(panic_runtime)), gated!( needs_panic_runtime, Normal, template!(Word), WarnFollowing, - experimental!(needs_panic_runtime) + @only_local: true, experimental!(needs_panic_runtime) ), gated!( compiler_builtins, Normal, template!(Word), WarnFollowing, + @only_local: true, "the `#[compiler_builtins]` attribute is used to identify the `compiler_builtins` crate \ which contains compiler-rt intrinsics and will never be stable", ), gated!( profiler_runtime, Normal, template!(Word), WarnFollowing, + @only_local: true, "the `#[profiler_runtime]` attribute is used to identify the `profiler_builtins` crate \ which contains the profiler runtime and will never be stable", ), @@ -611,7 +635,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ template!(Word, List: "name, /*opt*/ attributes(name1, name2, ...)"), ErrorFollowing, IMPL_DETAIL, ), - rustc_attr!(rustc_proc_macro_decls, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE), + rustc_attr!( + rustc_proc_macro_decls, Normal, template!(Word), WarnFollowing, + @only_local: true, INTERNAL_UNSTABLE + ), rustc_attr!( rustc_macro_transparency, Normal, template!(NameValueStr: "transparent|semitransparent|opaque"), ErrorFollowing, From 75e15f7cf4e55ed9572781930ee8babcaa256a47 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 28 Feb 2024 16:09:06 +0000 Subject: [PATCH 05/14] Deeply normalize obligations in refining_impl_trait --- .../src/check/compare_impl_item/refine.rs | 14 ++++++++----- .../src/traits/engine.rs | 9 +++++++++ .../impl-trait/in-trait/refine-normalize.rs | 20 +++++++++++++++++++ 3 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 tests/ui/impl-trait/in-trait/refine-normalize.rs diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs index b5e69b8e3766e..29dc434ab4532 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs @@ -136,11 +136,15 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>( // 1. Project the RPITIT projections from the trait to the opaques on the impl, // which means that they don't need to be mapped manually. // - // 2. Project any other projections that show up in the bound. That makes sure that - // we don't consider `tests/ui/async-await/in-trait/async-associated-types.rs` - // to be refining. - let (trait_bounds, impl_bounds) = - ocx.normalize(&ObligationCause::dummy(), param_env, (trait_bounds, impl_bounds)); + // 2. Deeply normalize any other projections that show up in the bound. That makes sure + // that we don't consider `tests/ui/async-await/in-trait/async-associated-types.rs` + // or `tests/ui/impl-trait/in-trait/refine-normalize.rs` to be refining. + let Ok((trait_bounds, impl_bounds)) = + ocx.deeply_normalize(&ObligationCause::dummy(), param_env, (trait_bounds, impl_bounds)) + else { + tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (selection)"); + return; + }; // Since we've normalized things, we need to resolve regions, since we'll // possibly have introduced region vars during projection. We don't expect diff --git a/compiler/rustc_trait_selection/src/traits/engine.rs b/compiler/rustc_trait_selection/src/traits/engine.rs index 1aaadf6cf044a..e789e9c2b6e16 100644 --- a/compiler/rustc_trait_selection/src/traits/engine.rs +++ b/compiler/rustc_trait_selection/src/traits/engine.rs @@ -107,6 +107,15 @@ impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> { self.register_infer_ok_obligations(infer_ok) } + pub fn deeply_normalize>>( + &self, + cause: &ObligationCause<'tcx>, + param_env: ty::ParamEnv<'tcx>, + value: T, + ) -> Result>> { + self.infcx.at(cause, param_env).deeply_normalize(value, &mut **self.engine.borrow_mut()) + } + /// Makes `expected <: actual`. pub fn eq_exp( &self, diff --git a/tests/ui/impl-trait/in-trait/refine-normalize.rs b/tests/ui/impl-trait/in-trait/refine-normalize.rs new file mode 100644 index 0000000000000..95f2cda6a7495 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/refine-normalize.rs @@ -0,0 +1,20 @@ +//@ check-pass +//@ edition: 2021 +//@ revisions: current next +//@[next] compile-flags: -Znext-solver + +#![deny(refining_impl_trait)] + +pub trait Foo { + type Item; + + fn hello() -> impl Iterator; +} + +impl Foo for () { + type Item = (); + + fn hello() -> impl Iterator { [()].into_iter() } +} + +fn main() {} From 55129453c6cfed8884e58be1f7435d4e35a77f0d Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Wed, 28 Feb 2024 14:56:36 -0800 Subject: [PATCH 06/14] Implement unwind safety for Condvar Closes #118009 This commit adds unwind safety to Condvar. Previously, only select platforms implemented unwind safety through auto traits. Known by this committer: Linux was unwind safe, but Mac and Windows are not before this change. --- library/std/src/panic.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/std/src/panic.rs b/library/std/src/panic.rs index 3728d5b64b865..3d576af681e03 100644 --- a/library/std/src/panic.rs +++ b/library/std/src/panic.rs @@ -6,7 +6,7 @@ use crate::any::Any; use crate::collections; use crate::panicking; use crate::sync::atomic::{AtomicU8, Ordering}; -use crate::sync::{Mutex, RwLock}; +use crate::sync::{Condvar, Mutex, RwLock}; use crate::thread::Result; #[doc(hidden)] @@ -67,11 +67,15 @@ pub fn panic_any(msg: M) -> ! { impl UnwindSafe for Mutex {} #[stable(feature = "catch_unwind", since = "1.9.0")] impl UnwindSafe for RwLock {} +#[stable(feature = "catch_unwind", since = "1.9.0")] +impl UnwindSafe for Condvar {} #[stable(feature = "unwind_safe_lock_refs", since = "1.12.0")] impl RefUnwindSafe for Mutex {} #[stable(feature = "unwind_safe_lock_refs", since = "1.12.0")] impl RefUnwindSafe for RwLock {} +#[stable(feature = "unwind_safe_lock_refs", since = "1.12.0")] +impl RefUnwindSafe for Condvar {} // https://github.com/rust-lang/rust/issues/62301 #[stable(feature = "hashbrown", since = "1.36.0")] From 3fbdec4937a95a5af04186a799dc3b07840a4599 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 28 Feb 2024 08:48:19 +1100 Subject: [PATCH 07/14] Add a comment about how `IntoDiagnostic` should be impl'd. --- compiler/rustc_errors/src/diagnostic.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 01f36ad6a7866..0cf519d2029f4 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -108,6 +108,25 @@ impl EmissionGuarantee for rustc_span::fatal_error::FatalError { /// Trait implemented by error types. This is rarely implemented manually. Instead, use /// `#[derive(Diagnostic)]` -- see [rustc_macros::Diagnostic]. +/// +/// When implemented manually, it should be generic over the emission +/// guarantee, i.e.: +/// ```ignore (fragment) +/// impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for Foo { ... } +/// ``` +/// rather than being specific: +/// ```ignore (fragment) +/// impl<'a> IntoDiagnostic<'a> for Bar { ... } // the default type param is `ErrorGuaranteed` +/// impl<'a> IntoDiagnostic<'a, ()> for Baz { ... } +/// ``` +/// There are two reasons for this. +/// - A diagnostic like `Foo` *could* be emitted at any level -- `level` is +/// passed in to `into_diagnostic` from outside. Even if in practice it is +/// always emitted at a single level, we let the diagnostic creation/emission +/// site determine the level (by using `create_err`, `emit_warn`, etc.) +/// rather than the `IntoDiagnostic` impl. +/// - Derived impls are always generic, and it's good for the hand-written +/// impls to be consistent with them. #[rustc_diagnostic_item = "IntoDiagnostic"] pub trait IntoDiagnostic<'a, G: EmissionGuarantee = ErrorGuaranteed> { /// Write out as a diagnostic out of `DiagCtxt`. From 199be469ec37b30c876069762e20f531f1f12f22 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 28 Feb 2024 09:43:23 +1100 Subject: [PATCH 08/14] Refactor `DiagCtxtInner::flush_delayed`. This commit: - Moves the ICE file create/open outside the loop. (Redoing it on every loop iteration works, but is really weird.) - Moves the explanatory note emission above the loop, which removes the need for the `enumerate` call. - Introduces a `decorate` local. --- compiler/rustc_errors/src/lib.rs | 42 ++++++++++++++++---------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index bc338b01d8bb6..2652feff62a45 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -1498,14 +1498,26 @@ impl DiagCtxtInner { let bugs: Vec<_> = std::mem::take(&mut self.delayed_bugs).into_iter().map(|(b, _)| b).collect(); - // If backtraces are enabled, also print the query stack let backtrace = std::env::var_os("RUST_BACKTRACE").map_or(true, |x| &x != "0"); - for (i, bug) in bugs.into_iter().enumerate() { - if let Some(file) = self.ice_file.as_ref() - && let Ok(mut out) = std::fs::File::options().create(true).append(true).open(file) - { - let _ = write!( - &mut out, + let decorate = backtrace || self.ice_file.is_none(); + let mut out = self + .ice_file + .as_ref() + .and_then(|file| std::fs::File::options().create(true).append(true).open(file).ok()); + + // Put the overall explanation before the `DelayedBug`s, to frame them + // better (e.g. separate warnings from them). Also, use notes, which + // don't count as errors, to avoid possibly triggering + // `-Ztreat-err-as-bug`, which we don't want. + let note1 = "no errors encountered even though delayed bugs were created"; + let note2 = "those delayed bugs will now be shown as internal compiler errors"; + self.emit_diagnostic(DiagInner::new(Note, note1)); + self.emit_diagnostic(DiagInner::new(Note, note2)); + + for bug in bugs { + if let Some(out) = &mut out { + _ = write!( + out, "delayed bug: {}\n{}\n", bug.inner .messages @@ -1516,21 +1528,9 @@ impl DiagCtxtInner { ); } - if i == 0 { - // Put the overall explanation before the `DelayedBug`s, to - // frame them better (e.g. separate warnings from them). Also, - // make it a note so it doesn't count as an error, because that - // could trigger `-Ztreat-err-as-bug`, which we don't want. - let note1 = "no errors encountered even though delayed bugs were created"; - let note2 = "those delayed bugs will now be shown as internal compiler errors"; - self.emit_diagnostic(DiagInner::new(Note, note1)); - self.emit_diagnostic(DiagInner::new(Note, note2)); - } - - let mut bug = - if backtrace || self.ice_file.is_none() { bug.decorate(self) } else { bug.inner }; + let mut bug = if decorate { bug.decorate(self) } else { bug.inner }; - // "Undelay" the delayed bugs (into plain `Bug`s). + // "Undelay" the delayed bugs into plain bugs. if bug.level != DelayedBug { // NOTE(eddyb) not panicking here because we're already producing // an ICE, and the more information the merrier. From 9dfe5ef8b5496f5749223ef127d701563af4fe30 Mon Sep 17 00:00:00 2001 From: sisungo Date: Thu, 29 Feb 2024 13:16:24 +0800 Subject: [PATCH 09/14] Fix typo in `rustc_passes/messages.ftl` Line 190 contains unpaired parentheses. --- compiler/rustc_passes/messages.ftl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_passes/messages.ftl b/compiler/rustc_passes/messages.ftl index 648ef9d51deaa..c223b8475288b 100644 --- a/compiler/rustc_passes/messages.ftl +++ b/compiler/rustc_passes/messages.ftl @@ -187,7 +187,7 @@ passes_doc_attr_not_crate_level = `#![doc({$attr_name} = "...")]` isn't allowed as a crate-level attribute passes_doc_cfg_hide_takes_list = - `#[doc(cfg_hide(...)]` takes a list of attributes + `#[doc(cfg_hide(...))]` takes a list of attributes passes_doc_expect_str = doc {$attr_name} attribute expects a string: #[doc({$attr_name} = "a")] From 9c6a0766be95fc197f4f30764a794eb4d50b649a Mon Sep 17 00:00:00 2001 From: Ibraheem Ahmed Date: Thu, 29 Feb 2024 00:56:31 -0500 Subject: [PATCH 10/14] document potential memory leak in unbounded channel --- library/std/src/sync/mpmc/list.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/std/src/sync/mpmc/list.rs b/library/std/src/sync/mpmc/list.rs index a1b275112a1ed..b6bae7dc50ce3 100644 --- a/library/std/src/sync/mpmc/list.rs +++ b/library/std/src/sync/mpmc/list.rs @@ -547,6 +547,9 @@ impl Channel { } let mut head = self.head.index.load(Ordering::Acquire); + // the channel may be uninitialized, so we have to swap to avoid overwriting any sender's attempts + // to initalize the first block before noticing that the receivers disconnected. late allocations + // will be deallocated by the sender in Drop let mut block = self.head.block.swap(ptr::null_mut(), Ordering::AcqRel); // If we're going to be dropping messages we need to synchronize with initialization From 1850ba7f548d13b7849bb8686728a113c0e6fb09 Mon Sep 17 00:00:00 2001 From: r0cky Date: Thu, 29 Feb 2024 14:00:08 +0800 Subject: [PATCH 11/14] Remove unused diagnostic struct --- compiler/rustc_builtin_macros/src/errors.rs | 21 ----------- compiler/rustc_hir_analysis/src/errors.rs | 7 ---- compiler/rustc_parse/src/errors.rs | 8 ----- compiler/rustc_resolve/src/errors.rs | 39 --------------------- 4 files changed, 75 deletions(-) diff --git a/compiler/rustc_builtin_macros/src/errors.rs b/compiler/rustc_builtin_macros/src/errors.rs index 23d2da128e59c..6546a35734c63 100644 --- a/compiler/rustc_builtin_macros/src/errors.rs +++ b/compiler/rustc_builtin_macros/src/errors.rs @@ -136,27 +136,6 @@ pub(crate) struct BenchSig { pub(crate) span: Span, } -#[derive(Diagnostic)] -#[diag(builtin_macros_test_arg_non_lifetime)] -pub(crate) struct TestArgNonLifetime { - #[primary_span] - pub(crate) span: Span, -} - -#[derive(Diagnostic)] -#[diag(builtin_macros_should_panic)] -pub(crate) struct ShouldPanic { - #[primary_span] - pub(crate) span: Span, -} - -#[derive(Diagnostic)] -#[diag(builtin_macros_test_args)] -pub(crate) struct TestArgs { - #[primary_span] - pub(crate) span: Span, -} - #[derive(Diagnostic)] #[diag(builtin_macros_alloc_must_statics)] pub(crate) struct AllocMustStatics { diff --git a/compiler/rustc_hir_analysis/src/errors.rs b/compiler/rustc_hir_analysis/src/errors.rs index ccad3b66d6b1d..5330260fbf513 100644 --- a/compiler/rustc_hir_analysis/src/errors.rs +++ b/compiler/rustc_hir_analysis/src/errors.rs @@ -1004,13 +1004,6 @@ pub(crate) struct StaticSpecialize { pub span: Span, } -#[derive(Diagnostic)] -#[diag(hir_analysis_missing_tilde_const)] -pub(crate) struct MissingTildeConst { - #[primary_span] - pub span: Span, -} - #[derive(Diagnostic)] pub(crate) enum DropImplPolarity { #[diag(hir_analysis_drop_impl_negative)] diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index 6c506a8efe00f..91dbf0321d2c6 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -557,14 +557,6 @@ pub(crate) struct CatchAfterTry { pub span: Span, } -#[derive(Diagnostic)] -#[diag(parse_gen_fn)] -#[help] -pub(crate) struct GenFn { - #[primary_span] - pub span: Span, -} - #[derive(Diagnostic)] #[diag(parse_comma_after_base_struct)] #[note] diff --git a/compiler/rustc_resolve/src/errors.rs b/compiler/rustc_resolve/src/errors.rs index adc4cd911a79e..6f23f53199664 100644 --- a/compiler/rustc_resolve/src/errors.rs +++ b/compiler/rustc_resolve/src/errors.rs @@ -7,32 +7,6 @@ use rustc_span::{ use crate::{late::PatternSource, Res}; -#[derive(Diagnostic)] -#[diag(resolve_parent_module_reset_for_binding, code = E0637)] -pub(crate) struct ParentModuleResetForBinding; - -#[derive(Diagnostic)] -#[diag(resolve_ampersand_used_without_explicit_lifetime_name, code = E0637)] -#[note] -pub(crate) struct AmpersandUsedWithoutExplicitLifetimeName(#[primary_span] pub(crate) Span); - -#[derive(Diagnostic)] -#[diag(resolve_underscore_lifetime_name_cannot_be_used_here, code = E0637)] -#[note] -pub(crate) struct UnderscoreLifetimeNameCannotBeUsedHere(#[primary_span] pub(crate) Span); - -#[derive(Diagnostic)] -#[diag(resolve_crate_may_not_be_imported)] -pub(crate) struct CrateMayNotBeImported(#[primary_span] pub(crate) Span); - -#[derive(Diagnostic)] -#[diag(resolve_crate_root_imports_must_be_named_explicitly)] -pub(crate) struct CrateRootNamesMustBeNamedExplicitly(#[primary_span] pub(crate) Span); - -#[derive(Diagnostic)] -#[diag(resolve_crate_root_imports_must_be_named_explicitly)] -pub(crate) struct ResolutionError(#[primary_span] pub(crate) Span); - #[derive(Diagnostic)] #[diag(resolve_generic_params_from_outer_item, code = E0401)] pub(crate) struct GenericParamsFromOuterItem { @@ -467,19 +441,6 @@ pub(crate) struct UnreachableLabelSubLabelUnreachable { pub(crate) ident_span: Span, } -#[derive(Diagnostic)] -#[diag(resolve_trait_impl_mismatch)] -pub(crate) struct TraitImplMismatch { - #[primary_span] - #[label] - pub(crate) span: Span, - pub(crate) name: Symbol, - pub(crate) kind: String, - #[label(resolve_label_trait_item)] - pub(crate) trait_item_span: Span, - pub(crate) trait_path: String, -} - #[derive(Diagnostic)] #[diag(resolve_invalid_asm_sym)] #[help] From 7c9fa952c3be1f7d0872fe9cd5f1f4a0327771b9 Mon Sep 17 00:00:00 2001 From: Ibraheem Ahmed Date: Thu, 29 Feb 2024 01:33:02 -0500 Subject: [PATCH 12/14] fix typos Co-authored-by: Ralf Jung --- library/std/src/sync/mpmc/list.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/std/src/sync/mpmc/list.rs b/library/std/src/sync/mpmc/list.rs index b6bae7dc50ce3..9e7148c716cda 100644 --- a/library/std/src/sync/mpmc/list.rs +++ b/library/std/src/sync/mpmc/list.rs @@ -547,9 +547,9 @@ impl Channel { } let mut head = self.head.index.load(Ordering::Acquire); - // the channel may be uninitialized, so we have to swap to avoid overwriting any sender's attempts - // to initalize the first block before noticing that the receivers disconnected. late allocations - // will be deallocated by the sender in Drop + // The channel may be uninitialized, so we have to swap to avoid overwriting any sender's attempts + // to initalize the first block before noticing that the receivers disconnected. Late allocations + // will be deallocated by the sender in Drop. let mut block = self.head.block.swap(ptr::null_mut(), Ordering::AcqRel); // If we're going to be dropping messages we need to synchronize with initialization From da37c8f1f2ed24bc06667bf13aedd63b4aad2b9f Mon Sep 17 00:00:00 2001 From: sisungo Date: Thu, 29 Feb 2024 14:59:10 +0800 Subject: [PATCH 13/14] Fix tests that are affected by this change --- tests/rustdoc-ui/lints/doc_cfg_hide.stderr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/rustdoc-ui/lints/doc_cfg_hide.stderr b/tests/rustdoc-ui/lints/doc_cfg_hide.stderr index b7e8870fdf548..ca6a14a42b8f4 100644 --- a/tests/rustdoc-ui/lints/doc_cfg_hide.stderr +++ b/tests/rustdoc-ui/lints/doc_cfg_hide.stderr @@ -18,7 +18,7 @@ help: to apply to the crate, use an inner attribute LL | #![doc(cfg_hide(doc))] | + -error: `#[doc(cfg_hide(...)]` takes a list of attributes +error: `#[doc(cfg_hide(...))]` takes a list of attributes --> $DIR/doc_cfg_hide.rs:4:8 | LL | #![doc(cfg_hide = "test")] @@ -27,7 +27,7 @@ LL | #![doc(cfg_hide = "test")] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82730 -error: `#[doc(cfg_hide(...)]` takes a list of attributes +error: `#[doc(cfg_hide(...))]` takes a list of attributes --> $DIR/doc_cfg_hide.rs:6:8 | LL | #![doc(cfg_hide)] From ad4c932ac4d877f782986461f77c074134204a0d Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Wed, 28 Feb 2024 16:13:28 +0000 Subject: [PATCH 14/14] Restore the standard library review rotation to its former glory --- triagebot.toml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/triagebot.toml b/triagebot.toml index e084b555464dc..802079f496e13 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -673,6 +673,12 @@ compiler = [ libs = [ "@cuviper", "@Mark-Simulacrum", + "@m-ou-se", + "@Amanieu", + "@Nilstrieb", + "@workingjubilee", + "@joboet", + "@jhpratt", ] bootstrap = [ "@Mark-Simulacrum", @@ -810,7 +816,7 @@ project-stable-mir = [ "/compiler/rustc_type_ir" = ["compiler", "types"] "/compiler/stable_mir" = ["project-stable-mir"] "/library/alloc" = ["libs"] -"/library/core" = ["libs"] +"/library/core" = ["libs", "@scottmcm"] "/library/panic_abort" = ["libs"] "/library/panic_unwind" = ["libs"] "/library/proc_macro" = ["@petrochenkov"]