diff --git a/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs b/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs index 45c217168a8d9..477c9478c3609 100644 --- a/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs +++ b/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs @@ -271,10 +271,10 @@ fn create_elf_raw_dylib_stub(sess: &Session, soname: &str, symbols: &[DllImport] vers.push((version_name, dynstr)); id }; - syms.push((name, dynstr, Some(ver))); + syms.push((name, dynstr, Some(ver), symbol.is_fn)); } else { let dynstr = stub.add_dynamic_string(symbol_name.as_bytes()); - syms.push((symbol_name, dynstr, None)); + syms.push((symbol_name, dynstr, None, symbol.is_fn)); } } @@ -398,10 +398,11 @@ fn create_elf_raw_dylib_stub(sess: &Session, soname: &str, symbols: &[DllImport] // .dynsym stub.write_null_dynamic_symbol(); - for (_name, dynstr, _ver) in syms.iter().copied() { + for (_name, dynstr, _ver, is_fn) in syms.iter().copied() { + let sym_type = if is_fn { elf::STT_FUNC } else { elf::STT_NOTYPE }; stub.write_dynamic_symbol(&write::Sym { name: Some(dynstr), - st_info: (elf::STB_GLOBAL << 4) | elf::STT_NOTYPE, + st_info: (elf::STB_GLOBAL << 4) | sym_type, st_other: elf::STV_DEFAULT, section: Some(text_section), st_shndx: 0, // ignored by object in favor of the `section` field @@ -417,7 +418,7 @@ fn create_elf_raw_dylib_stub(sess: &Session, soname: &str, symbols: &[DllImport] if !vers.is_empty() { // .gnu_version stub.write_null_gnu_versym(); - for (_name, _dynstr, ver) in syms.iter().copied() { + for (_name, _dynstr, ver, _is_fn) in syms.iter().copied() { stub.write_gnu_versym(if let Some(ver) = ver { assert!((2 + ver as u16) < elf::VERSYM_HIDDEN); elf::VERSYM_HIDDEN | (2 + ver as u16) diff --git a/compiler/rustc_data_structures/src/marker.rs b/compiler/rustc_data_structures/src/marker.rs index 72d5f004194a8..e2193a97a0f43 100644 --- a/compiler/rustc_data_structures/src/marker.rs +++ b/compiler/rustc_data_structures/src/marker.rs @@ -59,11 +59,16 @@ macro_rules! already_send { // These structures are already `Send`. already_send!( - [std::backtrace::Backtrace][std::io::Stdout][std::io::Stderr][std::io::Error][std::fs::File][std::panic::Location<'_>] - [rustc_arena::DroplessArena][jobserver_crate::Client][jobserver_crate::HelperThread] - [crate::memmap::Mmap][crate::profiling::SelfProfiler][crate::owned_slice::OwnedSlice] + [std::sync::atomic::AtomicBool][std::sync::atomic::AtomicUsize][std::sync::atomic::AtomicU8] + [std::sync::atomic::AtomicU32][std::backtrace::Backtrace][std::io::Stdout][std::io::Stderr] + [std::io::Error][std::fs::File][std::panic::Location<'_>][rustc_arena::DroplessArena] + [jobserver_crate::Client][jobserver_crate::HelperThread][crate::memmap::Mmap] + [crate::profiling::SelfProfiler][crate::owned_slice::OwnedSlice] ); +#[cfg(target_has_atomic = "64")] +already_send!([std::sync::atomic::AtomicU64]); + macro_rules! impl_dyn_send { ($($($attr: meta)* [$ty: ty where $($generics2: tt)*])*) => { $(unsafe impl<$($generics2)*> DynSend for $ty {})* diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index a2427d9ca5889..6f9795db17ebe 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -1036,31 +1036,13 @@ impl InvalidAtomicOrdering { expr: &Expr<'hir>, recognized_names: &[Symbol], // used for fast path calculation ) -> Option<(Symbol, &'hir [Expr<'hir>])> { - const ATOMIC_TYPES: &[Symbol] = &[ - sym::AtomicBool, - sym::AtomicPtr, - sym::AtomicUsize, - sym::AtomicU8, - sym::AtomicU16, - sym::AtomicU32, - sym::AtomicU64, - sym::AtomicU128, - sym::AtomicIsize, - sym::AtomicI8, - sym::AtomicI16, - sym::AtomicI32, - sym::AtomicI64, - sym::AtomicI128, - ]; if let ExprKind::MethodCall(method_path, _, args, _) = &expr.kind && recognized_names.contains(&method_path.ident.name) && let Some(m_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) // skip extension traits, only lint functions from the standard library && let Some(impl_did) = cx.tcx.inherent_impl_of_assoc(m_def_id) && let Some(adt) = cx.tcx.type_of(impl_did).instantiate_identity().ty_adt_def() - && let parent = cx.tcx.parent(adt.did()) - && cx.tcx.is_diagnostic_item(sym::atomic_mod, parent) - && ATOMIC_TYPES.contains(&cx.tcx.item_name(adt.did())) + && cx.tcx.is_diagnostic_item(sym::Atomic, adt.did()) { return Some((method_path.ident.name, args)); } diff --git a/compiler/rustc_middle/src/dep_graph/dep_node.rs b/compiler/rustc_middle/src/dep_graph/dep_node.rs index 599c84597a8b9..c356d566626d1 100644 --- a/compiler/rustc_middle/src/dep_graph/dep_node.rs +++ b/compiler/rustc_middle/src/dep_graph/dep_node.rs @@ -174,11 +174,6 @@ impl fmt::Debug for DepNode { /// of the `DepKind`. Overall, this allows to implement `DepContext` using this manual /// jump table instead of large matches. pub struct DepKindVTable<'tcx> { - /// Anonymous queries cannot be replayed from one compiler invocation to the next. - /// When their result is needed, it is recomputed. They are useful for fine-grained - /// dependency tracking, and caching within one compiler invocation. - pub is_anon: bool, - /// Eval-always queries do not track their dependencies, and are always recomputed, even if /// their inputs have not changed since the last compiler invocation. The result is still /// cached within one compiler invocation. diff --git a/compiler/rustc_middle/src/queries.rs b/compiler/rustc_middle/src/queries.rs index 0ff38a0f36041..f54b291a2024f 100644 --- a/compiler/rustc_middle/src/queries.rs +++ b/compiler/rustc_middle/src/queries.rs @@ -150,10 +150,10 @@ use crate::{dep_graph, mir, thir}; // `Providers` that the driver creates (using several `rustc_*` crates). // // The result type of each query must implement `Clone`, and additionally -// `ty::query::values::Value`, which produces an appropriate placeholder -// (error) value if the query resulted in a query cycle. +// `ty::query::from_cycle_error::FromCycleError`, which produces an appropriate +// placeholder (error) value if the query resulted in a query cycle. // Queries marked with `cycle_fatal` do not need the latter implementation, -// as they will raise an fatal error on query cycles instead. +// as they will raise a fatal error on query cycles instead. rustc_queries! { /// Caches the expansion of a derive proc macro, e.g. `#[derive(Serialize)]`. /// The key is: diff --git a/compiler/rustc_middle/src/query/plumbing.rs b/compiler/rustc_middle/src/query/plumbing.rs index 072e29aaa9063..e1a19e5ffec7f 100644 --- a/compiler/rustc_middle/src/query/plumbing.rs +++ b/compiler/rustc_middle/src/query/plumbing.rs @@ -62,18 +62,6 @@ pub enum CycleErrorHandling { Stash, } -pub type WillCacheOnDiskForKeyFn<'tcx, Key> = fn(tcx: TyCtxt<'tcx>, key: &Key) -> bool; - -pub type TryLoadFromDiskFn<'tcx, Key, Value> = fn( - tcx: TyCtxt<'tcx>, - key: &Key, - prev_index: SerializedDepNodeIndex, - index: DepNodeIndex, -) -> Option; - -pub type IsLoadableFromDiskFn<'tcx, Key> = - fn(tcx: TyCtxt<'tcx>, key: &Key, index: SerializedDepNodeIndex) -> bool; - #[derive(Clone, Debug)] pub struct CycleError { /// The query and related span that uses the cycle. @@ -126,7 +114,7 @@ pub struct QueryVTable<'tcx, C: QueryCache> { pub cycle_error_handling: CycleErrorHandling, pub state: QueryState<'tcx, C::Key>, pub cache: C, - pub will_cache_on_disk_for_key_fn: Option>, + pub will_cache_on_disk_for_key_fn: Option, key: &C::Key) -> bool>, /// Function pointer that calls `tcx.$query(key)` for this query and /// discards the returned value. @@ -142,8 +130,17 @@ pub struct QueryVTable<'tcx, C: QueryCache> { /// This should be the only code that calls the provider function. pub invoke_provider_fn: fn(tcx: TyCtxt<'tcx>, key: C::Key) -> C::Value, - pub try_load_from_disk_fn: Option>, - pub is_loadable_from_disk_fn: Option>, + pub try_load_from_disk_fn: Option< + fn( + tcx: TyCtxt<'tcx>, + key: &C::Key, + prev_index: SerializedDepNodeIndex, + index: DepNodeIndex, + ) -> Option, + >, + + pub is_loadable_from_disk_fn: + Option, key: &C::Key, index: SerializedDepNodeIndex) -> bool>, /// Function pointer that hashes this query's result values. /// @@ -151,7 +148,7 @@ pub struct QueryVTable<'tcx, C: QueryCache> { pub hash_value_fn: Option, &C::Value) -> Fingerprint>, pub value_from_cycle_error: - fn(tcx: TyCtxt<'tcx>, cycle_error: &CycleError, guar: ErrorGuaranteed) -> C::Value, + fn(tcx: TyCtxt<'tcx>, cycle_error: CycleError, guar: ErrorGuaranteed) -> C::Value, pub format_value: fn(&C::Value) -> String, /// Formats a human-readable description of this query and its key, as @@ -216,7 +213,7 @@ impl<'tcx, C: QueryCache> QueryVTable<'tcx, C> { pub fn value_from_cycle_error( &self, tcx: TyCtxt<'tcx>, - cycle_error: &CycleError, + cycle_error: CycleError, guar: ErrorGuaranteed, ) -> C::Value { (self.value_from_cycle_error)(tcx, cycle_error, guar) @@ -650,18 +647,6 @@ macro_rules! define_callbacks { }; } -// Each of these queries corresponds to a function pointer field in the -// `Providers` struct for requesting a value of that type, and a method -// on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way -// which memoizes and does dep-graph tracking, wrapping around the actual -// `Providers` that the driver creates (using several `rustc_*` crates). -// -// The result type of each query must implement `Clone`, and additionally -// `ty::query::values::Value`, which produces an appropriate placeholder -// (error) value if the query resulted in a query cycle. -// Queries marked with `cycle_fatal` do not need the latter implementation, -// as they will raise an fatal error on query cycles instead. - mod sealed { use rustc_hir::def_id::{LocalModDefId, ModDefId}; diff --git a/compiler/rustc_query_impl/src/dep_kind_vtables.rs b/compiler/rustc_query_impl/src/dep_kind_vtables.rs index fa82a0413b1ad..01e37ca3e3ee1 100644 --- a/compiler/rustc_query_impl/src/dep_kind_vtables.rs +++ b/compiler/rustc_query_impl/src/dep_kind_vtables.rs @@ -13,7 +13,6 @@ mod non_query { // We use this for most things when incr. comp. is turned off. pub(crate) fn Null<'tcx>() -> DepKindVTable<'tcx> { DepKindVTable { - is_anon: false, is_eval_always: false, key_fingerprint_style: KeyFingerprintStyle::Unit, force_from_dep_node_fn: Some(|_, dep_node, _| { @@ -26,7 +25,6 @@ mod non_query { // We use this for the forever-red node. pub(crate) fn Red<'tcx>() -> DepKindVTable<'tcx> { DepKindVTable { - is_anon: false, is_eval_always: false, key_fingerprint_style: KeyFingerprintStyle::Unit, force_from_dep_node_fn: Some(|_, dep_node, _| { @@ -38,7 +36,6 @@ mod non_query { pub(crate) fn SideEffect<'tcx>() -> DepKindVTable<'tcx> { DepKindVTable { - is_anon: false, is_eval_always: false, key_fingerprint_style: KeyFingerprintStyle::Unit, force_from_dep_node_fn: Some(|tcx, _, prev_index| { @@ -51,7 +48,6 @@ mod non_query { pub(crate) fn AnonZeroDeps<'tcx>() -> DepKindVTable<'tcx> { DepKindVTable { - is_anon: true, is_eval_always: false, key_fingerprint_style: KeyFingerprintStyle::Opaque, force_from_dep_node_fn: Some(|_, _, _| bug!("cannot force an anon node")), @@ -61,7 +57,6 @@ mod non_query { pub(crate) fn TraitSelect<'tcx>() -> DepKindVTable<'tcx> { DepKindVTable { - is_anon: true, is_eval_always: false, key_fingerprint_style: KeyFingerprintStyle::Unit, force_from_dep_node_fn: None, @@ -71,7 +66,6 @@ mod non_query { pub(crate) fn CompileCodegenUnit<'tcx>() -> DepKindVTable<'tcx> { DepKindVTable { - is_anon: false, is_eval_always: false, key_fingerprint_style: KeyFingerprintStyle::Opaque, force_from_dep_node_fn: None, @@ -81,7 +75,6 @@ mod non_query { pub(crate) fn CompileMonoItem<'tcx>() -> DepKindVTable<'tcx> { DepKindVTable { - is_anon: false, is_eval_always: false, key_fingerprint_style: KeyFingerprintStyle::Opaque, force_from_dep_node_fn: None, @@ -91,7 +84,6 @@ mod non_query { pub(crate) fn Metadata<'tcx>() -> DepKindVTable<'tcx> { DepKindVTable { - is_anon: false, is_eval_always: false, key_fingerprint_style: KeyFingerprintStyle::Unit, force_from_dep_node_fn: None, @@ -124,7 +116,6 @@ where } DepKindVTable { - is_anon, is_eval_always, key_fingerprint_style, force_from_dep_node_fn: can_recover.then_some(force_from_dep_node_inner::), diff --git a/compiler/rustc_query_impl/src/execution.rs b/compiler/rustc_query_impl/src/execution.rs index 67054b415214b..323d40fdbaabb 100644 --- a/compiler/rustc_query_impl/src/execution.rs +++ b/compiler/rustc_query_impl/src/execution.rs @@ -5,7 +5,7 @@ use rustc_data_structures::hash_table::{Entry, HashTable}; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_data_structures::sync::{DynSend, DynSync}; use rustc_data_structures::{outline, sharded, sync}; -use rustc_errors::{Diag, FatalError, StashKey}; +use rustc_errors::{FatalError, StashKey}; use rustc_middle::dep_graph::{DepGraphData, DepNodeKey, SerializedDepNodeIndex}; use rustc_middle::query::plumbing::QueryVTable; use rustc_middle::query::{ @@ -126,24 +126,14 @@ fn mk_cycle<'tcx, C: QueryCache>( cycle_error: CycleError, ) -> C::Value { let error = report_cycle(tcx.sess, &cycle_error); - handle_cycle_error(query, tcx, &cycle_error, error) -} - -fn handle_cycle_error<'tcx, C: QueryCache>( - query: &'tcx QueryVTable<'tcx, C>, - tcx: TyCtxt<'tcx>, - cycle_error: &CycleError, - error: Diag<'_>, -) -> C::Value { match query.cycle_error_handling { CycleErrorHandling::Error => { let guar = error.emit(); query.value_from_cycle_error(tcx, cycle_error, guar) } CycleErrorHandling::Fatal => { - error.emit(); - tcx.dcx().abort_if_errors(); - unreachable!() + let guar = error.emit(); + guar.raise_fatal(); } CycleErrorHandling::DelayBug => { let guar = error.delay_as_bug(); @@ -340,15 +330,15 @@ fn try_execute_query<'tcx, C: QueryCache, const INCR: bool>( // Only call `wait_for_query` if we're using a Rayon thread pool // as it will attempt to mark the worker thread as blocked. - return wait_for_query(query, tcx, span, key, latch, current_job_id); - } - - let id = job.id; - drop(state_lock); + wait_for_query(query, tcx, span, key, latch, current_job_id) + } else { + let id = job.id; + drop(state_lock); - // If we are single-threaded we know that we have cycle error, - // so we just return the error. - cycle_error(query, tcx, id, span) + // If we are single-threaded we know that we have cycle error, + // so we just return the error. + cycle_error(query, tcx, id, span) + } } ActiveKeyStatus::Poisoned => FatalError.raise(), } @@ -430,12 +420,6 @@ fn execute_job_non_incr<'tcx, C: QueryCache>( ) -> (C::Value, DepNodeIndex) { debug_assert!(!tcx.dep_graph.is_fully_enabled()); - // Fingerprint the key, just to assert that it doesn't - // have anything we don't consider hashable - if cfg!(debug_assertions) { - let _ = key.to_fingerprint(tcx); - } - let prof_timer = tcx.prof.query_provider(); // Call the query provider. let value = @@ -443,14 +427,14 @@ fn execute_job_non_incr<'tcx, C: QueryCache>( let dep_node_index = tcx.dep_graph.next_virtual_depnode_index(); prof_timer.finish_with_query_invocation_id(dep_node_index.into()); - // Similarly, fingerprint the result to assert that - // it doesn't have anything not considered hashable. - if cfg!(debug_assertions) - && let Some(hash_value_fn) = query.hash_value_fn - { - tcx.with_stable_hashing_context(|mut hcx| { - hash_value_fn(&mut hcx, &value); - }); + // Sanity: Fingerprint the key and the result to assert they don't contain anything unhashable. + if cfg!(debug_assertions) { + let _ = key.to_fingerprint(tcx); + if let Some(hash_value_fn) = query.hash_value_fn { + tcx.with_stable_hashing_context(|mut hcx| { + hash_value_fn(&mut hcx, &value); + }); + } } (value, dep_node_index) diff --git a/compiler/rustc_query_impl/src/values.rs b/compiler/rustc_query_impl/src/from_cycle_error.rs similarity index 87% rename from compiler/rustc_query_impl/src/values.rs rename to compiler/rustc_query_impl/src/from_cycle_error.rs index 8f55e98df867e..a13db9004d678 100644 --- a/compiler/rustc_query_impl/src/values.rs +++ b/compiler/rustc_query_impl/src/from_cycle_error.rs @@ -17,58 +17,47 @@ use rustc_span::{ErrorGuaranteed, Span}; use crate::job::report_cycle; -pub(crate) trait Value<'tcx>: Sized { - fn from_cycle_error(tcx: TyCtxt<'tcx>, cycle_error: &CycleError, guar: ErrorGuaranteed) - -> Self; +pub(crate) trait FromCycleError<'tcx>: Sized { + /// Try to produce a `Self` value that represents an error form (e.g. `TyKind::Error`). + /// + /// Note: the default impl calls `raise_fatal`, ending compilation immediately! Only a few + /// types override this with a non-fatal impl. + fn from_cycle_error(tcx: TyCtxt<'tcx>, cycle_error: CycleError, guar: ErrorGuaranteed) -> Self; } -impl<'tcx, T> Value<'tcx> for T { +impl<'tcx, T> FromCycleError<'tcx> for T { default fn from_cycle_error( tcx: TyCtxt<'tcx>, - cycle_error: &CycleError, + cycle_error: CycleError, _guar: ErrorGuaranteed, ) -> T { - tcx.sess.dcx().abort_if_errors(); - bug!( - "<{} as Value>::from_cycle_error called without errors: {:#?}", - std::any::type_name::(), - cycle_error.cycle, - ); + let Some(guar) = tcx.sess.dcx().has_errors() else { + bug!( + "<{} as FromCycleError>::from_cycle_error called without errors: {:#?}", + std::any::type_name::(), + cycle_error.cycle, + ); + }; + guar.raise_fatal(); } } -impl<'tcx> Value<'tcx> for Ty<'_> { - fn from_cycle_error(tcx: TyCtxt<'tcx>, _: &CycleError, guar: ErrorGuaranteed) -> Self { +impl<'tcx> FromCycleError<'tcx> for Ty<'_> { + fn from_cycle_error(tcx: TyCtxt<'tcx>, _: CycleError, guar: ErrorGuaranteed) -> Self { // SAFETY: This is never called when `Self` is not `Ty<'tcx>`. // FIXME: Represent the above fact in the trait system somehow. unsafe { std::mem::transmute::, Ty<'_>>(Ty::new_error(tcx, guar)) } } } -impl<'tcx> Value<'tcx> for Result>, CyclePlaceholder> { - fn from_cycle_error(_tcx: TyCtxt<'tcx>, _: &CycleError, guar: ErrorGuaranteed) -> Self { +impl<'tcx> FromCycleError<'tcx> for Result>, CyclePlaceholder> { + fn from_cycle_error(_tcx: TyCtxt<'tcx>, _: CycleError, guar: ErrorGuaranteed) -> Self { Err(CyclePlaceholder(guar)) } } -impl<'tcx> Value<'tcx> for ty::SymbolName<'_> { - fn from_cycle_error(tcx: TyCtxt<'tcx>, _: &CycleError, _guar: ErrorGuaranteed) -> Self { - // SAFETY: This is never called when `Self` is not `SymbolName<'tcx>`. - // FIXME: Represent the above fact in the trait system somehow. - unsafe { - std::mem::transmute::, ty::SymbolName<'_>>(ty::SymbolName::new( - tcx, "", - )) - } - } -} - -impl<'tcx> Value<'tcx> for ty::Binder<'_, ty::FnSig<'_>> { - fn from_cycle_error( - tcx: TyCtxt<'tcx>, - cycle_error: &CycleError, - guar: ErrorGuaranteed, - ) -> Self { +impl<'tcx> FromCycleError<'tcx> for ty::Binder<'_, ty::FnSig<'_>> { + fn from_cycle_error(tcx: TyCtxt<'tcx>, cycle_error: CycleError, guar: ErrorGuaranteed) -> Self { let err = Ty::new_error(tcx, guar); let arity = if let Some(info) = cycle_error.cycle.get(0) @@ -97,10 +86,10 @@ impl<'tcx> Value<'tcx> for ty::Binder<'_, ty::FnSig<'_>> { } } -impl<'tcx> Value<'tcx> for Representability { +impl<'tcx> FromCycleError<'tcx> for Representability { fn from_cycle_error( tcx: TyCtxt<'tcx>, - cycle_error: &CycleError, + cycle_error: CycleError, _guar: ErrorGuaranteed, ) -> Self { let mut item_and_field_ids = Vec::new(); @@ -133,30 +122,22 @@ impl<'tcx> Value<'tcx> for Representability { } } -impl<'tcx> Value<'tcx> for ty::EarlyBinder<'_, Ty<'_>> { - fn from_cycle_error( - tcx: TyCtxt<'tcx>, - cycle_error: &CycleError, - guar: ErrorGuaranteed, - ) -> Self { +impl<'tcx> FromCycleError<'tcx> for ty::EarlyBinder<'_, Ty<'_>> { + fn from_cycle_error(tcx: TyCtxt<'tcx>, cycle_error: CycleError, guar: ErrorGuaranteed) -> Self { ty::EarlyBinder::bind(Ty::from_cycle_error(tcx, cycle_error, guar)) } } -impl<'tcx> Value<'tcx> for ty::EarlyBinder<'_, ty::Binder<'_, ty::FnSig<'_>>> { - fn from_cycle_error( - tcx: TyCtxt<'tcx>, - cycle_error: &CycleError, - guar: ErrorGuaranteed, - ) -> Self { +impl<'tcx> FromCycleError<'tcx> for ty::EarlyBinder<'_, ty::Binder<'_, ty::FnSig<'_>>> { + fn from_cycle_error(tcx: TyCtxt<'tcx>, cycle_error: CycleError, guar: ErrorGuaranteed) -> Self { ty::EarlyBinder::bind(ty::Binder::from_cycle_error(tcx, cycle_error, guar)) } } -impl<'tcx> Value<'tcx> for &[ty::Variance] { +impl<'tcx> FromCycleError<'tcx> for &[ty::Variance] { fn from_cycle_error( tcx: TyCtxt<'tcx>, - cycle_error: &CycleError, + cycle_error: CycleError, _guar: ErrorGuaranteed, ) -> Self { search_for_cycle_permutation( @@ -201,10 +182,10 @@ fn search_for_cycle_permutation( otherwise() } -impl<'tcx, T> Value<'tcx> for Result> { +impl<'tcx, T> FromCycleError<'tcx> for Result> { fn from_cycle_error( tcx: TyCtxt<'tcx>, - cycle_error: &CycleError, + cycle_error: CycleError, _guar: ErrorGuaranteed, ) -> Self { let diag = search_for_cycle_permutation( @@ -280,7 +261,7 @@ impl<'tcx, T> Value<'tcx> for Result> { ControlFlow::Continue(()) } }, - || report_cycle(tcx.sess, cycle_error), + || report_cycle(tcx.sess, &cycle_error), ); let guar = diag.emit(); diff --git a/compiler/rustc_query_impl/src/lib.rs b/compiler/rustc_query_impl/src/lib.rs index 875dd07ff25f0..5be636877fa50 100644 --- a/compiler/rustc_query_impl/src/lib.rs +++ b/compiler/rustc_query_impl/src/lib.rs @@ -18,10 +18,10 @@ use rustc_middle::ty::TyCtxt; use rustc_span::Span; pub use crate::dep_kind_vtables::make_dep_kind_vtables; +use crate::from_cycle_error::FromCycleError; pub use crate::job::{QueryJobMap, break_query_cycles, print_query_stack}; use crate::plumbing::try_mark_green; use crate::profiling_support::QueryKeyStringCache; -use crate::values::Value; #[macro_use] mod plumbing; @@ -29,9 +29,9 @@ mod plumbing; mod dep_kind_vtables; mod error; mod execution; +mod from_cycle_error; mod job; mod profiling_support; -mod values; /// Trait that knows how to look up the [`QueryVTable`] for a particular query. /// diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs index f005e55418294..f22b5be75cafa 100644 --- a/compiler/rustc_query_impl/src/plumbing.rs +++ b/compiler/rustc_query_impl/src/plumbing.rs @@ -554,7 +554,8 @@ macro_rules! define_queries { None }), value_from_cycle_error: |tcx, cycle, guar| { - let result: queries::$name::Value<'tcx> = Value::from_cycle_error(tcx, cycle, guar); + let result: queries::$name::Value<'tcx> = + FromCycleError::from_cycle_error(tcx, cycle, guar); erase::erase_val(result) }, hash_value_fn: if_no_hash!( diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 9a2d68fc6639f..b7255ba67dfdb 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -171,20 +171,7 @@ symbols! { AsyncGenFinished, AsyncGenPending, AsyncGenReady, - AtomicBool, - AtomicI8, - AtomicI16, - AtomicI32, - AtomicI64, - AtomicI128, - AtomicIsize, - AtomicPtr, - AtomicU8, - AtomicU16, - AtomicU32, - AtomicU64, - AtomicU128, - AtomicUsize, + Atomic, BTreeMap, Bool, Borrow, @@ -485,7 +472,6 @@ symbols! { atomic_load, atomic_max, atomic_min, - atomic_mod, atomic_nand, atomic_or, atomic_singlethreadfence, diff --git a/library/core/src/bstr/traits.rs b/library/core/src/bstr/traits.rs index 7da6c5f13cce1..bcfffd52d7419 100644 --- a/library/core/src/bstr/traits.rs +++ b/library/core/src/bstr/traits.rs @@ -268,4 +268,5 @@ impl_slice_index!(range::RangeFrom); impl_slice_index!(ops::RangeInclusive); impl_slice_index!(range::RangeInclusive); impl_slice_index!(ops::RangeToInclusive); +impl_slice_index!(range::RangeToInclusive); impl_slice_index!((ops::Bound, ops::Bound)); diff --git a/library/core/src/ffi/c_str.rs b/library/core/src/ffi/c_str.rs index 621277179bb38..5fc97d9a69efd 100644 --- a/library/core/src/ffi/c_str.rs +++ b/library/core/src/ffi/c_str.rs @@ -8,7 +8,7 @@ use crate::iter::FusedIterator; use crate::marker::PhantomData; use crate::ptr::NonNull; use crate::slice::memchr; -use crate::{fmt, ops, slice, str}; +use crate::{fmt, ops, range, slice, str}; // FIXME: because this is doc(inline)d, we *have* to use intra-doc links because the actual link // depends on where the item is being documented. however, since this is libcore, we can't @@ -716,6 +716,16 @@ impl ops::Index> for CStr { } } +#[unstable(feature = "new_range_api", issue = "125687")] +impl ops::Index> for CStr { + type Output = CStr; + + #[inline] + fn index(&self, index: range::RangeFrom) -> &CStr { + ops::Index::index(self, ops::RangeFrom::from(index)) + } +} + #[stable(feature = "cstring_asref", since = "1.7.0")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] impl const AsRef for CStr { diff --git a/library/core/src/range.rs b/library/core/src/range.rs index 0ef0d192a8682..16e6bb6df7da7 100644 --- a/library/core/src/range.rs +++ b/library/core/src/range.rs @@ -43,7 +43,7 @@ pub use iter::{RangeFromIter, RangeIter}; // pub use crate::ops::{Bound, IntoBounds, OneSidedRange, RangeBounds, RangeFull, RangeTo}; use crate::iter::Step; use crate::ops::Bound::{self, Excluded, Included, Unbounded}; -use crate::ops::{IntoBounds, RangeBounds}; +use crate::ops::{IntoBounds, OneSidedRange, OneSidedRangeBound, RangeBounds}; /// A (half-open) range bounded inclusively below and exclusively above /// (`start..end` in a future edition). @@ -546,6 +546,18 @@ impl const IntoBounds for RangeFrom { } } +#[unstable(feature = "one_sided_range", issue = "69780")] +// #[unstable(feature = "new_range_api", issue = "125687")] +#[rustc_const_unstable(feature = "const_range", issue = "none")] +impl const OneSidedRange for RangeFrom +where + Self: RangeBounds, +{ + fn bound(self) -> (OneSidedRangeBound, T) { + (OneSidedRangeBound::StartInclusive, self.start) + } +} + #[unstable(feature = "new_range_api", issue = "125687")] #[rustc_const_unstable(feature = "const_index", issue = "143775")] impl const From> for legacy::RangeFrom { @@ -573,9 +585,8 @@ impl const From> for RangeFrom { /// The `..=last` syntax is a `RangeToInclusive`: /// /// ``` -/// #![feature(new_range_api)] /// #![feature(new_range)] -/// assert_eq!((..=5), std::range::RangeToInclusive{ last: 5 }); +/// assert_eq!((..=5), std::range::RangeToInclusive { last: 5 }); /// ``` /// /// It does not have an [`IntoIterator`] implementation, so you can't use it in a @@ -606,14 +617,14 @@ impl const From> for RangeFrom { #[lang = "RangeToInclusiveCopy"] #[doc(alias = "..=")] #[derive(Copy, Clone, PartialEq, Eq, Hash)] -#[unstable(feature = "new_range_api", issue = "125687")] +#[stable(feature = "new_range_to_inclusive_api", since = "CURRENT_RUSTC_VERSION")] pub struct RangeToInclusive { /// The upper bound of the range (inclusive) - #[unstable(feature = "new_range_api", issue = "125687")] + #[stable(feature = "new_range_to_inclusive_api", since = "CURRENT_RUSTC_VERSION")] pub last: Idx, } -#[unstable(feature = "new_range_api", issue = "125687")] +#[stable(feature = "new_range_to_inclusive_api", since = "CURRENT_RUSTC_VERSION")] impl fmt::Debug for RangeToInclusive { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "..=")?; @@ -637,7 +648,7 @@ impl> RangeToInclusive { /// assert!(!(..=f32::NAN).contains(&0.5)); /// ``` #[inline] - #[unstable(feature = "new_range_api", issue = "125687")] + #[stable(feature = "new_range_to_inclusive_api", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_range", issue = "none")] pub const fn contains(&self, item: &U) -> bool where @@ -648,13 +659,13 @@ impl> RangeToInclusive { } } -#[unstable(feature = "new_range_api", issue = "125687")] +#[stable(feature = "new_range_to_inclusive_api", since = "CURRENT_RUSTC_VERSION")] impl From> for RangeToInclusive { fn from(value: legacy::RangeToInclusive) -> Self { Self { last: value.end } } } -#[unstable(feature = "new_range_api", issue = "125687")] +#[stable(feature = "new_range_to_inclusive_api", since = "CURRENT_RUSTC_VERSION")] impl From> for legacy::RangeToInclusive { fn from(value: RangeToInclusive) -> Self { Self { end: value.last } @@ -664,7 +675,7 @@ impl From> for legacy::RangeToInclusive { // RangeToInclusive cannot impl From> // because underflow would be possible with (..0).into() -#[unstable(feature = "new_range_api", issue = "125687")] +#[stable(feature = "new_range_to_inclusive_api", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_range", issue = "none")] impl const RangeBounds for RangeToInclusive { fn start_bound(&self) -> Bound<&T> { @@ -675,6 +686,18 @@ impl const RangeBounds for RangeToInclusive { } } +#[stable(feature = "new_range_to_inclusive_api", since = "CURRENT_RUSTC_VERSION")] +#[rustc_const_unstable(feature = "const_range", issue = "none")] +impl const RangeBounds for RangeToInclusive<&T> { + fn start_bound(&self) -> Bound<&T> { + Unbounded + } + fn end_bound(&self) -> Bound<&T> { + Included(self.last) + } +} + +// #[stable(feature = "new_range_to_inclusive_api", since = "CURRENT_RUSTC_VERSION")] #[unstable(feature = "range_into_bounds", issue = "136903")] #[rustc_const_unstable(feature = "const_range", issue = "none")] impl const IntoBounds for RangeToInclusive { @@ -682,3 +705,15 @@ impl const IntoBounds for RangeToInclusive { (Unbounded, Included(self.last)) } } + +// #[stable(feature = "new_range_to_inclusive_api", since = "CURRENT_RUSTC_VERSION")] +#[unstable(feature = "one_sided_range", issue = "69780")] +#[rustc_const_unstable(feature = "const_range", issue = "none")] +impl const OneSidedRange for RangeToInclusive +where + Self: RangeBounds, +{ + fn bound(self) -> (OneSidedRangeBound, T) { + (OneSidedRangeBound::EndInclusive, self.last) + } +} diff --git a/library/core/src/slice/index.rs b/library/core/src/slice/index.rs index 3a76c098bb530..59239e62916a0 100644 --- a/library/core/src/slice/index.rs +++ b/library/core/src/slice/index.rs @@ -129,7 +129,7 @@ mod private_slice_index { impl Sealed for range::Range {} #[stable(feature = "new_range_inclusive_api", since = "CURRENT_RUSTC_VERSION")] impl Sealed for range::RangeInclusive {} - #[unstable(feature = "new_range_api", issue = "125687")] + #[stable(feature = "new_range_to_inclusive_api", since = "CURRENT_RUSTC_VERSION")] impl Sealed for range::RangeToInclusive {} #[unstable(feature = "new_range_api", issue = "125687")] impl Sealed for range::RangeFrom {} @@ -801,7 +801,7 @@ unsafe impl const SliceIndex<[T]> for ops::RangeToInclusive { } /// The methods `index` and `index_mut` panic if the end of the range is out of bounds. -#[stable(feature = "inclusive_range", since = "1.26.0")] +#[stable(feature = "new_range_to_inclusive_api", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_index", issue = "143775")] unsafe impl const SliceIndex<[T]> for range::RangeToInclusive { type Output = [T]; diff --git a/library/core/src/str/traits.rs b/library/core/src/str/traits.rs index edf07c0c16f42..03d47cacf5db9 100644 --- a/library/core/src/str/traits.rs +++ b/library/core/src/str/traits.rs @@ -763,6 +763,52 @@ unsafe impl const SliceIndex for ops::RangeToInclusive { } } +/// Implements substring slicing with syntax `&self[..= last]` or `&mut +/// self[..= last]`. +/// +/// Returns a slice of the given string from the byte range \[0, `last`\]. +/// Equivalent to `&self [0 .. last + 1]`, except if `last` has the maximum +/// value for `usize`. +/// +/// This operation is *O*(1). +/// +/// # Panics +/// +/// Panics if `last` does not point to the ending byte offset of a character +/// (`last + 1` is either a starting byte offset as defined by +/// `is_char_boundary`, or equal to `len`), or if `last >= len`. +#[stable(feature = "new_range_to_inclusive_api", since = "CURRENT_RUSTC_VERSION")] +#[rustc_const_unstable(feature = "const_index", issue = "143775")] +unsafe impl const SliceIndex for range::RangeToInclusive { + type Output = str; + #[inline] + fn get(self, slice: &str) -> Option<&Self::Output> { + (0..=self.last).get(slice) + } + #[inline] + fn get_mut(self, slice: &mut str) -> Option<&mut Self::Output> { + (0..=self.last).get_mut(slice) + } + #[inline] + unsafe fn get_unchecked(self, slice: *const str) -> *const Self::Output { + // SAFETY: the caller must uphold the safety contract for `get_unchecked`. + unsafe { (0..=self.last).get_unchecked(slice) } + } + #[inline] + unsafe fn get_unchecked_mut(self, slice: *mut str) -> *mut Self::Output { + // SAFETY: the caller must uphold the safety contract for `get_unchecked_mut`. + unsafe { (0..=self.last).get_unchecked_mut(slice) } + } + #[inline] + fn index(self, slice: &str) -> &Self::Output { + (0..=self.last).index(slice) + } + #[inline] + fn index_mut(self, slice: &mut str) -> &mut Self::Output { + (0..=self.last).index_mut(slice) + } +} + /// Parse a value from a string /// /// `FromStr`'s [`from_str`] method is often used implicitly, through diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index adc2bbcde51b0..18b05c36fd441 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -238,7 +238,6 @@ #![stable(feature = "rust1", since = "1.0.0")] #![cfg_attr(not(target_has_atomic_load_store = "8"), allow(dead_code))] #![cfg_attr(not(target_has_atomic_load_store = "8"), allow(unused_imports))] -#![rustc_diagnostic_item = "atomic_mod"] // Clippy complains about the pattern of "safe function calling unsafe function taking pointers". // This happens with AtomicPtr intrinsics but is fine, as the pointers clippy is concerned about // are just normal values that get loaded/stored, but not dereferenced. @@ -248,40 +247,60 @@ use self::Ordering::*; use crate::cell::UnsafeCell; use crate::hint::spin_loop; use crate::intrinsics::AtomicOrdering as AO; +use crate::mem::transmute; use crate::{fmt, intrinsics}; -trait Sealed {} +#[unstable( + feature = "atomic_internals", + reason = "implementation detail which may disappear or be replaced at any time", + issue = "none" +)] +#[expect(missing_debug_implementations)] +mod private { + pub(super) trait Sealed {} + + #[cfg(target_has_atomic_load_store = "8")] + #[repr(C, align(1))] + pub struct Align1(T); + #[cfg(target_has_atomic_load_store = "16")] + #[repr(C, align(2))] + pub struct Align2(T); + #[cfg(target_has_atomic_load_store = "32")] + #[repr(C, align(4))] + pub struct Align4(T); + #[cfg(target_has_atomic_load_store = "64")] + #[repr(C, align(8))] + pub struct Align8(T); + #[cfg(target_has_atomic_load_store = "128")] + #[repr(C, align(16))] + pub struct Align16(T); +} /// A marker trait for primitive types which can be modified atomically. /// /// This is an implementation detail for [Atomic]\ which may disappear or be replaced at any time. -/// -/// # Safety -/// -/// Types implementing this trait must be primitives that can be modified atomically. -/// -/// The associated `Self::AtomicInner` type must have the same size and bit validity as `Self`, -/// but may have a higher alignment requirement, so the following `transmute`s are sound: -/// -/// - `&mut Self::AtomicInner` as `&mut Self` -/// - `Self` as `Self::AtomicInner` or the reverse +// +// # Safety +// +// Types implementing this trait must be primitives that can be modified atomically. +// +// The associated `Self::Storage` type must have the same size, but may have fewer validity +// invariants or a higher alignment requirement than `Self`. #[unstable( feature = "atomic_internals", reason = "implementation detail which may disappear or be replaced at any time", issue = "none" )] #[expect(private_bounds)] -pub unsafe trait AtomicPrimitive: Sized + Copy + Sealed { +pub unsafe trait AtomicPrimitive: Sized + Copy + private::Sealed { /// Temporary implementation detail. - type AtomicInner: Sized; + type Storage: Sized; } macro impl_atomic_primitive( - $Atom:ident $(<$T:ident>)? ($Primitive:ty), - size($size:literal), - align($align:literal) $(,)? + [$($T:ident)?] $Primitive:ty as $Storage:ident<$Operand:ty>, size($size:literal) ) { - impl $(<$T>)? Sealed for $Primitive {} + impl $(<$T>)? private::Sealed for $Primitive {} #[unstable( feature = "atomic_internals", @@ -290,42 +309,42 @@ macro impl_atomic_primitive( )] #[cfg(target_has_atomic_load_store = $size)] unsafe impl $(<$T>)? AtomicPrimitive for $Primitive { - type AtomicInner = $Atom $(<$T>)?; + type Storage = private::$Storage<$Operand>; } } -impl_atomic_primitive!(AtomicBool(bool), size("8"), align(1)); -impl_atomic_primitive!(AtomicI8(i8), size("8"), align(1)); -impl_atomic_primitive!(AtomicU8(u8), size("8"), align(1)); -impl_atomic_primitive!(AtomicI16(i16), size("16"), align(2)); -impl_atomic_primitive!(AtomicU16(u16), size("16"), align(2)); -impl_atomic_primitive!(AtomicI32(i32), size("32"), align(4)); -impl_atomic_primitive!(AtomicU32(u32), size("32"), align(4)); -impl_atomic_primitive!(AtomicI64(i64), size("64"), align(8)); -impl_atomic_primitive!(AtomicU64(u64), size("64"), align(8)); -impl_atomic_primitive!(AtomicI128(i128), size("128"), align(16)); -impl_atomic_primitive!(AtomicU128(u128), size("128"), align(16)); +impl_atomic_primitive!([] bool as Align1, size("8")); +impl_atomic_primitive!([] i8 as Align1, size("8")); +impl_atomic_primitive!([] u8 as Align1, size("8")); +impl_atomic_primitive!([] i16 as Align2, size("16")); +impl_atomic_primitive!([] u16 as Align2, size("16")); +impl_atomic_primitive!([] i32 as Align4, size("32")); +impl_atomic_primitive!([] u32 as Align4, size("32")); +impl_atomic_primitive!([] i64 as Align8, size("64")); +impl_atomic_primitive!([] u64 as Align8, size("64")); +impl_atomic_primitive!([] i128 as Align16, size("128")); +impl_atomic_primitive!([] u128 as Align16, size("128")); #[cfg(target_pointer_width = "16")] -impl_atomic_primitive!(AtomicIsize(isize), size("ptr"), align(2)); +impl_atomic_primitive!([] isize as Align2, size("ptr")); #[cfg(target_pointer_width = "32")] -impl_atomic_primitive!(AtomicIsize(isize), size("ptr"), align(4)); +impl_atomic_primitive!([] isize as Align4, size("ptr")); #[cfg(target_pointer_width = "64")] -impl_atomic_primitive!(AtomicIsize(isize), size("ptr"), align(8)); +impl_atomic_primitive!([] isize as Align8, size("ptr")); #[cfg(target_pointer_width = "16")] -impl_atomic_primitive!(AtomicUsize(usize), size("ptr"), align(2)); +impl_atomic_primitive!([] usize as Align2, size("ptr")); #[cfg(target_pointer_width = "32")] -impl_atomic_primitive!(AtomicUsize(usize), size("ptr"), align(4)); +impl_atomic_primitive!([] usize as Align4, size("ptr")); #[cfg(target_pointer_width = "64")] -impl_atomic_primitive!(AtomicUsize(usize), size("ptr"), align(8)); +impl_atomic_primitive!([] usize as Align8, size("ptr")); #[cfg(target_pointer_width = "16")] -impl_atomic_primitive!(AtomicPtr(*mut T), size("ptr"), align(2)); +impl_atomic_primitive!([T] *mut T as Align2<*mut T>, size("ptr")); #[cfg(target_pointer_width = "32")] -impl_atomic_primitive!(AtomicPtr(*mut T), size("ptr"), align(4)); +impl_atomic_primitive!([T] *mut T as Align4<*mut T>, size("ptr")); #[cfg(target_pointer_width = "64")] -impl_atomic_primitive!(AtomicPtr(*mut T), size("ptr"), align(8)); +impl_atomic_primitive!([T] *mut T as Align8<*mut T>, size("ptr")); /// A memory location which can be safely modified from multiple threads. /// @@ -342,7 +361,16 @@ impl_atomic_primitive!(AtomicPtr(*mut T), size("ptr"), align(8)); /// /// [module-level documentation]: crate::sync::atomic #[unstable(feature = "generic_atomic", issue = "130539")] -pub type Atomic = ::AtomicInner; +#[repr(C)] +#[rustc_diagnostic_item = "Atomic"] +pub struct Atomic { + v: UnsafeCell, +} + +#[stable(feature = "rust1", since = "1.0.0")] +unsafe impl Send for Atomic {} +#[stable(feature = "rust1", since = "1.0.0")] +unsafe impl Sync for Atomic {} // Some architectures don't have byte-sized atomics, which results in LLVM // emulating them using a LL/SC loop. However for AtomicBool we can take @@ -367,11 +395,7 @@ const EMULATE_ATOMIC_BOOL: bool = cfg!(any( /// loads and stores of `u8`. #[cfg(target_has_atomic_load_store = "8")] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_diagnostic_item = "AtomicBool"] -#[repr(C, align(1))] -pub struct AtomicBool { - v: UnsafeCell, -} +pub type AtomicBool = Atomic; #[cfg(target_has_atomic_load_store = "8")] #[stable(feature = "rust1", since = "1.0.0")] @@ -383,11 +407,6 @@ impl Default for AtomicBool { } } -// Send is implicitly implemented for AtomicBool. -#[cfg(target_has_atomic_load_store = "8")] -#[stable(feature = "rust1", since = "1.0.0")] -unsafe impl Sync for AtomicBool {} - /// A raw pointer type which can be safely shared between threads. /// /// This type has the same size and bit validity as a `*mut T`. @@ -396,13 +415,7 @@ unsafe impl Sync for AtomicBool {} /// loads and stores of pointers. Its size depends on the target pointer's size. #[cfg(target_has_atomic_load_store = "ptr")] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_diagnostic_item = "AtomicPtr"] -#[cfg_attr(target_pointer_width = "16", repr(C, align(2)))] -#[cfg_attr(target_pointer_width = "32", repr(C, align(4)))] -#[cfg_attr(target_pointer_width = "64", repr(C, align(8)))] -pub struct AtomicPtr { - p: UnsafeCell<*mut T>, -} +pub type AtomicPtr = Atomic<*mut T>; #[cfg(target_has_atomic_load_store = "ptr")] #[stable(feature = "rust1", since = "1.0.0")] @@ -413,13 +426,6 @@ impl Default for AtomicPtr { } } -#[cfg(target_has_atomic_load_store = "ptr")] -#[stable(feature = "rust1", since = "1.0.0")] -unsafe impl Send for AtomicPtr {} -#[cfg(target_has_atomic_load_store = "ptr")] -#[stable(feature = "rust1", since = "1.0.0")] -unsafe impl Sync for AtomicPtr {} - /// Atomic memory orderings /// /// Memory orderings specify the way atomic operations synchronize memory. @@ -528,7 +534,9 @@ impl AtomicBool { #[rustc_const_stable(feature = "const_atomic_new", since = "1.24.0")] #[must_use] pub const fn new(v: bool) -> AtomicBool { - AtomicBool { v: UnsafeCell::new(v as u8) } + // SAFETY: + // `Atomic` is essentially a transparent wrapper around `T`. + unsafe { transmute(v) } } /// Creates a new `AtomicBool` from a pointer. @@ -597,7 +605,7 @@ impl AtomicBool { #[stable(feature = "atomic_access", since = "1.15.0")] pub fn get_mut(&mut self) -> &mut bool { // SAFETY: the mutable reference guarantees unique ownership. - unsafe { &mut *(self.v.get() as *mut bool) } + unsafe { &mut *self.as_ptr() } } /// Gets atomic access to a `&mut bool`. @@ -699,7 +707,11 @@ impl AtomicBool { #[stable(feature = "atomic_access", since = "1.15.0")] #[rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0")] pub const fn into_inner(self) -> bool { - self.v.into_inner() != 0 + // SAFETY: + // * `Atomic` is essentially a transparent wrapper around `T`. + // * all operations on `Atomic` ensure that `T::Storage` remains + // a valid `bool`. + unsafe { transmute(self) } } /// Loads a value from the bool. @@ -726,7 +738,7 @@ impl AtomicBool { pub fn load(&self, order: Ordering) -> bool { // SAFETY: any data races are prevented by atomic intrinsics and the raw // pointer passed in is valid because we got it from a reference. - unsafe { atomic_load(self.v.get(), order) != 0 } + unsafe { atomic_load(self.v.get().cast::(), order) != 0 } } /// Stores a value into the bool. @@ -756,7 +768,7 @@ impl AtomicBool { // SAFETY: any data races are prevented by atomic intrinsics and the raw // pointer passed in is valid because we got it from a reference. unsafe { - atomic_store(self.v.get(), val as u8, order); + atomic_store(self.v.get().cast::(), val as u8, order); } } @@ -790,7 +802,7 @@ impl AtomicBool { if val { self.fetch_or(true, order) } else { self.fetch_and(false, order) } } else { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_swap(self.v.get(), val as u8, order) != 0 } + unsafe { atomic_swap(self.v.get().cast::(), val as u8, order) != 0 } } } @@ -950,7 +962,13 @@ impl AtomicBool { } else { // SAFETY: data races are prevented by atomic intrinsics. match unsafe { - atomic_compare_exchange(self.v.get(), current as u8, new as u8, success, failure) + atomic_compare_exchange( + self.v.get().cast::(), + current as u8, + new as u8, + success, + failure, + ) } { Ok(x) => Ok(x != 0), Err(x) => Err(x != 0), @@ -1024,7 +1042,13 @@ impl AtomicBool { // SAFETY: data races are prevented by atomic intrinsics. match unsafe { - atomic_compare_exchange_weak(self.v.get(), current as u8, new as u8, success, failure) + atomic_compare_exchange_weak( + self.v.get().cast::(), + current as u8, + new as u8, + success, + failure, + ) } { Ok(x) => Ok(x != 0), Err(x) => Err(x != 0), @@ -1070,7 +1094,7 @@ impl AtomicBool { #[rustc_should_not_be_called_on_const_items] pub fn fetch_and(&self, val: bool, order: Ordering) -> bool { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_and(self.v.get(), val as u8, order) != 0 } + unsafe { atomic_and(self.v.get().cast::(), val as u8, order) != 0 } } /// Logical "nand" with a boolean value. @@ -1166,7 +1190,7 @@ impl AtomicBool { #[rustc_should_not_be_called_on_const_items] pub fn fetch_or(&self, val: bool, order: Ordering) -> bool { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_or(self.v.get(), val as u8, order) != 0 } + unsafe { atomic_or(self.v.get().cast::(), val as u8, order) != 0 } } /// Logical "xor" with a boolean value. @@ -1208,7 +1232,7 @@ impl AtomicBool { #[rustc_should_not_be_called_on_const_items] pub fn fetch_xor(&self, val: bool, order: Ordering) -> bool { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_xor(self.v.get(), val as u8, order) != 0 } + unsafe { atomic_xor(self.v.get().cast::(), val as u8, order) != 0 } } /// Logical "not" with a boolean value. @@ -1457,7 +1481,9 @@ impl AtomicPtr { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_atomic_new", since = "1.24.0")] pub const fn new(p: *mut T) -> AtomicPtr { - AtomicPtr { p: UnsafeCell::new(p) } + // SAFETY: + // `Atomic` is essentially a transparent wrapper around `T`. + unsafe { transmute(p) } } /// Creates a new `AtomicPtr` from a pointer. @@ -1544,7 +1570,9 @@ impl AtomicPtr { #[inline] #[stable(feature = "atomic_access", since = "1.15.0")] pub fn get_mut(&mut self) -> &mut *mut T { - self.p.get_mut() + // SAFETY: + // `Atomic` is essentially a transparent wrapper around `T`. + unsafe { &mut *self.as_ptr() } } /// Gets atomic access to a pointer. @@ -1672,7 +1700,9 @@ impl AtomicPtr { #[stable(feature = "atomic_access", since = "1.15.0")] #[rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0")] pub const fn into_inner(self) -> *mut T { - self.p.into_inner() + // SAFETY: + // `Atomic` is essentially a transparent wrapper around `T`. + unsafe { transmute(self) } } /// Loads a value from the pointer. @@ -1699,7 +1729,7 @@ impl AtomicPtr { #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub fn load(&self, order: Ordering) -> *mut T { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_load(self.p.get(), order) } + unsafe { atomic_load(self.as_ptr(), order) } } /// Stores a value into the pointer. @@ -1730,7 +1760,7 @@ impl AtomicPtr { pub fn store(&self, ptr: *mut T, order: Ordering) { // SAFETY: data races are prevented by atomic intrinsics. unsafe { - atomic_store(self.p.get(), ptr, order); + atomic_store(self.as_ptr(), ptr, order); } } @@ -1763,7 +1793,7 @@ impl AtomicPtr { #[rustc_should_not_be_called_on_const_items] pub fn swap(&self, ptr: *mut T, order: Ordering) -> *mut T { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_swap(self.p.get(), ptr, order) } + unsafe { atomic_swap(self.as_ptr(), ptr, order) } } /// Stores a value into the pointer if the current value is the same as the `current` value. @@ -1887,7 +1917,7 @@ impl AtomicPtr { failure: Ordering, ) -> Result<*mut T, *mut T> { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_compare_exchange(self.p.get(), current, new, success, failure) } + unsafe { atomic_compare_exchange(self.as_ptr(), current, new, success, failure) } } /// Stores a value into the pointer if the current value is the same as the `current` value. @@ -1954,7 +1984,7 @@ impl AtomicPtr { // but we know for sure that the pointer is valid (we just got it from // an `UnsafeCell` that we have by reference) and the atomic operation // itself allows us to safely mutate the `UnsafeCell` contents. - unsafe { atomic_compare_exchange_weak(self.p.get(), current, new, success, failure) } + unsafe { atomic_compare_exchange_weak(self.as_ptr(), current, new, success, failure) } } /// An alias for [`AtomicPtr::try_update`]. @@ -2243,7 +2273,7 @@ impl AtomicPtr { #[rustc_should_not_be_called_on_const_items] pub fn fetch_byte_add(&self, val: usize, order: Ordering) -> *mut T { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_add(self.p.get(), val, order).cast() } + unsafe { atomic_add(self.as_ptr(), val, order).cast() } } /// Offsets the pointer's address by subtracting `val` *bytes*, returning the @@ -2279,7 +2309,7 @@ impl AtomicPtr { #[rustc_should_not_be_called_on_const_items] pub fn fetch_byte_sub(&self, val: usize, order: Ordering) -> *mut T { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_sub(self.p.get(), val, order).cast() } + unsafe { atomic_sub(self.as_ptr(), val, order).cast() } } /// Performs a bitwise "or" operation on the address of the current pointer, @@ -2330,7 +2360,7 @@ impl AtomicPtr { #[rustc_should_not_be_called_on_const_items] pub fn fetch_or(&self, val: usize, order: Ordering) -> *mut T { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_or(self.p.get(), val, order).cast() } + unsafe { atomic_or(self.as_ptr(), val, order).cast() } } /// Performs a bitwise "and" operation on the address of the current @@ -2380,7 +2410,7 @@ impl AtomicPtr { #[rustc_should_not_be_called_on_const_items] pub fn fetch_and(&self, val: usize, order: Ordering) -> *mut T { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_and(self.p.get(), val, order).cast() } + unsafe { atomic_and(self.as_ptr(), val, order).cast() } } /// Performs a bitwise "xor" operation on the address of the current @@ -2428,7 +2458,7 @@ impl AtomicPtr { #[rustc_should_not_be_called_on_const_items] pub fn fetch_xor(&self, val: usize, order: Ordering) -> *mut T { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_xor(self.p.get(), val, order).cast() } + unsafe { atomic_xor(self.as_ptr(), val, order).cast() } } /// Returns a mutable pointer to the underlying pointer. @@ -2467,7 +2497,7 @@ impl AtomicPtr { #[rustc_const_stable(feature = "atomic_as_ptr", since = "1.70.0")] #[rustc_never_returns_null_ptr] pub const fn as_ptr(&self) -> *mut *mut T { - self.p.get() + self.v.get().cast() } } @@ -2520,7 +2550,6 @@ macro_rules! atomic_int { $stable_nand:meta, $const_stable_new:meta, $const_stable_into_inner:meta, - $diagnostic_item:meta, $s_int_type:literal, $extra_feature:expr, $min_fn:ident, $max_fn:ident, @@ -2557,11 +2586,7 @@ macro_rules! atomic_int { /// /// [module-level documentation]: crate::sync::atomic #[$stable] - #[$diagnostic_item] - #[repr(C, align($align))] - pub struct $atomic_type { - v: UnsafeCell<$int_type>, - } + pub type $atomic_type = Atomic<$int_type>; #[$stable] impl Default for $atomic_type { @@ -2586,10 +2611,6 @@ macro_rules! atomic_int { } } - // Send is implicitly implemented. - #[$stable] - unsafe impl Sync for $atomic_type {} - impl $atomic_type { /// Creates a new atomic integer. /// @@ -2605,7 +2626,9 @@ macro_rules! atomic_int { #[$const_stable_new] #[must_use] pub const fn new(v: $int_type) -> Self { - Self {v: UnsafeCell::new(v)} + // SAFETY: + // `Atomic` is essentially a transparent wrapper around `T`. + unsafe { transmute(v) } } /// Creates a new reference to an atomic integer from a pointer. @@ -2667,7 +2690,6 @@ macro_rules! atomic_int { unsafe { &*ptr.cast() } } - /// Returns a mutable reference to the underlying integer. /// /// This is safe because the mutable reference guarantees that no other threads are @@ -2686,7 +2708,9 @@ macro_rules! atomic_int { #[inline] #[$stable_access] pub fn get_mut(&mut self) -> &mut $int_type { - self.v.get_mut() + // SAFETY: + // `Atomic` is essentially a transparent wrapper around `T`. + unsafe { &mut *self.as_ptr() } } #[doc = concat!("Get atomic access to a `&mut ", stringify!($int_type), "`.")] @@ -2815,7 +2839,9 @@ macro_rules! atomic_int { #[$stable_access] #[$const_stable_into_inner] pub const fn into_inner(self) -> $int_type { - self.v.into_inner() + // SAFETY: + // `Atomic` is essentially a transparent wrapper around `T`. + unsafe { transmute(self) } } /// Loads a value from the atomic integer. @@ -2841,7 +2867,7 @@ macro_rules! atomic_int { #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub fn load(&self, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_load(self.v.get(), order) } + unsafe { atomic_load(self.as_ptr(), order) } } /// Stores a value into the atomic integer. @@ -2869,7 +2895,7 @@ macro_rules! atomic_int { #[rustc_should_not_be_called_on_const_items] pub fn store(&self, val: $int_type, order: Ordering) { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_store(self.v.get(), val, order); } + unsafe { atomic_store(self.as_ptr(), val, order); } } /// Stores a value into the atomic integer, returning the previous value. @@ -2898,7 +2924,7 @@ macro_rules! atomic_int { #[rustc_should_not_be_called_on_const_items] pub fn swap(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_swap(self.v.get(), val, order) } + unsafe { atomic_swap(self.as_ptr(), val, order) } } /// Stores a value into the atomic integer if the current value is the same as @@ -3036,7 +3062,7 @@ macro_rules! atomic_int { success: Ordering, failure: Ordering) -> Result<$int_type, $int_type> { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_compare_exchange(self.v.get(), current, new, success, failure) } + unsafe { atomic_compare_exchange(self.as_ptr(), current, new, success, failure) } } /// Stores a value into the atomic integer if the current value is the same as @@ -3101,7 +3127,7 @@ macro_rules! atomic_int { failure: Ordering) -> Result<$int_type, $int_type> { // SAFETY: data races are prevented by atomic intrinsics. unsafe { - atomic_compare_exchange_weak(self.v.get(), current, new, success, failure) + atomic_compare_exchange_weak(self.as_ptr(), current, new, success, failure) } } @@ -3133,7 +3159,7 @@ macro_rules! atomic_int { #[rustc_should_not_be_called_on_const_items] pub fn fetch_add(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_add(self.v.get(), val, order) } + unsafe { atomic_add(self.as_ptr(), val, order) } } /// Subtracts from the current value, returning the previous value. @@ -3164,7 +3190,7 @@ macro_rules! atomic_int { #[rustc_should_not_be_called_on_const_items] pub fn fetch_sub(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_sub(self.v.get(), val, order) } + unsafe { atomic_sub(self.as_ptr(), val, order) } } /// Bitwise "and" with the current value. @@ -3198,7 +3224,7 @@ macro_rules! atomic_int { #[rustc_should_not_be_called_on_const_items] pub fn fetch_and(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_and(self.v.get(), val, order) } + unsafe { atomic_and(self.as_ptr(), val, order) } } /// Bitwise "nand" with the current value. @@ -3232,7 +3258,7 @@ macro_rules! atomic_int { #[rustc_should_not_be_called_on_const_items] pub fn fetch_nand(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_nand(self.v.get(), val, order) } + unsafe { atomic_nand(self.as_ptr(), val, order) } } /// Bitwise "or" with the current value. @@ -3266,7 +3292,7 @@ macro_rules! atomic_int { #[rustc_should_not_be_called_on_const_items] pub fn fetch_or(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_or(self.v.get(), val, order) } + unsafe { atomic_or(self.as_ptr(), val, order) } } /// Bitwise "xor" with the current value. @@ -3300,7 +3326,7 @@ macro_rules! atomic_int { #[rustc_should_not_be_called_on_const_items] pub fn fetch_xor(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_xor(self.v.get(), val, order) } + unsafe { atomic_xor(self.as_ptr(), val, order) } } /// An alias for @@ -3499,7 +3525,7 @@ macro_rules! atomic_int { #[rustc_should_not_be_called_on_const_items] pub fn fetch_max(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { $max_fn(self.v.get(), val, order) } + unsafe { $max_fn(self.as_ptr(), val, order) } } /// Minimum with the current value. @@ -3546,7 +3572,7 @@ macro_rules! atomic_int { #[rustc_should_not_be_called_on_const_items] pub fn fetch_min(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { $min_fn(self.v.get(), val, order) } + unsafe { $min_fn(self.as_ptr(), val, order) } } /// Returns a mutable pointer to the underlying integer. @@ -3586,7 +3612,7 @@ macro_rules! atomic_int { #[rustc_const_stable(feature = "atomic_as_ptr", since = "1.70.0")] #[rustc_never_returns_null_ptr] pub const fn as_ptr(&self) -> *mut $int_type { - self.v.get() + self.v.get().cast() } } } @@ -3604,7 +3630,6 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - rustc_diagnostic_item = "AtomicI8", "i8", "", atomic_min, atomic_max, @@ -3623,7 +3648,6 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - rustc_diagnostic_item = "AtomicU8", "u8", "", atomic_umin, atomic_umax, @@ -3642,7 +3666,6 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - rustc_diagnostic_item = "AtomicI16", "i16", "", atomic_min, atomic_max, @@ -3661,7 +3684,6 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - rustc_diagnostic_item = "AtomicU16", "u16", "", atomic_umin, atomic_umax, @@ -3680,7 +3702,6 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - rustc_diagnostic_item = "AtomicI32", "i32", "", atomic_min, atomic_max, @@ -3699,7 +3720,6 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - rustc_diagnostic_item = "AtomicU32", "u32", "", atomic_umin, atomic_umax, @@ -3718,7 +3738,6 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - rustc_diagnostic_item = "AtomicI64", "i64", "", atomic_min, atomic_max, @@ -3737,7 +3756,6 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - rustc_diagnostic_item = "AtomicU64", "u64", "", atomic_umin, atomic_umax, @@ -3756,7 +3774,6 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "99069"), rustc_const_unstable(feature = "integer_atomics", issue = "99069"), rustc_const_unstable(feature = "integer_atomics", issue = "99069"), - rustc_diagnostic_item = "AtomicI128", "i128", "#![feature(integer_atomics)]\n\n", atomic_min, atomic_max, @@ -3775,7 +3792,6 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "99069"), rustc_const_unstable(feature = "integer_atomics", issue = "99069"), rustc_const_unstable(feature = "integer_atomics", issue = "99069"), - rustc_diagnostic_item = "AtomicU128", "u128", "#![feature(integer_atomics)]\n\n", atomic_umin, atomic_umax, @@ -3798,7 +3814,6 @@ macro_rules! atomic_int_ptr_sized { stable(feature = "atomic_nand", since = "1.27.0"), rustc_const_stable(feature = "const_ptr_sized_atomics", since = "1.24.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - rustc_diagnostic_item = "AtomicIsize", "isize", "", atomic_min, atomic_max, @@ -3817,7 +3832,6 @@ macro_rules! atomic_int_ptr_sized { stable(feature = "atomic_nand", since = "1.27.0"), rustc_const_stable(feature = "const_ptr_sized_atomics", since = "1.24.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - rustc_diagnostic_item = "AtomicUsize", "usize", "", atomic_umin, atomic_umax, diff --git a/src/etc/gdb_providers.py b/src/etc/gdb_providers.py index b0b6682f5279e..bd27998b37706 100644 --- a/src/etc/gdb_providers.py +++ b/src/etc/gdb_providers.py @@ -18,6 +18,12 @@ def unwrap_unique_or_non_null(unique_or_nonnull): return ptr if ptr.type.code == gdb.TYPE_CODE_PTR else ptr[ptr.type.fields()[0]] +def unwrap_scalar_wrappers(wrapper): + while not wrapper.type.is_scalar: + wrapper = wrapper[wrapper.type.fields()[0]] + return wrapper + + # GDB 14 has a tag class that indicates that extension methods are ok # to call. Use of this tag only requires that printers hide local # attributes and methods by prefixing them with "_". @@ -197,8 +203,8 @@ def __init__(self, valobj, is_atomic=False): self._is_atomic = is_atomic self._ptr = unwrap_unique_or_non_null(valobj["ptr"]) self._value = self._ptr["data" if is_atomic else "value"] - self._strong = self._ptr["strong"]["v" if is_atomic else "value"]["value"] - self._weak = self._ptr["weak"]["v" if is_atomic else "value"]["value"] - 1 + self._strong = unwrap_scalar_wrappers(self._ptr["strong"]) + self._weak = unwrap_scalar_wrappers(self._ptr["weak"]) - 1 def to_string(self): if self._is_atomic: diff --git a/src/etc/lldb_providers.py b/src/etc/lldb_providers.py index 582471622baa6..88d210691d00e 100644 --- a/src/etc/lldb_providers.py +++ b/src/etc/lldb_providers.py @@ -9,6 +9,7 @@ eBasicTypeUnsignedLong, eBasicTypeUnsignedChar, eFormatChar, + eTypeIsInteger, ) from rust_types import is_tuple_fields @@ -90,6 +91,12 @@ def unwrap_unique_or_non_null(unique_or_nonnull: SBValue) -> SBValue: return ptr if ptr.TypeIsPointerType() else ptr.GetChildAtIndex(0) +def unwrap_scalar_wrappers(wrapper: SBValue) -> SBValue: + while (wrapper.type.GetTypeFlags() & eTypeIsInteger) == 0: + wrapper = wrapper.GetChildAtIndex(0) + return wrapper + + class DefaultSyntheticProvider: def __init__(self, valobj: SBValue, _dict: LLDBOpaque): # logger = Logger.Logger() @@ -1246,12 +1253,9 @@ class StdRcSyntheticProvider: rust 1.33.0: struct NonNull { pointer: *const T } struct NonZero(T) struct RcInner { strong: Cell, weak: Cell, value: T } - struct Cell { value: UnsafeCell } - struct UnsafeCell { value: T } struct Arc { ptr: NonNull>, ... } - struct ArcInner { strong: atomic::AtomicUsize, weak: atomic::AtomicUsize, data: T } - struct AtomicUsize { v: UnsafeCell } + struct ArcInner { strong: atomic::Atomic, weak: atomic::Atomic, data: T } """ def __init__(self, valobj: SBValue, _dict: LLDBOpaque, is_atomic: bool = False): @@ -1261,16 +1265,8 @@ def __init__(self, valobj: SBValue, _dict: LLDBOpaque, is_atomic: bool = False): self.value = self.ptr.GetChildMemberWithName("data" if is_atomic else "value") - self.strong = ( - self.ptr.GetChildMemberWithName("strong") - .GetChildAtIndex(0) - .GetChildMemberWithName("value") - ) - self.weak = ( - self.ptr.GetChildMemberWithName("weak") - .GetChildAtIndex(0) - .GetChildMemberWithName("value") - ) + self.strong = unwrap_scalar_wrappers(self.ptr.GetChildMemberWithName("strong")) + self.weak = unwrap_scalar_wrappers(self.ptr.GetChildMemberWithName("weak")) self.value_builder = ValueBuilder(valobj) diff --git a/src/etc/natvis/libcore.natvis b/src/etc/natvis/libcore.natvis index d09f0d635692a..a2755888094a1 100644 --- a/src/etc/natvis/libcore.natvis +++ b/src/etc/natvis/libcore.natvis @@ -89,38 +89,38 @@ - - {(bool)v.value} + + {(bool)v.value.__0} - - {v.value} + + {v.value.__0} - - {v.value} + + {v.value.__0} - - {v.value} + + {v.value.__0} - - {v.value} + + {v.value.__0} - - {v.value} + + {v.value.__0} - - {v.value} + + {v.value.__0} - - {v.value} + + {v.value.__0} - - {v.value} + + {v.value.__0} - - {v.value} + + {v.value.__0} - - {v.value} + + {v.value.__0} diff --git a/src/tools/clippy/clippy_lints/src/loops/missing_spin_loop.rs b/src/tools/clippy/clippy_lints/src/loops/missing_spin_loop.rs index d5dbcbe9dc701..ca8383070d70f 100644 --- a/src/tools/clippy/clippy_lints/src/loops/missing_spin_loop.rs +++ b/src/tools/clippy/clippy_lints/src/loops/missing_spin_loop.rs @@ -40,7 +40,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, cond: &'tcx Expr<'_>, body: &' && let ExprKind::MethodCall(method, callee, ..) = unpack_cond(cond).kind && [sym::load, sym::compare_exchange, sym::compare_exchange_weak].contains(&method.ident.name) && let callee_ty = cx.typeck_results().expr_ty(callee) - && callee_ty.is_diag_item(cx, sym::AtomicBool) + && callee_ty.is_diag_item(cx, sym::Atomic) && let Some(std_or_core) = std_or_core(cx) { span_lint_and_sugg( diff --git a/src/tools/clippy/tests/ui/mut_key.stderr b/src/tools/clippy/tests/ui/mut_key.stderr index 0d504584fbae8..e7a1d6833847e 100644 --- a/src/tools/clippy/tests/ui/mut_key.stderr +++ b/src/tools/clippy/tests/ui/mut_key.stderr @@ -5,8 +5,8 @@ LL | fn should_not_take_this_arg(m: &mut HashMap, _n: usize) -> Hash | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: ... because it contains `Key`, which has interior mutability - = note: ... because it contains `AtomicUsize`, which has interior mutability - = note: ... because it contains `UnsafeCell`, which has interior mutability + = note: ... because it contains `Atomic`, which has interior mutability + = note: ... because it contains `UnsafeCell<::Storage>`, which has interior mutability = note: `-D clippy::mutable-key-type` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::mutable_key_type)]` @@ -17,8 +17,8 @@ LL | fn should_not_take_this_arg(m: &mut HashMap, _n: usize) -> Hash | ^^^^^^^^^^^^ | = note: ... because it contains `Key`, which has interior mutability - = note: ... because it contains `AtomicUsize`, which has interior mutability - = note: ... because it contains `UnsafeCell`, which has interior mutability + = note: ... because it contains `Atomic`, which has interior mutability + = note: ... because it contains `UnsafeCell<::Storage>`, which has interior mutability error: mutable key type --> tests/ui/mut_key.rs:35:5 @@ -27,8 +27,8 @@ LL | let _other: HashMap = HashMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: ... because it contains `Key`, which has interior mutability - = note: ... because it contains `AtomicUsize`, which has interior mutability - = note: ... because it contains `UnsafeCell`, which has interior mutability + = note: ... because it contains `Atomic`, which has interior mutability + = note: ... because it contains `UnsafeCell<::Storage>`, which has interior mutability error: mutable key type --> tests/ui/mut_key.rs:64:22 @@ -38,8 +38,8 @@ LL | fn tuples_bad(_m: &mut HashMap<(Key, U), bool>) {} | = note: ... because it contains `(Key, U)`, which has interior mutability = note: ... because it contains `Key`, which has interior mutability - = note: ... because it contains `AtomicUsize`, which has interior mutability - = note: ... because it contains `UnsafeCell`, which has interior mutability + = note: ... because it contains `Atomic`, which has interior mutability + = note: ... because it contains `UnsafeCell<::Storage>`, which has interior mutability error: mutable key type --> tests/ui/mut_key.rs:77:5 diff --git a/tests/debuginfo/numeric-types.rs b/tests/debuginfo/numeric-types.rs index 81fa7900c5faf..dbbc4ee6e8614 100644 --- a/tests/debuginfo/numeric-types.rs +++ b/tests/debuginfo/numeric-types.rs @@ -114,52 +114,40 @@ //@ cdb-check: [+0x000] __0 : 0x78 [Type: unsigned __int64] //@ cdb-command: dx a_bool_t -//@ cdb-check:a_bool_t : true [Type: core::sync::atomic::AtomicBool] -//@ cdb-check: [+0x000] v : 0x1 [Type: core::cell::UnsafeCell] +//@ cdb-check:a_bool_t : true [Type: core::sync::atomic::Atomic] //@ cdb-command: dx a_bool_f -//@ cdb-check:a_bool_f : false [Type: core::sync::atomic::AtomicBool] -//@ cdb-check: [+0x000] v : 0x0 [Type: core::cell::UnsafeCell] +//@ cdb-check:a_bool_f : false [Type: core::sync::atomic::Atomic] //@ cdb-command: dx a_i8 -//@ cdb-check:a_i8 : 2 [Type: core::sync::atomic::AtomicI8] -//@ cdb-check: [+0x000] v : 2 [Type: core::cell::UnsafeCell] +//@ cdb-check:a_i8 : 2 [Type: core::sync::atomic::Atomic] //@ cdb-command: dx a_i16 -//@ cdb-check:a_i16 : 4 [Type: core::sync::atomic::AtomicI16] -//@ cdb-check: [+0x000] v : 4 [Type: core::cell::UnsafeCell] +//@ cdb-check:a_i16 : 4 [Type: core::sync::atomic::Atomic] //@ cdb-command: dx a_i32 -//@ cdb-check:a_i32 : 8 [Type: core::sync::atomic::AtomicI32] -//@ cdb-check: [+0x000] v : 8 [Type: core::cell::UnsafeCell] +//@ cdb-check:a_i32 : 8 [Type: core::sync::atomic::Atomic] //@ cdb-command: dx a_i64 -//@ cdb-check:a_i64 : 16 [Type: core::sync::atomic::AtomicI64] -//@ cdb-check: [+0x000] v : 16 [Type: core::cell::UnsafeCell] +//@ cdb-check:a_i64 : 16 [Type: core::sync::atomic::Atomic] //@ cdb-command: dx a_isize -//@ cdb-check:a_isize : 32 [Type: core::sync::atomic::AtomicIsize] -//@ cdb-check: [+0x000] v : 32 [Type: core::cell::UnsafeCell] +//@ cdb-check:a_isize : 32 [Type: core::sync::atomic::Atomic] //@ cdb-command: dx a_u8 -//@ cdb-check:a_u8 : 0x40 [Type: core::sync::atomic::AtomicU8] -//@ cdb-check: [+0x000] v : 0x40 [Type: core::cell::UnsafeCell] +//@ cdb-check:a_u8 : 0x40 [Type: core::sync::atomic::Atomic] //@ cdb-command: dx a_u16 -//@ cdb-check:a_u16 : 0x80 [Type: core::sync::atomic::AtomicU16] -//@ cdb-check: [+0x000] v : 0x80 [Type: core::cell::UnsafeCell] +//@ cdb-check:a_u16 : 0x80 [Type: core::sync::atomic::Atomic] //@ cdb-command: dx a_u32 -//@ cdb-check:a_u32 : 0x100 [Type: core::sync::atomic::AtomicU32] -//@ cdb-check: [+0x000] v : 0x100 [Type: core::cell::UnsafeCell] +//@ cdb-check:a_u32 : 0x100 [Type: core::sync::atomic::Atomic] //@ cdb-command: dx a_u64 -//@ cdb-check:a_u64 : 0x200 [Type: core::sync::atomic::AtomicU64] -//@ cdb-check: [+0x000] v : 0x200 [Type: core::cell::UnsafeCell] +//@ cdb-check:a_u64 : 0x200 [Type: core::sync::atomic::Atomic] //@ cdb-command: dx a_usize -//@ cdb-check:a_usize : 0x400 [Type: core::sync::atomic::AtomicUsize] -//@ cdb-check: [+0x000] v : 0x400 [Type: core::cell::UnsafeCell] +//@ cdb-check:a_usize : 0x400 [Type: core::sync::atomic::Atomic] // === GDB TESTS =================================================================================== diff --git a/tests/debuginfo/rc_arc.rs b/tests/debuginfo/rc_arc.rs index a2eeeaad6aa8b..b22b7e0d1611d 100644 --- a/tests/debuginfo/rc_arc.rs +++ b/tests/debuginfo/rc_arc.rs @@ -38,13 +38,13 @@ //@ cdb-command:dx arc,d //@ cdb-check:arc,d : 222 [Type: alloc::sync::Arc] -//@ cdb-check: [Reference count] : 21 [Type: core::sync::atomic::AtomicUsize] -//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-check: [Reference count] : 21 [Type: core::sync::atomic::Atomic] +//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::Atomic] //@ cdb-command:dx weak_arc,d //@ cdb-check:weak_arc,d : 222 [Type: alloc::sync::Weak] -//@ cdb-check: [Reference count] : 21 [Type: core::sync::atomic::AtomicUsize] -//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-check: [Reference count] : 21 [Type: core::sync::atomic::Atomic] +//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::Atomic] //@ cdb-command:dx dyn_rc,d //@ cdb-check:dyn_rc,d [Type: alloc::rc::Rc,alloc::alloc::Global>] @@ -76,19 +76,19 @@ //@ cdb-command:dx dyn_arc,d //@ cdb-check:dyn_arc,d [Type: alloc::sync::Arc,alloc::alloc::Global>] -//@ cdb-check: [Reference count] : 51 [Type: core::sync::atomic::AtomicUsize] -//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-check: [Reference count] : 51 [Type: core::sync::atomic::Atomic] +//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::Atomic] //@ cdb-command:dx dyn_arc_weak,d //@ cdb-check:dyn_arc_weak,d [Type: alloc::sync::Weak,alloc::alloc::Global>] -//@ cdb-check: [Reference count] : 51 [Type: core::sync::atomic::AtomicUsize] -//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-check: [Reference count] : 51 [Type: core::sync::atomic::Atomic] +//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::Atomic] //@ cdb-command:dx slice_arc,d //@ cdb-check:slice_arc,d : { len=3 } [Type: alloc::sync::Arc,alloc::alloc::Global>] //@ cdb-check: [Length] : 3 [Type: [...]] -//@ cdb-check: [Reference count] : 61 [Type: core::sync::atomic::AtomicUsize] -//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-check: [Reference count] : 61 [Type: core::sync::atomic::Atomic] +//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::Atomic] //@ cdb-check: [0] : 4 [Type: u32] //@ cdb-check: [1] : 5 [Type: u32] //@ cdb-check: [2] : 6 [Type: u32] @@ -96,8 +96,8 @@ //@ cdb-command:dx slice_arc_weak,d //@ cdb-check:slice_arc_weak,d : { len=3 } [Type: alloc::sync::Weak,alloc::alloc::Global>] //@ cdb-check: [Length] : 3 [Type: [...]] -//@ cdb-check: [Reference count] : 61 [Type: core::sync::atomic::AtomicUsize] -//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-check: [Reference count] : 61 [Type: core::sync::atomic::Atomic] +//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::Atomic] //@ cdb-check: [0] : 4 [Type: u32] //@ cdb-check: [1] : 5 [Type: u32] //@ cdb-check: [2] : 6 [Type: u32] diff --git a/tests/rustdoc-html/jump-to-def/non-local-method.rs b/tests/rustdoc-html/jump-to-def/non-local-method.rs index c601f3259c4da..e084899b2495e 100644 --- a/tests/rustdoc-html/jump-to-def/non-local-method.rs +++ b/tests/rustdoc-html/jump-to-def/non-local-method.rs @@ -4,8 +4,8 @@ //@ has 'src/foo/non-local-method.rs.html' -//@ has - '//a[@href="{{channel}}/core/sync/atomic/struct.AtomicIsize.html"]' 'std::sync::atomic::AtomicIsize' -use std::sync::atomic::AtomicIsize; +//@ has - '//a[@href="{{channel}}/alloc/boxed/struct.Box.html"]' 'std::boxed::Box' +use std::boxed::Box; //@ has - '//a[@href="{{channel}}/std/io/trait.Read.html"]' 'std::io::Read' use std::io::Read; //@ has - '//a[@href="{{channel}}/std/io/index.html"]' 'std::io' @@ -21,9 +21,9 @@ pub fn bar2(readable: T) { } pub fn bar() { - //@ has - '//a[@href="{{channel}}/core/sync/atomic/struct.AtomicIsize.html"]' 'AtomicIsize' - //@ has - '//a[@href="{{channel}}/core/sync/atomic/struct.AtomicIsize.html#method.new"]' 'new' - let _ = AtomicIsize::new(0); + //@ has - '//a[@href="{{channel}}/alloc/boxed/struct.Box.html"]' 'Box' + //@ has - '//a[@href="{{channel}}/alloc/boxed/struct.Box.html#method.new"]' 'new' + let _ = Box::new(0); //@ has - '//a[@href="#49"]' 'local_private' local_private(); } diff --git a/tests/rustdoc-html/reexport/overlapping-reexport-105735-2.rs b/tests/rustdoc-html/reexport/overlapping-reexport-105735-2.rs index fa43924ff4ebf..1b2e756c2ce70 100644 --- a/tests/rustdoc-html/reexport/overlapping-reexport-105735-2.rs +++ b/tests/rustdoc-html/reexport/overlapping-reexport-105735-2.rs @@ -1,26 +1,26 @@ -// Regression test to ensure that both `AtomicU8` items are displayed but not the re-export. +// Regression test to ensure that both `Thing` items are displayed but not the re-export. // https://github.com/rust-lang/rust/issues/105735 #![crate_name = "foo"] #![no_std] //@ has 'foo/index.html' -//@ has - '//dt/a[@class="type"]' 'AtomicU8' -//@ has - '//dt/a[@class="constant"]' 'AtomicU8' +//@ has - '//dt/a[@class="type"]' 'Thing' +//@ has - '//dt/a[@class="constant"]' 'Thing' // We also ensure we don't have another item displayed. //@ count - '//*[@id="main-content"]/*[@class="section-header"]' 2 //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Type Aliases' //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Constants' mod other { - pub type AtomicU8 = (); + pub type Thing = (); } mod thing { - pub use crate::other::AtomicU8; + pub use crate::other::Thing; #[allow(non_upper_case_globals)] - pub const AtomicU8: () = (); + pub const Thing: () = (); } -pub use crate::thing::AtomicU8; +pub use crate::thing::Thing; diff --git a/tests/rustdoc-html/reexport/overlapping-reexport-105735.rs b/tests/rustdoc-html/reexport/overlapping-reexport-105735.rs index d1b5c0b6749ad..499887b918ded 100644 --- a/tests/rustdoc-html/reexport/overlapping-reexport-105735.rs +++ b/tests/rustdoc-html/reexport/overlapping-reexport-105735.rs @@ -1,22 +1,22 @@ -// Regression test to ensure that both `AtomicU8` items are displayed but not the re-export. +// Regression test to ensure that both `Ordering` items are displayed but not the re-export. // https://github.com/rust-lang/rust/issues/105735 #![crate_name = "foo"] #![no_std] //@ has 'foo/index.html' -//@ has - '//dt/a[@class="struct"]' 'AtomicU8' -//@ has - '//dt/a[@class="constant"]' 'AtomicU8' +//@ has - '//dt/a[@class="enum"]' 'Ordering' +//@ has - '//dt/a[@class="constant"]' 'Ordering' // We also ensure we don't have another item displayed. //@ count - '//*[@id="main-content"]/*[@class="section-header"]' 2 -//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Structs' +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Enums' //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Constants' mod thing { - pub use core::sync::atomic::AtomicU8; + pub use core::cmp::Ordering; #[allow(non_upper_case_globals)] - pub const AtomicU8: () = (); + pub const Ordering: () = (); } -pub use crate::thing::AtomicU8; +pub use crate::thing::Ordering; diff --git a/tests/ui/asm/bad-template.aarch64.stderr b/tests/ui/asm/bad-template.aarch64.stderr index 30c793f3a4476..5f7ebb539107c 100644 --- a/tests/ui/asm/bad-template.aarch64.stderr +++ b/tests/ui/asm/bad-template.aarch64.stderr @@ -1,5 +1,5 @@ error: invalid reference to argument at index 0 - --> $DIR/bad-template.rs:20:15 + --> $DIR/bad-template.rs:22:15 | LL | asm!("{}"); | ^^ from here @@ -7,7 +7,7 @@ LL | asm!("{}"); = note: no arguments were given error: invalid reference to argument at index 1 - --> $DIR/bad-template.rs:22:15 + --> $DIR/bad-template.rs:24:15 | LL | asm!("{1}", in(reg) foo); | ^^^ from here @@ -15,7 +15,7 @@ LL | asm!("{1}", in(reg) foo); = note: there is 1 argument error: argument never used - --> $DIR/bad-template.rs:22:21 + --> $DIR/bad-template.rs:24:21 | LL | asm!("{1}", in(reg) foo); | ^^^^^^^^^^^ argument never used @@ -23,13 +23,13 @@ LL | asm!("{1}", in(reg) foo); = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {0} */"` error: there is no argument named `a` - --> $DIR/bad-template.rs:25:16 + --> $DIR/bad-template.rs:27:16 | LL | asm!("{a}"); | ^ error: invalid reference to argument at index 0 - --> $DIR/bad-template.rs:27:15 + --> $DIR/bad-template.rs:29:15 | LL | asm!("{}", a = in(reg) foo); | ^^ --------------- named argument @@ -38,13 +38,13 @@ LL | asm!("{}", a = in(reg) foo); | = note: no positional arguments were given note: named arguments cannot be referenced by position - --> $DIR/bad-template.rs:27:20 + --> $DIR/bad-template.rs:29:20 | LL | asm!("{}", a = in(reg) foo); | ^^^^^^^^^^^^^^^ error: named argument never used - --> $DIR/bad-template.rs:27:20 + --> $DIR/bad-template.rs:29:20 | LL | asm!("{}", a = in(reg) foo); | ^^^^^^^^^^^^^^^ named argument never used @@ -52,7 +52,7 @@ LL | asm!("{}", a = in(reg) foo); = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"` error: invalid reference to argument at index 1 - --> $DIR/bad-template.rs:30:15 + --> $DIR/bad-template.rs:32:15 | LL | asm!("{1}", a = in(reg) foo); | ^^^ from here @@ -60,7 +60,7 @@ LL | asm!("{1}", a = in(reg) foo); = note: no positional arguments were given error: named argument never used - --> $DIR/bad-template.rs:30:21 + --> $DIR/bad-template.rs:32:21 | LL | asm!("{1}", a = in(reg) foo); | ^^^^^^^^^^^^^^^ named argument never used @@ -68,7 +68,7 @@ LL | asm!("{1}", a = in(reg) foo); = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"` error: invalid reference to argument at index 0 - --> $DIR/bad-template.rs:37:15 + --> $DIR/bad-template.rs:39:15 | LL | asm!("{}", in("x0") foo); | ^^ ------------ explicit register argument @@ -77,24 +77,24 @@ LL | asm!("{}", in("x0") foo); | = note: no positional arguments were given note: explicit register arguments cannot be used in the asm template - --> $DIR/bad-template.rs:37:20 + --> $DIR/bad-template.rs:39:20 | LL | asm!("{}", in("x0") foo); | ^^^^^^^^^^^^ help: use the register name directly in the assembly code - --> $DIR/bad-template.rs:37:20 + --> $DIR/bad-template.rs:39:20 | LL | asm!("{}", in("x0") foo); | ^^^^^^^^^^^^ error: asm template modifier must be a single character - --> $DIR/bad-template.rs:39:17 + --> $DIR/bad-template.rs:41:17 | LL | asm!("{:foo}", in(reg) foo); | ^^^ error: multiple unused asm arguments - --> $DIR/bad-template.rs:42:18 + --> $DIR/bad-template.rs:44:18 | LL | asm!("", in(reg) 0, in(reg) 1); | ^^^^^^^^^ ^^^^^^^^^ argument never used @@ -104,7 +104,7 @@ LL | asm!("", in(reg) 0, in(reg) 1); = help: if these arguments are intentionally unused, consider using them in an asm comment: `"/* {0} {1} */"` error: invalid reference to argument at index 0 - --> $DIR/bad-template.rs:48:14 + --> $DIR/bad-template.rs:50:14 | LL | global_asm!("{}"); | ^^ from here @@ -112,7 +112,7 @@ LL | global_asm!("{}"); = note: no arguments were given error: invalid reference to argument at index 1 - --> $DIR/bad-template.rs:50:14 + --> $DIR/bad-template.rs:52:14 | LL | global_asm!("{1}", const FOO); | ^^^ from here @@ -120,7 +120,7 @@ LL | global_asm!("{1}", const FOO); = note: there is 1 argument error: argument never used - --> $DIR/bad-template.rs:50:20 + --> $DIR/bad-template.rs:52:20 | LL | global_asm!("{1}", const FOO); | ^^^^^^^^^ argument never used @@ -128,13 +128,13 @@ LL | global_asm!("{1}", const FOO); = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {0} */"` error: there is no argument named `a` - --> $DIR/bad-template.rs:53:15 + --> $DIR/bad-template.rs:55:15 | LL | global_asm!("{a}"); | ^ error: invalid reference to argument at index 0 - --> $DIR/bad-template.rs:55:14 + --> $DIR/bad-template.rs:57:14 | LL | global_asm!("{}", a = const FOO); | ^^ ------------- named argument @@ -143,13 +143,13 @@ LL | global_asm!("{}", a = const FOO); | = note: no positional arguments were given note: named arguments cannot be referenced by position - --> $DIR/bad-template.rs:55:19 + --> $DIR/bad-template.rs:57:19 | LL | global_asm!("{}", a = const FOO); | ^^^^^^^^^^^^^ error: named argument never used - --> $DIR/bad-template.rs:55:19 + --> $DIR/bad-template.rs:57:19 | LL | global_asm!("{}", a = const FOO); | ^^^^^^^^^^^^^ named argument never used @@ -157,7 +157,7 @@ LL | global_asm!("{}", a = const FOO); = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"` error: invalid reference to argument at index 1 - --> $DIR/bad-template.rs:58:14 + --> $DIR/bad-template.rs:60:14 | LL | global_asm!("{1}", a = const FOO); | ^^^ from here @@ -165,7 +165,7 @@ LL | global_asm!("{1}", a = const FOO); = note: no positional arguments were given error: named argument never used - --> $DIR/bad-template.rs:58:20 + --> $DIR/bad-template.rs:60:20 | LL | global_asm!("{1}", a = const FOO); | ^^^^^^^^^^^^^ named argument never used @@ -173,13 +173,13 @@ LL | global_asm!("{1}", a = const FOO); = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"` error: asm template modifier must be a single character - --> $DIR/bad-template.rs:61:16 + --> $DIR/bad-template.rs:63:16 | LL | global_asm!("{:foo}", const FOO); | ^^^ error: multiple unused asm arguments - --> $DIR/bad-template.rs:63:17 + --> $DIR/bad-template.rs:65:17 | LL | global_asm!("", const FOO, const FOO); | ^^^^^^^^^ ^^^^^^^^^ argument never used @@ -189,7 +189,7 @@ LL | global_asm!("", const FOO, const FOO); = help: if these arguments are intentionally unused, consider using them in an asm comment: `"/* {0} {1} */"` warning: formatting may not be suitable for sub-register argument - --> $DIR/bad-template.rs:39:15 + --> $DIR/bad-template.rs:41:15 | LL | asm!("{:foo}", in(reg) foo); | ^^^^^^ --- for this argument diff --git a/tests/ui/asm/bad-template.rs b/tests/ui/asm/bad-template.rs index 966611949926d..51fae14f54d0f 100644 --- a/tests/ui/asm/bad-template.rs +++ b/tests/ui/asm/bad-template.rs @@ -1,5 +1,7 @@ //@ add-minicore //@ revisions: x86_64 aarch64 +//@ reference: asm.ts-args.at-least-once +//@ reference: asm.template-modifiers.only-one //@ [x86_64] compile-flags: --target x86_64-unknown-linux-gnu //@ [aarch64] compile-flags: --target aarch64-unknown-linux-gnu diff --git a/tests/ui/asm/bad-template.x86_64.stderr b/tests/ui/asm/bad-template.x86_64.stderr index 6b3f95677d07a..9947117621f1c 100644 --- a/tests/ui/asm/bad-template.x86_64.stderr +++ b/tests/ui/asm/bad-template.x86_64.stderr @@ -1,5 +1,5 @@ error: invalid reference to argument at index 0 - --> $DIR/bad-template.rs:20:15 + --> $DIR/bad-template.rs:22:15 | LL | asm!("{}"); | ^^ from here @@ -7,7 +7,7 @@ LL | asm!("{}"); = note: no arguments were given error: invalid reference to argument at index 1 - --> $DIR/bad-template.rs:22:15 + --> $DIR/bad-template.rs:24:15 | LL | asm!("{1}", in(reg) foo); | ^^^ from here @@ -15,7 +15,7 @@ LL | asm!("{1}", in(reg) foo); = note: there is 1 argument error: argument never used - --> $DIR/bad-template.rs:22:21 + --> $DIR/bad-template.rs:24:21 | LL | asm!("{1}", in(reg) foo); | ^^^^^^^^^^^ argument never used @@ -23,13 +23,13 @@ LL | asm!("{1}", in(reg) foo); = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {0} */"` error: there is no argument named `a` - --> $DIR/bad-template.rs:25:16 + --> $DIR/bad-template.rs:27:16 | LL | asm!("{a}"); | ^ error: invalid reference to argument at index 0 - --> $DIR/bad-template.rs:27:15 + --> $DIR/bad-template.rs:29:15 | LL | asm!("{}", a = in(reg) foo); | ^^ --------------- named argument @@ -38,13 +38,13 @@ LL | asm!("{}", a = in(reg) foo); | = note: no positional arguments were given note: named arguments cannot be referenced by position - --> $DIR/bad-template.rs:27:20 + --> $DIR/bad-template.rs:29:20 | LL | asm!("{}", a = in(reg) foo); | ^^^^^^^^^^^^^^^ error: named argument never used - --> $DIR/bad-template.rs:27:20 + --> $DIR/bad-template.rs:29:20 | LL | asm!("{}", a = in(reg) foo); | ^^^^^^^^^^^^^^^ named argument never used @@ -52,7 +52,7 @@ LL | asm!("{}", a = in(reg) foo); = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"` error: invalid reference to argument at index 1 - --> $DIR/bad-template.rs:30:15 + --> $DIR/bad-template.rs:32:15 | LL | asm!("{1}", a = in(reg) foo); | ^^^ from here @@ -60,7 +60,7 @@ LL | asm!("{1}", a = in(reg) foo); = note: no positional arguments were given error: named argument never used - --> $DIR/bad-template.rs:30:21 + --> $DIR/bad-template.rs:32:21 | LL | asm!("{1}", a = in(reg) foo); | ^^^^^^^^^^^^^^^ named argument never used @@ -68,7 +68,7 @@ LL | asm!("{1}", a = in(reg) foo); = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"` error: invalid reference to argument at index 0 - --> $DIR/bad-template.rs:34:15 + --> $DIR/bad-template.rs:36:15 | LL | asm!("{}", in("eax") foo); | ^^ ------------- explicit register argument @@ -77,24 +77,24 @@ LL | asm!("{}", in("eax") foo); | = note: no positional arguments were given note: explicit register arguments cannot be used in the asm template - --> $DIR/bad-template.rs:34:20 + --> $DIR/bad-template.rs:36:20 | LL | asm!("{}", in("eax") foo); | ^^^^^^^^^^^^^ help: use the register name directly in the assembly code - --> $DIR/bad-template.rs:34:20 + --> $DIR/bad-template.rs:36:20 | LL | asm!("{}", in("eax") foo); | ^^^^^^^^^^^^^ error: asm template modifier must be a single character - --> $DIR/bad-template.rs:39:17 + --> $DIR/bad-template.rs:41:17 | LL | asm!("{:foo}", in(reg) foo); | ^^^ error: multiple unused asm arguments - --> $DIR/bad-template.rs:42:18 + --> $DIR/bad-template.rs:44:18 | LL | asm!("", in(reg) 0, in(reg) 1); | ^^^^^^^^^ ^^^^^^^^^ argument never used @@ -104,7 +104,7 @@ LL | asm!("", in(reg) 0, in(reg) 1); = help: if these arguments are intentionally unused, consider using them in an asm comment: `"/* {0} {1} */"` error: invalid reference to argument at index 0 - --> $DIR/bad-template.rs:48:14 + --> $DIR/bad-template.rs:50:14 | LL | global_asm!("{}"); | ^^ from here @@ -112,7 +112,7 @@ LL | global_asm!("{}"); = note: no arguments were given error: invalid reference to argument at index 1 - --> $DIR/bad-template.rs:50:14 + --> $DIR/bad-template.rs:52:14 | LL | global_asm!("{1}", const FOO); | ^^^ from here @@ -120,7 +120,7 @@ LL | global_asm!("{1}", const FOO); = note: there is 1 argument error: argument never used - --> $DIR/bad-template.rs:50:20 + --> $DIR/bad-template.rs:52:20 | LL | global_asm!("{1}", const FOO); | ^^^^^^^^^ argument never used @@ -128,13 +128,13 @@ LL | global_asm!("{1}", const FOO); = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {0} */"` error: there is no argument named `a` - --> $DIR/bad-template.rs:53:15 + --> $DIR/bad-template.rs:55:15 | LL | global_asm!("{a}"); | ^ error: invalid reference to argument at index 0 - --> $DIR/bad-template.rs:55:14 + --> $DIR/bad-template.rs:57:14 | LL | global_asm!("{}", a = const FOO); | ^^ ------------- named argument @@ -143,13 +143,13 @@ LL | global_asm!("{}", a = const FOO); | = note: no positional arguments were given note: named arguments cannot be referenced by position - --> $DIR/bad-template.rs:55:19 + --> $DIR/bad-template.rs:57:19 | LL | global_asm!("{}", a = const FOO); | ^^^^^^^^^^^^^ error: named argument never used - --> $DIR/bad-template.rs:55:19 + --> $DIR/bad-template.rs:57:19 | LL | global_asm!("{}", a = const FOO); | ^^^^^^^^^^^^^ named argument never used @@ -157,7 +157,7 @@ LL | global_asm!("{}", a = const FOO); = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"` error: invalid reference to argument at index 1 - --> $DIR/bad-template.rs:58:14 + --> $DIR/bad-template.rs:60:14 | LL | global_asm!("{1}", a = const FOO); | ^^^ from here @@ -165,7 +165,7 @@ LL | global_asm!("{1}", a = const FOO); = note: no positional arguments were given error: named argument never used - --> $DIR/bad-template.rs:58:20 + --> $DIR/bad-template.rs:60:20 | LL | global_asm!("{1}", a = const FOO); | ^^^^^^^^^^^^^ named argument never used @@ -173,13 +173,13 @@ LL | global_asm!("{1}", a = const FOO); = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"` error: asm template modifier must be a single character - --> $DIR/bad-template.rs:61:16 + --> $DIR/bad-template.rs:63:16 | LL | global_asm!("{:foo}", const FOO); | ^^^ error: multiple unused asm arguments - --> $DIR/bad-template.rs:63:17 + --> $DIR/bad-template.rs:65:17 | LL | global_asm!("", const FOO, const FOO); | ^^^^^^^^^ ^^^^^^^^^ argument never used @@ -189,7 +189,7 @@ LL | global_asm!("", const FOO, const FOO); = help: if these arguments are intentionally unused, consider using them in an asm comment: `"/* {0} {1} */"` warning: formatting may not be suitable for sub-register argument - --> $DIR/bad-template.rs:39:15 + --> $DIR/bad-template.rs:41:15 | LL | asm!("{:foo}", in(reg) foo); | ^^^^^^ --- for this argument diff --git a/tests/ui/asm/cfg-parse-error.rs b/tests/ui/asm/cfg-parse-error.rs index 0c6b63872a432..c13d003cbcebc 100644 --- a/tests/ui/asm/cfg-parse-error.rs +++ b/tests/ui/asm/cfg-parse-error.rs @@ -1,4 +1,5 @@ //@ needs-asm-support +//@ reference: asm.attributes.supported-attributes use std::arch::asm; diff --git a/tests/ui/asm/cfg-parse-error.stderr b/tests/ui/asm/cfg-parse-error.stderr index 726dee271108f..8a70d39a43dc6 100644 --- a/tests/ui/asm/cfg-parse-error.stderr +++ b/tests/ui/asm/cfg-parse-error.stderr @@ -1,5 +1,5 @@ error: expected one of `#`, `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `label`, `lateout`, `options`, `out`, or `sym`, found `""` - --> $DIR/cfg-parse-error.rs:15:13 + --> $DIR/cfg-parse-error.rs:16:13 | LL | a = out(reg) x, | - expected one of 11 possible tokens @@ -7,7 +7,7 @@ LL | "", | ^^ unexpected token error: expected one of `#`, `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `label`, `lateout`, `options`, `out`, or `sym`, found `""` - --> $DIR/cfg-parse-error.rs:25:13 + --> $DIR/cfg-parse-error.rs:26:13 | LL | }, | - expected one of 11 possible tokens @@ -15,19 +15,19 @@ LL | "", | ^^ unexpected token error: expected token: `,` - --> $DIR/cfg-parse-error.rs:40:26 + --> $DIR/cfg-parse-error.rs:41:26 | LL | a = out(reg) x, | ^ expected `,` error: this attribute is not supported on assembly - --> $DIR/cfg-parse-error.rs:46:13 + --> $DIR/cfg-parse-error.rs:47:13 | LL | #[rustfmt::skip] | ^^^^^^^^^^^^^^^^ error: an inner attribute is not permitted in this context - --> $DIR/cfg-parse-error.rs:52:13 + --> $DIR/cfg-parse-error.rs:53:13 | LL | #![rustfmt::skip] | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/asm/cfg.rs b/tests/ui/asm/cfg.rs index d7a2c78f58d26..74f5eb5481588 100644 --- a/tests/ui/asm/cfg.rs +++ b/tests/ui/asm/cfg.rs @@ -3,6 +3,7 @@ //@ revisions: reva revb //@ only-x86_64 //@ run-pass +//@ reference: asm.attributes.supported-attributes use std::arch::{asm, naked_asm}; diff --git a/tests/ui/asm/invalid-const-operand.rs b/tests/ui/asm/invalid-const-operand.rs index bbf4001752a4b..5c7b1a6b9654f 100644 --- a/tests/ui/asm/invalid-const-operand.rs +++ b/tests/ui/asm/invalid-const-operand.rs @@ -1,6 +1,7 @@ //@ needs-asm-support //@ ignore-nvptx64 //@ ignore-spirv +//@ reference: asm.operand-type.supported-operands.const use std::arch::{asm, global_asm}; diff --git a/tests/ui/asm/invalid-const-operand.stderr b/tests/ui/asm/invalid-const-operand.stderr index 01aa843c6fb19..3a3129ff3f6be 100644 --- a/tests/ui/asm/invalid-const-operand.stderr +++ b/tests/ui/asm/invalid-const-operand.stderr @@ -1,5 +1,5 @@ error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/invalid-const-operand.rs:44:26 + --> $DIR/invalid-const-operand.rs:45:26 | LL | asm!("{}", const x); | ^ non-constant value @@ -11,7 +11,7 @@ LL + const x: /* Type */ = 0; | error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/invalid-const-operand.rs:47:36 + --> $DIR/invalid-const-operand.rs:48:36 | LL | asm!("{}", const const_foo(x)); | ^ non-constant value @@ -23,7 +23,7 @@ LL + const x: /* Type */ = 0; | error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/invalid-const-operand.rs:50:36 + --> $DIR/invalid-const-operand.rs:51:36 | LL | asm!("{}", const const_bar(x)); | ^ non-constant value @@ -35,7 +35,7 @@ LL + const x: /* Type */ = 0; | error: invalid type for `const` operand - --> $DIR/invalid-const-operand.rs:12:19 + --> $DIR/invalid-const-operand.rs:13:19 | LL | global_asm!("{}", const 0f32); | ^^^^^^---- @@ -45,7 +45,7 @@ LL | global_asm!("{}", const 0f32); = help: `const` operands must be of an integer type error: invalid type for `const` operand - --> $DIR/invalid-const-operand.rs:14:19 + --> $DIR/invalid-const-operand.rs:15:19 | LL | global_asm!("{}", const 0 as *mut u8); | ^^^^^^------------ @@ -55,7 +55,7 @@ LL | global_asm!("{}", const 0 as *mut u8); = help: `const` operands must be of an integer type error: invalid type for `const` operand - --> $DIR/invalid-const-operand.rs:24:20 + --> $DIR/invalid-const-operand.rs:25:20 | LL | asm!("{}", const 0f32); | ^^^^^^---- @@ -65,7 +65,7 @@ LL | asm!("{}", const 0f32); = help: `const` operands must be of an integer type error: invalid type for `const` operand - --> $DIR/invalid-const-operand.rs:26:20 + --> $DIR/invalid-const-operand.rs:27:20 | LL | asm!("{}", const 0 as *mut u8); | ^^^^^^------------ @@ -75,7 +75,7 @@ LL | asm!("{}", const 0 as *mut u8); = help: `const` operands must be of an integer type error: invalid type for `const` operand - --> $DIR/invalid-const-operand.rs:28:20 + --> $DIR/invalid-const-operand.rs:29:20 | LL | asm!("{}", const &0); | ^^^^^^-- diff --git a/tests/ui/asm/invalid-sym-operand.rs b/tests/ui/asm/invalid-sym-operand.rs index 2129c20b9681d..48df1918daf0f 100644 --- a/tests/ui/asm/invalid-sym-operand.rs +++ b/tests/ui/asm/invalid-sym-operand.rs @@ -1,6 +1,7 @@ //@ needs-asm-support //@ ignore-nvptx64 //@ ignore-spirv +//@ reference: asm.operand-type.supported-operands.sym use std::arch::{asm, global_asm}; diff --git a/tests/ui/asm/invalid-sym-operand.stderr b/tests/ui/asm/invalid-sym-operand.stderr index f0e6a17c25f6b..ef9ed04550580 100644 --- a/tests/ui/asm/invalid-sym-operand.stderr +++ b/tests/ui/asm/invalid-sym-operand.stderr @@ -1,5 +1,5 @@ error: invalid `sym` operand - --> $DIR/invalid-sym-operand.rs:27:24 + --> $DIR/invalid-sym-operand.rs:28:24 | LL | asm!("{}", sym x); | ^ is a local variable @@ -7,7 +7,7 @@ LL | asm!("{}", sym x); = help: `sym` operands must refer to either a function or a static error: invalid `sym` operand - --> $DIR/invalid-sym-operand.rs:13:19 + --> $DIR/invalid-sym-operand.rs:14:19 | LL | global_asm!("{}", sym C); | ^^^^^ is an `i32` @@ -15,7 +15,7 @@ LL | global_asm!("{}", sym C); = help: `sym` operands must refer to either a function or a static error: invalid `sym` operand - --> $DIR/invalid-sym-operand.rs:25:20 + --> $DIR/invalid-sym-operand.rs:26:20 | LL | asm!("{}", sym C); | ^^^^^ is an `i32` diff --git a/tests/ui/asm/naked-asm-outside-naked-fn.rs b/tests/ui/asm/naked-asm-outside-naked-fn.rs index 0a15b21f4d014..1a82d0a595ef7 100644 --- a/tests/ui/asm/naked-asm-outside-naked-fn.rs +++ b/tests/ui/asm/naked-asm-outside-naked-fn.rs @@ -2,6 +2,7 @@ //@ needs-asm-support //@ ignore-nvptx64 //@ ignore-spirv +//@ reference: asm.scope.naked_asm #![crate_type = "lib"] diff --git a/tests/ui/asm/naked-asm-outside-naked-fn.stderr b/tests/ui/asm/naked-asm-outside-naked-fn.stderr index 2cebaa9ea285d..85a50a49fecfc 100644 --- a/tests/ui/asm/naked-asm-outside-naked-fn.stderr +++ b/tests/ui/asm/naked-asm-outside-naked-fn.stderr @@ -1,17 +1,17 @@ error: the `naked_asm!` macro can only be used in functions marked with `#[unsafe(naked)]` - --> $DIR/naked-asm-outside-naked-fn.rs:20:5 + --> $DIR/naked-asm-outside-naked-fn.rs:21:5 | LL | naked_asm!("") | ^^^^^^^^^^^^^^ error: the `naked_asm!` macro can only be used in functions marked with `#[unsafe(naked)]` - --> $DIR/naked-asm-outside-naked-fn.rs:25:9 + --> $DIR/naked-asm-outside-naked-fn.rs:26:9 | LL | (|| naked_asm!(""))() | ^^^^^^^^^^^^^^ error: the `naked_asm!` macro can only be used in functions marked with `#[unsafe(naked)]` - --> $DIR/naked-asm-outside-naked-fn.rs:31:9 + --> $DIR/naked-asm-outside-naked-fn.rs:32:9 | LL | naked_asm!(""); | ^^^^^^^^^^^^^^ diff --git a/tests/ui/asm/naked-functions-inline.rs b/tests/ui/asm/naked-functions-inline.rs index b6fddc88e19b8..436c027fee873 100644 --- a/tests/ui/asm/naked-functions-inline.rs +++ b/tests/ui/asm/naked-functions-inline.rs @@ -1,4 +1,5 @@ //@ needs-asm-support +//@ reference: attributes.codegen.naked.inline #![crate_type = "lib"] use std::arch::naked_asm; diff --git a/tests/ui/asm/naked-functions-inline.stderr b/tests/ui/asm/naked-functions-inline.stderr index 785ecf734b9d2..68648be72328e 100644 --- a/tests/ui/asm/naked-functions-inline.stderr +++ b/tests/ui/asm/naked-functions-inline.stderr @@ -1,5 +1,5 @@ error[E0736]: attribute incompatible with `#[unsafe(naked)]` - --> $DIR/naked-functions-inline.rs:12:3 + --> $DIR/naked-functions-inline.rs:13:3 | LL | #[unsafe(naked)] | ---------------- function marked with `#[unsafe(naked)]` here @@ -7,7 +7,7 @@ LL | #[inline] | ^^^^^^ the `inline` attribute is incompatible with `#[unsafe(naked)]` error[E0736]: attribute incompatible with `#[unsafe(naked)]` - --> $DIR/naked-functions-inline.rs:19:3 + --> $DIR/naked-functions-inline.rs:20:3 | LL | #[unsafe(naked)] | ---------------- function marked with `#[unsafe(naked)]` here @@ -15,7 +15,7 @@ LL | #[inline(always)] | ^^^^^^ the `inline` attribute is incompatible with `#[unsafe(naked)]` error[E0736]: attribute incompatible with `#[unsafe(naked)]` - --> $DIR/naked-functions-inline.rs:26:3 + --> $DIR/naked-functions-inline.rs:27:3 | LL | #[unsafe(naked)] | ---------------- function marked with `#[unsafe(naked)]` here @@ -23,7 +23,7 @@ LL | #[inline(never)] | ^^^^^^ the `inline` attribute is incompatible with `#[unsafe(naked)]` error[E0736]: attribute incompatible with `#[unsafe(naked)]` - --> $DIR/naked-functions-inline.rs:33:18 + --> $DIR/naked-functions-inline.rs:34:18 | LL | #[unsafe(naked)] | ---------------- function marked with `#[unsafe(naked)]` here diff --git a/tests/ui/asm/naked-functions-testattrs.rs b/tests/ui/asm/naked-functions-testattrs.rs index 6dc14a6840ecb..63acd11c02509 100644 --- a/tests/ui/asm/naked-functions-testattrs.rs +++ b/tests/ui/asm/naked-functions-testattrs.rs @@ -1,5 +1,6 @@ //@ needs-asm-support //@ compile-flags: --test +//@ reference: attributes.codegen.naked.testing #![feature(test)] #![crate_type = "lib"] diff --git a/tests/ui/asm/naked-functions-testattrs.stderr b/tests/ui/asm/naked-functions-testattrs.stderr index 8aab2f04ee29e..ad2041ec118b9 100644 --- a/tests/ui/asm/naked-functions-testattrs.stderr +++ b/tests/ui/asm/naked-functions-testattrs.stderr @@ -1,5 +1,5 @@ error[E0736]: cannot use `#[unsafe(naked)]` with testing attributes - --> $DIR/naked-functions-testattrs.rs:10:1 + --> $DIR/naked-functions-testattrs.rs:11:1 | LL | #[test] | ------- function marked with testing attribute here @@ -7,7 +7,7 @@ LL | #[unsafe(naked)] | ^^^^^^^^^^^^^^^^ `#[unsafe(naked)]` is incompatible with testing attributes error[E0736]: cannot use `#[unsafe(naked)]` with testing attributes - --> $DIR/naked-functions-testattrs.rs:18:1 + --> $DIR/naked-functions-testattrs.rs:19:1 | LL | #[test] | ------- function marked with testing attribute here @@ -15,7 +15,7 @@ LL | #[unsafe(naked)] | ^^^^^^^^^^^^^^^^ `#[unsafe(naked)]` is incompatible with testing attributes error[E0736]: cannot use `#[unsafe(naked)]` with testing attributes - --> $DIR/naked-functions-testattrs.rs:26:1 + --> $DIR/naked-functions-testattrs.rs:27:1 | LL | #[test] | ------- function marked with testing attribute here @@ -23,7 +23,7 @@ LL | #[unsafe(naked)] | ^^^^^^^^^^^^^^^^ `#[unsafe(naked)]` is incompatible with testing attributes error[E0736]: cannot use `#[unsafe(naked)]` with testing attributes - --> $DIR/naked-functions-testattrs.rs:33:1 + --> $DIR/naked-functions-testattrs.rs:34:1 | LL | #[bench] | -------- function marked with testing attribute here diff --git a/tests/ui/asm/naked-functions.rs b/tests/ui/asm/naked-functions.rs index a6f41698b4117..dadacb8d4683e 100644 --- a/tests/ui/asm/naked-functions.rs +++ b/tests/ui/asm/naked-functions.rs @@ -1,6 +1,7 @@ //@ needs-asm-support //@ ignore-nvptx64 //@ ignore-spirv +//@ reference: attributes.codegen.naked.body #![feature(asm_unwind, linkage, rustc_attrs)] #![crate_type = "lib"] diff --git a/tests/ui/asm/naked-functions.stderr b/tests/ui/asm/naked-functions.stderr index b94a09bb92ed9..2b67c3aecd73c 100644 --- a/tests/ui/asm/naked-functions.stderr +++ b/tests/ui/asm/naked-functions.stderr @@ -1,107 +1,107 @@ error: the `in` operand cannot be used with `naked_asm!` - --> $DIR/naked-functions.rs:46:29 + --> $DIR/naked-functions.rs:47:29 | LL | naked_asm!("/* {0} */", in(reg) a) | ^^ the `in` operand is not meaningful for global-scoped inline assembly, remove it error: the `in` operand cannot be used with `naked_asm!` - --> $DIR/naked-functions.rs:67:10 + --> $DIR/naked-functions.rs:68:10 | LL | in(reg) a, | ^^ the `in` operand is not meaningful for global-scoped inline assembly, remove it error: the `noreturn` option cannot be used with `naked_asm!` - --> $DIR/naked-functions.rs:87:28 + --> $DIR/naked-functions.rs:88:28 | LL | naked_asm!("", options(noreturn)); | ^^^^^^^^ the `noreturn` option is not meaningful for global-scoped inline assembly error: the `nomem` option cannot be used with `naked_asm!` - --> $DIR/naked-functions.rs:104:28 + --> $DIR/naked-functions.rs:105:28 | LL | naked_asm!("", options(nomem, preserves_flags)); | ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly error: the `preserves_flags` option cannot be used with `naked_asm!` - --> $DIR/naked-functions.rs:104:35 + --> $DIR/naked-functions.rs:105:35 | LL | naked_asm!("", options(nomem, preserves_flags)); | ^^^^^^^^^^^^^^^ the `preserves_flags` option is not meaningful for global-scoped inline assembly error: the `readonly` option cannot be used with `naked_asm!` - --> $DIR/naked-functions.rs:111:28 + --> $DIR/naked-functions.rs:112:28 | LL | naked_asm!("", options(readonly, nostack), options(pure)); | ^^^^^^^^ the `readonly` option is not meaningful for global-scoped inline assembly error: the `nostack` option cannot be used with `naked_asm!` - --> $DIR/naked-functions.rs:111:38 + --> $DIR/naked-functions.rs:112:38 | LL | naked_asm!("", options(readonly, nostack), options(pure)); | ^^^^^^^ the `nostack` option is not meaningful for global-scoped inline assembly error: the `pure` option cannot be used with `naked_asm!` - --> $DIR/naked-functions.rs:111:56 + --> $DIR/naked-functions.rs:112:56 | LL | naked_asm!("", options(readonly, nostack), options(pure)); | ^^^^ the `pure` option is not meaningful for global-scoped inline assembly error: the `may_unwind` option cannot be used with `naked_asm!` - --> $DIR/naked-functions.rs:119:28 + --> $DIR/naked-functions.rs:120:28 | LL | naked_asm!("", options(may_unwind)); | ^^^^^^^^^^ the `may_unwind` option is not meaningful for global-scoped inline assembly error: this is a user specified error - --> $DIR/naked-functions.rs:150:5 + --> $DIR/naked-functions.rs:151:5 | LL | compile_error!("this is a user specified error") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this is a user specified error - --> $DIR/naked-functions.rs:156:5 + --> $DIR/naked-functions.rs:157:5 | LL | compile_error!("this is a user specified error"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: asm template must be a string literal - --> $DIR/naked-functions.rs:163:16 + --> $DIR/naked-functions.rs:164:16 | LL | naked_asm!(invalid_syntax) | ^^^^^^^^^^^^^^ error[E0787]: the `asm!` macro is not allowed in naked functions - --> $DIR/naked-functions.rs:12:14 + --> $DIR/naked-functions.rs:13:14 | LL | unsafe { asm!("", options(raw)) }; | ^^^^^^^^^^^^^^^^^^^^^^ consider using the `naked_asm!` macro instead error: patterns not allowed in naked function parameters - --> $DIR/naked-functions.rs:24:5 + --> $DIR/naked-functions.rs:25:5 | LL | mut a: u32, | ^^^^^ error: patterns not allowed in naked function parameters - --> $DIR/naked-functions.rs:26:5 + --> $DIR/naked-functions.rs:27:5 | LL | &b: &i32, | ^^ error: patterns not allowed in naked function parameters - --> $DIR/naked-functions.rs:28:6 + --> $DIR/naked-functions.rs:29:6 | LL | (None | Some(_)): Option>, | ^^^^^^^^^^^^^^ error: patterns not allowed in naked function parameters - --> $DIR/naked-functions.rs:30:5 + --> $DIR/naked-functions.rs:31:5 | LL | P { x, y }: P, | ^^^^^^^^^^ error: referencing function parameters is not allowed in naked functions - --> $DIR/naked-functions.rs:39:5 + --> $DIR/naked-functions.rs:40:5 | LL | a + 1 | ^ @@ -109,7 +109,7 @@ LL | a + 1 = help: follow the calling convention in asm block to use parameters error[E0787]: naked functions must contain a single `naked_asm!` invocation - --> $DIR/naked-functions.rs:37:1 + --> $DIR/naked-functions.rs:38:1 | LL | pub extern "C" fn inc(a: u32) -> u32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -118,7 +118,7 @@ LL | a + 1 | ----- not allowed in naked functions error[E0787]: naked functions must contain a single `naked_asm!` invocation - --> $DIR/naked-functions.rs:51:1 + --> $DIR/naked-functions.rs:52:1 | LL | pub extern "C" fn inc_closure(a: u32) -> u32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -127,7 +127,7 @@ LL | (|| a + 1)() | ------------ not allowed in naked functions error[E0787]: naked functions must contain a single `naked_asm!` invocation - --> $DIR/naked-functions.rs:57:1 + --> $DIR/naked-functions.rs:58:1 | LL | pub extern "C" fn unsupported_operands() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -144,13 +144,13 @@ LL | let mut e = 0usize; | ------------------- not allowed in naked functions error[E0787]: naked functions must contain a single `naked_asm!` invocation - --> $DIR/naked-functions.rs:79:1 + --> $DIR/naked-functions.rs:80:1 | LL | pub extern "C" fn missing_assembly() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0787]: naked functions must contain a single `naked_asm!` invocation - --> $DIR/naked-functions.rs:84:1 + --> $DIR/naked-functions.rs:85:1 | LL | pub extern "C" fn too_many_asm_blocks() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -159,7 +159,7 @@ LL | naked_asm!(""); | -------------- multiple `naked_asm!` invocations are not allowed in naked functions error: referencing function parameters is not allowed in naked functions - --> $DIR/naked-functions.rs:96:11 + --> $DIR/naked-functions.rs:97:11 | LL | *&y | ^ @@ -167,7 +167,7 @@ LL | *&y = help: follow the calling convention in asm block to use parameters error[E0787]: naked functions must contain a single `naked_asm!` invocation - --> $DIR/naked-functions.rs:94:5 + --> $DIR/naked-functions.rs:95:5 | LL | pub extern "C" fn inner(y: usize) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/asm/non-const.rs b/tests/ui/asm/non-const.rs index dc9317b90b117..2ee4b9c1d70af 100644 --- a/tests/ui/asm/non-const.rs +++ b/tests/ui/asm/non-const.rs @@ -1,4 +1,5 @@ //@ needs-asm-support +//@ reference: asm.operand-type.supported-operands.const use std::arch::global_asm; diff --git a/tests/ui/asm/non-const.stderr b/tests/ui/asm/non-const.stderr index d7a901ba20ee5..e25960cc5a516 100644 --- a/tests/ui/asm/non-const.stderr +++ b/tests/ui/asm/non-const.stderr @@ -1,11 +1,11 @@ error[E0015]: cannot call non-const function `non_const_fn` in constants - --> $DIR/non-const.rs:10:31 + --> $DIR/non-const.rs:11:31 | LL | global_asm!("/* {} */", const non_const_fn(0)); | ^^^^^^^^^^^^^^^ | note: function `non_const_fn` is not const - --> $DIR/non-const.rs:8:1 + --> $DIR/non-const.rs:9:1 | LL | fn non_const_fn(x: i32) -> i32 { x } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/asm/noreturn.rs b/tests/ui/asm/noreturn.rs index c99715e9f8064..5351d4bc47332 100644 --- a/tests/ui/asm/noreturn.rs +++ b/tests/ui/asm/noreturn.rs @@ -1,5 +1,6 @@ //@ needs-asm-support //@ check-pass +//@ reference: asm.options.supported-options.noreturn #![feature(never_type)] #![crate_type = "rlib"] diff --git a/tests/ui/asm/parse-error.rs b/tests/ui/asm/parse-error.rs index d135ccae12804..f8e3b1622a8bc 100644 --- a/tests/ui/asm/parse-error.rs +++ b/tests/ui/asm/parse-error.rs @@ -1,4 +1,7 @@ //@ needs-asm-support +//@ reference: asm.syntax +//@ reference: asm.ts-args.syntax +//@ reference: asm.ts-args.one-or-more use std::arch::{asm, global_asm}; diff --git a/tests/ui/asm/parse-error.stderr b/tests/ui/asm/parse-error.stderr index fe6802b0c0c9e..9bb7b28b4424e 100644 --- a/tests/ui/asm/parse-error.stderr +++ b/tests/ui/asm/parse-error.stderr @@ -1,167 +1,167 @@ error: requires at least a template string argument - --> $DIR/parse-error.rs:9:9 + --> $DIR/parse-error.rs:12:9 | LL | asm!(); | ^^^^^^ error: asm template must be a string literal - --> $DIR/parse-error.rs:11:14 + --> $DIR/parse-error.rs:14:14 | LL | asm!(foo); | ^^^ error: expected token: `,` - --> $DIR/parse-error.rs:13:19 + --> $DIR/parse-error.rs:16:19 | LL | asm!("{}" foo); | ^^^ expected `,` error: expected operand, clobber_abi, options, or additional template string - --> $DIR/parse-error.rs:15:20 + --> $DIR/parse-error.rs:18:20 | LL | asm!("{}", foo); | ^^^ expected operand, clobber_abi, options, or additional template string error: expected `(`, found `foo` - --> $DIR/parse-error.rs:17:23 + --> $DIR/parse-error.rs:20:23 | LL | asm!("{}", in foo); | ^^^ expected `(` error: expected `)`, found `foo` - --> $DIR/parse-error.rs:19:27 + --> $DIR/parse-error.rs:22:27 | LL | asm!("{}", in(reg foo)); | ^^^ expected `)` error: expected expression, found end of macro arguments - --> $DIR/parse-error.rs:21:27 + --> $DIR/parse-error.rs:24:27 | LL | asm!("{}", in(reg)); | ^ expected expression error: expected register class or explicit register - --> $DIR/parse-error.rs:23:26 + --> $DIR/parse-error.rs:26:26 | LL | asm!("{}", inout(=) foo => bar); | ^ error: expected expression, found end of macro arguments - --> $DIR/parse-error.rs:25:37 + --> $DIR/parse-error.rs:28:37 | LL | asm!("{}", inout(reg) foo =>); | ^ expected expression error: expected one of `!`, `,`, `.`, `::`, `?`, `{`, or an operator, found `=>` - --> $DIR/parse-error.rs:27:32 + --> $DIR/parse-error.rs:30:32 | LL | asm!("{}", in(reg) foo => bar); | ^^ expected one of 7 possible tokens error: expected a path for argument to `sym` - --> $DIR/parse-error.rs:29:24 + --> $DIR/parse-error.rs:32:24 | LL | asm!("{}", sym foo + bar); | ^^^^^^^^^ error: expected one of `)`, `att_syntax`, `may_unwind`, `nomem`, `noreturn`, `nostack`, `preserves_flags`, `pure`, `raw`, or `readonly`, found `foo` - --> $DIR/parse-error.rs:31:26 + --> $DIR/parse-error.rs:34:26 | LL | asm!("", options(foo)); | ^^^ expected one of 10 possible tokens error: expected one of `)` or `,`, found `foo` - --> $DIR/parse-error.rs:33:32 + --> $DIR/parse-error.rs:36:32 | LL | asm!("", options(nomem foo)); | ^^^ expected one of `)` or `,` error: expected one of `)`, `att_syntax`, `may_unwind`, `nomem`, `noreturn`, `nostack`, `preserves_flags`, `pure`, `raw`, or `readonly`, found `foo` - --> $DIR/parse-error.rs:35:33 + --> $DIR/parse-error.rs:38:33 | LL | asm!("", options(nomem, foo)); | ^^^ expected one of 10 possible tokens error: at least one abi must be provided as an argument to `clobber_abi` - --> $DIR/parse-error.rs:42:30 + --> $DIR/parse-error.rs:45:30 | LL | asm!("", clobber_abi()); | ^ error: expected string literal - --> $DIR/parse-error.rs:44:30 + --> $DIR/parse-error.rs:47:30 | LL | asm!("", clobber_abi(foo)); | ^^^ not a string literal error: expected one of `)` or `,`, found `foo` - --> $DIR/parse-error.rs:46:34 + --> $DIR/parse-error.rs:49:34 | LL | asm!("", clobber_abi("C" foo)); | ^^^ expected one of `)` or `,` error: expected string literal - --> $DIR/parse-error.rs:48:35 + --> $DIR/parse-error.rs:51:35 | LL | asm!("", clobber_abi("C", foo)); | ^^^ not a string literal error: expected string literal - --> $DIR/parse-error.rs:50:30 + --> $DIR/parse-error.rs:53:30 | LL | asm!("", clobber_abi(1)); | ^ not a string literal error: expected string literal - --> $DIR/parse-error.rs:52:30 + --> $DIR/parse-error.rs:55:30 | LL | asm!("", clobber_abi(())); | ^ not a string literal error: expected string literal - --> $DIR/parse-error.rs:54:30 + --> $DIR/parse-error.rs:57:30 | LL | asm!("", clobber_abi(uwu)); | ^^^ not a string literal error: expected string literal - --> $DIR/parse-error.rs:56:30 + --> $DIR/parse-error.rs:59:30 | LL | asm!("", clobber_abi({})); | ^ not a string literal error: expected string literal - --> $DIR/parse-error.rs:58:30 + --> $DIR/parse-error.rs:61:30 | LL | asm!("", clobber_abi(loop {})); | ^^^^ not a string literal error: expected string literal - --> $DIR/parse-error.rs:60:30 + --> $DIR/parse-error.rs:63:30 | LL | asm!("", clobber_abi(if)); | ^^ not a string literal error: expected string literal - --> $DIR/parse-error.rs:62:30 + --> $DIR/parse-error.rs:65:30 | LL | asm!("", clobber_abi(do)); | ^^ not a string literal error: expected string literal - --> $DIR/parse-error.rs:64:30 + --> $DIR/parse-error.rs:67:30 | LL | asm!("", clobber_abi(<)); | ^ not a string literal error: expected string literal - --> $DIR/parse-error.rs:66:30 + --> $DIR/parse-error.rs:69:30 | LL | asm!("", clobber_abi(.)); | ^ not a string literal error: duplicate argument named `a` - --> $DIR/parse-error.rs:74:36 + --> $DIR/parse-error.rs:77:36 | LL | asm!("{a}", a = const foo, a = const bar); | ------------- ^^^^^^^^^^^^^ duplicate argument @@ -169,7 +169,7 @@ LL | asm!("{a}", a = const foo, a = const bar); | previously here error: argument never used - --> $DIR/parse-error.rs:74:36 + --> $DIR/parse-error.rs:77:36 | LL | asm!("{a}", a = const foo, a = const bar); | ^^^^^^^^^^^^^ argument never used @@ -177,151 +177,151 @@ LL | asm!("{a}", a = const foo, a = const bar); = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"` error: expected one of `#`, `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `label`, `lateout`, `options`, `out`, or `sym`, found `""` - --> $DIR/parse-error.rs:80:29 + --> $DIR/parse-error.rs:83:29 | LL | asm!("", options(), ""); | ^^ expected one of 11 possible tokens error: expected one of `#`, `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `label`, `lateout`, `options`, `out`, or `sym`, found `"{}"` - --> $DIR/parse-error.rs:82:33 + --> $DIR/parse-error.rs:85:33 | LL | asm!("{}", in(reg) foo, "{}", out(reg) foo); | ^^^^ expected one of 11 possible tokens error: asm template must be a string literal - --> $DIR/parse-error.rs:84:14 + --> $DIR/parse-error.rs:87:14 | LL | asm!(format!("{{{}}}", 0), in(reg) foo); | ^^^^^^^^^^^^^^^^^^^^ error: asm template must be a string literal - --> $DIR/parse-error.rs:86:21 + --> $DIR/parse-error.rs:89:21 | LL | asm!("{1}", format!("{{{}}}", 0), in(reg) foo, out(reg) bar); | ^^^^^^^^^^^^^^^^^^^^ error: _ cannot be used for input operands - --> $DIR/parse-error.rs:88:28 + --> $DIR/parse-error.rs:91:28 | LL | asm!("{}", in(reg) _); | ^ error: _ cannot be used for input operands - --> $DIR/parse-error.rs:90:31 + --> $DIR/parse-error.rs:93:31 | LL | asm!("{}", inout(reg) _); | ^ error: _ cannot be used for input operands - --> $DIR/parse-error.rs:92:35 + --> $DIR/parse-error.rs:95:35 | LL | asm!("{}", inlateout(reg) _); | ^ error: requires at least a template string argument - --> $DIR/parse-error.rs:99:1 + --> $DIR/parse-error.rs:102:1 | LL | global_asm!(); | ^^^^^^^^^^^^^ error: asm template must be a string literal - --> $DIR/parse-error.rs:101:13 + --> $DIR/parse-error.rs:104:13 | LL | global_asm!(FOO); | ^^^ error: expected token: `,` - --> $DIR/parse-error.rs:103:18 + --> $DIR/parse-error.rs:106:18 | LL | global_asm!("{}" FOO); | ^^^ expected `,` error: expected operand, options, or additional template string - --> $DIR/parse-error.rs:105:19 + --> $DIR/parse-error.rs:108:19 | LL | global_asm!("{}", FOO); | ^^^ expected operand, options, or additional template string error: expected expression, found end of macro arguments - --> $DIR/parse-error.rs:107:24 + --> $DIR/parse-error.rs:110:24 | LL | global_asm!("{}", const); | ^ expected expression error: expected one of `,`, `.`, `?`, or an operator, found `FOO` - --> $DIR/parse-error.rs:109:30 + --> $DIR/parse-error.rs:112:30 | LL | global_asm!("{}", const(reg) FOO); | ^^^ expected one of `,`, `.`, `?`, or an operator error: expected one of `)`, `att_syntax`, or `raw`, found `FOO` - --> $DIR/parse-error.rs:111:25 + --> $DIR/parse-error.rs:114:25 | LL | global_asm!("", options(FOO)); | ^^^ expected one of `)`, `att_syntax`, or `raw` error: expected one of `)`, `att_syntax`, or `raw`, found `FOO` - --> $DIR/parse-error.rs:113:25 + --> $DIR/parse-error.rs:116:25 | LL | global_asm!("", options(FOO,)); | ^^^ expected one of `)`, `att_syntax`, or `raw` error: expected one of `)` or `,`, found `FOO` - --> $DIR/parse-error.rs:115:31 + --> $DIR/parse-error.rs:118:31 | LL | global_asm!("", options(nomem FOO)); | ^^^ expected one of `)` or `,` error: expected one of `)`, `att_syntax`, or `raw`, found `FOO` - --> $DIR/parse-error.rs:117:32 + --> $DIR/parse-error.rs:120:32 | LL | global_asm!("", options(nomem, FOO)); | ^^^ expected one of `)`, `att_syntax`, or `raw` error: expected string literal - --> $DIR/parse-error.rs:120:29 + --> $DIR/parse-error.rs:123:29 | LL | global_asm!("", clobber_abi(FOO)); | ^^^ not a string literal error: expected one of `)` or `,`, found `FOO` - --> $DIR/parse-error.rs:122:33 + --> $DIR/parse-error.rs:125:33 | LL | global_asm!("", clobber_abi("C" FOO)); | ^^^ expected one of `)` or `,` error: expected string literal - --> $DIR/parse-error.rs:124:34 + --> $DIR/parse-error.rs:127:34 | LL | global_asm!("", clobber_abi("C", FOO)); | ^^^ not a string literal error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:126:19 + --> $DIR/parse-error.rs:129:19 | LL | global_asm!("{}", clobber_abi("C"), const FOO); | ^^^^^^^^^^^^^^^^ error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:128:28 + --> $DIR/parse-error.rs:131:28 | LL | global_asm!("", options(), clobber_abi("C")); | ^^^^^^^^^^^^^^^^ error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:130:30 + --> $DIR/parse-error.rs:133:30 | LL | global_asm!("{}", options(), clobber_abi("C"), const FOO); | ^^^^^^^^^^^^^^^^ error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:132:17 + --> $DIR/parse-error.rs:135:17 | LL | global_asm!("", clobber_abi("C"), clobber_abi("C")); | ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ error: duplicate argument named `a` - --> $DIR/parse-error.rs:134:35 + --> $DIR/parse-error.rs:137:35 | LL | global_asm!("{a}", a = const FOO, a = const BAR); | ------------- ^^^^^^^^^^^^^ duplicate argument @@ -329,7 +329,7 @@ LL | global_asm!("{a}", a = const FOO, a = const BAR); | previously here error: argument never used - --> $DIR/parse-error.rs:134:35 + --> $DIR/parse-error.rs:137:35 | LL | global_asm!("{a}", a = const FOO, a = const BAR); | ^^^^^^^^^^^^^ argument never used @@ -337,67 +337,67 @@ LL | global_asm!("{a}", a = const FOO, a = const BAR); = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"` error: expected one of `#`, `clobber_abi`, `const`, `options`, or `sym`, found `""` - --> $DIR/parse-error.rs:137:28 + --> $DIR/parse-error.rs:140:28 | LL | global_asm!("", options(), ""); | ^^ expected one of `#`, `clobber_abi`, `const`, `options`, or `sym` error: expected one of `#`, `clobber_abi`, `const`, `options`, or `sym`, found `"{}"` - --> $DIR/parse-error.rs:139:30 + --> $DIR/parse-error.rs:142:30 | LL | global_asm!("{}", const FOO, "{}", const FOO); | ^^^^ expected one of `#`, `clobber_abi`, `const`, `options`, or `sym` error: asm template must be a string literal - --> $DIR/parse-error.rs:141:13 + --> $DIR/parse-error.rs:144:13 | LL | global_asm!(format!("{{{}}}", 0), const FOO); | ^^^^^^^^^^^^^^^^^^^^ error: asm template must be a string literal - --> $DIR/parse-error.rs:143:20 + --> $DIR/parse-error.rs:146:20 | LL | global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR); | ^^^^^^^^^^^^^^^^^^^^ error: the `in` operand cannot be used with `global_asm!` - --> $DIR/parse-error.rs:146:19 + --> $DIR/parse-error.rs:149:19 | LL | global_asm!("{}", in(reg)); | ^^ the `in` operand is not meaningful for global-scoped inline assembly, remove it error: the `out` operand cannot be used with `global_asm!` - --> $DIR/parse-error.rs:148:19 + --> $DIR/parse-error.rs:151:19 | LL | global_asm!("{}", out(reg)); | ^^^ the `out` operand is not meaningful for global-scoped inline assembly, remove it error: the `lateout` operand cannot be used with `global_asm!` - --> $DIR/parse-error.rs:150:19 + --> $DIR/parse-error.rs:153:19 | LL | global_asm!("{}", lateout(reg)); | ^^^^^^^ the `lateout` operand is not meaningful for global-scoped inline assembly, remove it error: the `inout` operand cannot be used with `global_asm!` - --> $DIR/parse-error.rs:152:19 + --> $DIR/parse-error.rs:155:19 | LL | global_asm!("{}", inout(reg)); | ^^^^^ the `inout` operand is not meaningful for global-scoped inline assembly, remove it error: the `inlateout` operand cannot be used with `global_asm!` - --> $DIR/parse-error.rs:154:19 + --> $DIR/parse-error.rs:157:19 | LL | global_asm!("{}", inlateout(reg)); | ^^^^^^^^^ the `inlateout` operand is not meaningful for global-scoped inline assembly, remove it error: the `label` operand cannot be used with `global_asm!` - --> $DIR/parse-error.rs:156:19 + --> $DIR/parse-error.rs:159:19 | LL | global_asm!("{}", label(reg)); | ^^^^^ the `label` operand is not meaningful for global-scoped inline assembly, remove it error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:37:37 + --> $DIR/parse-error.rs:40:37 | LL | asm!("{}", options(), const foo); | ^^^ non-constant value @@ -409,7 +409,7 @@ LL + const foo: /* Type */ = 0; | error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:69:44 + --> $DIR/parse-error.rs:72:44 | LL | asm!("{}", clobber_abi("C"), const foo); | ^^^ non-constant value @@ -421,7 +421,7 @@ LL + const foo: /* Type */ = 0; | error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:72:55 + --> $DIR/parse-error.rs:75:55 | LL | asm!("{}", options(), clobber_abi("C"), const foo); | ^^^ non-constant value @@ -433,7 +433,7 @@ LL + const foo: /* Type */ = 0; | error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:74:31 + --> $DIR/parse-error.rs:77:31 | LL | asm!("{a}", a = const foo, a = const bar); | ^^^ non-constant value @@ -445,7 +445,7 @@ LL + const foo: /* Type */ = 0; | error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:74:46 + --> $DIR/parse-error.rs:77:46 | LL | asm!("{a}", a = const foo, a = const bar); | ^^^ non-constant value diff --git a/tests/ui/asm/simple_global_asm.rs b/tests/ui/asm/simple_global_asm.rs index 68b0b83858e18..d92c2eee1026a 100644 --- a/tests/ui/asm/simple_global_asm.rs +++ b/tests/ui/asm/simple_global_asm.rs @@ -1,5 +1,6 @@ //@ run-pass //@ needs-asm-support +//@ reference: asm.scope.global_asm #![allow(dead_code)] diff --git a/tests/ui/asm/tainting-on-error.rs b/tests/ui/asm/tainting-on-error.rs index a8e9af911580d..aa9f33de3753c 100644 --- a/tests/ui/asm/tainting-on-error.rs +++ b/tests/ui/asm/tainting-on-error.rs @@ -1,4 +1,5 @@ //@ needs-asm-support +//@ reference: asm.operand-type.supported-operands.sym use std::arch::asm; diff --git a/tests/ui/asm/tainting-on-error.stderr b/tests/ui/asm/tainting-on-error.stderr index bd706d1f310bf..a44f8fad9cbb4 100644 --- a/tests/ui/asm/tainting-on-error.stderr +++ b/tests/ui/asm/tainting-on-error.stderr @@ -1,5 +1,5 @@ error: invalid `sym` operand - --> $DIR/tainting-on-error.rs:9:13 + --> $DIR/tainting-on-error.rs:10:13 | LL | sym None::<()>, | ^^^^^^^^^^^^^^ is an `Option<()>` diff --git a/tests/ui/asm/unsupported-option.fixed b/tests/ui/asm/unsupported-option.fixed index d313d8028b6c2..a7c763c736073 100644 --- a/tests/ui/asm/unsupported-option.fixed +++ b/tests/ui/asm/unsupported-option.fixed @@ -1,5 +1,6 @@ //@ needs-asm-support //@ run-rustfix +//@ reference: asm.options.global_asm-restriction use std::arch::global_asm; diff --git a/tests/ui/asm/unsupported-option.rs b/tests/ui/asm/unsupported-option.rs index d75f8e7f5693e..4dccab5fcfac9 100644 --- a/tests/ui/asm/unsupported-option.rs +++ b/tests/ui/asm/unsupported-option.rs @@ -1,5 +1,6 @@ //@ needs-asm-support //@ run-rustfix +//@ reference: asm.options.global_asm-restriction use std::arch::global_asm; diff --git a/tests/ui/asm/unsupported-option.stderr b/tests/ui/asm/unsupported-option.stderr index 7a6927152b667..bb69a17a0097d 100644 --- a/tests/ui/asm/unsupported-option.stderr +++ b/tests/ui/asm/unsupported-option.stderr @@ -1,17 +1,17 @@ error: the `nomem` option cannot be used with `global_asm!` - --> $DIR/unsupported-option.rs:8:25 + --> $DIR/unsupported-option.rs:9:25 | LL | global_asm!("", options(nomem, readonly, noreturn, raw)); | ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly error: the `readonly` option cannot be used with `global_asm!` - --> $DIR/unsupported-option.rs:8:32 + --> $DIR/unsupported-option.rs:9:32 | LL | global_asm!("", options(nomem, readonly, noreturn, raw)); | ^^^^^^^^ the `readonly` option is not meaningful for global-scoped inline assembly error: the `noreturn` option cannot be used with `global_asm!` - --> $DIR/unsupported-option.rs:8:42 + --> $DIR/unsupported-option.rs:9:42 | LL | global_asm!("", options(nomem, readonly, noreturn, raw)); | ^^^^^^^^ the `noreturn` option is not meaningful for global-scoped inline assembly diff --git a/tests/ui/borrowck/issue-47215-ice-from-drop-elab.stderr b/tests/ui/borrowck/issue-47215-ice-from-drop-elab.stderr index d6aeb410ec4de..d237d21d77de3 100644 --- a/tests/ui/borrowck/issue-47215-ice-from-drop-elab.stderr +++ b/tests/ui/borrowck/issue-47215-ice-from-drop-elab.stderr @@ -2,7 +2,7 @@ error[E0507]: cannot move out of static item `X` --> $DIR/issue-47215-ice-from-drop-elab.rs:17:21 | LL | let mut x = X; - | ^ move occurs because `X` has type `AtomicUsize`, which does not implement the `Copy` trait + | ^ move occurs because `X` has type `Atomic`, which does not implement the `Copy` trait | help: consider borrowing here | diff --git a/tests/ui/consts/const_refs_to_static-ice-121413.rs b/tests/ui/consts/const_refs_to_static-ice-121413.rs index 27d5d8600b4b0..d0f89283ed049 100644 --- a/tests/ui/consts/const_refs_to_static-ice-121413.rs +++ b/tests/ui/consts/const_refs_to_static-ice-121413.rs @@ -5,7 +5,7 @@ //@ compile-flags: -Zextra-const-ub-checks // ignore-tidy-linelength const REF_INTERIOR_MUT: &usize = { - //~^ HELP consider importing this struct + //~^ HELP consider importing this type alias static FOO: Sync = AtomicUsize::new(0); //~^ ERROR cannot find //~| WARN trait objects without an explicit `dyn` are deprecated diff --git a/tests/ui/consts/const_refs_to_static-ice-121413.stderr b/tests/ui/consts/const_refs_to_static-ice-121413.stderr index 150b8cb079e72..2787109769324 100644 --- a/tests/ui/consts/const_refs_to_static-ice-121413.stderr +++ b/tests/ui/consts/const_refs_to_static-ice-121413.stderr @@ -4,7 +4,7 @@ error[E0433]: cannot find type `AtomicUsize` in this scope LL | static FOO: Sync = AtomicUsize::new(0); | ^^^^^^^^^^^ use of undeclared type `AtomicUsize` | -help: consider importing this struct +help: consider importing this type alias | LL + use std::sync::atomic::AtomicUsize; | diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static.rs b/tests/ui/consts/miri_unleashed/const_refers_to_static.rs index eb78b5335cba9..9546f34792ad4 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static.rs +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static.rs @@ -8,7 +8,7 @@ use std::sync::atomic::Ordering; const MUTATE_INTERIOR_MUT: usize = { static FOO: AtomicUsize = AtomicUsize::new(0); - FOO.fetch_add(1, Ordering::Relaxed) //~ERROR calling non-const function `AtomicUsize::fetch_add` + FOO.fetch_add(1, Ordering::Relaxed) //~ERROR calling non-const function `Atomic::::fetch_add` }; const READ_INTERIOR_MUT: usize = { diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr index 5b8797c511627..bf7d6eecb7c3a 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr @@ -1,4 +1,4 @@ -error[E0080]: calling non-const function `AtomicUsize::fetch_add` +error[E0080]: calling non-const function `Atomic::::fetch_add` --> $DIR/const_refers_to_static.rs:11:5 | LL | FOO.fetch_add(1, Ordering::Relaxed) diff --git a/tests/ui/lint/const-item-interior-mutations-const-atomics.stderr b/tests/ui/lint/const-item-interior-mutations-const-atomics.stderr index 908a196828999..dd6f561f5b799 100644 --- a/tests/ui/lint/const-item-interior-mutations-const-atomics.stderr +++ b/tests/ui/lint/const-item-interior-mutations-const-atomics.stderr @@ -4,7 +4,7 @@ warning: mutation of an interior mutable `const` item with call to `store` LL | let _a = A.store(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -22,7 +22,7 @@ warning: mutation of an interior mutable `const` item with call to `swap` LL | let _a = A.swap(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -39,7 +39,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_and_ LL | let _a = A.compare_and_swap(false, true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -56,7 +56,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_exch LL | let _a = A.compare_exchange(false, true, Ordering::SeqCst, Ordering::Relaxed); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -73,7 +73,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_exch LL | let _a = A.compare_exchange_weak(false, true, Ordering::SeqCst, Ordering::Relaxed); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -90,7 +90,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_and` LL | let _a = A.fetch_and(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -107,7 +107,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_nand` LL | let _a = A.fetch_nand(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -124,7 +124,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_or` LL | let _a = A.fetch_or(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -141,7 +141,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_xor` LL | let _a = A.fetch_xor(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -158,7 +158,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_not` LL | let _a = A.fetch_not(Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -175,7 +175,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_update LL | let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(true)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -192,7 +192,7 @@ warning: mutation of an interior mutable `const` item with call to `try_update` LL | let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(false)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -209,7 +209,7 @@ warning: mutation of an interior mutable `const` item with call to `update` LL | let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| true); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -226,7 +226,7 @@ warning: mutation of an interior mutable `const` item with call to `store` LL | let _a = A.store(std::ptr::null_mut(), Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -243,7 +243,7 @@ warning: mutation of an interior mutable `const` item with call to `swap` LL | let _a = A.swap(std::ptr::null_mut(), Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -260,7 +260,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_and_ LL | let _a = A.compare_and_swap(std::ptr::null_mut(), std::ptr::null_mut(), Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -275,7 +275,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_exch --> $DIR/const-item-interior-mutations-const-atomics.rs:64:14 | LL | let _a = A.compare_exchange( - | ^ `A` is a interior mutable `const` item of type `AtomicPtr` + | ^ `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | ______________| | | LL | | @@ -299,7 +299,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_exch --> $DIR/const-item-interior-mutations-const-atomics.rs:72:14 | LL | let _a = A.compare_exchange_weak( - | ^ `A` is a interior mutable `const` item of type `AtomicPtr` + | ^ `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | ______________| | | LL | | @@ -325,7 +325,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_update LL | let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(std::ptr::null_mut())); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -342,7 +342,7 @@ warning: mutation of an interior mutable `const` item with call to `try_update` LL | let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(std::ptr::null_mut())); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -359,7 +359,7 @@ warning: mutation of an interior mutable `const` item with call to `update` LL | let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| std::ptr::null_mut()); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -376,7 +376,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_ptr_ad LL | let _a = A.fetch_ptr_add(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -393,7 +393,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_ptr_su LL | let _a = A.fetch_ptr_sub(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -410,7 +410,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_byte_a LL | let _a = A.fetch_byte_add(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -427,7 +427,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_byte_s LL | let _a = A.fetch_byte_sub(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -444,7 +444,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_and` LL | let _a = A.fetch_and(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -461,7 +461,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_or` LL | let _a = A.fetch_or(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -478,7 +478,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_xor` LL | let _a = A.fetch_xor(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -495,7 +495,7 @@ warning: mutation of an interior mutable `const` item with call to `store` LL | let _a = A.store(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -512,7 +512,7 @@ warning: mutation of an interior mutable `const` item with call to `swap` LL | let _a = A.swap(2, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -529,7 +529,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_and_ LL | let _a = A.compare_and_swap(2, 3, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -546,7 +546,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_exch LL | let _a = A.compare_exchange(3, 4, Ordering::SeqCst, Ordering::Relaxed); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -563,7 +563,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_exch LL | let _a = A.compare_exchange_weak(4, 5, Ordering::SeqCst, Ordering::Relaxed); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -580,7 +580,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_add` LL | let _a = A.fetch_add(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -597,7 +597,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_sub` LL | let _a = A.fetch_sub(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -614,7 +614,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_add` LL | let _a = A.fetch_add(2, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -631,7 +631,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_nand` LL | let _a = A.fetch_nand(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -648,7 +648,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_or` LL | let _a = A.fetch_or(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -665,7 +665,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_xor` LL | let _a = A.fetch_xor(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -682,7 +682,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_update LL | let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(10)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -699,7 +699,7 @@ warning: mutation of an interior mutable `const` item with call to `try_update` LL | let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(11)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -716,7 +716,7 @@ warning: mutation of an interior mutable `const` item with call to `update` LL | let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| 12); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -733,7 +733,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_max` LL | let _a = A.fetch_max(20, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -750,7 +750,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_min` LL | let _a = A.fetch_min(5, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified diff --git a/tests/ui/lint/ice-fuzzy-provenance-casts-with-inner-attr.rs b/tests/ui/lint/ice-fuzzy-provenance-casts-with-inner-attr.rs new file mode 100644 index 0000000000000..b8deb6ab3c64a --- /dev/null +++ b/tests/ui/lint/ice-fuzzy-provenance-casts-with-inner-attr.rs @@ -0,0 +1,24 @@ +// Regression test for #137588. +// The compiler used to ICE when emitting a `fuzzy_provenance_casts` lint +// diagnostic for code with an inner attribute spanning the entire file, +// causing `draw_code_line` to panic on an empty `file_lines` from a dummy span. + +//@ edition:2024 +//@ compile-flags: -Wfuzzy-provenance-casts + +#![feature(strict_provenance_lints)] +//~^ ERROR too many leading `super` keywords [E0433] +//~| ERROR cannot find type `Ts` in this scope [E0425] +//~| ERROR `#[prelude_import]` is for use by rustc only [E0658] +//~| WARN strict provenance disallows casting integer `usize` to pointer `*const u32` +#![core::contracts::ensures(|ret| ret.is_none_or(Stars::is_valid))] +//~^ ERROR use of unstable library feature `contracts` [E0658] +//~| ERROR inner macro attributes are unstable [E0658] +//~| ERROR cannot find type `Stars` in this scope [E0433] + +pub(super) fn foo() -> *const Ts { + unsafe { + let p2 = 0x52 as *const u32; + } +} +//~^ ERROR `main` function not found in crate diff --git a/tests/ui/lint/ice-fuzzy-provenance-casts-with-inner-attr.stderr b/tests/ui/lint/ice-fuzzy-provenance-casts-with-inner-attr.stderr new file mode 100644 index 0000000000000..342f39d2450d8 --- /dev/null +++ b/tests/ui/lint/ice-fuzzy-provenance-casts-with-inner-attr.stderr @@ -0,0 +1,93 @@ +error[E0658]: use of unstable library feature `contracts` + --> $DIR/ice-fuzzy-provenance-casts-with-inner-attr.rs:14:4 + | +LL | #![core::contracts::ensures(|ret| ret.is_none_or(Stars::is_valid))] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #128044 for more information + = help: add `#![feature(contracts)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: inner macro attributes are unstable + --> $DIR/ice-fuzzy-provenance-casts-with-inner-attr.rs:14:4 + | +LL | #![core::contracts::ensures(|ret| ret.is_none_or(Stars::is_valid))] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #54726 for more information + = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0433]: too many leading `super` keywords + --> $DIR/ice-fuzzy-provenance-casts-with-inner-attr.rs:9:1 + | +LL | / #![feature(strict_provenance_lints)] +... | +LL | | } + | |_^ there are too many leading `super` keywords + +error[E0425]: cannot find type `Ts` in this scope + --> $DIR/ice-fuzzy-provenance-casts-with-inner-attr.rs:9:1 + | +LL | / #![feature(strict_provenance_lints)] +... | +LL | | } + | |_^ not found in this scope + +error[E0658]: `#[prelude_import]` is for use by rustc only + --> $DIR/ice-fuzzy-provenance-casts-with-inner-attr.rs:9:1 + | +LL | / #![feature(strict_provenance_lints)] +... | +LL | | } + | |_^ + | + = help: add `#![feature(prelude_import)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0601]: `main` function not found in crate `ice_fuzzy_provenance_casts_with_inner_attr` + --> $DIR/ice-fuzzy-provenance-casts-with-inner-attr.rs:23:2 + | +LL | } + | ^ consider adding a `main` function to `$DIR/ice-fuzzy-provenance-casts-with-inner-attr.rs` + +error[E0433]: cannot find type `Stars` in this scope + --> $DIR/ice-fuzzy-provenance-casts-with-inner-attr.rs:14:50 + | +LL | #![core::contracts::ensures(|ret| ret.is_none_or(Stars::is_valid))] + | ^^^^^ use of undeclared type `Stars` + +warning: strict provenance disallows casting integer `usize` to pointer `*const u32` + --> $DIR/ice-fuzzy-provenance-casts-with-inner-attr.rs:9:1 + | +LL | / #![feature(strict_provenance_lints)] +... | +LL | | } + | |_^ + | + = help: if you can't comply with strict provenance and don't have a pointer with the correct provenance you can use `std::ptr::with_exposed_provenance()` instead + = note: requested on the command line with `-W fuzzy-provenance-casts` +help: use `.with_addr()` to adjust a valid pointer in the same allocation, to this address + | +LL - #![feature(strict_provenance_lints)] +LL - +LL - +LL - +LL - +LL - #![core::contracts::ensures(|ret| ret.is_none_or(Stars::is_valid))] +LL - +LL - +LL - +LL - +LL - pub(super) fn foo() -> *const Ts { +LL - unsafe { +LL - let p2 = 0x52 as *const u32; +LL - } +LL - } +LL + (...).with_addr() + | + +error: aborting due to 7 previous errors; 1 warning emitted + +Some errors have detailed explanations: E0425, E0433, E0601, E0658. +For more information about an error, try `rustc --explain E0425`. diff --git a/tests/ui/range/new_range_stability.rs b/tests/ui/range/new_range_stability.rs index 7200e1ac95d27..2d129fb6815f5 100644 --- a/tests/ui/range/new_range_stability.rs +++ b/tests/ui/range/new_range_stability.rs @@ -1,8 +1,10 @@ // Stable -use std::range::{RangeInclusive, RangeInclusiveIter}; +use std::range::{RangeInclusive, RangeInclusiveIter, RangeToInclusive}; fn range_inclusive(mut r: RangeInclusive) { + &[1, 2, 3][r]; // Indexing + r.start; r.last; r.contains(&5); @@ -14,6 +16,13 @@ fn range_inclusive(mut r: RangeInclusive) { i.remainder(); } +fn range_to_inclusive(mut r: RangeToInclusive) { + &[1, 2, 3][r]; // Indexing + + r.last; + r.contains(&5); +} + // Unstable module use std::range::legacy; //~ ERROR unstable diff --git a/tests/ui/range/new_range_stability.stderr b/tests/ui/range/new_range_stability.stderr index 871d691794ff0..b5a7e06e5f2ea 100644 --- a/tests/ui/range/new_range_stability.stderr +++ b/tests/ui/range/new_range_stability.stderr @@ -1,5 +1,5 @@ error[E0658]: use of unstable library feature `new_range_api` - --> $DIR/new_range_stability.rs:19:5 + --> $DIR/new_range_stability.rs:28:5 | LL | use std::range::legacy; | ^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | use std::range::legacy; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: use of unstable library feature `new_range_api` - --> $DIR/new_range_stability.rs:23:5 + --> $DIR/new_range_stability.rs:32:5 | LL | use std::range::RangeFrom; | ^^^^^^^^^^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | use std::range::RangeFrom; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: use of unstable library feature `new_range_api` - --> $DIR/new_range_stability.rs:24:5 + --> $DIR/new_range_stability.rs:33:5 | LL | use std::range::Range; | ^^^^^^^^^^^^^^^^^ @@ -29,7 +29,7 @@ LL | use std::range::Range; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: use of unstable library feature `new_range_api` - --> $DIR/new_range_stability.rs:25:5 + --> $DIR/new_range_stability.rs:34:5 | LL | use std::range::RangeFromIter; | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -39,7 +39,7 @@ LL | use std::range::RangeFromIter; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: use of unstable library feature `new_range_api` - --> $DIR/new_range_stability.rs:26:5 + --> $DIR/new_range_stability.rs:35:5 | LL | use std::range::RangeIter; | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/resolve/112590-2.stderr b/tests/ui/resolve/112590-2.stderr index 8569dd0c3fa08..75e7961cb35f4 100644 --- a/tests/ui/resolve/112590-2.stderr +++ b/tests/ui/resolve/112590-2.stderr @@ -49,7 +49,7 @@ error[E0433]: cannot find `sync_error` in `std` LL | let _t = std::sync_error::atomic::AtomicBool::new(true); | ^^^^^^^^^^ could not find `sync_error` in `std` | -help: consider importing this struct +help: consider importing this type alias | LL + use std::sync::atomic::AtomicBool; | diff --git a/tests/ui/static/missing-type.stderr b/tests/ui/static/missing-type.stderr index 6489ceb700a2e..5aad521fb403e 100644 --- a/tests/ui/static/missing-type.stderr +++ b/tests/ui/static/missing-type.stderr @@ -2,7 +2,7 @@ error: missing type for `static` item --> $DIR/missing-type.rs:2:16 | LL | static S_COUNT: = std::sync::atomic::AtomicUsize::new(0); - | ^ help: provide a type for the static variable: `AtomicUsize` + | ^ help: provide a type for the static variable: `Atomic` error: aborting due to 1 previous error diff --git a/tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.alignment_mismatch.stderr b/tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.alignment_mismatch.stderr index 93e189ffa0d3f..4b1cd8a5a1256 100644 --- a/tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.alignment_mismatch.stderr +++ b/tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.alignment_mismatch.stderr @@ -1,14 +1,20 @@ -error[E0599]: no function or associated item named `from_mut` found for struct `AtomicU64` in the current scope +error[E0599]: no function or associated item named `from_mut` found for struct `Atomic` in the current scope --> $DIR/atomic-from-mut-not-available.rs:24:36 | LL | core::sync::atomic::AtomicU64::from_mut(&mut 0u64); - | ^^^^^^^^ function or associated item not found in `AtomicU64` + | ^^^^^^^^ function or associated item not found in `Atomic` | -note: if you're trying to build a new `AtomicU64`, consider using `AtomicU64::new` which returns `AtomicU64` +note: if you're trying to build a new `Atomic`, consider using `Atomic::::new` which returns `Atomic` --> $SRC_DIR/core/src/sync/atomic.rs:LL:COL ::: $SRC_DIR/core/src/sync/atomic.rs:LL:COL | = note: in this macro invocation + = note: the function or associated item was found for + - `Atomic<*mut T>` + - `Atomic` + - `Atomic` + - `Atomic` + and 6 more types = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info) help: there is an associated function `from` with a similar name | diff --git a/tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.rs b/tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.rs index 7e9de3570eb91..519b6977dcb56 100644 --- a/tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.rs +++ b/tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.rs @@ -22,6 +22,6 @@ fn main() { core::sync::atomic::AtomicU64::from_mut(&mut 0u64); - //[alignment_mismatch]~^ ERROR no function or associated item named `from_mut` found for struct `AtomicU64` + //[alignment_mismatch]~^ ERROR no function or associated item named `from_mut` found for struct `Atomic` //[alignment_matches]~^^ ERROR use of unstable library feature `atomic_from_mut` } diff --git a/tests/ui/suggestions/into-convert.rs b/tests/ui/suggestions/into-convert.rs index 1c9a9e0aaf561..3fdb2587727a4 100644 --- a/tests/ui/suggestions/into-convert.rs +++ b/tests/ui/suggestions/into-convert.rs @@ -13,7 +13,7 @@ fn main() { let z: AtomicU32 = 1; //~^ ERROR mismatched types - //~| HELP call `Into::into` on this expression to convert `{integer}` into `AtomicU32` + //~| HELP call `Into::into` on this expression to convert `{integer}` into `Atomic` } struct A; diff --git a/tests/ui/suggestions/into-convert.stderr b/tests/ui/suggestions/into-convert.stderr index 704b280a985f4..8a754e7d2b3c0 100644 --- a/tests/ui/suggestions/into-convert.stderr +++ b/tests/ui/suggestions/into-convert.stderr @@ -30,11 +30,13 @@ error[E0308]: mismatched types --> $DIR/into-convert.rs:14:24 | LL | let z: AtomicU32 = 1; - | --------- ^ expected `AtomicU32`, found integer + | --------- ^ expected `Atomic`, found integer | | | expected due to this | -help: call `Into::into` on this expression to convert `{integer}` into `AtomicU32` + = note: expected struct `Atomic` + found type `{integer}` +help: call `Into::into` on this expression to convert `{integer}` into `Atomic` | LL | let z: AtomicU32 = 1.into(); | +++++++ diff --git a/tests/ui/sync/atomic-types-not-copyable.stderr b/tests/ui/sync/atomic-types-not-copyable.stderr index 05103f5d8f265..4d6918e63c744 100644 --- a/tests/ui/sync/atomic-types-not-copyable.stderr +++ b/tests/ui/sync/atomic-types-not-copyable.stderr @@ -2,7 +2,7 @@ error[E0507]: cannot move out of a shared reference --> $DIR/atomic-types-not-copyable.rs:11:13 | LL | let x = *&x; - | ^^^ move occurs because value has type `std::sync::atomic::AtomicBool`, which does not implement the `Copy` trait + | ^^^ move occurs because value has type `Atomic`, which does not implement the `Copy` trait | help: consider removing the dereference here | @@ -14,7 +14,7 @@ error[E0507]: cannot move out of a shared reference --> $DIR/atomic-types-not-copyable.rs:13:13 | LL | let x = *&x; - | ^^^ move occurs because value has type `std::sync::atomic::AtomicIsize`, which does not implement the `Copy` trait + | ^^^ move occurs because value has type `Atomic`, which does not implement the `Copy` trait | help: consider removing the dereference here | @@ -26,7 +26,7 @@ error[E0507]: cannot move out of a shared reference --> $DIR/atomic-types-not-copyable.rs:15:13 | LL | let x = *&x; - | ^^^ move occurs because value has type `std::sync::atomic::AtomicUsize`, which does not implement the `Copy` trait + | ^^^ move occurs because value has type `Atomic`, which does not implement the `Copy` trait | help: consider removing the dereference here | @@ -38,7 +38,7 @@ error[E0507]: cannot move out of a shared reference --> $DIR/atomic-types-not-copyable.rs:17:13 | LL | let x = *&x; - | ^^^ move occurs because value has type `std::sync::atomic::AtomicPtr`, which does not implement the `Copy` trait + | ^^^ move occurs because value has type `Atomic<*mut usize>`, which does not implement the `Copy` trait | help: consider removing the dereference here |