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_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`. 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. diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 1fb061f911474..327c70ede28ee 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -555,16 +555,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: @@ -572,7 +575,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", ), @@ -580,31 +584,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", ), @@ -630,7 +654,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, 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_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_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")] 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] 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/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 1d3c04f7807ab..98ded7f6cdf5b 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()) } } diff --git a/library/std/src/env.rs b/library/std/src/env.rs index 5bd20ebe208c0..1f2b8d3007dd9 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 there 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 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")] diff --git a/library/std/src/sync/mpmc/list.rs b/library/std/src/sync/mpmc/list.rs index a1b275112a1ed..9e7148c716cda 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 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)] 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() {} 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"]