diff --git a/compiler/rustc_abi/src/layout.rs b/compiler/rustc_abi/src/layout.rs index fa03fb87d02d1..f2e3f8431c105 100644 --- a/compiler/rustc_abi/src/layout.rs +++ b/compiler/rustc_abi/src/layout.rs @@ -198,6 +198,7 @@ impl LayoutCalculator { size, max_repr_align: None, unadjusted_abi_align: element.align.abi, + repr_c: element.repr_c, randomization_seed: element.randomization_seed.wrapping_add(Hash64::new(count)), }) } @@ -501,6 +502,10 @@ impl LayoutCalculator { return Err(LayoutCalculatorError::EmptyUnion); }; + // We also need to check for a `repr(transparent)` wrapper around `repr(C)` + let repr_c = + repr.c() || (repr.transparent() && only_variant.iter().any(|field| field.repr_c)); + let combined_seed = only_variant .iter() .map(|v| v.randomization_seed) @@ -516,6 +521,7 @@ impl LayoutCalculator { size: size.align_to(align), max_repr_align, unadjusted_abi_align, + repr_c, randomization_seed: combined_seed, }) } @@ -747,6 +753,7 @@ impl LayoutCalculator { align: AbiAlign::new(align), max_repr_align, unadjusted_abi_align, + repr_c: repr.c(), randomization_seed: combined_seed, }; @@ -1055,6 +1062,7 @@ impl LayoutCalculator { size, max_repr_align, unadjusted_abi_align, + repr_c: repr.c(), randomization_seed: combined_seed, }; @@ -1409,6 +1417,9 @@ impl LayoutCalculator { unadjusted_abi_align }; + // We also need to check for a `repr(transparent)` wrapper around `repr(C)` + let repr_c = repr.c() || (repr.transparent() && fields.iter().any(|field| field.repr_c)); + let seed = field_seed.wrapping_add(repr.field_shuffle_seed); Ok(LayoutData { @@ -1421,6 +1432,7 @@ impl LayoutCalculator { size, max_repr_align, unadjusted_abi_align, + repr_c, randomization_seed: seed, }) } @@ -1519,6 +1531,7 @@ where align: AbiAlign::new(align), max_repr_align: None, unadjusted_abi_align: elt.align.abi, + repr_c: false, randomization_seed: elt.randomization_seed.wrapping_add(Hash64::new(count.as_u64())), }) } diff --git a/compiler/rustc_abi/src/layout/coroutine.rs b/compiler/rustc_abi/src/layout/coroutine.rs index c102fbb3e843c..66119ac2f0b5a 100644 --- a/compiler/rustc_abi/src/layout/coroutine.rs +++ b/compiler/rustc_abi/src/layout/coroutine.rs @@ -313,6 +313,7 @@ where align, max_repr_align: None, unadjusted_abi_align: align.abi, + repr_c: false, randomization_seed: Default::default(), }) } diff --git a/compiler/rustc_abi/src/layout/simple.rs b/compiler/rustc_abi/src/layout/simple.rs index 1fffb84ec21cb..da7260fe6160e 100644 --- a/compiler/rustc_abi/src/layout/simple.rs +++ b/compiler/rustc_abi/src/layout/simple.rs @@ -25,6 +25,7 @@ impl LayoutData { size: Size::ZERO, max_repr_align: None, unadjusted_abi_align: dl.i8_align, + repr_c: false, randomization_seed: Hash64::new(0), } } @@ -42,6 +43,7 @@ impl LayoutData { size: Size::ZERO, max_repr_align: None, unadjusted_abi_align: dl.i8_align, + repr_c: false, randomization_seed: Hash64::ZERO, } } @@ -84,6 +86,7 @@ impl LayoutData { align, max_repr_align: None, unadjusted_abi_align: align.abi, + repr_c: false, randomization_seed: Hash64::new(randomization_seed), } } @@ -117,6 +120,7 @@ impl LayoutData { size, max_repr_align: None, unadjusted_abi_align: align, + repr_c: false, randomization_seed: Hash64::new(combined_seed), } } @@ -143,6 +147,7 @@ impl LayoutData { size: Size::ZERO, max_repr_align: None, unadjusted_abi_align: dl.i8_align, + repr_c: false, // Variant layouts never flow back into actual layout computations, // so dummy values are fine here. randomization_seed: Hash64::ZERO, @@ -169,6 +174,7 @@ impl LayoutData { align: parent.align, max_repr_align: parent.max_repr_align, unadjusted_abi_align: parent.unadjusted_abi_align, + repr_c: parent.repr_c, // Variant layouts never flow back into actual layout computations, // so dummy values are fine here. randomization_seed: Hash64::ZERO, diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index 2e1f77e77b29e..ff62f04fff052 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -2264,6 +2264,13 @@ pub struct LayoutData { /// alignment in some cases. pub unadjusted_abi_align: Align, + /// Whether this type is `repr(C)`, or a `repr(transparent)` wrapper around such, + /// or an array of such. + /// This matters because we must follow the C ABI for these types. + /// Some C ABIs pass `repr(C)` ZSTs by pointer, but `repr(Rust)` ZSTs should always + /// be ignored. + pub repr_c: bool, + /// The randomization seed based on this type's own repr and its fields. /// /// Since randomization is toggled on a per-crate basis even crates that do not have randomization @@ -2303,6 +2310,12 @@ impl LayoutData { } } } + + /// Returns `true` if this is a `repr(C)` type, + /// or an array of such, or a `repr(transparent)` wrapper around such + pub fn is_repr_c(&self) -> bool { + self.repr_c + } } impl fmt::Debug for LayoutData @@ -2324,6 +2337,7 @@ where variants, max_repr_align, unadjusted_abi_align, + repr_c, randomization_seed, } = self; f.debug_struct("Layout") @@ -2336,6 +2350,7 @@ where .field("variants", variants) .field("max_repr_align", max_repr_align) .field("unadjusted_abi_align", unadjusted_abi_align) + .field("repr_c", repr_c) .field("randomization_seed", randomization_seed) .finish() } diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 45ab9b8bc3b30..a7540e294ec37 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -44,7 +44,7 @@ use rustc_span::{Symbol, bug}; use rustc_structures::{CrateType, NativeLibKind}; use rustc_target::spec::crt_objects::CrtObjects; use rustc_target::spec::{ - Arch, BinaryFormat, Cc, CfgAbi, Env, LinkOutputKind, LinkSelfContainedComponents, + BinaryFormat, Cc, CfgAbi, Env, LinkOutputKind, LinkSelfContainedComponents, LinkSelfContainedDefault, LinkerFeatures, LinkerFlavor, LinkerFlavorCli, Lld, Os, RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, }; @@ -58,7 +58,7 @@ use super::linker::{self, Linker}; use super::metadata::{MetadataPosition, create_wrapper_file}; use super::rmeta_link::RmetaLinkCache; use super::rpath::{self, RPathConfig}; -use super::{apple, rmeta_link, versioned_llvm_target}; +use super::{apple, rmeta_link, symbol_export, versioned_llvm_target}; use crate::base::needs_allocator_shim_for_linking; use crate::{ CodegenLintLevelSpecs, CompiledModule, CompiledModules, CrateInfo, NativeLib, SymbolExport, @@ -2759,10 +2759,6 @@ fn add_rpath_args( } } -fn strip_numeric_suffix<'a>(base: &'a str, suffix: impl AsRef, fallback: &'a str) -> &'a str { - if suffix.as_ref().parse::().is_ok() { base } else { fallback } -} - fn undecorate_c_symbol<'a>( name: &'a str, sess: &Session, @@ -2775,47 +2771,11 @@ fn undecorate_c_symbol<'a>( name.strip_prefix('_') } BinaryFormat::Coff => { - // MSVC C++ mangled names start with '?' and use a completely different - // decorating scheme that includes '@@' as structural delimiters. - // They must not be subjected to C calling-convention undecoration. - if name.starts_with('?') { - return Some(name); + // COFF undecoration is shared with `symbol_edit`'s binary-level matching. + match symbol_export::coff_machine_for_arch(&sess.target.arch) { + Some(machine) => Some(symbol_export::undecorate_coff_symbol(name, machine, kind)), + None => Some(name), } - Some(match sess.target.arch { - Arch::X86 => { - // COFF 32-bit: strip calling-convention decorations. - if let Some(rest) = name.strip_prefix('@') { - // fastcall: @foo@N -> foo - rest.rsplit_once('@') - .map(|(base, suffix)| strip_numeric_suffix(base, suffix, name)) - .unwrap_or(name) - } else if let Some(stripped) = name.strip_prefix('_') { - if let Some((base, suffix)) = stripped.rsplit_once('@') { - // stdcall: _foo@N -> foo - strip_numeric_suffix(base, suffix, stripped) - } else { - // cdecl: _foo -> foo - stripped - } - } else { - // vectorcall: foo@@N -> foo - name.rsplit_once("@@") - .map(|(base, suffix)| strip_numeric_suffix(base, suffix, name)) - .unwrap_or(name) - } - } - Arch::X86_64 => { - // COFF 64-bit: vectorcall mangling (foo@@N -> foo) also applies on x86_64. - name.rsplit_once("@@") - .map(|(base, suffix)| strip_numeric_suffix(base, suffix, name)) - .unwrap_or(name) - } - Arch::Arm64EC if kind == SymbolExportKind::Text => { - // Arm64EC: `#` prefix distinguishes ARM64EC text symbols from x64 thunks. - name.strip_prefix('#').unwrap_or(name) - } - _ => name, - }) } // ELF: no decoration _ => Some(name), diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_edit.rs b/compiler/rustc_codegen_ssa/src/back/symbol_edit.rs index fa6fc1368e133..2ed758112a9fb 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_edit.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_edit.rs @@ -12,6 +12,9 @@ use object::read::elf::{SectionHeader as _, Sym as _}; use object::read::macho::Nlist; use object::{Endianness, elf, macho, pe}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_middle::middle::exported_symbols::SymbolExportKind; + +use super::symbol_export::undecorate_coff_symbol; struct Patch { offset: usize, @@ -58,20 +61,8 @@ pub(super) fn apply_edits<'a>( rename, mem::offset_of!(macho::Nlist32, n_type), ), - Some(object::File::Coff(f)) => coff_edit_impl( - data, - f.coff_header(), - hide, - rename, - coff_strip_underscore(f.coff_header()), - ), - Some(object::File::CoffBig(f)) => coff_edit_impl( - data, - f.coff_header(), - hide, - rename, - coff_strip_underscore(f.coff_header()), - ), + Some(object::File::Coff(f)) => coff_edit_impl(data, f.coff_header(), hide, rename), + Some(object::File::CoffBig(f)) => coff_edit_impl(data, f.coff_header(), hide, rename), _ => None, }; match result { @@ -99,28 +90,20 @@ pub(super) fn collect_internal_names( object::File::MachO32(_) => { macho_collect_impl::>(data, exported, out) } - object::File::Coff(f) => coff_collect_impl( - data, - f.coff_header(), - exported, - out, - coff_strip_underscore(f.coff_header()), - ), - object::File::CoffBig(f) => coff_collect_impl( - data, - f.coff_header(), - exported, - out, - coff_strip_underscore(f.coff_header()), - ), + object::File::Coff(f) => coff_collect_impl(data, f.coff_header(), exported, out), + object::File::CoffBig(f) => coff_collect_impl(data, f.coff_header(), exported, out), _ => {} } } -/// Whether this machine's COFF ABI decorates external symbols with a leading `_` -/// (i686 only). -fn coff_strip_underscore(header: &impl CoffHeader) -> bool { - header.machine() == pe::IMAGE_FILE_MACHINE_I386 +/// The `SymbolExportKind` of a COFF symbol, so `#`-prefixed `Arm64EC` text symbols are told +/// apart from data symbols during undecoration. +fn coff_symbol_kind(sym: &impl object::read::coff::ImageSymbol) -> SymbolExportKind { + if sym.derived_type() == pe::IMAGE_SYM_DTYPE_FUNCTION { + SymbolExportKind::Text + } else { + SymbolExportKind::Data + } } fn elf_collect_impl>( @@ -485,10 +468,10 @@ fn coff_collect_impl<'data, Coff: CoffHeader>( header: &'data Coff, exported: &FxHashSet, out: &mut FxHashSet, - strip_underscore: bool, ) { let Ok(symbols) = header.symbols(data) else { return }; let strings = symbols.strings(); + let machine = header.machine(); for (_index, sym) in symbols.iter() { let sclass = sym.storage_class(); @@ -499,15 +482,10 @@ fn coff_collect_impl<'data, Coff: CoffHeader>( continue; } let Ok(name_bytes) = sym.name(strings) else { continue }; - let Ok(mut name) = str::from_utf8(name_bytes).map(String::from) else { continue }; - if strip_underscore { - name = name.strip_prefix('_').unwrap_or(&name).to_string(); - } - let is_exported = exported.contains(&name) - || (header.machine() == pe::IMAGE_FILE_MACHINE_ARM64EC - && name.strip_prefix('#').is_some_and(|name| exported.contains(name))); - if !is_exported { - out.insert(name); + let Ok(name) = str::from_utf8(name_bytes) else { continue }; + let name = undecorate_coff_symbol(name, machine, coff_symbol_kind(sym)); + if !exported.contains(name) { + out.insert(name.to_string()); } } } @@ -517,7 +495,6 @@ fn coff_edit_impl<'data, Coff: CoffHeader>( header: &'data Coff, hide: bool, rename: Option<&(FxHashSet, &str)>, - strip_underscore: bool, ) -> Option> { // COFF has no visibility concept, so hiding is unsupported; the caller // has already warned and does not request it. @@ -545,6 +522,7 @@ fn coff_edit_impl<'data, Coff: CoffHeader>( let Ok(symbols) = header.symbols(data) else { return None }; let strings = symbols.strings(); + let machine = header.machine(); let mut renames = Vec::new(); for (index, sym) in symbols.iter() { @@ -554,8 +532,7 @@ fn coff_edit_impl<'data, Coff: CoffHeader>( } let Ok(name_bytes) = sym.name(strings) else { continue }; let Ok(name) = str::from_utf8(name_bytes) else { continue }; - let check_name = - if strip_underscore { name.strip_prefix('_').unwrap_or(name) } else { name }; + let check_name = undecorate_coff_symbol(name, machine, coff_symbol_kind(sym)); if rename.is_some_and(|(rename_set, _)| rename_set.contains(check_name)) { renames.push(RenameEntry { name_field_offset: symbol_bytes_offset + index.0 * sym_size, diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index b11dee2ca3827..bda08821c9f22 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -1,5 +1,6 @@ use std::collections::hash_map::Entry::*; +use object::pe; use rustc_abi::{CanonAbi, X86Call}; use rustc_ast::expand::allocator::{AllocatorKind, NO_ALLOC_SHIM_IS_UNSTABLE, global_fn_name}; use rustc_crate_store::CrateDepKind; @@ -813,6 +814,68 @@ pub(crate) fn exporting_symbol_name_for_instance_in_crate<'tcx>( maybe_emutls_symbol_name(tcx, symbol, &undecorated).unwrap_or(undecorated) } +fn strip_numeric_suffix<'a>(base: &'a str, suffix: impl AsRef, fallback: &'a str) -> &'a str { + if suffix.as_ref().parse::().is_ok() { base } else { fallback } +} + +/// COFF `IMAGE_FILE_MACHINE_*` for an arch with decorated symbols, or `None`. +pub(super) fn coff_machine_for_arch(arch: &Arch) -> Option { + match *arch { + Arch::X86 => Some(pe::IMAGE_FILE_MACHINE_I386), + Arch::X86_64 => Some(pe::IMAGE_FILE_MACHINE_AMD64), + Arch::Arm64EC => Some(pe::IMAGE_FILE_MACHINE_ARM64EC), + _ => None, + } +} + +/// Undecorated counterpart of [`linking_symbol_name_for_instance_in_crate`]. +pub(super) fn undecorate_coff_symbol<'a>( + name: &'a str, + machine: u16, + kind: SymbolExportKind, +) -> &'a str { + // MSVC C++ mangled names start with '?' and use a completely different + // decorating scheme that includes '@@' as structural delimiters. + // They must not be subjected to C calling-convention undecoration. + if name.starts_with('?') { + return name; + } + match machine { + pe::IMAGE_FILE_MACHINE_I386 => { + if let Some(rest) = name.strip_prefix('@') { + // fastcall: @foo@N -> foo + rest.rsplit_once('@') + .map(|(base, suffix)| strip_numeric_suffix(base, suffix, name)) + .unwrap_or(name) + } else if let Some(stripped) = name.strip_prefix('_') { + if let Some((base, suffix)) = stripped.rsplit_once('@') { + // stdcall: _foo@N -> foo + strip_numeric_suffix(base, suffix, stripped) + } else { + // cdecl: _foo -> foo + stripped + } + } else { + // vectorcall: foo@@N -> foo + name.rsplit_once("@@") + .map(|(base, suffix)| strip_numeric_suffix(base, suffix, name)) + .unwrap_or(name) + } + } + pe::IMAGE_FILE_MACHINE_AMD64 => { + // vectorcall: foo@@N -> foo + name.rsplit_once("@@") + .map(|(base, suffix)| strip_numeric_suffix(base, suffix, name)) + .unwrap_or(name) + } + pe::IMAGE_FILE_MACHINE_ARM64EC if kind == SymbolExportKind::Text => { + // `#` prefix distinguishes ARM64EC text symbols from x64 thunks. + name.strip_prefix('#').unwrap_or(name) + } + _ => name, + } +} + /// On amdhsa, `gpu-kernel` functions have an associated metadata object with a `.kd` suffix. /// Add it to the symbols list for all kernel functions, so that it is exported in the linked /// object. diff --git a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs index 5764400148ca7..c8cbd955acc5e 100644 --- a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs @@ -519,6 +519,9 @@ fn report_eval_error<'tcx>( where_ = if num_frames == 0 { "here" } else { "inside this call" }, ), ); + for span in crate::util::context_spans(*ecx.tcx, span, cid.instance.def_id()) { + diag.span_context(span); + } for frame in frames { diag.subdiagnostic(frame); } diff --git a/compiler/rustc_const_eval/src/diagnostics.rs b/compiler/rustc_const_eval/src/diagnostics.rs index 995356fd3b488..f7c5d6c36cecb 100644 --- a/compiler/rustc_const_eval/src/diagnostics.rs +++ b/compiler/rustc_const_eval/src/diagnostics.rs @@ -310,6 +310,7 @@ pub(crate) struct NonConstImplNote { #[derive(Clone)] pub(crate) struct FrameNote { pub span: Span, + pub span_context: Vec, pub times: i32, pub where_: &'static str, pub instance: String, @@ -322,6 +323,9 @@ impl Subdiagnostic for FrameNote { if self.has_label && !self.span.is_dummy() { span.push_span_label(self.span, msg!("the failure occurred here")); } + for sp in &self.span_context { + span.push_span_context(*sp); + } let msg = msg!( r#"{$times -> [0] inside {$where_ -> diff --git a/compiler/rustc_const_eval/src/interpret/stack.rs b/compiler/rustc_const_eval/src/interpret/stack.rs index 8a731e25d8f4b..61cc31479b652 100644 --- a/compiler/rustc_const_eval/src/interpret/stack.rs +++ b/compiler/rustc_const_eval/src/interpret/stack.rs @@ -230,18 +230,21 @@ impl<'tcx> FrameInfo<'tcx> { diagnostics::FrameNote { where_: "closure", span, + span_context: vec![], instance: String::new(), times: 0, has_label: false, } } else { let instance = format!("{}", self.instance); + let span_context = crate::util::context_spans(tcx, span, self.instance.def_id()); // Note: this triggers a `must_produce_diag` state, which means that if we ever get // here we must emit a diagnostic. We should never display a `FrameInfo` unless we // actually want to emit a warning or error to the user. diagnostics::FrameNote { where_: "instance", span, + span_context, instance, times: 0, has_label: false, diff --git a/compiler/rustc_const_eval/src/util/mod.rs b/compiler/rustc_const_eval/src/util/mod.rs index c63d7748087c9..e7fcdef588d2e 100644 --- a/compiler/rustc_const_eval/src/util/mod.rs +++ b/compiler/rustc_const_eval/src/util/mod.rs @@ -1,4 +1,8 @@ +use rustc_hir::def::DefKind; +use rustc_hir::def_id::DefId; use rustc_middle::mir; +use rustc_middle::ty::TyCtxt; +use rustc_span::Span; mod alignment; pub(crate) mod caller_location; @@ -16,7 +20,7 @@ pub use self::type_name::type_name; /// same type as the result. #[inline] pub fn binop_left_homogeneous(op: mir::BinOp) -> bool { - use rustc_middle::mir::BinOp::*; + use mir::BinOp::*; match op { Add | AddUnchecked | Sub | SubUnchecked | Mul | MulUnchecked | Div | Rem | BitXor | BitAnd | BitOr | Offset | Shl | ShlUnchecked | Shr | ShrUnchecked => true, @@ -30,7 +34,7 @@ pub fn binop_left_homogeneous(op: mir::BinOp) -> bool { /// same type as the LHS. #[inline] pub fn binop_right_homogeneous(op: mir::BinOp) -> bool { - use rustc_middle::mir::BinOp::*; + use mir::BinOp::*; match op { Add | AddUnchecked | AddWithOverflow | Sub | SubUnchecked | SubWithOverflow | Mul | MulUnchecked | MulWithOverflow | Div | Rem | BitXor | BitAnd | BitOr | Eq | Ne | Lt @@ -48,3 +52,43 @@ pub fn unop_homogeneous(op: mir::UnOp) -> bool { mir::UnOp::PtrMetadata => false, } } + +pub fn context_spans(tcx: TyCtxt<'_>, span: Span, def_id: DefId) -> Vec { + // For consts where the enclosing item might be useful context, include their spans in the + // diagnostic. + let instance_span = tcx.def_span(def_id).shrink_to_lo(); + let parent = tcx.parent(def_id); + let parent_span = tcx.def_span(parent).shrink_to_lo(); + let mut span = span; + if let Some(sp) = span.macro_backtrace().last() { + // We want the outermost span when macros are involved, as we don't care about the + // macro's internal consts for the purposes of adding context. + span = sp.call_site; + } + match (tcx.def_kind(def_id), tcx.def_kind(parent)) { + ( + _, + DefKind::Struct + | DefKind::Union + | DefKind::Enum + | DefKind::Trait + | DefKind::Impl { .. } + | DefKind::TyAlias + | DefKind::Const + | DefKind::Fn + | DefKind::Static { .. }, + ) + | (DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy, _) + if span.eq_ctxt(instance_span) && span.eq_ctxt(parent_span) => + { + vec![instance_span, parent_span] + } + (_, DefKind::Variant) if span.eq_ctxt(instance_span) && span.eq_ctxt(parent_span) => { + vec![instance_span, parent_span, tcx.def_span(tcx.parent(parent)).shrink_to_lo()] + } + (DefKind::Const | DefKind::Static { .. }, _) if span.eq_ctxt(instance_span) => { + vec![instance_span] + } + _ => vec![], + } +} diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 1e75902884fe1..76fd59577f248 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -964,8 +964,8 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), res = res.and(enter_wf_checking_ctxt(tcx, def_id, |wfcx| { let ty = tcx.type_of(def_id).instantiate_identity(); let ty_span = tcx.ty_span(def_id); - let ty = wfcx.deeply_normalize(ty_span, Some(WellFormedLoc::Ty(def_id)), ty); - wfcx.register_wf_obligation(ty_span, Some(WellFormedLoc::Ty(def_id)), ty.into()); + let ty = wfcx.deeply_normalize(ty_span, WellFormedLoc::Ty(def_id), ty); + wfcx.register_wf_obligation(ty_span, WellFormedLoc::Ty(def_id), ty.into()); wfcx.register_bound( traits::ObligationCause::new( ty_span, @@ -993,12 +993,8 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), let span = tcx.def_span(def_id); if tcx.type_alias_is_checked(def_id) { res = res.and(enter_wf_checking_ctxt(tcx, def_id, |wfcx| { - let item_ty = wfcx.deeply_normalize(span, Some(WellFormedLoc::Ty(def_id)), ty); - wfcx.register_wf_obligation( - span, - Some(WellFormedLoc::Ty(def_id)), - item_ty.into(), - ); + let item_ty = wfcx.deeply_normalize(span, WellFormedLoc::Ty(def_id), ty); + wfcx.register_wf_obligation(span, WellFormedLoc::Ty(def_id), item_ty.into()); check_where_clauses(wfcx, def_id); Ok(()) })); diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 043e3fad05056..86f386381b9e2 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -68,12 +68,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> { // Convenience function to normalize during wfcheck. This performs // `ObligationCtxt::normalize`, but provides a nice `ObligationCauseCode`. - fn normalize( - &self, - span: Span, - loc: Option, - value: Unnormalized<'tcx, T>, - ) -> T + fn normalize(&self, span: Span, loc: WellFormedLoc, value: Unnormalized<'tcx, T>) -> T where T: TypeFoldable>, { @@ -96,7 +91,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> { pub(super) fn deeply_normalize( &self, span: Span, - loc: Option, + loc: WellFormedLoc, value: Unnormalized<'tcx, T>, ) -> T where @@ -122,7 +117,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> { pub(super) fn register_wf_obligation( &self, span: Span, - loc: Option, + loc: WellFormedLoc, term: ty::Term<'tcx>, ) { let cause = traits::ObligationCause::new( @@ -802,7 +797,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &ty::GenericParamDef) -> Result<(), Er if tcx.features().const_param_ty_unchecked() { enter_wf_checking_ctxt(tcx, tcx.local_parent(def_id), |wfcx| { - wfcx.register_wf_obligation(span, None, ty.into()); + wfcx.register_wf_obligation(span, WellFormedLoc::None, ty.into()); Ok(()) }) } else if tcx.features().adt_const_params() || tcx.features().min_adt_const_params() { @@ -916,7 +911,7 @@ pub(crate) fn check_associated_item( tcx: TyCtxt<'_>, def_id: LocalDefId, ) -> Result<(), ErrorGuaranteed> { - let loc = Some(WellFormedLoc::Ty(def_id)); + let loc = WellFormedLoc::Ty(def_id); enter_wf_checking_ctxt(tcx, def_id, |wfcx| { let item = tcx.associated_item(def_id); @@ -936,7 +931,7 @@ pub(crate) fn check_associated_item( match item.kind { ty::AssocKind::Const { .. } => { let ty = tcx.type_of(def_id).instantiate_identity(); - let ty = wfcx.deeply_normalize(span, Some(WellFormedLoc::Ty(def_id)), ty); + let ty = wfcx.deeply_normalize(span, WellFormedLoc::Ty(def_id), ty); wfcx.register_wf_obligation(span, loc, ty.into()); if item.defaultness(tcx).has_value() { @@ -964,7 +959,7 @@ pub(crate) fn check_associated_item( } if item.defaultness(tcx).has_value() { let ty = tcx.type_of(def_id).instantiate_identity(); - let ty = wfcx.deeply_normalize(span, Some(WellFormedLoc::Ty(def_id)), ty); + let ty = wfcx.deeply_normalize(span, WellFormedLoc::Ty(def_id), ty); wfcx.register_wf_obligation(span, loc, ty.into()); } Ok(()) @@ -1013,10 +1008,10 @@ pub(crate) fn check_type_defn<'tcx>( let span = tcx.ty_span(field_id); let ty = wfcx.deeply_normalize( span, - None, + WellFormedLoc::None, tcx.type_of(field.did).instantiate_identity(), ); - wfcx.register_wf_obligation(span, Some(WellFormedLoc::Ty(field_id)), ty.into()); + wfcx.register_wf_obligation(span, WellFormedLoc::Ty(field_id), ty.into()); if matches!(ty.kind(), ty::Adt(def, _) if def.repr().scalable()) && !matches!(adt_def.repr().scalable, Some(ScalableElt::Container)) @@ -1051,7 +1046,11 @@ pub(crate) fn check_type_defn<'tcx>( { let last = idx == variant.fields.len() - 1; let span = tcx.ty_span(field.did.expect_local()); - let ty = wfcx.normalize(span, None, tcx.type_of(field.did).instantiate_identity()); + let ty = wfcx.normalize( + span, + WellFormedLoc::None, + tcx.type_of(field.did).instantiate_identity(), + ); wfcx.register_bound( traits::ObligationCause::new( span, @@ -1215,7 +1214,7 @@ pub(crate) fn check_static_item<'tcx>( } let span = tcx.ty_span(item_id); - let loc = Some(WellFormedLoc::Ty(item_id)); + let loc = WellFormedLoc::Ty(item_id); let item_ty = wfcx.deeply_normalize(span, loc, Unnormalized::new_wip(ty)); let is_foreign_item = tcx.is_foreign_item(item_id); @@ -1231,7 +1230,7 @@ pub(crate) fn check_static_item<'tcx>( }; let forbid_unsized = !(is_foreign_item && is_structurally_foreign_item()); - wfcx.register_wf_obligation(span, Some(WellFormedLoc::Ty(item_id)), item_ty.into()); + wfcx.register_wf_obligation(span, WellFormedLoc::Ty(item_id), item_ty.into()); if forbid_unsized { let span = tcx.def_span(item_id); wfcx.register_bound( @@ -1300,12 +1299,16 @@ pub(super) fn check_const_item<'tcx>( if let Some(direct_rhs) = tcx.const_of_item(def_id) { let raw_ct = direct_rhs.instantiate_identity(); - let norm_ct = wfcx.deeply_normalize(span, Some(WellFormedLoc::Ty(def_id)), raw_ct); - wfcx.register_wf_obligation(span, Some(WellFormedLoc::Ty(def_id)), norm_ct.into()); + let norm_ct = wfcx.deeply_normalize(span, WellFormedLoc::Ty(def_id), raw_ct); + wfcx.register_wf_obligation(span, WellFormedLoc::Ty(def_id), norm_ct.into()); wfcx.register_obligation(Obligation::new( tcx, - ObligationCause::new(span, def_id, ObligationCauseCode::WellFormed(None)), + ObligationCause::new( + span, + def_id, + ObligationCauseCode::WellFormed(WellFormedLoc::Ty(def_id)), + ), wfcx.param_env, ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(norm_ct, item_ty)), )); @@ -1330,7 +1333,7 @@ fn check_impl<'tcx>( let trait_span = of_trait.trait_ref.path.span; let trait_ref = wfcx.deeply_normalize( trait_span, - Some(WellFormedLoc::Ty(item.hir_id().expect_owner().def_id)), + WellFormedLoc::Ty(item.hir_id().expect_owner().def_id), trait_ref, ); let trait_pred = @@ -1367,7 +1370,7 @@ fn check_impl<'tcx>( { let bound = wfcx.normalize( item.span, - Some(WellFormedLoc::Ty(item.hir_id().expect_owner().def_id)), + WellFormedLoc::Ty(item.hir_id().expect_owner().def_id), bound, ); wfcx.register_obligation(Obligation::new( @@ -1375,7 +1378,9 @@ fn check_impl<'tcx>( ObligationCause::new( impl_.self_ty.span, wfcx.body_def_id, - ObligationCauseCode::WellFormed(None), + ObligationCauseCode::WellFormed(WellFormedLoc::HirId( + of_trait.trait_ref.hir_ref_id, + )), ), wfcx.param_env, bound.to_host_effect_clause(tcx, ty::BoundConstness::Maybe), @@ -1390,12 +1395,12 @@ fn check_impl<'tcx>( let self_ty = tcx.type_of(item.owner_id).instantiate_identity().skip_norm_wip(); let self_ty = wfcx.deeply_normalize( item.span, - Some(WellFormedLoc::Ty(item.hir_id().expect_owner().def_id)), + WellFormedLoc::Ty(item.hir_id().expect_owner().def_id), Unnormalized::new_wip(self_ty), ); wfcx.register_wf_obligation( impl_.self_ty.span, - Some(WellFormedLoc::Ty(item.hir_id().expect_owner().def_id)), + WellFormedLoc::Ty(item.hir_id().expect_owner().def_id), self_ty.into(), ); } @@ -1437,7 +1442,8 @@ pub(super) fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, def_id: wfcx.register_wf_obligation( tcx.def_span(param.def_id), matches!(param.kind, GenericParamDefKind::Type { .. }) - .then(|| WellFormedLoc::Ty(param.def_id.expect_local())), + .then(|| WellFormedLoc::Ty(param.def_id.expect_local())) + .unwrap_or(WellFormedLoc::None), default.as_term().unwrap(), ); } else { @@ -1466,7 +1472,7 @@ pub(super) fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, def_id: let cause = traits::ObligationCause::new( tcx.def_span(param.def_id), wfcx.body_def_id, - ObligationCauseCode::WellFormed(None), + ObligationCauseCode::WellFormed(WellFormedLoc::Ty(def_id)), ); wfcx.register_obligation(Obligation::new( tcx, @@ -1560,7 +1566,7 @@ pub(super) fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, def_id: // Note the subtle difference from how we handle `gen_clauses` // below: there, we are not trying to prove those clauses // to be *true* but merely *well-formed*. - let clause = wfcx.normalize(sp, None, clause); + let clause = wfcx.normalize(sp, WellFormedLoc::None, clause); let cause = traits::ObligationCause::new( sp, wfcx.body_def_id, @@ -1636,12 +1642,12 @@ fn check_fn_or_method<'tcx>( tcx.mk_type_list_from_iter(sig.inputs_and_output.iter().enumerate().map(|(idx, ty)| { wfcx.deeply_normalize( arg_span(idx), - Some(WellFormedLoc::Param { + WellFormedLoc::Param { function: def_id, // Note that the `param_idx` of the output type is // one greater than the index of the last input type. param_idx: idx, - }), + }, Unnormalized::new_wip(ty), ) })); @@ -1649,7 +1655,7 @@ fn check_fn_or_method<'tcx>( for (idx, ty) in sig.inputs_and_output.iter().enumerate() { wfcx.register_wf_obligation( arg_span(idx), - Some(WellFormedLoc::Param { function: def_id, param_idx: idx }), + WellFormedLoc::Param { function: def_id, param_idx: idx }, ty.into(), ); } @@ -1726,7 +1732,7 @@ fn check_method_receiver<'tcx>( } let span = fn_sig.decl.inputs[0].span; - let loc = Some(WellFormedLoc::Param { function: method.def_id.expect_local(), param_idx: 0 }); + let loc = WellFormedLoc::Param { function: method.def_id.expect_local(), param_idx: 0 }; let sig = tcx.fn_sig(method.def_id).instantiate_identity().skip_norm_wip(); let sig = tcx.liberate_late_bound_regions(method.def_id, sig); @@ -2319,7 +2325,8 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> { // Match the existing behavior. if clause.is_global() && !clause.has_type_flags(TypeFlags::HAS_BINDER_VARS) { - let clause = self.normalize(span, None, Unnormalized::new_wip(clause)); + let clause = + self.normalize(span, WellFormedLoc::None, Unnormalized::new_wip(clause)); // only use the span of the predicate clause (#90869) let hir_node = tcx.hir_node_by_def_id(self.body_def_id); diff --git a/compiler/rustc_hir_analysis/src/hir_wf_check.rs b/compiler/rustc_hir_analysis/src/hir_wf_check.rs index 9b05789a28f49..9806b7b873918 100644 --- a/compiler/rustc_hir_analysis/src/hir_wf_check.rs +++ b/compiler/rustc_hir_analysis/src/hir_wf_check.rs @@ -19,7 +19,8 @@ pub(super) fn diagnostic_hir_wf_check<'tcx>( ) -> Option> { let def_id = match loc { WellFormedLoc::Ty(def_id) => def_id, - WellFormedLoc::Param { function, param_idx: _ } => function, + WellFormedLoc::Param { function, .. } => function, + WellFormedLoc::HirId(_) | WellFormedLoc::None => return None, }; let hir_id = tcx.local_def_id_to_hir_id(def_id); @@ -85,7 +86,7 @@ pub(super) fn diagnostic_hir_wf_check<'tcx>( let cause = traits::ObligationCause::new( ty.span, self.def_id, - traits::ObligationCauseCode::WellFormed(None), + traits::ObligationCauseCode::WellFormed(WellFormedLoc::HirId(ty.hir_id)), ); ocx.register_obligation(traits::Obligation::new( @@ -191,7 +192,7 @@ pub(super) fn diagnostic_hir_wf_check<'tcx>( } ref node => bug!("Unexpected node {:?}", node), }, - WellFormedLoc::Param { function: _, param_idx } => { + WellFormedLoc::Param { param_idx, .. } => { let fn_decl = tcx.hir_fn_decl_by_hir_id(hir_id).unwrap(); // Get return type if param_idx as usize == fn_decl.inputs.len() { @@ -204,6 +205,7 @@ pub(super) fn diagnostic_hir_wf_check<'tcx>( vec![&fn_decl.inputs[param_idx as usize]] } } + WellFormedLoc::HirId(_) | WellFormedLoc::None => return None, }; for ty in tys { visitor.visit_ty_unambig(ty); diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 025c64896edb7..b431e9951a87e 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -11,7 +11,7 @@ use rustc_hir::def_id::DefId; use rustc_hir::{self as hir, HirId}; use rustc_hir_analysis::autoderef::Autoderef; use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes}; -use rustc_infer::traits::{Obligation, ObligationCause, ObligationCauseCode}; +use rustc_infer::traits::{Obligation, ObligationCause, ObligationCauseCode, WellFormedLoc}; use rustc_middle::ty::adjustment::{ Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability, }; @@ -177,7 +177,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.register_wf_obligation( output.into(), call_expr.span, - ObligationCauseCode::WellFormed(None), + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(call_expr.hir_id)), ); output @@ -728,7 +728,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // now we have to unify it with signature input in order to resolve // all inference variables. After that we update input signature for // adjustments search for mapped arguments. - let cause = self.cause(call_expr.span, ObligationCauseCode::Misc); + let cause = self.cause( + call_expr.span, + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(call_expr.hir_id)), + ); if self .at(&cause, self.param_env) .sup(DefineOpaqueTypes::Yes, formal_input_tys[0], adjusted_arg_type) @@ -1115,7 +1118,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { match const_context { Some(hir::ConstContext::Const { .. } | hir::ConstContext::Static(_)) => {} Some(hir::ConstContext::ConstFn) | None => { - self.dcx().span_err(span, "comptime fns can only be called at compile time"); + self.dcx().emit_err(diagnostics::ComptimeFnCalledOutsideConstContext { + span, + const_block: diagnostics::WrapConstBlock { + left: span.shrink_to_lo(), + right: span.shrink_to_hi(), + }, + }); } } } diff --git a/compiler/rustc_hir_typeck/src/check.rs b/compiler/rustc_hir_typeck/src/check.rs index b1b7aa5727097..8061e522f43aa 100644 --- a/compiler/rustc_hir_typeck/src/check.rs +++ b/compiler/rustc_hir_typeck/src/check.rs @@ -72,10 +72,10 @@ pub(super) fn check_fn<'a, 'tcx>( fcx.register_wf_obligation( param_ty.into(), param.span, - ObligationCauseCode::WellFormed(Some(WellFormedLoc::Param { + ObligationCauseCode::WellFormed(WellFormedLoc::Param { function: fn_def_id, param_idx: idx, - })), + }), ); } diff --git a/compiler/rustc_hir_typeck/src/diagnostics.rs b/compiler/rustc_hir_typeck/src/diagnostics.rs index 12e1006cc734f..5522ce033ee9c 100644 --- a/compiler/rustc_hir_typeck/src/diagnostics.rs +++ b/compiler/rustc_hir_typeck/src/diagnostics.rs @@ -1349,3 +1349,24 @@ impl ExprParenthesesNeeded { #[derive(Diagnostic)] #[diag("`#[panic_handler]` functions can't be `unsafe`")] pub(crate) struct UnsafePanicHandlers; + +#[derive(Diagnostic)] +#[diag("comptime functions can only be called at compile time")] +pub(crate) struct ComptimeFnCalledOutsideConstContext { + #[primary_span] + pub span: Span, + #[subdiagnostic] + pub const_block: WrapConstBlock, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion( + "wrap the call in a const block to force compile time evaluation", + applicability = "maybe-incorrect" +)] +pub(crate) struct WrapConstBlock { + #[suggestion_part(code = "const {{ ")] + pub left: Span, + #[suggestion_part(code = " }}")] + pub right: Span, +} diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 9f0d00d5274fa..a301cb6a397d9 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -25,6 +25,7 @@ use rustc_hir::{ExprKind, HirId, QPath, is_range_literal}; use rustc_hir_analysis::diagnostics::{NoFieldOnType, NoVariantNamed}; use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer as _; use rustc_infer::infer::{self, DefineOpaqueTypes, InferOk, RegionVariableOrigin}; +use rustc_infer::traits::WellFormedLoc; use rustc_infer::traits::query::NoSolution; use rustc_middle::ty::adjustment::{Adjust, Adjustment, AllowTwoPhase}; use rustc_middle::ty::consts::ConstExt; @@ -699,14 +700,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.require_type_is_sized_deferred( output, call_expr_and_args.map_or(expr.span, |(e, _)| e.span), - ObligationCauseCode::SizedCallReturnType, + ObligationCauseCode::SizedCallReturnType(expr.hir_id), ); } // We always require that the type provided as the value for // a type parameter outlives the moment of instantiation. let args = self.typeck_results.borrow().node_args(expr.hir_id); - self.add_wf_bounds(args, expr.span); + self.add_wf_bounds(args, expr.span, expr.hir_id); ty } @@ -1772,7 +1773,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.deferred_repeat_expr_checks.borrow_mut().push((element, element_ty, count)); let ty = Ty::new_array_with_const_len(tcx, t, count); - self.register_wf_obligation(ty.into(), expr.span, ObligationCauseCode::WellFormed(None)); + self.register_wf_obligation( + ty.into(), + expr.span, + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(expr.hir_id)), + ); ty } @@ -1944,7 +1949,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.register_wf_obligation( field_type.into(), field.expr.span, - ObligationCauseCode::WellFormed(None), + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(field.expr.hir_id)), ); // Make sure to give a type to the field even if there's @@ -3895,7 +3900,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.require_type_is_sized( field_ty, expr.span, - ObligationCauseCode::Misc, + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(expr.hir_id)), ); } @@ -3924,7 +3929,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.require_type_is_sized( field_ty, expr.span, - ObligationCauseCode::Misc, + ObligationCauseCode::WellFormed(WellFormedLoc::HirId( + expr.hir_id, + )), ); } diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 1ad6225a8c467..b0f940dd7a21a 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -22,7 +22,7 @@ use rustc_hir_analysis::hir_ty_lowering::{ }; use rustc_infer::infer::canonical::{Canonical, OriginalQueryValues, QueryResponse}; use rustc_infer::infer::{DefineOpaqueTypes, InferResult}; -use rustc_infer::traits::TraitErrors; +use rustc_infer::traits::{TraitErrors, WellFormedLoc}; use rustc_lint_defs::builtin::{SELF_CONSTRUCTOR_FROM_OUTER_ITEM, UNREACHABLE_CODE}; use rustc_middle::ty::adjustment::{ Adjust, Adjustment, AutoBorrow, AutoBorrowMutability, DerefAdjustKind, @@ -543,7 +543,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(crate) fn lower_ty(&self, hir_ty: &hir::Ty<'_>) -> LoweredTy<'tcx> { let ty = self.lowerer().lower_ty(hir_ty); - self.register_wf_obligation(ty.into(), hir_ty.span, ObligationCauseCode::WellFormed(None)); + self.register_wf_obligation( + ty.into(), + hir_ty.span, + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(hir_ty.hir_id)), + ); LoweredTy::from_raw(self, hir_ty.span, ty) } @@ -608,7 +612,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.register_wf_obligation( ct.into(), self.tcx.hir_span(const_arg.hir_id), - ObligationCauseCode::WellFormed(None), + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(const_arg.hir_id)), ); ct } @@ -664,9 +668,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } /// Registers obligations that all `args` are well-formed. - pub(crate) fn add_wf_bounds(&self, args: GenericArgsRef<'tcx>, span: Span) { + pub(crate) fn add_wf_bounds(&self, args: GenericArgsRef<'tcx>, span: Span, hir_id: HirId) { for term in args.iter().filter_map(ty::GenericArg::as_term) { - self.register_wf_obligation(term, span, ObligationCauseCode::WellFormed(None)); + self.register_wf_obligation( + term, + span, + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(hir_id)), + ); } } @@ -810,7 +818,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.register_wf_obligation( ty.raw.into(), qself.span, - ObligationCauseCode::WellFormed(None), + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(hir_id)), ); self.select_obligations_where_possible(|_| {}); diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index 937182c2030da..8ecd7838a0e69 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -19,6 +19,7 @@ use rustc_index::IndexVec; use rustc_infer::infer::{ BoundRegionConversionTime, DefineOpaqueTypes, InferOk, TypeTrace, relate, }; +use rustc_infer::traits::WellFormedLoc; use rustc_middle::ty::adjustment::AllowTwoPhase; use rustc_middle::ty::error::{ExpectedFound, TypeError}; use rustc_middle::ty::print::with_forced_trimmed_paths; @@ -230,7 +231,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.register_wf_obligation( fn_input_ty.into(), arg_expr.span, - ObligationCauseCode::WellFormed(None), + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(arg_expr.hir_id)), ); self.check_place_expr_if_unsized(fn_input_ty, arg_expr); @@ -1197,7 +1198,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.register_wf_obligation( decl_ty.into(), decl.pat.span, - ObligationCauseCode::WellFormed(None), + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(decl.pat.hir_id)), ); } self.overwrite_local_ty_if_err(decl.hir_id, decl.pat, pat_ty); diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index 5efb2775c77fe..2945a6b3b5136 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -193,7 +193,7 @@ fn typeck_with_inspect<'tcx>( let expected_type = fcx.normalize(body.value.span, Unnormalized::new_wip(expected_type)); - let wf_code = ObligationCauseCode::WellFormed(Some(WellFormedLoc::Ty(def_id))); + let wf_code = ObligationCauseCode::WellFormed(WellFormedLoc::Ty(def_id)); fcx.register_wf_obligation(expected_type.into(), body.value.span, wf_code); if let hir::Node::AnonConst(_) = node { diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs index 4518e419aea0f..721e9a38fc50c 100644 --- a/compiler/rustc_hir_typeck/src/method/confirm.rs +++ b/compiler/rustc_hir_typeck/src/method/confirm.rs @@ -13,6 +13,7 @@ use rustc_hir_analysis::hir_ty_lowering::{ use rustc_infer::infer::{ BoundRegionConversionTime, DefineOpaqueTypes, InferOk, RegionVariableOrigin, }; +use rustc_infer::traits::WellFormedLoc; use rustc_lint_defs::builtin::{ AMBIGUOUS_GLOB_IMPORTED_TRAITS, RESOLVING_TO_ITEMS_SHADOWING_SUPERTRAIT_ITEMS, }; @@ -648,7 +649,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { // this is a projection from a trait reference, so we have to // make sure that the trait reference inputs are well-formed. - self.add_wf_bounds(all_args, self.call_expr.span); + self.add_wf_bounds(all_args, self.call_expr.span, self.call_expr.hir_id); // the function type must also be well-formed (this is not // implied by the args being well-formed because of inherent @@ -657,7 +658,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { self.register_wf_obligation( ty.into(), self.span, - ObligationCauseCode::WellFormed(None), + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(self.call_expr.hir_id)), ); } } diff --git a/compiler/rustc_infer/src/infer/at.rs b/compiler/rustc_infer/src/infer/at.rs index 341ea9a70dbc7..6a34bd4884d73 100644 --- a/compiler/rustc_infer/src/infer/at.rs +++ b/compiler/rustc_infer/src/infer/at.rs @@ -78,6 +78,7 @@ impl<'tcx> InferCtxt<'tcx> { selection_cache: self.selection_cache.clone(), evaluation_cache: self.evaluation_cache.clone(), reported_trait_errors: self.reported_trait_errors.clone(), + reported_hir_errors: self.reported_hir_errors.clone(), reported_signature_mismatch: self.reported_signature_mismatch.clone(), tainted_by_errors: self.tainted_by_errors.clone(), universe: self.universe.clone(), @@ -108,6 +109,7 @@ impl<'tcx> InferCtxt<'tcx> { selection_cache: Default::default(), evaluation_cache: Default::default(), reported_trait_errors: self.reported_trait_errors.clone(), + reported_hir_errors: self.reported_hir_errors.clone(), reported_signature_mismatch: self.reported_signature_mismatch.clone(), tainted_by_errors: self.tainted_by_errors.clone(), universe: self.universe.clone(), diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index a7ce6a4353b59..c45c5e44aaa31 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -307,6 +307,11 @@ pub struct InferCtxt<'tcx> { pub reported_trait_errors: RefCell>>, ErrorGuaranteed)>>, + /// A set of predicates *on a specific* HIR node (the originating expression and its enclosing + /// statement), to avoid reporting multiple errors pointing at different sub-expressions in the + /// same method chain. + pub reported_hir_errors: RefCell>>>, + pub reported_signature_mismatch: RefCell)>>, /// When an error occurs, we want to avoid reporting "derived" @@ -689,6 +694,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> { selection_cache: Default::default(), evaluation_cache: Default::default(), reported_trait_errors: Default::default(), + reported_hir_errors: Default::default(), reported_signature_mismatch: Default::default(), tainted_by_errors: Cell::new(None), universe: Cell::new(ty::UniverseIndex::ROOT), diff --git a/compiler/rustc_lint/src/diagnostics.rs b/compiler/rustc_lint/src/diagnostics.rs index d9fc1703f8c03..601f1213650e1 100644 --- a/compiler/rustc_lint/src/diagnostics.rs +++ b/compiler/rustc_lint/src/diagnostics.rs @@ -3261,3 +3261,14 @@ pub(crate) enum RawBorrowViaReferenceSuggestion<'a> { #[help("consider using `&raw {$mutbl}` for a safer and more explicit raw pointer")] Spanless { mutbl: &'a str }, } + +#[derive(Diagnostic)] +#[diag("missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable`")] +#[note_once( + "`GenericTypeVisitable` is rust-analyzer's version of `TypeVisitable`; it should be implemented whenever the latter is" +)] +#[help("mark the type with `#[derive(GenericTypeVisitable)]`")] +#[help( + "or, if `GenericTypeVisitable` is derived, check whether all fields implement `GenericTypeVisitable`" +)] +pub(crate) struct MissingGenericTypeVisitableDeriveDiag; diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index b32fa2515238a..bce726311e51f 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -8,17 +8,20 @@ use rustc_hir as hir; use rustc_hir::def::Res; use rustc_hir::def_id::DefId; use rustc_hir::{Expr, ExprKind, HirId}; +use rustc_infer::infer::TyCtxtInferExt as _; use rustc_lint_defs::{declare_lint_pass, declare_tool_lint}; use rustc_middle::ty::{self, ClausePolarity, GenericArgsRef}; use rustc_span::hygiene::{ExpnKind, MacroKind}; -use rustc_span::{Span, sym}; +use rustc_span::{DUMMY_SP, Span, sym}; +use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _; +use rustc_trait_selection::traits::{Obligation, ObligationCause}; use crate::diagnostics::{ AttributeKindInFindAttr, BadOptAccessDiag, DefaultHashTypesDiag, - ImplicitSysrootCrateImportDiag, LintPassByHand, NonGlobImportTypeIrInherent, QueryInstability, - QueryUntracked, RustcMustMatchExhaustivelyNotExhaustive, SpanUseEqCtxtDiag, - SymbolInternStringLiteralDiag, TyQualified, TykindDiag, TykindKind, TypeIrDirectUse, - TypeIrInherentUsage, TypeIrTraitUsage, + ImplicitSysrootCrateImportDiag, LintPassByHand, MissingGenericTypeVisitableDeriveDiag, + NonGlobImportTypeIrInherent, QueryInstability, QueryUntracked, + RustcMustMatchExhaustivelyNotExhaustive, SpanUseEqCtxtDiag, SymbolInternStringLiteralDiag, + TyQualified, TykindDiag, TykindKind, TypeIrDirectUse, TypeIrInherentUsage, TypeIrTraitUsage, }; use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; @@ -873,3 +876,63 @@ impl<'tcx> LateLintPass<'tcx> for RustcMustMatchExhaustively { } } } + +declare_tool_lint! { + /// The `missing_generic_type_visitable_derive` lint detects types implementing `TypeVisitable` + /// but not deriving `GenericTypeVisitable`. + /// + /// `GenericTypeVisitable` is the analog of `TypeVisitable` used by rust-analyzer, and needs to + /// be implemented whenever `TypeVisitable` is. See [`rustc_type_ir::generic_visit`] for more + /// information. + pub rustc::MISSING_GENERIC_TYPE_VISITABLE_DERIVE, + // This lint is meant to be manually enabled in selected crates (currently only `rustc_type_ir`) + Allow, + "Forbid implementing `TypeVisitable` without deriving `GenericTypeVisitable`", + report_in_external_macro: true +} + +declare_lint_pass!(MissingGenericTypeVisitableDerive => [MISSING_GENERIC_TYPE_VISITABLE_DERIVE]); + +impl<'tcx> LateLintPass<'tcx> for MissingGenericTypeVisitableDerive { + fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) { + // lint ADTs except unions, as neither trait can be implemented on the latter + if matches!(item.kind, hir::ItemKind::Struct(..) | hir::ItemKind::Enum(..)) + && let Some(regular_id) = cx.tcx.get_diagnostic_item(sym::TypeVisitable) + && let Some(generic_id) = cx.tcx.get_diagnostic_item(sym::GenericTypeVisitable) + && let (infcx, param_env) = cx.tcx.infer_ctxt().build_with_typing_env(cx.typing_env()) + && let self_ty = { + let self_id = item.owner_id.to_def_id(); + let args = infcx.fresh_args_for_item(DUMMY_SP, self_id); + cx.tcx.type_of(self_id).instantiate(cx.tcx, args).skip_norm_wip() + } + // check whether `Self: TypeVisitable` holds for some `I`.. + && { + let predicate = + ty::TraitRef::new(cx.tcx, regular_id, [self_ty, infcx.next_ty_var(DUMMY_SP)]); + let obligation = + Obligation::new(cx.tcx, ObligationCause::dummy(), param_env, predicate); + + // NOTE: I initially went with `predicate_must_hold_modulo_regions` (which is what's + // used by Clippy's [`implements_trait`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/ty/fn.implements_trait.html), + // but that returned `false` more often than I'd hoped, and so I went with the + // next-most strict function. + infcx.predicate_may_hold(&obligation) + } + // ..while `Self: GenericTypeVisitable` doesn't + && { + let predicate = + ty::TraitRef::new(cx.tcx, generic_id, [self_ty, infcx.next_ty_var(DUMMY_SP)]); + let obligation = + Obligation::new(cx.tcx, ObligationCause::dummy(), param_env, predicate); + + !infcx.predicate_may_hold(&obligation) + } + { + cx.emit_span_lint( + MISSING_GENERIC_TYPE_VISITABLE_DERIVE, + item.span, + MissingGenericTypeVisitableDeriveDiag, + ); + } + } +} diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 2c84bebc71754..88d99449ba879 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -298,6 +298,7 @@ late_lint_methods!( BadOptAccess: BadOptAccess, DefaultHashTypes: DefaultHashTypes, DisallowedPassByRef: DisallowedPassByRef, + MissingGenericTypeVisitableDerive: MissingGenericTypeVisitableDerive, QueryStability: QueryStability, RustcMustMatchExhaustively: RustcMustMatchExhaustively, SpanUseEqCtxt: SpanUseEqCtxt, @@ -769,6 +770,11 @@ fn register_internals(store: &mut LintStore) { // // Late pass: RustcMustMatchExhaustively LintId::of(RUSTC_MUST_MATCH_EXHAUSTIVELY), + // Late pass: MissingGenericTypeVisitableDerive + // Note: this one is not included so that it doesn't become effectively warn-by-default + // (since `rustc::internal` is warn-by-default). Instead, it's enabled manually in + // each relevant crate. + // LintId::of(MISSING_GENERIC_TYPE_VISITABLE_DERIVE), ], ); } diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 31610f558974f..979dc2b903c88 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -85,6 +85,7 @@ pub mod hardwired { NON_EXHAUSTIVE_OMITTED_PATTERNS, OUT_OF_SCOPE_MACRO_CALLS, OVERLAPPING_RANGE_ENDPOINTS, + PARTIAL_STACK_PROTECTOR, PATTERNS_IN_FNS_WITHOUT_BODY, PRIVATE_BOUNDS, PRIVATE_INTERFACES, @@ -5922,3 +5923,63 @@ declare_lint! { reason: fcw!(FutureReleaseError #163263), }; } + +declare_lint! { + /// The `partial_stack_protector` lint detects uses of the `-Z stack-protector` + /// compile flag to build a program that contains crates that are not protected + /// by stack-protector, or protected by a weaker level of it than the crate + /// you are compiling. + /// + /// ### Example + /// + /// ```text + /// rustc -Z stack-protector=all + /// ``` + /// + /// ```rust,ignore (needs command line option) + /// fn main() {} + /// ``` + /// + /// This will produce: + /// + /// ```text + /// warning: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled + /// | + /// = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + /// = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + /// = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + /// = note: for more information, see issue #154613 + /// = note: `#[warn(partial_stack_protector)]` (part of `#[warn(future_incompatible)]`) on by default + /// ``` + /// + /// ### Explanation + /// + /// Using the `-Z stack-protector` flag on only part of a compiled object + /// will lead to a compiled program that is not fully protected by stack-protector, + /// which is a security risk. This was previously accepted and used in practice, + /// and is now being phased out. This is a [future-incompatible] lint to transition this + /// to a hard error in the future. See [issue #154613] for more details. + /// + /// If you intentionally want to use the `-Z stack-protector` flag for only a part + /// of your compiled program, you can allow it in a future-compatible way + /// using the `-Z allow-partial-mitigations=stack-protector` flag, which must be + /// passed *after* the `-Z stack-protector` flag in the command line, for example: + /// + /// ```text + /// rustc -Z stack-protector=all -Z allow-partial-mitigations=stack-protector + /// ``` + /// + /// The order dependency is by design, see the [RFC 3855] for details. + /// + /// [issue #154613]: https://github.com/rust-lang/rust/issues/154613 + /// [RFC 3855]: https://github.com/rust-lang/rfcs/blob/master/text/3855-mitigation-enforcement.md + /// [future-incompatible]: ../index.md#future-incompatible-lints + pub PARTIAL_STACK_PROTECTOR, + Warn, + "partial use of stack-protector that was previously accepted and used in practice", + @future_incompatible = FutureIncompatibleInfo { + reason: fcw!(FutureReleaseError #154613), + report_in_deps: false, + }; + crate_level_only +} diff --git a/compiler/rustc_metadata/src/creader.rs b/compiler/rustc_metadata/src/creader.rs index 10693448ea685..df15f7d159866 100644 --- a/compiler/rustc_metadata/src/creader.rs +++ b/compiler/rustc_metadata/src/creader.rs @@ -18,12 +18,14 @@ use rustc_hir::def_id::{CrateNum, LOCAL_CRATE, LocalDefId, StableCrateId}; use rustc_hir::definitions::{DefPathData, Definitions}; use rustc_index::IndexVec; use rustc_lint_defs as lint; -use rustc_lint_defs::builtin::UNUSED_CRATE_DEPENDENCIES; +use rustc_lint_defs::builtin::{PARTIAL_STACK_PROTECTOR, UNUSED_CRATE_DEPENDENCIES}; use rustc_middle::ty::data_structures::IndexSet; use rustc_middle::ty::{TyCtxt, TyCtxtFeed}; use rustc_proc_macro::bridge::client::Client as ProcMacroClient; use rustc_session::Session; -use rustc_session::config::mitigation_coverage::DeniedPartialMitigationLevel; +use rustc_session::config::mitigation_coverage::{ + DeniedPartialMitigationKind, DeniedPartialMitigationLevel, +}; use rustc_session::config::{ ExtendedTargetModifierInfo, ExternLocation, Externs, OptionsTargetModifiers, TargetModifier, }; @@ -499,11 +501,18 @@ impl CStore { } *errors += 1; - tcx.dcx().emit_err(diagnostics::MitigationLessStrictInDependency { + let diagnostic = diagnostics::MitigationLessStrictInDependency { mitigation_name: my_mitigation.kind.to_string(), mitigation_level: my_mitigation.level.level_str().to_string(), extern_crate: data.name(), - }); + }; + if my_mitigation.kind == DeniedPartialMitigationKind::StackProtector { + // make stack-protector only a forward-compat warning since it was + // pretty widely used + tcx.sess.psess.buffer_crate_lint(PARTIAL_STACK_PROTECTOR, diagnostic); + } else { + tcx.dcx().emit_err(diagnostic); + } } } } diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 5414863f4a459..29ca694b6431b 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -415,13 +415,17 @@ impl<'tcx> Body<'tcx> { pub fn typing_env(&self, tcx: TyCtxt<'tcx>) -> TypingEnv<'tcx> { if tcx.use_typing_mode_post_typeck_until_borrowck() { match self.phase { - MirPhase::Built if let Some(def_id) = self.source.def_id().as_local() => { + MirPhase::Built | MirPhase::Analysis(AnalysisPhase::Initial) + if let Some(def_id) = self.source.def_id().as_local() => + { TypingEnv::new( tcx.param_env(self.source.def_id()), ty::TypingMode::borrowck(tcx, def_id), ) } - MirPhase::Analysis(_) if let Some(def_id) = self.source.def_id().as_local() => { + MirPhase::Analysis(AnalysisPhase::PostCleanup) + if let Some(def_id) = self.source.def_id().as_local() => + { TypingEnv::new( tcx.param_env(self.source.def_id()), ty::TypingMode::post_borrowck_analysis(tcx, def_id), diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index 493f6989f342c..7c4c2d5aed157 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -238,7 +238,7 @@ pub enum ObligationCauseCode<'tcx> { /// Return type must be `Sized`. SizedReturnType, /// Return type of a call expression must be `Sized`. - SizedCallReturnType, + SizedCallReturnType(HirId), /// Yield type must be `Sized`. SizedYieldType, /// Inline asm operand type must be `Sized`. @@ -384,7 +384,7 @@ pub enum ObligationCauseCode<'tcx> { /// This is purely for diagnostic purposes - it is always /// correct to use `Misc` instead, or to specify /// `WellFormed(None)`. - WellFormed(Option), + WellFormed(WellFormedLoc), /// From `match_impl`. The cause for us having to match an impl, and the DefId we are matching /// against. @@ -461,6 +461,8 @@ pub enum WellFormedLoc { /// being the last 'parameter' param_idx: usize, }, + HirId(HirId), + None, } impl<'tcx> ObligationCauseCode<'tcx> { diff --git a/compiler/rustc_middle/src/ty/adt.rs b/compiler/rustc_middle/src/ty/adt.rs index 8ad5de3fa85cc..5b57f802c0c4f 100644 --- a/compiler/rustc_middle/src/ty/adt.rs +++ b/compiler/rustc_middle/src/ty/adt.rs @@ -384,30 +384,17 @@ impl AdtDefData { if find_attr!(tcx, did, Fundamental) { flags |= AdtFlags::IS_FUNDAMENTAL; } - if tcx.is_lang_item(did, LangItem::PhantomData) { - flags |= AdtFlags::IS_PHANTOM_DATA; - } - if tcx.is_lang_item(did, LangItem::OwnedBox) { - flags |= AdtFlags::IS_BOX; - } - if tcx.is_lang_item(did, LangItem::ManuallyDrop) { - flags |= AdtFlags::IS_MANUALLY_DROP; - } - if tcx.is_lang_item(did, LangItem::MaybeDangling) { - flags |= AdtFlags::IS_MAYBE_DANGLING; - } - if tcx.is_lang_item(did, LangItem::UnsafeCell) { - flags |= AdtFlags::IS_UNSAFE_CELL; - } - if tcx.is_lang_item(did, LangItem::UnsafePinned) { - flags |= AdtFlags::IS_UNSAFE_PINNED; - } - if tcx.is_lang_item(did, LangItem::Pin) { - flags |= AdtFlags::IS_PIN; - } - if tcx.is_lang_item(did, LangItem::FieldRepresentingType) { - flags |= AdtFlags::IS_FIELD_REPRESENTING_TYPE; - } + flags |= match tcx.as_lang_item(did) { + Some(LangItem::PhantomData) => AdtFlags::IS_PHANTOM_DATA, + Some(LangItem::OwnedBox) => AdtFlags::IS_BOX, + Some(LangItem::ManuallyDrop) => AdtFlags::IS_MANUALLY_DROP, + Some(LangItem::MaybeDangling) => AdtFlags::IS_MAYBE_DANGLING, + Some(LangItem::UnsafeCell) => AdtFlags::IS_UNSAFE_CELL, + Some(LangItem::UnsafePinned) => AdtFlags::IS_UNSAFE_PINNED, + Some(LangItem::Pin) => AdtFlags::IS_PIN, + Some(LangItem::FieldRepresentingType) => AdtFlags::IS_FIELD_REPRESENTING_TYPE, + _ => AdtFlags::NO_ADT_FLAGS, + }; AdtDefData { did, variants, flags, repr } } diff --git a/compiler/rustc_mir_transform/src/validate.rs b/compiler/rustc_mir_transform/src/validate.rs index 34bc276e790fb..c8564b8288cd2 100644 --- a/compiler/rustc_mir_transform/src/validate.rs +++ b/compiler/rustc_mir_transform/src/validate.rs @@ -629,11 +629,12 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { // is annoying. It is harmless enough to just not validate anything // in that case. We still check this after analysis as all opaque // types have been revealed at this point. - if pred.has_opaque_types() { + if !self.tcx.next_trait_solver_globally() && pred.has_opaque_types() { return true; } - let (infcx, param_env) = self.tcx.infer_ctxt().build_with_typing_env(self.typing_env); + let (infcx, param_env) = + self.tcx.infer_ctxt().ignoring_regions().build_with_typing_env(self.typing_env); let ocx = ObligationCtxt::new(&infcx); ocx.register_obligation(Obligation::new( self.tcx, diff --git a/compiler/rustc_passes/src/layout_test.rs b/compiler/rustc_passes/src/layout_test.rs index 961d39ec8e5ca..31490a49b695c 100644 --- a/compiler/rustc_passes/src/layout_test.rs +++ b/compiler/rustc_passes/src/layout_test.rs @@ -41,7 +41,7 @@ pub fn ensure_wf<'tcx>( traits::ObligationCause::new( span, def_id, - traits::ObligationCauseCode::WellFormed(Some(traits::WellFormedLoc::Ty(def_id))), + traits::ObligationCauseCode::WellFormed(traits::WellFormedLoc::Ty(def_id)), ), param_env, pred, diff --git a/compiler/rustc_resolve/src/diagnostics/impls.rs b/compiler/rustc_resolve/src/diagnostics/impls.rs index 744e7c22265ea..06c2742c489be 100644 --- a/compiler/rustc_resolve/src/diagnostics/impls.rs +++ b/compiler/rustc_resolve/src/diagnostics/impls.rs @@ -2314,6 +2314,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { // | ^ return; } + if span.in_derive_expansion() { + return; + } let span = self.tcx.sess.source_map().guess_head_span(def_span); let candidate_descr = suggestion.res.descr(); let candidate = suggestion.candidate; diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index ddde9982c0cae..c3421a735ddae 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -713,6 +713,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { self.suggest_at_operator_in_slice_pat_with_range(&mut err, path); self.suggest_range_struct_destructuring(&mut err, path, source); self.suggest_swapping_misplaced_self_ty_and_trait(&mut err, source, res, base_error.span); + self.detect_resolution_error_in_derive(&mut err, base_error.span); if let Some((span, label)) = base_error.span_label { err.span_label(span, label); @@ -1904,6 +1905,26 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { } } + /// If the name resolution error occurs in an ident that has no span context, but the enclosing + /// item is within a derive macro, point at the derive, as the error can either be because of an + /// invalid derive macro *or* a non-existing item that will already have been reported through + /// the annotated item. + fn detect_resolution_error_in_derive(&self, err: &mut Diag<'_>, span: Span) { + if let Some(item) = self.diag_metadata.current_item + && !item.span.eq_ctxt(span) + && item.span.in_derive_expansion() + { + // `item` comes from a `#[derive()]`, but the error `span` doesn't, which means that the + // derive is referencing a name coming from the annotated item. If the item exists, then + // the derive macro itself is buggy. If the item exists, then an error will have already + // been emitted while evaluating the annotated item itself, but we can't silence this + // one because one *can* write a derive macro referencing a non-existing item that is + // part of the expansion, *not* from the user's code. Because of that, at least for now, + // we just add context to the current error. + err.span_label(item.span, "in this derive macro"); + } + } + fn explain_functions_in_pattern( &self, err: &mut Diag<'_>, @@ -3681,6 +3702,9 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { (Some(Item { kind: ItemKind::Fn(fn_), .. }), _, _) if fn_.ident.name == sym::main => { // Ignore `fn main()` as we don't want to suggest `fn main()` } + (Some(Item { span, .. }), _, _) if span.in_derive_expansion() => { + return (None, None); + } ( Some(Item { kind: diff --git a/compiler/rustc_session/src/config/cfg.rs b/compiler/rustc_session/src/config/cfg.rs index 05e3c346cd767..d0d97592f0e4b 100644 --- a/compiler/rustc_session/src/config/cfg.rs +++ b/compiler/rustc_session/src/config/cfg.rs @@ -24,7 +24,6 @@ use std::hash::Hash; use std::iter; use rustc_abi::Align; -use rustc_ast::ast; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet}; use rustc_lint_defs::builtin::EXPLICIT_BUILTIN_CFGS_IN_FLAGS; use rustc_span::{Symbol, sym}; @@ -101,11 +100,9 @@ pub(crate) fn disallow_cfgs(sess: &Session, user_cfgs: &Cfg) { } else { format!("{}", cfg_name) }; - sess.psess.opt_span_buffer_lint( + sess.psess.buffer_crate_lint( EXPLICIT_BUILTIN_CFGS_IN_FLAGS, - None, - ast::CRATE_NODE_ID, - diagnostics::UnexpectedBuiltinCfg { cfg, cfg_name, controlled_by }.into(), + diagnostics::UnexpectedBuiltinCfg { cfg, cfg_name, controlled_by }, ) }; diff --git a/compiler/rustc_session/src/options/mitigation_coverage.rs b/compiler/rustc_session/src/options/mitigation_coverage.rs index dbe989100d567..22a6e4db9c57f 100644 --- a/compiler/rustc_session/src/options/mitigation_coverage.rs +++ b/compiler/rustc_session/src/options/mitigation_coverage.rs @@ -203,7 +203,9 @@ denied_partial_mitigations! { enum DeniedPartialMitigationKind { // The mitigation name should match the option name in rustc_session::options, // to allow for resetting the mitigation - (StackProtector, "stack-protector", EditionFuture, self.stack_protector()), + + // stack-protector is an unstable option, so it can be denied-partial + (StackProtector, "stack-protector", Edition2015, self.stack_protector()), (ControlFlowGuard, "control-flow-guard", EditionFuture, self.opts.cg.control_flow_guard == CFGuard::Checks) } } diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index 3bdfedb07775a..de3edee4d5fac 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -3,6 +3,7 @@ use std::sync::Arc; +use rustc_ast::ast; use rustc_ast::attr::AttrIdGenerator; use rustc_ast::node_id::NodeId; use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; @@ -158,6 +159,16 @@ impl ParseSess { self.opt_span_buffer_lint(lint, Some(span.into()), node_id, diagnostic.into()) } + /// Buffer a crate-level lint. This is used for lints that are associated with command-line + /// arguments and dependency structure. + pub fn buffer_crate_lint( + &self, + lint: &'static Lint, + diagnostic: impl Into, + ) { + self.opt_span_buffer_lint(lint, None, ast::CRATE_NODE_ID, diagnostic.into()) + } + pub fn dyn_buffer_lint< F: for<'a> FnOnce(DiagCtxtHandle<'a>, Level) -> Diag<'a> + DynSync + DynSend + 'static, >( diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index b36e13b66ba78..b9e7a9f5f94cb 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -237,6 +237,7 @@ symbols! { From, FromIterator, FromResidual, + GenericTypeVisitable, GlobalAlloc, Hash, HashMap, @@ -358,6 +359,7 @@ symbols! { TyCtxt, TyKind, Type, + TypeVisitable, Union, Unresolved, Unsafe, diff --git a/compiler/rustc_target/src/callconv/mips.rs b/compiler/rustc_target/src/callconv/mips.rs index d3a39d05b4964..3cce9095bd847 100644 --- a/compiler/rustc_target/src/callconv/mips.rs +++ b/compiler/rustc_target/src/callconv/mips.rs @@ -1,16 +1,43 @@ -use rustc_abi::{HasDataLayout, Size, TyAbiInterface}; +use rustc_abi::{Float, HasDataLayout, Integer, Numeric, Reg, RegKind, Size, TyAbiInterface}; +use rustc_span::bug; -use crate::callconv::{ArgAbi, FnAbi, Reg, Uniform}; +use crate::callconv::{ArgAbi, CastTarget, FnAbi, Uniform}; -fn classify_ret(cx: &C, ret: &mut ArgAbi<'_, Ty>, offset: &mut Size) +fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>, offset: &mut Size) where + Ty: TyAbiInterface<'a, C> + Copy, C: HasDataLayout, { - if !ret.layout.is_aggregate() { - ret.extend_integer_width_to(32); - } else { + let dl = cx.data_layout(); + let size = ret.layout.size; + + // Complex types with unsupported component types are returned as an aggregate. + let is_supported_complex_component = |numeric| match numeric { + Numeric::Int(Integer::I8 | Integer::I16 | Integer::I32 | Integer::I64, _) => true, + Numeric::Int(Integer::I128, _) => false, + Numeric::Float(Float::F32 | Float::F64) => true, + Numeric::Float(Float::F16 | Float::F128) => false, + Numeric::Float(Float::F16B | Float::PpcF128) => bug!("unsupported on mips"), + }; + + if let Some(component) = ret.layout.complex_number(cx) + && is_supported_complex_component(component) + { + match component { + Numeric::Int(Integer::I8 | Integer::I16, _) => { + // Pack Complex<{integer}> into a single register if that fits. + ret.cast_to(Reg { kind: RegKind::Integer, size }); + } + _ => { + let reg = Reg { kind: component.reg_kind(), size: component.size() }; + ret.cast_to(CastTarget::from(Uniform::new(reg, size))); + } + } + } else if ret.layout.is_aggregate() { ret.make_indirect(); - *offset += cx.data_layout().pointer_size(); + *offset += dl.pointer_size(); + } else { + ret.extend_integer_width_to(32); } } diff --git a/compiler/rustc_target/src/callconv/powerpc.rs b/compiler/rustc_target/src/callconv/powerpc.rs index 2b6a104e1221d..1748cbf24c28d 100644 --- a/compiler/rustc_target/src/callconv/powerpc.rs +++ b/compiler/rustc_target/src/callconv/powerpc.rs @@ -19,7 +19,7 @@ where // powerpc-unknown-linux-{gnu,musl,uclibc} doesn't ignore ZSTs. if cx.target_spec().os == Os::Linux && matches!(cx.target_spec().env, Env::Gnu | Env::Musl | Env::Uclibc) - && arg.layout.is_zst() + && arg.layout.is_repr_c() { arg.make_indirect_from_ignore(); } diff --git a/compiler/rustc_target/src/callconv/s390x.rs b/compiler/rustc_target/src/callconv/s390x.rs index 146cfc3c6ee65..ae0657ce54fbc 100644 --- a/compiler/rustc_target/src/callconv/s390x.rs +++ b/compiler/rustc_target/src/callconv/s390x.rs @@ -65,7 +65,7 @@ where // s390x-unknown-linux-{gnu,musl,uclibc} doesn't ignore ZSTs. if cx.target_spec().os == Os::Linux && matches!(cx.target_spec().env, Env::Gnu | Env::Musl | Env::Uclibc) - && arg.layout.is_zst() + && arg.layout.is_repr_c() { arg.make_indirect_from_ignore(); } diff --git a/compiler/rustc_target/src/callconv/sparc64.rs b/compiler/rustc_target/src/callconv/sparc64.rs index 22b388cf54101..bfe7f0cca3cc7 100644 --- a/compiler/rustc_target/src/callconv/sparc64.rs +++ b/compiler/rustc_target/src/callconv/sparc64.rs @@ -220,7 +220,7 @@ where continue; } if arg.is_ignore() { - if passes_zsts && arg.layout.is_zst() { + if passes_zsts && arg.layout.is_repr_c() { arg.make_indirect_from_ignore(); double_word_count += 1; } diff --git a/compiler/rustc_target/src/callconv/x86_win64.rs b/compiler/rustc_target/src/callconv/x86_win64.rs index 8e6f50bc9e5c4..01352f09e71b4 100644 --- a/compiler/rustc_target/src/callconv/x86_win64.rs +++ b/compiler/rustc_target/src/callconv/x86_win64.rs @@ -44,18 +44,25 @@ where } }; - if !fn_abi.ret.is_ignore() { + // Windows ABIs do not talk about ZST since such types do not exist in MSVC. + // However, clang and gcc allow ZST in their windows-gnu targets, and pass them by pointer indirection. + // We follow that for `repr(C)` ZSTs (and `repr(transparent)` wrappers around them), + // but `repr(Rust)` ones are always ignored (ensuring that `()` matches C `void`). + + if fn_abi.ret.is_ignore() { + if fn_abi.ret.layout.is_repr_c() { + fn_abi.ret.make_indirect_from_ignore(); + } + } else { fixup(&mut fn_abi.ret, true); } for arg in fn_abi.args.iter_mut() { - if arg.is_ignore() && arg.layout.is_zst() { - // Windows ABIs do not talk about ZST since such types do not exist in MSVC. - // In that sense we can do whatever we want here, and maybe we should throw an error - // (but of course that would be a massive breaking change now). - // We try to match clang and gcc (which allow ZST is their windows-gnu targets), so we - // pass ZST via pointer indirection. - arg.make_indirect_from_ignore(); + if arg.is_ignore() { + if arg.layout.is_repr_c() { + arg.make_indirect_from_ignore(); + } + continue; } if arg.layout.pass_indirectly_in_non_rustic_abis(cx) { @@ -64,7 +71,4 @@ where } fixup(arg, false); } - // FIXME: We should likely also do something about ZST return types, similar to above. - // However, that's non-trivial due to `()`. - // See . } diff --git a/compiler/rustc_target/src/spec/targets/m68k_unknown_none_elf.rs b/compiler/rustc_target/src/spec/targets/m68k_unknown_none_elf.rs index 56869348df852..6c8907d0b3a65 100644 --- a/compiler/rustc_target/src/spec/targets/m68k_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/m68k_unknown_none_elf.rs @@ -1,8 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{ - Arch, CodeModel, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, -}; +use crate::spec::{Arch, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions}; pub(crate) fn target() -> Target { let options = TargetOptions { @@ -12,7 +10,7 @@ pub(crate) fn target() -> Target { // LLD currently does not have support for M68k linker: Some("m68k-linux-gnu-ld".into()), panic_strategy: PanicStrategy::Abort, - code_model: Some(CodeModel::Medium), + code_model: None, has_rpath: false, // should be soft-float llvm_floatabi: None, diff --git a/compiler/rustc_target/src/spec/targets/thumbv7a_vex_v5_linker_script.ld b/compiler/rustc_target/src/spec/targets/thumbv7a_vex_v5_linker_script.ld index e0fa5dc301846..2cfa343119256 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv7a_vex_v5_linker_script.ld +++ b/compiler/rustc_target/src/spec/targets/thumbv7a_vex_v5_linker_script.ld @@ -118,7 +118,7 @@ SECTIONS { /* -- End of loadable sections - anything beyond this point shouldn't go in the binary uploaded to the device. -- */ - .bss (NOLOAD) : { + .bss (NOLOAD) : ALIGN(4) { __bss_start = .; *(.sbss*) *(.bss .bss.*) diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index 6a06a45f8ad19..6564c3543b6d2 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -171,6 +171,7 @@ static ARM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ }, &[], ), + ("bf16", Unstable(sym::arm_target_feature), &["neon"]), ("crc", Unstable(sym::arm_target_feature), &[]), ("d32", Unstable(sym::arm_target_feature), &[]), ("dotprod", Unstable(sym::arm_target_feature), &["neon"]), diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index 3b21c5e5f19ba..1614899ece03d 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -21,7 +21,7 @@ use rustc_hir::intravisit::Visitor; use rustc_hir::{self as hir, Node, expr_needs_parens}; use rustc_infer::infer::{InferOk, TypeTrace}; use rustc_infer::traits::solve::Goal; -use rustc_infer::traits::{ImplSource, TraitErrors}; +use rustc_infer::traits::{ImplSource, TraitErrors, WellFormedLoc}; use rustc_middle::traits::SignatureMismatchData; use rustc_middle::traits::select::OverflowError; use rustc_middle::ty::abstract_const::NotConstEvaluatable; @@ -74,9 +74,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { SelectionError::Unimplemented => { // If this obligation was generated as a result of well-formedness checking, see if we // can get a better error message by performing HIR-based well-formedness checking. - if let ObligationCauseCode::WellFormed(Some(wf_loc)) = + if let ObligationCauseCode::WellFormed(wf_loc) = root_obligation.cause.code().peel_derives() && !obligation.predicate.has_non_region_infer() + && !matches!(wf_loc, WellFormedLoc::None) { if let Some(cause) = self.tcx.diagnostic_hir_wf_check(( tcx.erase_and_anonymize_regions(obligation.predicate), @@ -831,6 +832,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { }; self.note_obligation_cause(&mut err, &obligation); + self.silence_redundant_cause(&mut err, &obligation, &root_obligation); err.emit_err() } } @@ -3083,6 +3085,61 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { } } + /// Register when multiple obligations come from the same statement and only emit one. + /// + /// This can significantly reduce the number of `_: Sized` failures on method chains. + fn silence_redundant_cause( + &self, + err: &mut Diag<'_>, + obligation: &PredicateObligation<'tcx>, + root_obligation: &PredicateObligation<'tcx>, + ) { + let hir_id = match root_obligation.cause.code() { + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(hir_id)) + | ObligationCauseCode::VariableType(hir_id) + | ObligationCauseCode::WhereClauseInExpr(_, _, hir_id, _) + | ObligationCauseCode::SizedCallReturnType(hir_id) => *hir_id, + ObligationCauseCode::WellFormed(WellFormedLoc::Param { function, .. }) => { + self.tcx.local_def_id_to_hir_id(*function) + } + _ => return, + }; + + // The lifetimes for different sub-expressions would be different inference variables. + let pred = self.tcx.erase_and_anonymize_regions(obligation.predicate); + + // Registering the expression itself is necessary to catch tail expressions and literals. + if let Some(preds) = self.reported_hir_errors.borrow().get(&hir_id) + && preds.contains(&pred) + { + err.downgrade_to_delayed_bug(); + } else { + self.reported_hir_errors.borrow_mut().entry(hir_id).or_default().insert(pred); + } + + // Look for the expression's parent statement, bail otherwise. We'll register the predicate + // against the statement's HirId. + for (_, node) in self.tcx.hir_parent_iter(hir_id) { + let hir_id = match node { + hir::Node::LetStmt(stmt) => stmt.hir_id, + hir::Node::Stmt(stmt) => stmt.hir_id, + hir::Node::Crate(_) + | hir::Node::Item(_) + | hir::Node::ImplItem(_) + | hir::Node::TraitItem(_) => break, + _ => continue, + }; + if let Some(preds) = self.reported_hir_errors.borrow().get(&hir_id) + && preds.contains(&pred) + { + err.downgrade_to_delayed_bug(); + } else { + self.reported_hir_errors.borrow_mut().entry(hir_id).or_default().insert(pred); + } + break; + } + } + pub fn note_obligation_cause( &self, err: &mut Diag<'_>, diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index 76755eb481db7..a2aae724228ba 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -4325,7 +4325,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { err.help("unsized fn params are gated as an unstable feature"); } } - ObligationCauseCode::SizedReturnType | ObligationCauseCode::SizedCallReturnType => { + ObligationCauseCode::SizedReturnType | ObligationCauseCode::SizedCallReturnType(_) => { err.note("the return type of a function must have a statically known size"); } ObligationCauseCode::SizedYieldType => { diff --git a/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs b/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs index 1d57fd9e4b285..0cc886a2c1909 100644 --- a/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs +++ b/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs @@ -749,14 +749,19 @@ fn receiver_is_dispatchable<'tcx>( let trait_predicate = ty::TraitRef::new_from_args(tcx, trait_def_id, args); clauses.push(trait_predicate.upcast(tcx)); - // U satisfies `Trait`'s where-bounds. + // U satisfies Trait's trait bounds. When normalizing `U: Trait`, aliases + // in the arguments of supertrait bounds can generate trait obligations which may only be + // be provable using where-clauses from Trait (#161621). clauses.extend( tcx.clauses_of(trait_def_id) .instantiate(tcx, args) .clauses .into_iter() - .map(Unnormalized::skip_norm_wip), + .map(Unnormalized::skip_norm_wip) + .filter(|clause| matches!(clause.kind().skip_binder(), ty::ClauseKind::Trait(_))), ); + // FIXME(@dianne): we need projection clauses too in some form, but adding them all + // unmodified can introduce ambiguity (#163550) let meta_sized_predicate = { let meta_sized_did = tcx.require_lang_item(LangItem::MetaSized, DUMMY_SP); diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index ba463184a41f8..41e6797e71d2d 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -7,7 +7,9 @@ use std::iter; use rustc_attr_ir::lang_items::LangItem; use rustc_hir as hir; -use rustc_infer::traits::{ObligationCauseCode, PredicateObligation, PredicateObligations}; +use rustc_infer::traits::{ + ObligationCauseCode, PredicateObligation, PredicateObligations, WellFormedLoc, +}; use rustc_middle::ty::{ self, DelayedSet, GenericArgsRef, PredicateProxy, Term, TermKind, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, @@ -352,7 +354,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { return self.out; } - let cause = self.cause(ObligationCauseCode::WellFormed(None)); + let cause = self.cause(ObligationCauseCode::WellFormed(WellFormedLoc::None)); let param_env = self.param_env; let mut obligations = PredicateObligations::with_capacity(self.out.len()); for mut obligation in self.out { @@ -519,7 +521,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { &mut traits::SelectionContext::new(self.infcx), self.param_env, data, - self.cause(ObligationCauseCode::WellFormed(None)), + self.cause(ObligationCauseCode::WellFormed(WellFormedLoc::None)), self.recursion_depth, &mut self.out, ); @@ -532,7 +534,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { fn add_wf_preds_for_projection_args(&mut self, args: GenericArgsRef<'tcx>) { let tcx = self.tcx(); - let cause = self.cause(ObligationCauseCode::WellFormed(None)); + let cause = self.cause(ObligationCauseCode::WellFormed(WellFormedLoc::None)); let param_env = self.param_env; let depth = self.recursion_depth; @@ -976,7 +978,7 @@ impl<'a, 'tcx> TypeVisitor> for WfPredicates<'a, 'tcx> { let principal_def_id = principal.skip_binder().def_id; self.out.push(traits::Obligation::with_depth( tcx, - self.cause(ObligationCauseCode::WellFormed(None)), + self.cause(ObligationCauseCode::WellFormed(WellFormedLoc::None)), self.recursion_depth, self.param_env, ty::Binder::dummy(ty::PredicateKind::DynCompatible(principal_def_id)), @@ -1044,7 +1046,7 @@ impl<'a, 'tcx> TypeVisitor> for WfPredicates<'a, 'tcx> { if let Some(pred_binder) = pred_binder { self.out.push(traits::Obligation::with_depth( tcx, - self.cause(ObligationCauseCode::WellFormed(None)), + self.cause(ObligationCauseCode::WellFormed(WellFormedLoc::None)), self.recursion_depth, self.param_env, pred_binder, @@ -1067,7 +1069,7 @@ impl<'a, 'tcx> TypeVisitor> for WfPredicates<'a, 'tcx> { // See also the comment on `fn obligations`, describing cycle // prevention, which happens before this can be reached. ty::Infer(_) => { - let cause = self.cause(ObligationCauseCode::WellFormed(None)); + let cause = self.cause(ObligationCauseCode::WellFormed(WellFormedLoc::None)); self.out.push(traits::Obligation::with_depth( tcx, cause, @@ -1094,7 +1096,8 @@ impl<'a, 'tcx> TypeVisitor> for WfPredicates<'a, 'tcx> { let predicate = ty::Binder::dummy(ty::PredicateKind::Clause( ty::ClauseKind::ConstEvaluatable(c), )); - let cause = self.cause(ObligationCauseCode::WellFormed(None)); + let cause = + self.cause(ObligationCauseCode::WellFormed(WellFormedLoc::None)); self.out.push(traits::Obligation::with_depth( tcx, cause, @@ -1128,7 +1131,7 @@ impl<'a, 'tcx> TypeVisitor> for WfPredicates<'a, 'tcx> { } } ty::ConstKind::Infer(_) => { - let cause = self.cause(ObligationCauseCode::WellFormed(None)); + let cause = self.cause(ObligationCauseCode::WellFormed(WellFormedLoc::None)); self.out.push(traits::Obligation::with_depth( tcx, @@ -1151,7 +1154,7 @@ impl<'a, 'tcx> TypeVisitor> for WfPredicates<'a, 'tcx> { let predicate = ty::Binder::dummy(ty::PredicateKind::Clause( ty::ClauseKind::ConstEvaluatable(c), )); - let cause = self.cause(ObligationCauseCode::WellFormed(None)); + let cause = self.cause(ObligationCauseCode::WellFormed(WellFormedLoc::None)); self.out.push(traits::Obligation::with_depth( tcx, cause, @@ -1174,7 +1177,8 @@ impl<'a, 'tcx> TypeVisitor> for WfPredicates<'a, 'tcx> { ty::Adt(adt_def, args) => { let adt_val = val.destructure_adt_const(); let variant_def = adt_def.variant(adt_val.variant); - let cause = self.cause(ObligationCauseCode::WellFormed(None)); + let cause = + self.cause(ObligationCauseCode::WellFormed(WellFormedLoc::None)); self.out.extend(variant_def.fields.iter().zip(adt_val.fields).map( |(field_def, &field_val)| { let field_ty = tcx @@ -1196,7 +1200,8 @@ impl<'a, 'tcx> TypeVisitor> for WfPredicates<'a, 'tcx> { } ty::Tuple(field_tys) => { let field_vals = val.to_branch(); - let cause = self.cause(ObligationCauseCode::WellFormed(None)); + let cause = + self.cause(ObligationCauseCode::WellFormed(WellFormedLoc::None)); self.out.extend(field_tys.iter().zip(field_vals).map( |(field_ty, &field_val)| { let predicate = ty::PredicateKind::Clause( @@ -1214,7 +1219,8 @@ impl<'a, 'tcx> TypeVisitor> for WfPredicates<'a, 'tcx> { } ty::Array(elem_ty, _len) => { let elem_vals = val.to_branch(); - let cause = self.cause(ObligationCauseCode::WellFormed(None)); + let cause = + self.cause(ObligationCauseCode::WellFormed(WellFormedLoc::None)); self.out.extend(elem_vals.iter().map(|&elem_val| { let predicate = ty::PredicateKind::Clause( diff --git a/compiler/rustc_ty_utils/src/common_traits.rs b/compiler/rustc_ty_utils/src/common_traits.rs index 48e2a68bec7f6..be93465b3b358 100644 --- a/compiler/rustc_ty_utils/src/common_traits.rs +++ b/compiler/rustc_ty_utils/src/common_traits.rs @@ -49,7 +49,8 @@ fn is_trait_raw<'tcx>( query: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>, item: LangItem, ) -> bool { - let (infcx, param_env) = tcx.infer_ctxt().build_with_typing_env(query.typing_env); + let (infcx, param_env) = + tcx.infer_ctxt().ignoring_regions().build_with_typing_env(query.typing_env); let trait_def_id = tcx.require_lang_item(item, DUMMY_SP); traits::type_known_to_meet_bound_modulo_regions(&infcx, param_env, query.value, trait_def_id) } diff --git a/compiler/rustc_type_ir/src/generic_visit.rs b/compiler/rustc_type_ir/src/generic_visit.rs index 2444990749411..5fc5ab39f6eb1 100644 --- a/compiler/rustc_type_ir/src/generic_visit.rs +++ b/compiler/rustc_type_ir/src/generic_visit.rs @@ -26,6 +26,7 @@ use crate::Interner; /// /// Therefore, it is advised to instead derive this using the derive /// macro located in `rustc_macros`. +#[cfg_attr(feature = "nightly", rustc_diagnostic_item = "GenericTypeVisitable")] pub unsafe trait GenericTypeVisitable { fn generic_visit_with(&self, visitor: &mut V); } @@ -116,6 +117,12 @@ unsafe impl> GenericTypeVisitable for [T] { } } +unsafe impl, const N: usize> GenericTypeVisitable for [T; N] { + fn generic_visit_with(&self, visitor: &mut V) { + self.iter().for_each(|it| it.generic_visit_with(visitor)); + } +} + unsafe impl, Ix: Idx> GenericTypeVisitable for IndexVec { fn generic_visit_with(&self, visitor: &mut V) { self.iter().for_each(|it| it.generic_visit_with(visitor)); @@ -172,57 +179,10 @@ unsafe impl, S: GenericTypeVisitable> GenericTy } } -macro_rules! trivial_impls { - ( $($ty:ty),* $(,)? ) => { - $( - unsafe impl - GenericTypeVisitable for $ty - { - fn generic_visit_with(&self, _visitor: &mut V) {} - } - )* - }; -} - unsafe impl GenericTypeVisitable for std::marker::PhantomData { fn generic_visit_with(&self, _visitor: &mut V) {} } -trivial_impls!( - (), - rustc_ast_ir::Mutability, - bool, - i8, - i16, - i32, - i64, - i128, - isize, - u8, - u16, - u32, - u64, - u128, - usize, - crate::ClausePolarity, - crate::BoundConstness, - crate::DebruijnIndex, - crate::solve::Certainty, - crate::UniverseIndex, - crate::BoundVar, - crate::InferTy, - crate::IntTy, - crate::UintTy, - crate::FloatTy, - crate::InferConst, - crate::RegionVid, - rustc_hash::FxBuildHasher, - crate::TypeFlags, - crate::solve::GoalSource, - crate::solve::VisibleForLeakCheck, - rustc_abi::ExternAbi, -); - // SAFETY: `FnSigKind` is a packed representation, therefore visiting its fields doesn't make sense unsafe impl GenericTypeVisitable for crate::FnSigKind { fn generic_visit_with(&self, _visitor: &mut V) {} diff --git a/compiler/rustc_type_ir/src/lib.rs b/compiler/rustc_type_ir/src/lib.rs index b7fa0c77e44ee..0be6a2c4152dc 100644 --- a/compiler/rustc_type_ir/src/lib.rs +++ b/compiler/rustc_type_ir/src/lib.rs @@ -27,6 +27,12 @@ #![allow(rustc::usage_of_type_ir_traits)] #![cfg_attr(feature = "nightly", allow(internal_features))] #![cfg_attr(feature = "nightly", feature(associated_type_defaults, rustc_attrs, negative_impls))] +// NOTE: the outer `cfg_attr` is only there so that r-a doesn't see the nightly-only `bootstrap` +// in the inner `cfg_attr`. When the latter is removed, the former can be removed as well. +#![cfg_attr( + feature = "nightly", + cfg_attr(not(bootstrap), deny(rustc::missing_generic_type_visitable_derive)) +)] // tidy-alphabetical-end extern crate self as rustc_type_ir; @@ -105,7 +111,6 @@ pub use predicate::*; pub use predicate_kind::*; pub use region_kind::*; pub use rustc_ast_ir::{FloatTy, IntTy, Movability, Mutability, Pinnedness, UintTy}; -use rustc_type_ir_macros::GenericTypeVisitable; #[cfg(feature = "nightly")] pub use serialize::*; pub use sty::*; @@ -251,7 +256,7 @@ pub fn debug_bound_var( } } -#[derive(Copy, Clone, PartialEq, Eq, Hash, GenericTypeVisitable)] +#[derive(Copy, Clone, PartialEq, Eq, Hash)] #[cfg_attr(feature = "nightly", derive(Decodable, Encodable, StableHash))] #[cfg_attr(feature = "nightly", rustc_pass_by_value)] pub enum Variance { diff --git a/compiler/rustc_type_ir/src/macros.rs b/compiler/rustc_type_ir/src/macros.rs index 3741c80d0eb14..096f43f81e608 100644 --- a/compiler/rustc_type_ir/src/macros.rs +++ b/compiler/rustc_type_ir/src/macros.rs @@ -31,6 +31,12 @@ macro_rules! TrivialTypeTraversalImpls { ::output() } } + + // NOTE: this deliberately avoids adding an `I: Interner` generic, because that would + // allow creating a trivial impl for arena-allocating types, which would be incorrect. + unsafe impl $crate::GenericTypeVisitable for $ty { + fn generic_visit_with(&self, _visitor: &mut V) {} + } )+ }; } @@ -44,21 +50,36 @@ macro_rules! TrivialTypeTraversalImpls { TrivialTypeTraversalImpls! { (), bool, - usize, + i8, + i16, + i32, + i64, + i128, + isize, u8, u16, u32, u64, + usize, // tidy-alphabetical-start crate::BoundConstness, + crate::BoundVar, crate::ClausePolarity, crate::DebruijnIndex, + crate::FloatTy, + crate::InferConst, + crate::InferTy, + crate::IntTy, + crate::RegionVid, + crate::TypeFlags, + crate::UintTy, crate::UniverseIndex, crate::Variance, crate::solve::BuiltinImplSource, crate::solve::Certainty, crate::solve::GoalSource, crate::solve::VisibleForLeakCheck, + rustc_abi::ExternAbi, rustc_ast_ir::Mutability, // tidy-alphabetical-end } diff --git a/compiler/rustc_type_ir/src/unnormalized.rs b/compiler/rustc_type_ir/src/unnormalized.rs index 17a8e0e75fa78..3b03d64cd57a3 100644 --- a/compiler/rustc_type_ir/src/unnormalized.rs +++ b/compiler/rustc_type_ir/src/unnormalized.rs @@ -3,7 +3,7 @@ use std::marker::PhantomData; use derive_where::derive_where; #[cfg(feature = "nightly")] use rustc_macros::StableHash_NoContext; -use rustc_type_ir_macros::TypeVisitable_Generic; +use rustc_type_ir_macros::{GenericTypeVisitable, TypeVisitable_Generic}; use crate::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder}; use crate::inherent::*; @@ -30,7 +30,7 @@ use crate::{ /// [here]: https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/Eager.20normalization.2C.20ahoy.21/with/582996293 #[derive_where(Clone, Copy, PartialOrd, PartialEq, Eq, Hash, Debug; T)] #[cfg_attr(feature = "nightly", derive(StableHash_NoContext))] -#[derive(TypeVisitable_Generic)] +#[derive(TypeVisitable_Generic, GenericTypeVisitable)] pub struct Unnormalized { value: T, #[type_visitable(ignore)] diff --git a/compiler/rustc_type_ir/src/visit.rs b/compiler/rustc_type_ir/src/visit.rs index 008b6aeb239ee..396c8c17a2952 100644 --- a/compiler/rustc_type_ir/src/visit.rs +++ b/compiler/rustc_type_ir/src/visit.rs @@ -59,6 +59,7 @@ use crate::{self as ty, Const, Interner, PredicateProxy, Region, TypeFlags}; /// /// To implement this conveniently, use the derive macro located in /// `rustc_macros`. +#[cfg_attr(feature = "nightly", rustc_diagnostic_item = "TypeVisitable")] pub trait TypeVisitable: fmt::Debug { /// The entry point for visiting. To visit a value `t` with a visitor `v` /// call: `t.visit_with(v)`. diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index a279c373dea4a..7404acac4143a 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -394,7 +394,7 @@ impl NonNull { /// use std::ptr::NonNull; /// /// let mut x = 0u32; - /// let ptr = NonNull::new(&mut x).expect("pointer should not be null"); + /// let ptr = NonNull::from_mut(&mut x); /// /// let x_value = unsafe { *ptr.as_ptr() }; /// assert_eq!(x_value, 0); @@ -436,7 +436,7 @@ impl NonNull { /// use std::ptr::NonNull; /// /// let mut x = 0u32; - /// let ptr = NonNull::new(&mut x as *mut _).expect("pointer should not be null"); + /// let ptr = NonNull::from_mut(&mut x); /// /// let ref_x = unsafe { ptr.as_ref() }; /// println!("{ref_x}"); @@ -472,7 +472,7 @@ impl NonNull { /// use std::ptr::NonNull; /// /// let mut x = 0u32; - /// let mut ptr = NonNull::new(&mut x).expect("pointer should not be null"); + /// let mut ptr = NonNull::from_mut(&mut x); /// /// let x_ref = unsafe { ptr.as_mut() }; /// assert_eq!(*x_ref, 0); @@ -499,7 +499,7 @@ impl NonNull { /// use std::ptr::NonNull; /// /// let mut x = 0u32; - /// let ptr = NonNull::new(&mut x as *mut _).expect("pointer should not be null"); + /// let ptr = NonNull::from_mut(&mut x); /// /// let casted_ptr = ptr.cast::(); /// let raw_ptr: *mut i8 = casted_ptr.as_ptr(); diff --git a/library/std/src/sys/pal/vexos/mod.rs b/library/std/src/sys/pal/vexos/mod.rs index 540da6cbc950f..ac4af7ca157e2 100644 --- a/library/std/src/sys/pal/vexos/mod.rs +++ b/library/std/src/sys/pal/vexos/mod.rs @@ -5,7 +5,6 @@ mod unsupported_common; pub use unsupported_common::{init, unsupported, unsupported_err}; use crate::arch::global_asm; -use crate::ptr; use crate::sys::stdio; use crate::time::{Duration, Instant}; @@ -16,8 +15,21 @@ global_asm!( .arm _boot: - ldr sp, =__stack_top @ Set up the user stack. - blx _start @ Jump to the Rust entrypoint. + @ Set up the user stack. + ldr sp, =__stack_top + + @ Clear the .bss (uninitialized statics) section by filling it with zeroes. + @ This is required, since the compiler assumes it will be zeroed on first access. + mov r0, #0 + ldr r1, =__bss_start + ldr r2, =__bss_end + .Lclear_bss: + cmp r1, r2 + beq .Lbss_done + str r0, [r1], #4 + b .Lclear_bss + .Lbss_done: + blx _start @ Jump to the Rust entrypoint. "# ); @@ -25,20 +37,9 @@ global_asm!( #[unsafe(no_mangle)] pub unsafe extern "C" fn _start() -> ! { unsafe extern "C" { - static mut __bss_start: u8; - static mut __bss_end: u8; - fn main() -> i32; } - // Clear the .bss (uninitialized statics) section by filling it with zeroes. - // This is required, since the compiler assumes it will be zeroed on first access. - ptr::write_bytes( - &raw mut __bss_start, - 0, - (&raw mut __bss_end).offset_from_unsigned(&raw mut __bss_start), - ); - main(); cleanup(); diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 7d2c3cc07bf85..ceaa28fc4bdb8 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1822,7 +1822,10 @@ HELP: to skip test's attempt to check tidiness, pass `--skip src/tools/tidy` to } builder.info("tidy check"); - cmd.delay_failure().run(builder); + let ctx = builder.as_ref(); + let mut cmd = cmd.delay_failure(); + // spawn child in background so we can do additional work in parallel + let tidy = cmd.start(ctx); builder.info("x.py completions check"); let completion_paths = get_completion_paths(builder); @@ -1838,6 +1841,9 @@ HELP: to skip test's attempt to check tidiness, pass `--skip src/tools/tidy` to helpers::exit_process(1); } + // now wait for the child to complete + tidy.wait_for_output(ctx); + builder.info("x.py help check"); if builder.config.cmd.bless() { builder.ensure(crate::core::build_steps::run::GenerateHelp); diff --git a/src/bootstrap/src/utils/exec.rs b/src/bootstrap/src/utils/exec.rs index 559b878124bc9..774322b4bd3b8 100644 --- a/src/bootstrap/src/utils/exec.rs +++ b/src/bootstrap/src/utils/exec.rs @@ -353,6 +353,11 @@ impl<'a> BootstrapCommand { exec_ctx.as_ref().run(self, OutputMode::Capture, OutputMode::Print) } + #[track_caller] + pub fn start(&mut self, exec_ctx: impl AsRef) -> DeferredCommand<'_> { + exec_ctx.as_ref().start(self, OutputMode::Print, OutputMode::Print) + } + /// Spawn the command in background, while capturing and returning all its output. #[track_caller] #[expect(dead_code, reason = "general-purpose, currently unused")] diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index 05e17c335aaf0..3de95a9a86d77 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -757,9 +757,12 @@ auto: # x86_64-mingw is split into two jobs to run tests in parallel. - name: test-x86_64-mingw-1 + # required to run LLDB 22 + required_python_version: '3.11' env: SCRIPT: make ci-mingw-x RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-gnu + LLDB_PATH: ./citools/clang-rust/bin/lldb.exe <<: *job-windows - name: test-x86_64-mingw-2 diff --git a/src/ci/scripts/install-clang.sh b/src/ci/scripts/install-clang.sh index 2647fc225c9ab..cacb83400f636 100755 --- a/src/ci/scripts/install-clang.sh +++ b/src/ci/scripts/install-clang.sh @@ -13,7 +13,7 @@ source "$(cd "$(dirname "$0")" && pwd)/../shared.sh" # Try to keep this in sync with src/ci/docker/scripts/build-clang.sh LLVM_VERSION="22.1.8" -if isWindows && ! isKnownToBeMingwBuild; then +if isWindows; then # If we're compiling for MSVC then we, like most other distribution builders, # switch to clang as the compiler. This'll allow us eventually to enable LTO # amongst LLVM and rustc. Note that we only do this on MSVC as I don't think @@ -24,6 +24,9 @@ if isWindows && ! isKnownToBeMingwBuild; then # don't want to run the installer directly; extracting it is more reliable # in CI environments. + # On MinGW builds we still install LLVM, but only so we can access LLDB so + # we can run `tests/debuginfo` + mkdir -p citools/clang-rust cd citools @@ -39,12 +42,16 @@ if isWindows && ! isKnownToBeMingwBuild; then retry curl -f "${MIRRORS_BASE}/LLVM-${LLVM_VERSION}-${suffix}.exe" \ -o "LLVM-${LLVM_VERSION}-${suffix}.exe" 7z x -oclang-rust/ "LLVM-${LLVM_VERSION}-${suffix}.exe" - ciCommandSetEnv RUST_CONFIGURE_ARGS \ - "${RUST_CONFIGURE_ARGS} --set llvm.clang-cl=$(pwd)/clang-rust/bin/clang-cl.exe" - # Disable downloading CI LLVM on this builder; - # setting up clang-cl just above conflicts with the default if-unchanged option. - ciCommandSetEnv NO_DOWNLOAD_CI_LLVM 1 + if ! isKnownToBeMingwBuild; then + ciCommandSetEnv RUST_CONFIGURE_ARGS \ + "${RUST_CONFIGURE_ARGS} --set llvm.clang-cl=$(pwd)/clang-rust/bin/clang-cl.exe" + + + # Disable downloading CI LLVM on this builder; + # setting up clang-cl just above conflicts with the default if-unchanged option. + ciCommandSetEnv NO_DOWNLOAD_CI_LLVM 1 + fi fi if isWindows; then diff --git a/src/tools/compiletest/src/runtest/run_make.rs b/src/tools/compiletest/src/runtest/run_make.rs index 0debf8b3dcbf0..9c1485bbf5665 100644 --- a/src/tools/compiletest/src/runtest/run_make.rs +++ b/src/tools/compiletest/src/runtest/run_make.rs @@ -7,7 +7,6 @@ use camino::{Utf8Path, Utf8PathBuf}; use super::{ProcRes, TestCx, disable_error_reporting}; use crate::common::TestSuite; -use crate::read2::Truncated; use crate::util::{ArgFileCommand, copy_dir_all, dylib_env_var}; impl TestCx<'_> { @@ -176,6 +175,8 @@ impl TestCx<'_> { let mut cmd = Command::new(&recipe_bin); cmd.current_dir(&rmake_out_dir) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) // Provide the target-specific env var that is used to record dylib search paths. For // example, this could be `LD_LIBRARY_PATH` on some linux distros but `PATH` on Windows. .env("LD_LIB_PATH_ENVVAR", dylib_env_var()) @@ -341,39 +342,16 @@ impl TestCx<'_> { } } - if self.config.capture { - cmd.stdout(Stdio::piped()).stderr(Stdio::piped()); - let proc = disable_error_reporting(|| cmd.spawn().expect("failed to spawn `rmake`")); - let (Output { stdout, stderr, status }, truncated) = self.read2_abbreviated(proc); - let stdout = String::from_utf8_lossy(&stdout).into_owned(); - let stderr = String::from_utf8_lossy(&stderr).into_owned(); - // This conditions on `status.success()` so we don't print output twice on error. - self.dump_output( - status.success(), - &cmd.get_program().to_string_lossy(), - &stdout, - &stderr, - ); - if !status.success() { - let res = - ProcRes { status, stdout, stderr, truncated, cmdline: format!("{:?}", cmd) }; - self.fatal_proc_rec("rmake recipe failed to complete", &res); - } - } else { - // When --no-capture is passed, we don't need to capture the output and just wait for the process to finish - let mut proc = - disable_error_reporting(|| cmd.spawn().expect("failed to spawn `rmake`")); - let status = proc.wait().expect("failed to wait for `rmake`"); - if !status.success() { - let res = ProcRes { - status, - stdout: String::new(), - stderr: String::new(), - truncated: Truncated::No, - cmdline: format!("{:?}", cmd), - }; - self.fatal_proc_rec("rmake recipe failed to complete", &res); - } + let proc = disable_error_reporting(|| cmd.spawn().expect("failed to spawn `rmake`")); + let (Output { stdout, stderr, status }, truncated) = self.read2_abbreviated(proc); + let stdout = String::from_utf8_lossy(&stdout).into_owned(); + let stderr = String::from_utf8_lossy(&stderr).into_owned(); + // This conditions on `status.success()` so we don't print output twice on error. + // NOTE: this code is called from an executor thread, so it's hidden by default unless --no-capture is passed. + self.dump_output(status.success(), &cmd.get_program().to_string_lossy(), &stdout, &stderr); + if !status.success() { + let res = ProcRes { status, stdout, stderr, truncated, cmdline: format!("{:?}", cmd) }; + self.fatal_proc_rec("rmake recipe failed to complete", &res); } } } diff --git a/src/tools/miri/tests/fail/const-ub-checks.stderr b/src/tools/miri/tests/fail/const-ub-checks.stderr index df2d5653d2db6..cd01bbbbf72d2 100644 --- a/src/tools/miri/tests/fail/const-ub-checks.stderr +++ b/src/tools/miri/tests/fail/const-ub-checks.stderr @@ -1,6 +1,8 @@ error[E0080]: accessing memory based on pointer with alignment ALIGN, but alignment ALIGN is required --> tests/fail/const-ub-checks.rs:LL:CC | +LL | const UNALIGNED_READ: () = unsafe { +... LL | ptr.read(); | ^^^^^^^^^^ evaluation of `UNALIGNED_READ` failed here diff --git a/src/tools/miri/tests/fail/erroneous_const.stderr b/src/tools/miri/tests/fail/erroneous_const.stderr index 1aa87dd7188ce..6a897832fefc7 100644 --- a/src/tools/miri/tests/fail/erroneous_const.stderr +++ b/src/tools/miri/tests/fail/erroneous_const.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> tests/fail/erroneous_const.rs:LL:CC | +LL | impl PrintName { LL | const VOID: ! = panic!(); | ^^^^^^^^ evaluation of `PrintName::::VOID` failed here diff --git a/src/tools/tidy/src/bins.rs b/src/tools/tidy/src/bins.rs index 2dcbd8e9b38a2..2364084a053c0 100644 --- a/src/tools/tidy/src/bins.rs +++ b/src/tools/tidy/src/bins.rs @@ -111,7 +111,7 @@ mod os_impl { #[cfg(unix)] pub fn check(path: &Path, tidy_ctx: TidyCtx) { - let mut check = tidy_ctx.start_check("bins"); + let check = tidy_ctx.start_check("bins"); use std::ffi::OsStr; diff --git a/src/tools/tidy/src/codegen.rs b/src/tools/tidy/src/codegen.rs index b87e19c40a8fd..48cdf632ea11f 100644 --- a/src/tools/tidy/src/codegen.rs +++ b/src/tools/tidy/src/codegen.rs @@ -20,7 +20,7 @@ fn has_supported_extension(path: &Path) -> bool { } pub fn check(path: &Path, tidy_ctx: TidyCtx) { - let mut check = tidy_ctx.start_check(CheckId::new("codegen").path(path)); + let check = tidy_ctx.start_check(CheckId::new("codegen").path(path)); fn skip(path: &Path, is_dir: bool) -> bool { if path.file_name().is_some_and(|name| name.to_string_lossy().starts_with(".#")) { diff --git a/src/tools/tidy/src/debug_artifacts.rs b/src/tools/tidy/src/debug_artifacts.rs index a1a0f37f7844b..76c97513e6c4d 100644 --- a/src/tools/tidy/src/debug_artifacts.rs +++ b/src/tools/tidy/src/debug_artifacts.rs @@ -8,7 +8,7 @@ use crate::walk::{filter_dirs, filter_not_rust, walk}; const GRAPHVIZ_POSTFLOW_MSG: &str = "`borrowck_graphviz_postflow` attribute in test"; pub fn check(test_dir: &Path, tidy_ctx: TidyCtx) { - let mut check = tidy_ctx.start_check(CheckId::new("debug_artifacts").path(test_dir)); + let check = tidy_ctx.start_check(CheckId::new("debug_artifacts").path(test_dir)); walk( test_dir, diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index e1a5495f81954..cc0443410ecd7 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -3,8 +3,9 @@ use std::collections::{BTreeSet, HashMap, HashSet}; use std::fmt::{Display, Formatter}; use std::fs::{self, read_dir}; -use std::io; use std::path::Path; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::{io, thread}; use cargo_metadata::semver::Version; use cargo_metadata::{Metadata, Package, PackageId}; @@ -649,63 +650,78 @@ const PERMITTED_CRANELIFT_DEPENDENCIES: &[&str] = &[ /// /// `root` is path to the directory with the root `Cargo.toml` (for the workspace). `cargo` is path /// to the cargo executable. -pub fn check(root: &Path, cargo: &Path, tidy_ctx: TidyCtx) { +pub fn check(root: &Path, cargo: &Path, sem: &'_ crate::Semaphore, tidy_ctx: TidyCtx) { let mut check = tidy_ctx.start_check("deps"); let bless = tidy_ctx.is_bless_enabled(); + let is_ci = tidy_ctx.is_running_on_ci(); - let mut checked_runtime_licenses = false; + let checked_runtime_licenses = AtomicBool::new(false); check_proc_macro_dep_list(root, cargo, bless, &mut check); - for &WorkspaceInfo { path, exceptions, allowed_deps: crates_and_deps, submodules } in WORKSPACES - { - if has_missing_submodule(root, submodules, tidy_ctx.is_running_on_ci()) { - continue; - } + thread::scope(|s| { + for (i, WorkspaceInfo { path, exceptions, allowed_deps: crates_and_deps, submodules }) in + WORKSPACES.iter().enumerate() + { + let check = ✓ + let checked_runtime_licenses = &checked_runtime_licenses; + // starting deps::check already consumed one semaphore permit, with concurrency == 1 + // this would deadlock if we tried to get one here for the first thread, so + // we only do it for additional threads beyond the first one. + let guard = if i > 0 { Some(sem.acquire()) } else { None }; + s.spawn(move || { + if has_missing_submodule(root, submodules, is_ci) { + return; + } - if !root.join(path).join("Cargo.lock").exists() { - check.error(format!("the `{path}` workspace doesn't have a Cargo.lock")); - continue; - } + if !root.join(path).join("Cargo.lock").exists() { + check.error(format!("the `{path}` workspace doesn't have a Cargo.lock")); + return; + } + + let mut cmd = cargo_metadata::MetadataCommand::new(); + cmd.cargo_path(cargo) + .manifest_path(root.join(path).join("Cargo.toml")) + .features(cargo_metadata::CargoOpt::AllFeatures) + .other_options(vec!["--locked".to_owned()]); + let metadata = t!(cmd.exec()); + + // Check for packages which have been moved into a different workspace and not updated + let absolute_root = + if *path == "." { root.to_path_buf() } else { t!(std::path::absolute(root.join(path))) }; + let absolute_root_real = t!(std::path::absolute(&metadata.workspace_root)); + if absolute_root_real != absolute_root { + check.error(format!("{path} is part of another workspace ({} != {}), remove from `WORKSPACES` ({WORKSPACE_LOCATION})", absolute_root.display(), absolute_root_real.display())); + } + check_license_exceptions(&metadata, path, exceptions, &check); + if let Some(PermittedDeps { roots, deps: permitted_deps, deps_loc }) = crates_and_deps { + let descr = roots.map_or(path, |roots| roots.get(0).unwrap_or(&path)); + check_permitted_dependencies( + &metadata, + descr, + permitted_deps, + *roots, + *deps_loc, + &check, + ); + } - let mut cmd = cargo_metadata::MetadataCommand::new(); - cmd.cargo_path(cargo) - .manifest_path(root.join(path).join("Cargo.toml")) - .features(cargo_metadata::CargoOpt::AllFeatures) - .other_options(vec!["--locked".to_owned()]); - let metadata = t!(cmd.exec()); - - // Check for packages which have been moved into a different workspace and not updated - let absolute_root = - if path == "." { root.to_path_buf() } else { t!(std::path::absolute(root.join(path))) }; - let absolute_root_real = t!(std::path::absolute(&metadata.workspace_root)); - if absolute_root_real != absolute_root { - check.error(format!("{path} is part of another workspace ({} != {}), remove from `WORKSPACES` ({WORKSPACE_LOCATION})", absolute_root.display(), absolute_root_real.display())); - } - check_license_exceptions(&metadata, path, exceptions, &mut check); - if let Some(PermittedDeps { roots, deps: permitted_deps, deps_loc }) = crates_and_deps { - let descr = roots.map_or(path, |roots| roots.get(0).unwrap_or(&path)); - check_permitted_dependencies( - &metadata, - descr, - permitted_deps, - roots, - deps_loc, - &mut check, - ); - } - if path == "library" { - check_runtime_license_exceptions(&metadata, &mut check); - check_runtime_no_duplicate_dependencies(&metadata, &mut check); - check_runtime_no_proc_macros(&metadata, &mut check); - checked_runtime_licenses = true; + if *path == "library" { + check_runtime_license_exceptions(&metadata, &check); + check_runtime_no_duplicate_dependencies(&metadata, &check); + check_runtime_no_proc_macros(&metadata, &check); + checked_runtime_licenses.store(true, Ordering::Relaxed); + } + + let _guard = guard; + }); } - } + }); // Sanity check to ensure we don't accidentally remove the workspace containing the runtime // crates. - assert!(checked_runtime_licenses); + assert!(checked_runtime_licenses.load(Ordering::Relaxed)); } /// Ensure the list of proc-macro crate transitive dependencies is up to date @@ -808,7 +824,7 @@ pub fn has_missing_submodule(root: &Path, submodules: &[&str], is_ci: bool) -> b /// /// Unlike for tools we don't allow exceptions to the `LICENSES` list for the runtime with the sole /// exception of `fortanix-sgx-abi` which is only used on x86_64-fortanix-unknown-sgx. -fn check_runtime_license_exceptions(metadata: &Metadata, check: &mut RunningCheck) { +fn check_runtime_license_exceptions(metadata: &Metadata, check: &RunningCheck) { for pkg in &metadata.packages { if pkg.source.is_none() { // No need to check local packages. @@ -843,7 +859,7 @@ fn check_license_exceptions( metadata: &Metadata, workspace: &str, exceptions: &[(&str, &str)], - check: &mut RunningCheck, + check: &RunningCheck, ) { // Validate the EXCEPTIONS list hasn't changed. for (name, license) in exceptions { @@ -910,7 +926,7 @@ fn check_license_exceptions( } } -fn check_runtime_no_duplicate_dependencies(metadata: &Metadata, check: &mut RunningCheck) { +fn check_runtime_no_duplicate_dependencies(metadata: &Metadata, check: &RunningCheck) { let mut seen_pkgs = HashSet::new(); for pkg in &metadata.packages { if pkg.source.is_none() { @@ -926,7 +942,7 @@ fn check_runtime_no_duplicate_dependencies(metadata: &Metadata, check: &mut Runn } } -fn check_runtime_no_proc_macros(metadata: &Metadata, check: &mut RunningCheck) { +fn check_runtime_no_proc_macros(metadata: &Metadata, check: &RunningCheck) { for pkg in &metadata.packages { if pkg.targets.iter().any(|target| target.is_proc_macro()) { check.error(format!( @@ -949,7 +965,7 @@ fn check_permitted_dependencies( permitted_dependencies: &[&'static str], restricted_dependency_crates: Option<&[&'static str]>, permitted_location: ListLocation, - check: &mut RunningCheck, + check: &RunningCheck, ) { let mut has_permitted_dep_error = false; let mut deps = HashSet::new(); diff --git a/src/tools/tidy/src/diagnostics.rs b/src/tools/tidy/src/diagnostics.rs index 3f93316f63606..2ccc9e61232ea 100644 --- a/src/tools/tidy/src/diagnostics.rs +++ b/src/tools/tidy/src/diagnostics.rs @@ -2,6 +2,7 @@ use std::collections::HashSet; use std::fmt::{Display, Formatter}; use std::io; use std::path::{Path, PathBuf}; +use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Mutex}; use build_helper::ci::CiEnv; @@ -86,10 +87,10 @@ impl TidyCtx { ctx.start_check(id.clone()); RunningCheck { id, - bad: false, + bad: AtomicBool::new(false), ctx: self.diag_ctx.clone(), #[cfg(test)] - errors: vec![], + errors: Mutex::new(vec![]), } } @@ -228,10 +229,10 @@ impl FinishedCheck { /// Represents a single tidy check, identified by its `name`, running. pub struct RunningCheck { id: CheckId, - bad: bool, + bad: AtomicBool, ctx: Arc>, #[cfg(test)] - errors: Vec, + errors: Mutex>, } impl RunningCheck { @@ -245,26 +246,26 @@ impl RunningCheck { } /// Immediately output an error and mark the check as failed. - pub fn error(&mut self, msg: T) { + pub fn error(&self, msg: T) { self.mark_as_bad(); let msg = msg.to_string(); output_message(&msg, Some(&self.id), Some(COLOR_ERROR)); #[cfg(test)] - self.errors.push(msg); + self.errors.lock().unwrap().push(msg); } /// Immediately output a warning. - pub fn warning(&mut self, msg: T) { + pub fn warning(&self, msg: T) { output_message(&msg.to_string(), Some(&self.id), Some(COLOR_WARNING)); } /// Output an informational message - pub fn message(&mut self, msg: T) { + pub fn message(&self, msg: T) { output_message(&msg.to_string(), Some(&self.id), None); } /// Output a message only if verbose output is enabled. - pub fn verbose_msg(&mut self, msg: T) { + pub fn verbose_msg(&self, msg: T) { if self.is_verbose_enabled() { self.message(msg); } @@ -272,7 +273,7 @@ impl RunningCheck { /// Has an error already occurred for this check? pub fn is_bad(&self) -> bool { - self.bad + self.bad.load(Ordering::Relaxed) } /// Is verbose output enabled? @@ -282,17 +283,20 @@ impl RunningCheck { #[cfg(test)] pub fn get_errors(&self) -> Vec { - self.errors.clone() + self.errors.lock().unwrap().clone() } - fn mark_as_bad(&mut self) { - self.bad = true; + fn mark_as_bad(&self) { + self.bad.store(true, Ordering::Relaxed); } } impl Drop for RunningCheck { fn drop(&mut self) { - self.ctx.lock().unwrap().finish_check(FinishedCheck { id: self.id.clone(), bad: self.bad }) + self.ctx.lock().unwrap().finish_check(FinishedCheck { + id: self.id.clone(), + bad: self.bad.load(Ordering::Relaxed), + }) } } diff --git a/src/tools/tidy/src/edition.rs b/src/tools/tidy/src/edition.rs index de21846ab1883..1e5f36221aa2a 100644 --- a/src/tools/tidy/src/edition.rs +++ b/src/tools/tidy/src/edition.rs @@ -6,7 +6,7 @@ use crate::diagnostics::{CheckId, TidyCtx}; use crate::walk::{filter_dirs, walk}; pub fn check(path: &Path, tidy_ctx: TidyCtx) { - let mut check = tidy_ctx.start_check(CheckId::new("edition").path(path)); + let check = tidy_ctx.start_check(CheckId::new("edition").path(path)); walk(path, |path, _is_dir| filter_dirs(path), &mut |entry, contents| { let file = entry.path(); let filename = file.file_name().unwrap(); diff --git a/src/tools/tidy/src/extdeps.rs b/src/tools/tidy/src/extdeps.rs index 79b562270f7ce..9fff8babc3fae 100644 --- a/src/tools/tidy/src/extdeps.rs +++ b/src/tools/tidy/src/extdeps.rs @@ -16,7 +16,7 @@ const ALLOWED_SOURCES: &[&str] = &[ /// Checks for external package sources. `root` is the path to the directory that contains the /// workspace `Cargo.toml`. pub fn check(root: &Path, tidy_ctx: TidyCtx) { - let mut check = tidy_ctx.start_check("extdeps"); + let check = tidy_ctx.start_check("extdeps"); for &WorkspaceInfo { path, submodules, .. } in crate::deps::WORKSPACES { if crate::deps::has_missing_submodule(root, submodules, tidy_ctx.is_running_on_ci()) { diff --git a/src/tools/tidy/src/extra_checks/mod.rs b/src/tools/tidy/src/extra_checks/mod.rs index 7176f8cabc595..55dc6dfd2d3c2 100644 --- a/src/tools/tidy/src/extra_checks/mod.rs +++ b/src/tools/tidy/src/extra_checks/mod.rs @@ -171,7 +171,7 @@ pub fn check( } fn py_prepare(root_path: &Path, outdir: &Path, tidy_ctx: &TidyCtx) -> Option { - let mut check = tidy_ctx.start_check("extra_checks:py_prepare"); + let check = tidy_ctx.start_check("extra_checks:py_prepare"); let venv_path = outdir.join("venv"); let mut reqs_path = root_path.to_owned(); @@ -187,7 +187,7 @@ fn py_prepare(root_path: &Path, outdir: &Path, tidy_ctx: &TidyCtx) -> Option Option<()> { - let mut check = tidy_ctx.start_check("extra_checks:js_prepare"); + let check = tidy_ctx.start_check("extra_checks:js_prepare"); if let Err(e) = rustdoc_js::npm_install(root_path, outdir, npm) { check.error(e.to_string()); @@ -206,7 +206,7 @@ fn show_bless_help(mode: &str, action: &str, bless: bool) { } fn check_spellcheck(root_path: &Path, outdir: &Path, cargo: &Path, tidy_ctx: &TidyCtx) { - let mut check = tidy_ctx.start_check("extra_checks:spellcheck"); + let check = tidy_ctx.start_check("extra_checks:spellcheck"); let bless = tidy_ctx.is_bless_enabled(); @@ -230,7 +230,7 @@ fn check_spellcheck(root_path: &Path, outdir: &Path, cargo: &Path, tidy_ctx: &Ti } fn check_js_lint(outdir: &Path, librustdoc_path: &Path, tools_path: &Path, tidy_ctx: &TidyCtx) { - let mut check = tidy_ctx.start_check("extra_checks:js_lint"); + let check = tidy_ctx.start_check("extra_checks:js_lint"); let bless = tidy_ctx.is_bless_enabled(); @@ -252,7 +252,7 @@ fn check_js_lint(outdir: &Path, librustdoc_path: &Path, tools_path: &Path, tidy_ } fn check_js_typecheck(outdir: &Path, librustdoc_path: &Path, tidy_ctx: &TidyCtx) { - let mut check = tidy_ctx.start_check("extra_checks:js_typecheck"); + let check = tidy_ctx.start_check("extra_checks:js_typecheck"); eprintln!("typechecking javascript files"); if let Err(e) = rustdoc_js::typecheck(outdir, librustdoc_path) { @@ -266,7 +266,7 @@ fn check_shell_lint( file_args: &Vec<&OsStr>, tidy_ctx: &TidyCtx, ) { - let mut check = tidy_ctx.start_check("extra_checks:shell_lint"); + let check = tidy_ctx.start_check("extra_checks:shell_lint"); eprintln!("linting shell files"); @@ -297,7 +297,7 @@ fn check_python_lint( py_path: &Path, tidy_ctx: &TidyCtx, ) { - let mut check = tidy_ctx.start_check("extra_checks:python_lint"); + let check = tidy_ctx.start_check("extra_checks:python_lint"); let bless = tidy_ctx.is_bless_enabled(); @@ -340,7 +340,7 @@ fn check_python_fmt( py_path: &Path, tidy_ctx: &TidyCtx, ) { - let mut check = tidy_ctx.start_check("extra_checks:python_fmt"); + let check = tidy_ctx.start_check("extra_checks:python_fmt"); let bless = tidy_ctx.is_bless_enabled(); @@ -380,7 +380,7 @@ fn check_cpp_fmt( py_path: &Path, tidy_ctx: &TidyCtx, ) { - let mut check = tidy_ctx.start_check("extra_checks:cpp_fmt"); + let check = tidy_ctx.start_check("extra_checks:cpp_fmt"); let bless = tidy_ctx.is_bless_enabled(); diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index 117de57d03dd4..e7301f3e92a5c 100644 --- a/src/tools/tidy/src/features.rs +++ b/src/tools/tidy/src/features.rs @@ -125,7 +125,7 @@ pub fn check( let filename_gate = test_filen_gate(&filen_underscore, &mut features); for (i, line) in contents.lines().enumerate() { - let mut err = |msg: &str| { + let err = |msg: &str| { check.error(format!("{}:{}: {}", file.display(), i + 1, msg)); }; @@ -449,7 +449,7 @@ fn get_and_check_lib_features( let mut lib_features = Features::new(); map_lib_features(base_src_path, &mut |res, file, line| match res { Ok((name, f)) => { - let mut check_features = |f: &Feature, list: &Features, display: &str| { + let check_features = |f: &Feature, list: &Features, display: &str| { if let Some(s) = list.get(name) && f.tracking_issue != s.tracking_issue && f.level != Status::Accepted diff --git a/src/tools/tidy/src/filenames.rs b/src/tools/tidy/src/filenames.rs index a355588fd99ca..e31350cb3108c 100644 --- a/src/tools/tidy/src/filenames.rs +++ b/src/tools/tidy/src/filenames.rs @@ -13,7 +13,7 @@ use std::process::Command; use crate::diagnostics::TidyCtx; pub fn check(root_path: &Path, tidy_ctx: TidyCtx) { - let mut check = tidy_ctx.start_check("filenames"); + let check = tidy_ctx.start_check("filenames"); let stat_output = Command::new("git") .arg("-C") .arg(root_path) diff --git a/src/tools/tidy/src/gcc_submodule.rs b/src/tools/tidy/src/gcc_submodule.rs index 46b816f5c9d0e..0dfd45beaf8df 100644 --- a/src/tools/tidy/src/gcc_submodule.rs +++ b/src/tools/tidy/src/gcc_submodule.rs @@ -7,7 +7,7 @@ use std::process::Command; use crate::diagnostics::TidyCtx; pub fn check(root_path: &Path, compiler_path: &Path, tidy_ctx: TidyCtx) { - let mut check = tidy_ctx.start_check("gcc_submodule"); + let check = tidy_ctx.start_check("gcc_submodule"); let cg_gcc_version_path = compiler_path.join("rustc_codegen_gcc/libgccjit.version"); let cg_gcc_version = std::fs::read_to_string(&cg_gcc_version_path) diff --git a/src/tools/tidy/src/known_bug.rs b/src/tools/tidy/src/known_bug.rs index e6038341ba966..d7a490752db14 100644 --- a/src/tools/tidy/src/known_bug.rs +++ b/src/tools/tidy/src/known_bug.rs @@ -6,7 +6,7 @@ use crate::diagnostics::{CheckId, TidyCtx}; use crate::walk::*; pub fn check(filepath: &Path, tidy_ctx: TidyCtx) { - let mut check = tidy_ctx.start_check(CheckId::new("known_bug").path(filepath)); + let check = tidy_ctx.start_check(CheckId::new("known_bug").path(filepath)); walk(filepath, |path, _is_dir| filter_not_rust(path), &mut |entry, contents| { let file: &Path = entry.path(); diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index 9975570fa17fc..55889713d3a59 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -4,6 +4,7 @@ //! to be used by tools. use std::ffi::OsStr; +use std::num::NonZeroUsize; use std::process::Command; macro_rules! static_regex { @@ -136,3 +137,39 @@ pub mod unknown_revision; pub mod unstable_book; pub mod walk; pub mod x_version; + +pub struct Semaphore { + sem: std::sync::Mutex, + cond: std::sync::Condvar, +} + +impl Semaphore { + pub fn new(count: NonZeroUsize) -> Self { + Self { sem: std::sync::Mutex::new(count.get()), cond: std::sync::Condvar::new() } + } + + pub fn acquire(&self) -> Guard<'_> { + let mut count = self.sem.lock().unwrap(); + while *count == 0 { + count = self.cond.wait(count).unwrap(); + } + *count -= 1; + Guard { sem: self } + } + + fn release(&self) { + let mut count = self.sem.lock().unwrap(); + *count += 1; + self.cond.notify_one(); + } +} + +pub struct Guard<'a> { + sem: &'a Semaphore, +} + +impl Drop for Guard<'_> { + fn drop(&mut self) { + self.sem.release(); + } +} diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs index c77ef00be9eaf..ee8796022f399 100644 --- a/src/tools/tidy/src/main.rs +++ b/src/tools/tidy/src/main.rs @@ -4,8 +4,8 @@ //! etc. This is run by default on `./x.py test` and as part of the auto //! builders. The tidy checks can be executed with `./x.py test tidy`. -use std::collections::VecDeque; -use std::thread::{self, ScopedJoinHandle, scope}; +use std::num::NonZeroUsize; +use std::thread::{self, scope}; use std::{env, process}; use tidy::arg_parser::TidyArgParser; @@ -46,22 +46,9 @@ fn main() { let tidy_ctx = TidyCtx::new(&root_path, verbose, ci, TidyFlags::new(bless)); - let drain_handles = |handles: &mut VecDeque>| { - // poll all threads for completion before awaiting the oldest one - for i in (0..handles.len()).rev() { - if handles[i].is_finished() { - handles.swap_remove_back(i).unwrap().join().unwrap(); - } - } - - while handles.len() >= concurrency { - handles.pop_front().unwrap().join().unwrap(); - } - }; + let sem = Semaphore::new(NonZeroUsize::new(concurrency).unwrap()); scope(|s| { - let mut handles: VecDeque> = VecDeque::with_capacity(concurrency); - macro_rules! check { ($p:ident) => { check!(@ $p, name=format!("{}", stringify!($p))); @@ -76,20 +63,19 @@ fn main() { check!(@ $p, name=name, $path $(,$args)*); }; (@ $p:ident, name=$name:expr $(, $args:expr)* ) => { - drain_handles(&mut handles); - + let guard = sem.acquire(); let tidy_ctx = tidy_ctx.clone(); - let handle = thread::Builder::new().name($name).spawn_scoped(s, || { + thread::Builder::new().name($name).spawn_scoped(s, || { $p::check($($args, )* tidy_ctx); + let _guard = guard; }).unwrap(); - handles.push_back(handle); } } check!(target_specific_tests, &tests_path); // Checks that are done on the cargo workspace. - check!(deps, &root_path, &cargo); + check!(deps, &root_path, &cargo, &sem); check!(extdeps, &root_path); // Checks over tests. @@ -124,8 +110,8 @@ fn main() { check!(bins, &root_path); } - check!(style, &src_path); check!(style, &tests_path); + check!(style, &src_path); check!(style, &compiler_path); check!(style, &library_path); @@ -146,8 +132,6 @@ fn main() { check!(filenames, &root_path); let collected = { - drain_handles(&mut handles); - features::check(&src_path, &tests_path, &compiler_path, &library_path, tidy_ctx.clone()) }; check!(unstable_book, &src_path, collected); diff --git a/src/tools/tidy/src/rustdoc_gui_tests.rs b/src/tools/tidy/src/rustdoc_gui_tests.rs index 848250e18e74a..61c5e1e18dd07 100644 --- a/src/tools/tidy/src/rustdoc_gui_tests.rs +++ b/src/tools/tidy/src/rustdoc_gui_tests.rs @@ -5,7 +5,7 @@ use std::path::Path; use crate::diagnostics::{CheckId, TidyCtx}; pub fn check(path: &Path, tidy_ctx: TidyCtx) { - let mut check = tidy_ctx.start_check(CheckId::new("rustdoc_gui_tests").path(path)); + let check = tidy_ctx.start_check(CheckId::new("rustdoc_gui_tests").path(path)); crate::walk::walk( &path.join("rustdoc-gui"), diff --git a/src/tools/tidy/src/rustdoc_html_tests.rs b/src/tools/tidy/src/rustdoc_html_tests.rs index 1cb7cd3efb584..b2114ca4b97bc 100644 --- a/src/tools/tidy/src/rustdoc_html_tests.rs +++ b/src/tools/tidy/src/rustdoc_html_tests.rs @@ -7,7 +7,7 @@ use crate::diagnostics::{CheckId, TidyCtx}; pub fn check(path: &Path, tidy_ctx: TidyCtx) { let path = path.join("rustdoc-html"); - let mut check = tidy_ctx.start_check(CheckId::new("rustdoc_html_tests").path(&path)); + let check = tidy_ctx.start_check(CheckId::new("rustdoc_html_tests").path(&path)); // The list of subdirectories in rustdoc-html tests. // Compare previous subdirectory with current subdirectory diff --git a/src/tools/tidy/src/rustdoc_json.rs b/src/tools/tidy/src/rustdoc_json.rs index ef7dabc8021ba..ccda812e8963f 100644 --- a/src/tools/tidy/src/rustdoc_json.rs +++ b/src/tools/tidy/src/rustdoc_json.rs @@ -9,7 +9,7 @@ use crate::diagnostics::{CheckId, TidyCtx}; const RUSTDOC_JSON_TYPES: &str = "src/rustdoc-json-types"; pub fn check(src_path: &Path, tidy_ctx: TidyCtx) { - let mut check = tidy_ctx.start_check(CheckId::new("rustdoc_json").path(src_path)); + let check = tidy_ctx.start_check(CheckId::new("rustdoc_json").path(src_path)); let Some(base_commit) = &tidy_ctx.base_commit else { check.verbose_msg("No base commit, skipping rustdoc_json check"); diff --git a/src/tools/tidy/src/rustdoc_templates.rs b/src/tools/tidy/src/rustdoc_templates.rs index faeb95a92b763..ba76319c11052 100644 --- a/src/tools/tidy/src/rustdoc_templates.rs +++ b/src/tools/tidy/src/rustdoc_templates.rs @@ -13,7 +13,7 @@ use crate::walk::walk; const TAGS: &[(&str, &str)] = &[("{#", "#}"), ("{%", "%}"), ("{{", "}}")]; pub fn check(librustdoc_path: &Path, tidy_ctx: TidyCtx) { - let mut check = tidy_ctx.start_check(CheckId::new("rustdoc_templates").path(librustdoc_path)); + let check = tidy_ctx.start_check(CheckId::new("rustdoc_templates").path(librustdoc_path)); walk( &librustdoc_path.join("html/templates"), diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs index 6d8a6371f89e3..5d57211b914d7 100644 --- a/src/tools/tidy/src/style.rs +++ b/src/tools/tidy/src/style.rs @@ -432,13 +432,13 @@ fn check_file_style(base_path: &Path, check: &mut RunningCheck, file: &Path, con lines += 1; } - let mut err = |msg: &str| { + let err = |msg: &str| { check.error(format!("{}:{}: {msg}", file.display(), line_number)); }; if !is_this_file - && trimmed.contains("dbg!") && !trimmed.starts_with("//") + && trimmed.contains("dbg!") && !file.ancestors().any(|a| { (a.ends_with("tests") && a.join("COMPILER_TESTS.md").exists()) || a.ends_with("library/alloctests") @@ -453,8 +453,8 @@ fn check_file_style(base_path: &Path, check: &mut RunningCheck, file: &Path, con } if !is_this_file - && trimmed.contains("todo!") && !trimmed.starts_with("//") + && trimmed.contains("todo!") && !file.ancestors().any(|a| { (a.ends_with("tests") && a.join("COMPILER_TESTS.md").exists()) || a.ends_with("library/alloctests") @@ -516,10 +516,11 @@ fn check_file_style(base_path: &Path, check: &mut RunningCheck, file: &Path, con || Directives::parse(LineNumber::WholeFile, line) .iter() .any(|directive| directive.is_ignore_and_defuse())); - let has_alphabetical_directive = - line.contains("tidy-alphabetical-start") || line.contains("tidy-alphabetical-end"); + let has_alphabetical_directive = contains_potential_directive + && (line.contains("tidy-alphabetical-start") + || line.contains("tidy-alphabetical-end")); let has_other_tidy_ignore_directive = - line.contains("ignore-tidy-target-specific-tests"); + contains_potential_directive && line.contains("ignore-tidy-target-specific-tests"); let has_recognized_directive = has_recognized_ignore_directive || has_alphabetical_directive || has_other_tidy_ignore_directive; @@ -644,7 +645,7 @@ fn check_file_style(base_path: &Path, check: &mut RunningCheck, file: &Path, con } else if let Some((start_line, backtick_count, directive)) = comment_block.take() && backtick_count % 2 == 1 { - let mut err = |msg: &str| { + let err = |msg: &str| { check.error(format!("{}:{start_line}: {msg}", file.display())); }; let block_len = line_number - start_line; @@ -671,12 +672,12 @@ fn check_file_style(base_path: &Path, check: &mut RunningCheck, file: &Path, con ignore.check_usage(check, file); } if leading_new_lines { - let mut err = |_| { + let err = |_| { check.error(format!("{}: leading newline", file.display())); }; suppressible_tidy_err!(err, file_ignore.leading_newlines, "missing leading newline"); } - let mut err = |msg: &str| { + let err = |msg: &str| { check.error(format!("{}: {}", file.display(), msg)); }; match trailing_new_lines { @@ -689,7 +690,7 @@ fn check_file_style(base_path: &Path, check: &mut RunningCheck, file: &Path, con ), }; if lines > LINES { - let mut err = |_| { + let err = |_| { check.error(format!( "{}: too many lines ({lines}) (add `// \ ignore-tidy-file-filelength` to the file to suppress this error)", diff --git a/src/tools/tidy/src/style/directive.rs b/src/tools/tidy/src/style/directive.rs index f605aa1aa15ee..f8b7138bf448c 100644 --- a/src/tools/tidy/src/style/directive.rs +++ b/src/tools/tidy/src/style/directive.rs @@ -323,8 +323,13 @@ pub enum LineNumber { } pub fn match_ignore(contents: &str, whole_file: bool, check: Option<&str>) -> bool { - let comments = [("// ", ""), ("# ", ""), ("/* ", " */"), ("")]; let base = "ignore-tidy"; + // fast-path + if !contents.contains(base) { + return false; + } + + let comments = [("// ", ""), ("# ", ""), ("/* ", " */"), ("")]; let file = if whole_file { "file-" } else { "" }; for (start, end) in comments { diff --git a/src/tools/tidy/src/target_policy.rs b/src/tools/tidy/src/target_policy.rs index 83fbe6a0d8dae..976b0fd868a11 100644 --- a/src/tools/tidy/src/target_policy.rs +++ b/src/tools/tidy/src/target_policy.rs @@ -25,7 +25,7 @@ const EXCEPTIONS: &[&str] = &[ ]; pub fn check(root_path: &Path, tidy_ctx: TidyCtx) { - let mut check = tidy_ctx.start_check("target_policy"); + let check = tidy_ctx.start_check("target_policy"); let mut targets_to_find = HashSet::new(); diff --git a/src/tools/tidy/src/target_specific_tests.rs b/src/tools/tidy/src/target_specific_tests.rs index 418843869ff83..fc4b37ea52737 100644 --- a/src/tools/tidy/src/target_specific_tests.rs +++ b/src/tools/tidy/src/target_specific_tests.rs @@ -20,7 +20,7 @@ struct RevisionInfo<'a> { } pub fn check(tests_path: &Path, tidy_ctx: TidyCtx) { - let mut check = tidy_ctx.start_check(CheckId::new("target-specific-tests").path(tests_path)); + let check = tidy_ctx.start_check(CheckId::new("target-specific-tests").path(tests_path)); crate::walk::walk(tests_path, |path, _is_dir| filter_not_rust(path), &mut |entry, content| { if content.contains("// ignore-tidy-target-specific-tests") { diff --git a/src/tools/tidy/src/tests_placement.rs b/src/tools/tidy/src/tests_placement.rs index 18b00608fdce5..90555776348c7 100644 --- a/src/tools/tidy/src/tests_placement.rs +++ b/src/tools/tidy/src/tests_placement.rs @@ -6,7 +6,7 @@ const FORBIDDEN_PATH: &str = "src/test"; const ALLOWED_PATH: &str = "tests"; pub fn check(root_path: &Path, tidy_ctx: TidyCtx) { - let mut check = tidy_ctx.start_check("tests_placement"); + let check = tidy_ctx.start_check("tests_placement"); if root_path.join(FORBIDDEN_PATH).exists() { check.error(format!( diff --git a/src/tools/tidy/src/tests_revision_unpaired_stdout_stderr.rs b/src/tools/tidy/src/tests_revision_unpaired_stdout_stderr.rs index 88dc1ce1ae0a7..3f49674fb4677 100644 --- a/src/tools/tidy/src/tests_revision_unpaired_stdout_stderr.rs +++ b/src/tools/tidy/src/tests_revision_unpaired_stdout_stderr.rs @@ -16,7 +16,7 @@ const EXTENSIONS: &[&str] = &["stdout", "stderr"]; const SPECIAL_TEST: &str = "tests/ui/command/need-crate-arg-ignore-tidy.x.rs"; pub fn check(tests_path: &Path, tidy_ctx: TidyCtx) { - let mut check = tidy_ctx + let check = tidy_ctx .start_check(CheckId::new("tests_revision_unpaired_stdout_stderr").path(tests_path)); // Recurse over subdirectories under `tests/` diff --git a/src/tools/tidy/src/triagebot.rs b/src/tools/tidy/src/triagebot.rs index 4eb3e9a82ab35..e155aef9c97a6 100644 --- a/src/tools/tidy/src/triagebot.rs +++ b/src/tools/tidy/src/triagebot.rs @@ -19,7 +19,7 @@ static SUBMODULES: LazyLock> = LazyLock::new(|| { }); pub fn check(path: &Path, tidy_ctx: TidyCtx) { - let mut check = tidy_ctx.start_check("triagebot"); + let check = tidy_ctx.start_check("triagebot"); let triagebot_path = path.join("triagebot.toml"); // This check is mostly to catch broken path filters *within* `triagebot.toml`, and not enforce diff --git a/src/tools/tidy/src/unit_tests.rs b/src/tools/tidy/src/unit_tests.rs index 74b6c4a3845a6..58a70896fc236 100644 --- a/src/tools/tidy/src/unit_tests.rs +++ b/src/tools/tidy/src/unit_tests.rs @@ -15,7 +15,7 @@ use crate::diagnostics::{CheckId, TidyCtx}; use crate::walk::{filter_dirs, walk}; pub fn check(root_path: &Path, stdlib: bool, tidy_ctx: TidyCtx) { - let mut check = tidy_ctx.start_check(CheckId::new("unit_tests").path(root_path)); + let check = tidy_ctx.start_check(CheckId::new("unit_tests").path(root_path)); let skip = move |path: &Path, is_dir| { let file_name = path.file_name().unwrap_or_default(); diff --git a/src/tools/tidy/src/x_version.rs b/src/tools/tidy/src/x_version.rs index ba675c9c14eef..e2ba849dfe6ba 100644 --- a/src/tools/tidy/src/x_version.rs +++ b/src/tools/tidy/src/x_version.rs @@ -6,7 +6,7 @@ use semver::Version; use crate::diagnostics::{CheckId, TidyCtx}; pub fn check(root: &Path, cargo: &Path, tidy_ctx: TidyCtx) { - let mut check = tidy_ctx.start_check(CheckId::new("x_version").path(root)); + let check = tidy_ctx.start_check(CheckId::new("x_version").path(root)); let cargo_list = Command::new(cargo).args(["install", "--list"]).stdout(Stdio::piped()).spawn(); let child = match cargo_list { diff --git a/tests/assembly-gcc/stack-protector/stack-protector-heuristics-effect.rs b/tests/assembly-gcc/stack-protector/stack-protector-heuristics-effect.rs index c8945ed96b3ee..49fcfce438c2e 100644 --- a/tests/assembly-gcc/stack-protector/stack-protector-heuristics-effect.rs +++ b/tests/assembly-gcc/stack-protector/stack-protector-heuristics-effect.rs @@ -8,7 +8,7 @@ //@ [strong] compile-flags: -Z stack-protector=strong //@ [basic] compile-flags: -Z stack-protector=basic //@ [none] compile-flags: -Z stack-protector=none -//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled +//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled -Z allow-partial-mitigations=stack-protector #![crate_type = "lib"] #![allow(internal_features)] diff --git a/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-2.rs b/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-2.rs index 07e92fbfde6dc..5ff5ed621fbaa 100644 --- a/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-2.rs +++ b/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-2.rs @@ -7,7 +7,7 @@ //@ [all] compile-flags: -Z stack-protector=all //@ [strong] compile-flags: -Z stack-protector=strong //@ [none] compile-flags: -Z stack-protector=none -//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled +//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled -Z allow-partial-mitigations=stack-protector //@ min-llvm-version: 23 #![crate_type = "lib"] diff --git a/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-32bit-2.rs b/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-32bit-2.rs index 8cd7f730bd5e5..4be0c3a3dbe98 100644 --- a/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-32bit-2.rs +++ b/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-32bit-2.rs @@ -6,7 +6,7 @@ //@ [all] compile-flags: -Z stack-protector=all //@ [strong] compile-flags: -Z stack-protector=strong //@ [none] compile-flags: -Z stack-protector=none -//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled +//@ compile-flags: -Z allow-partial-mitigations=stack-protector -C opt-level=2 -Z merge-functions=disabled #![crate_type = "lib"] #![allow(internal_features)] diff --git a/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-32bit.rs b/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-32bit.rs index d1b51068fce5a..c0b81f9ba2fdf 100644 --- a/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-32bit.rs +++ b/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-32bit.rs @@ -7,7 +7,7 @@ //@ [strong] compile-flags: -Z stack-protector=strong //@ [basic] compile-flags: -Z stack-protector=basic //@ [none] compile-flags: -Z stack-protector=none -//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled -Cpanic=abort -Cdebuginfo=1 +//@ compile-flags: -Z allow-partial-mitigations=stack-protector -C opt-level=2 -Z merge-functions=disabled -Cpanic=abort -Cdebuginfo=1 #![crate_type = "lib"] #![allow(internal_features)] diff --git a/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-64bit-2.rs b/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-64bit-2.rs index ac0f89b8e9c0a..36e315c38e0f8 100644 --- a/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-64bit-2.rs +++ b/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-64bit-2.rs @@ -6,7 +6,7 @@ //@ [all] compile-flags: -Z stack-protector=all //@ [strong] compile-flags: -Z stack-protector=strong //@ [none] compile-flags: -Z stack-protector=none -//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled +//@ compile-flags: -Z allow-partial-mitigations=stack-protector -C opt-level=2 -Z merge-functions=disabled #![crate_type = "lib"] #![feature(unsized_fn_params)] diff --git a/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-64bit.rs b/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-64bit.rs index 56a6f08da5877..87d3ba54d10af 100644 --- a/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-64bit.rs +++ b/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-64bit.rs @@ -7,7 +7,7 @@ //@ [strong] compile-flags: -Z stack-protector=strong //@ [basic] compile-flags: -Z stack-protector=basic //@ [none] compile-flags: -Z stack-protector=none -//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled -Cpanic=abort +//@ compile-flags: -Z allow-partial-mitigations=stack-protector -C opt-level=2 -Z merge-functions=disabled -Cpanic=abort #![crate_type = "lib"] #![feature(unsized_fn_params)] diff --git a/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect.rs b/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect.rs index 56cf0035e25bf..7b802e52ad7c9 100644 --- a/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect.rs +++ b/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect.rs @@ -8,7 +8,7 @@ //@ [strong] compile-flags: -Z stack-protector=strong //@ [basic] compile-flags: -Z stack-protector=basic //@ [none] compile-flags: -Z stack-protector=none -//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled +//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled -Z allow-partial-mitigations=stack-protector // NOTE: the heuristics for stack smash protection inappropriately rely on types in LLVM IR, // despite those types having no semantic meaning. This means that the `basic` and `strong` diff --git a/tests/assembly-llvm/stack-protector/stack-protector-safe-stack.rs b/tests/assembly-llvm/stack-protector/stack-protector-safe-stack.rs index 24a1276adc4ac..e9a217919f1ca 100644 --- a/tests/assembly-llvm/stack-protector/stack-protector-safe-stack.rs +++ b/tests/assembly-llvm/stack-protector/stack-protector-safe-stack.rs @@ -8,7 +8,7 @@ //@ [safestack] compile-flags: -Z stack-protector=none -Z sanitizer=safestack //@ [safestack_strong] compile-flags: -Z stack-protector=strong -Z sanitizer=safestack //@ [safestack_all] compile-flags: -Z stack-protector=all -Z sanitizer=safestack -//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled --target x86_64-unknown-linux-gnu +//@ compile-flags: -Z allow-partial-mitigations=stack-protector -C opt-level=2 -Z merge-functions=disabled --target x86_64-unknown-linux-gnu //@ needs-llvm-components: x86 #![feature(unsized_fn_params)] diff --git a/tests/assembly-llvm/stack-protector/stack-protector-target-support.rs b/tests/assembly-llvm/stack-protector/stack-protector-target-support.rs index 9f182985d1573..c2a4ad5e2f74e 100644 --- a/tests/assembly-llvm/stack-protector/stack-protector-target-support.rs +++ b/tests/assembly-llvm/stack-protector/stack-protector-target-support.rs @@ -173,7 +173,7 @@ //@ [r84] needs-llvm-components: x86 //@ [r85] compile-flags: --target x86_64-unknown-redox //@ [r85] needs-llvm-components: x86 -//@ compile-flags: -Z stack-protector=all -Cpanic=abort +//@ compile-flags: -Z stack-protector=all -Z allow-partial-mitigations=stack-protector -Cpanic=abort //@ compile-flags: -C opt-level=2 #![crate_type = "lib"] diff --git a/tests/codegen-llvm/abi-win64-zst.rs b/tests/codegen-llvm/abi-win64-zst.rs deleted file mode 100644 index e855b60ca4d26..0000000000000 --- a/tests/codegen-llvm/abi-win64-zst.rs +++ /dev/null @@ -1,53 +0,0 @@ -//@ add-minicore -//@ compile-flags: -Z merge-functions=disabled - -//@ revisions: windows-gnu -//@[windows-gnu] compile-flags: --target x86_64-pc-windows-gnu -//@[windows-gnu] needs-llvm-components: x86 - -//@ revisions: windows-msvc -//@[windows-msvc] compile-flags: --target x86_64-pc-windows-msvc -//@[windows-msvc] needs-llvm-components: x86 - -// Also test what happens when using a Windows ABI on Linux. -//@ revisions: linux -//@[linux] compile-flags: --target x86_64-unknown-linux-gnu -//@[linux] needs-llvm-components: x86 - -#![feature(no_core, rustc_attrs, abi_vectorcall)] -#![no_core] -#![crate_type = "lib"] - -extern crate minicore; -use minicore::*; - -// Make sure the argument is always passed when explicitly requesting a Windows ABI. -// Our goal here is to match clang: . - -// CHECK: define win64cc void @pass_zst_win64(ptr {{[^,]*}}) -#[no_mangle] -extern "win64" fn pass_zst_win64(_: ()) {} - -// CHECK: define x86_vectorcallcc void @pass_zst_vectorcall(ptr {{[^,]*}}) -#[no_mangle] -extern "vectorcall" fn pass_zst_vectorcall(_: ()) {} - -// windows-gnu: define void @pass_zst_fastcall(ptr {{[^,]*}}) -// windows-msvc: define void @pass_zst_fastcall(ptr {{[^,]*}}) -#[no_mangle] -#[cfg(windows)] // "fastcall" is not valid on 64bit Linux -extern "fastcall" fn pass_zst_fastcall(_: ()) {} - -// The sysv64 ABI ignores ZST. - -// CHECK: define x86_64_sysvcc void @pass_zst_sysv64() -#[no_mangle] -extern "sysv64" fn pass_zst_sysv64(_: ()) {} - -// For `extern "C"` functions, ZST are ignored on Linux put passed on Windows. - -// linux: define void @pass_zst_c() -// windows-msvc: define void @pass_zst_c(ptr {{[^,]*}}) -// windows-gnu: define void @pass_zst_c(ptr {{[^,]*}}) -#[no_mangle] -extern "C" fn pass_zst_c(_: ()) {} diff --git a/tests/codegen-llvm/abi-x86_64-win-zst.rs b/tests/codegen-llvm/abi-x86_64-win-zst.rs new file mode 100644 index 0000000000000..bcb275a78bb82 --- /dev/null +++ b/tests/codegen-llvm/abi-x86_64-win-zst.rs @@ -0,0 +1,149 @@ +//@ add-minicore +//@ compile-flags: -Z merge-functions=disabled + +//@ revisions: windows-gnu +//@[windows-gnu] compile-flags: --target x86_64-pc-windows-gnu +//@[windows-gnu] needs-llvm-components: x86 + +//@ revisions: windows-msvc +//@[windows-msvc] compile-flags: --target x86_64-pc-windows-msvc +//@[windows-msvc] needs-llvm-components: x86 + +// Also test what happens when using a Windows ABI on Linux. +//@ revisions: linux +//@[linux] compile-flags: --target x86_64-unknown-linux-gnu +//@[linux] needs-llvm-components: x86 + +#![feature(no_core, rustc_attrs, abi_vectorcall)] +#![no_core] +#![crate_type = "lib"] + +extern crate minicore; +use minicore::*; + +#[repr(C)] +struct CMaybeZst; + +#[repr(transparent)] +struct CMaybeZst2((), CMaybeZst, ()); + +// Make sure the argument is always passed when explicitly requesting a Windows ABI, +// and it is `repr(C)` - but not if it is `repr(Rust)`. +// Our goal here is to match clang: . + +// CHECK: define win64cc void @pass_rust_zst_win64() +#[no_mangle] +extern "win64" fn pass_rust_zst_win64(_: ()) {} + +// CHECK: define win64cc void @pass_c_maybezst_win64(ptr {{[^,]*}}) +#[no_mangle] +extern "win64" fn pass_c_maybezst_win64(_: CMaybeZst) {} + +// CHECK: define win64cc void @pass_c_maybezst_2_win64(ptr {{[^,]*}}) +#[no_mangle] +extern "win64" fn pass_c_maybezst_2_win64(_: CMaybeZst2) {} + +// CHECK: define x86_vectorcallcc void @pass_rust_zst_vectorcall() +#[no_mangle] +extern "vectorcall" fn pass_rust_zst_vectorcall(_: ()) {} + +// CHECK: define x86_vectorcallcc void @pass_c_maybezst_vectorcall(ptr {{[^,]*}}) +#[no_mangle] +extern "vectorcall" fn pass_c_maybezst_vectorcall(_: CMaybeZst) {} + +// CHECK: define x86_vectorcallcc void @pass_c_maybezst_2_vectorcall(ptr {{[^,]*}}) +#[no_mangle] +extern "vectorcall" fn pass_c_maybezst_2_vectorcall(_: CMaybeZst2) {} + +// windows-gnu: define void @pass_rust_zst_fastcall() +// windows-msvc: define void @pass_rust_zst_fastcall() +#[no_mangle] +#[cfg(windows)] // "fastcall" is not valid on 64bit Linux +extern "fastcall" fn pass_rust_zst_fastcall(_: ()) {} + +// windows-gnu: define void @pass_c_maybezst_fastcall(ptr {{[^,]*}}) +// windows-msvc: define void @pass_c_maybezst_fastcall(ptr {{[^,]*}}) +#[no_mangle] +#[cfg(windows)] // "fastcall" is not valid on 64bit Linux +extern "fastcall" fn pass_c_maybezst_fastcall(_: CMaybeZst) {} + +// windows-gnu: define void @pass_c_maybezst_2_fastcall(ptr {{[^,]*}}) +// windows-msvc: define void @pass_c_maybezst_2_fastcall(ptr {{[^,]*}}) +#[no_mangle] +#[cfg(windows)] // "fastcall" is not valid on 64bit Linux +extern "fastcall" fn pass_c_maybezst_2_fastcall(_: CMaybeZst2) {} + +// The sysv64 ABI ignores ZST. + +// CHECK: define x86_64_sysvcc void @pass_rust_zst_sysv64() +#[no_mangle] +extern "sysv64" fn pass_rust_zst_sysv64(_: ()) {} + +// CHECK: define x86_64_sysvcc void @pass_c_maybezst_sysv64() +#[no_mangle] +extern "sysv64" fn pass_c_maybezst_sysv64(_: CMaybeZst) {} + +// CHECK: define x86_64_sysvcc void @pass_c_maybezst_2_sysv64() +#[no_mangle] +extern "sysv64" fn pass_c_maybezst_2_sysv64(_: CMaybeZst2) {} + +// For `extern "C"` functions, ZST are ignored on Linux put passed on Windows. + +// linux: define void @pass_rust_zst_c() +// windows-msvc: define void @pass_rust_zst_c() +// windows-gnu: define void @pass_rust_zst_c() +#[no_mangle] +extern "C" fn pass_rust_zst_c(_: ()) {} + +// linux: define void @pass_c_maybezst_c() +// windows-msvc: define void @pass_c_maybezst_c(ptr {{[^,]*}}) +// windows-gnu: define void @pass_c_maybezst_c(ptr {{[^,]*}}) +#[no_mangle] +extern "C" fn pass_c_maybezst_c(_: CMaybeZst) {} + +// linux: define void @pass_c_maybezst_2_c() +// windows-msvc: define void @pass_c_maybezst_2_c(ptr {{[^,]*}}) +// windows-gnu: define void @pass_c_maybezst_2_c(ptr {{[^,]*}}) +#[no_mangle] +extern "C" fn pass_c_maybezst_2_c(_: CMaybeZst2) {} + +// Now check `repr(C)` return types. +// Again, we seek to match clang: + +// CHECK: define win64cc void @ret_c_maybezst_win64(ptr {{[^,]*}}) +#[no_mangle] +extern "win64" fn ret_c_maybezst_win64() -> CMaybeZst { + CMaybeZst +} + +// CHECK: define x86_vectorcallcc void @ret_c_maybezst_vectorcall(ptr {{[^,]*}}) +#[no_mangle] +extern "vectorcall" fn ret_c_maybezst_vectorcall() -> CMaybeZst { + CMaybeZst +} + +// windows-gnu: define void @ret_c_maybezst_fastcall(ptr {{[^,]*}}) +// windows-msvc: define void @ret_c_maybezst_fastcall(ptr {{[^,]*}}) +#[no_mangle] +#[cfg(windows)] // "fastcall" is not valid on 64bit Linux +extern "fastcall" fn ret_c_maybezst_fastcall() -> CMaybeZst { + CMaybeZst +} + +// The sysv64 ABI ignores ZST. + +// CHECK: define x86_64_sysvcc void @ret_c_maybezst_sysv64() +#[no_mangle] +extern "sysv64" fn ret_c_maybezst_sysv64() -> CMaybeZst { + CMaybeZst +} + +// For `extern "C"` functions, ZST are ignored on Linux but returned via pointer on Windows. + +// linux: define void @ret_c_maybezst_c() +// windows-msvc: define void @ret_c_maybezst_c(ptr {{[^,]*}}) +// windows-gnu: define void @ret_c_maybezst_c(ptr {{[^,]*}}) +#[no_mangle] +extern "C" fn ret_c_maybezst_c() -> CMaybeZst { + CMaybeZst +} diff --git a/tests/codegen-llvm/complex-abi.rs b/tests/codegen-llvm/complex-abi.rs index 45224bd9316fe..cd0afa1b4dab8 100644 --- a/tests/codegen-llvm/complex-abi.rs +++ b/tests/codegen-llvm/complex-abi.rs @@ -83,16 +83,18 @@ //@ [MIPS64EL] compile-flags: --target mips64el-unknown-linux-gnuabi64 //@ [MIPS64EL] needs-llvm-components: mips +//@ revisions: MIPS MIPSEL +//@ [MIPS] compile-flags: --target mips-unknown-linux-gnu +//@ [MIPS] needs-llvm-components: mips +//@ [MIPSEL] compile-flags: --target mipsel-unknown-linux-gnu +//@ [MIPSEL] needs-llvm-components: mips + // FIXME: the below revisions are deliberately disabled for now. // revisions: POWERPC // [POWERPC] compile-flags: --target powerpc-unknown-linux-gnu // [POWERPC] needs-llvm-components: powerpc -// revisions: MIPS -// [MIPS] compile-flags: --target mips-unknown-linux-gnu -// [MIPS] needs-llvm-components: mips - // revisions: NVPTX // [NVPTX] compile-flags: --target nvptx64-nvidia-cuda // [NVPTX] needs-llvm-components: nvptx @@ -151,7 +153,8 @@ pub extern "C" fn cplx_f32(x: Complex) -> Complex { // LOONGARCH64: define{{.*}} { float, float } @cplx_f32({ float, float } {{.*}}) // MIPS64: define{{.*}} { float, float } @cplx_f32([2 x float] {{.*}}) // MIPS64EL: define{{.*}} { float, float } @cplx_f32([2 x float] {{.*}}) - // MIPS: define{{.*}} { float, float } @cplx_f32([2 x i32] {{.*}}) + // MIPS: define{{.*}} [2 x float] @cplx_f32([2 x i32] {{.*}}) + // MIPSEL: define{{.*}} [2 x float] @cplx_f32([2 x i32] {{.*}}) // NVPTX: define{{.*}} { float, float } @cplx_f32(ptr {{.*}} byval({ float, float }) {{.*}}) // POWERPC64: define{{.*}} { float, float } @cplx_f32({ float, float } %0) // POWERPC64LE: define{{.*}} { float, float } @cplx_f32({ float, float } %0) @@ -186,7 +189,8 @@ pub extern "C" fn cplx_f64(x: Complex) -> Complex { // LOONGARCH64: define{{.*}} { double, double } @cplx_f64({ double, double } {{.*}}) // MIPS64: define{{.*}} { double, double } @cplx_f64([2 x double] {{.*}}) // MIPS64EL: define{{.*}} { double, double } @cplx_f64([2 x double] {{.*}}) - // MIPS: define{{.*}} { double, double } @cplx_f64(i32 {{.*}}, i32 {{.*}}, i32 {{.*}}, i32 {{.*}}) + // MIPS: define{{.*}} [2 x double] @cplx_f64([4 x i32] {{.*}}) + // MIPSEL: define{{.*}} [2 x double] @cplx_f64([4 x i32] {{.*}}) // NVPTX: define{{.*}} { double, double } @cplx_f64(ptr {{.*}} byval({ double, double }) {{.*}}) // POWERPC64: define{{.*}} { double, double } @cplx_f64({ double, double } %0) // POWERPC64LE: define{{.*}} { double, double } @cplx_f64({ double, double } %0) @@ -238,7 +242,8 @@ pub extern "C" fn cplx_i8(x: Complex) -> Complex { // LOONGARCH64: define{{.*}} i64 @cplx_i8(i64{{.*}}) // MIPS64: define{{.*}} i16 @cplx_i8(i16 inreg {{.*}}) // MIPS64EL: define{{.*}} i16 @cplx_i8(i16 inreg {{.*}}) - // MIPS: define{{.*}} { i8, i8 } @cplx_i8(i16 {{.*}}) + // MIPS: define{{.*}} i16 @cplx_i8(i32 {{.*}}) + // MIPSEL: define{{.*}} i16 @cplx_i8(i32 {{.*}}) // NVPTX: define{{.*}} { i8, i8 } @cplx_i8(ptr {{.*}} byval({ i8, i8 }) {{.*}}) // POWERPC64: define{{.*}} { i8, i8 } @cplx_i8({ i8, i8 } %0) // POWERPC64LE: define{{.*}} { i8, i8 } @cplx_i8({ i8, i8 } %0) @@ -273,7 +278,8 @@ pub extern "C" fn cplx_i16(x: Complex) -> Complex { // LOONGARCH64: define{{.*}} i64 @cplx_i16(i64{{.*}}) // MIPS64: define{{.*}} i32 @cplx_i16(i32 inreg {{.*}}) // MIPS64EL: define{{.*}} i32 @cplx_i16(i32 inreg {{.*}}) - // MIPS: define{{.*}} { i16, i16 } @cplx_i16(i32 {{.*}}) + // MIPS: define{{.*}} i32 @cplx_i16(i32 {{.*}}) + // MIPSEL: define{{.*}} i32 @cplx_i16(i32 {{.*}}) // NVPTX: define{{.*}} { i16, i16 } @cplx_i16(ptr {{.*}} byval({ i16, i16 }) {{.*}}) // POWERPC64: define{{.*}} { i16, i16 } @cplx_i16(i16 {{.*}}, i16 {{.*}}) // POWERPC64LE: define{{.*}} { i16, i16 } @cplx_i16(i16 {{.*}}, i16 {{.*}}) @@ -308,7 +314,8 @@ pub extern "C" fn cplx_i32(x: Complex) -> Complex { // LOONGARCH64: define{{.*}} i64 @cplx_i32(i64 {{.*}}) // MIPS64: define{{.*}} i64 @cplx_i32(i64 inreg {{.*}}) // MIPS64EL: define{{.*}} i64 @cplx_i32(i64 inreg {{.*}}) - // MIPS: define{{.*}} { i32, i32 } @cplx_i32(i32 {{.*}}, i32 {{.*}}) + // MIPS: define{{.*}} [2 x i32] @cplx_i32([2 x i32] {{.*}}) + // MIPSEL: define{{.*}} [2 x i32] @cplx_i32([2 x i32] {{.*}}) // NVPTX: define{{.*}} { i32, i32 } @cplx_i32(ptr {{.*}} byval({ i32, i32 }) {{.*}}) // POWERPC64: define{{.*}} { i32, i32 } @cplx_i32({ i32, i32 } %0) // POWERPC64LE: define{{.*}} { i32, i32 } @cplx_i32({ i32, i32 } %0) @@ -343,7 +350,8 @@ pub extern "C" fn cplx_i64(x: Complex) -> Complex { // LOONGARCH64: define{{.*}} [2 x i64] @cplx_i64([2 x i64] {{.*}}) // MIPS64: define{{.*}} { i64, i64 } @cplx_i64(i128 {{.*}}) // MIPS64EL: define{{.*}} { i64, i64 } @cplx_i64(i128 {{.*}}) - // MIPS: define{{.*}} { i64, i64 } @cplx_i64(i32 {{.*}}, i32 {{.*}}, i32 {{.*}}, i32 {{.*}}) + // MIPS: define{{.*}} [2 x i64] @cplx_i64([4 x i32] {{.*}}) + // MIPSEL: define{{.*}} [2 x i64] @cplx_i64([4 x i32] {{.*}}) // NVPTX: define{{.*}} { i64, i64 } @cplx_i64(ptr {{.*}} byval({ i64, i64 }) {{.*}}) // POWERPC64: define{{.*}} { i64, i64 } @cplx_i64({ i64, i64 } %0) // POWERPC64LE: define{{.*}} { i64, i64 } @cplx_i64({ i64, i64 } %0) @@ -383,7 +391,8 @@ pub extern "C" fn wrapper_cplx_i64( // LOONGARCH64: define{{.*}} [2 x i64] @wrapper_cplx_i64([2 x i64] {{.*}}) // MIPS64: define{{.*}} { i64, i64 } @wrapper_cplx_i64(i128 {{.*}}) // MIPS64EL: define{{.*}} { i64, i64 } @wrapper_cplx_i64(i128 {{.*}}) - // MIPS: define{{.*}} { i64, i64 } @wrapper_cplx_i64(i32 {{.*}}, i32 {{.*}}, i32 {{.*}}, i32 {{.*}}) + // MIPS: define{{.*}} [2 x i64] @wrapper_cplx_i64([4 x i32] {{.*}}) + // MIPSEL: define{{.*}} [2 x i64] @wrapper_cplx_i64([4 x i32] {{.*}}) // NVPTX: define{{.*}} { i64, i64 } @wrapper_cplx_i64(ptr {{.*}} byval({ i64, i64 }) {{.*}}) // POWERPC64: define{{.*}} { i64, i64 } @wrapper_cplx_i64({ i64, i64 } %0) // POWERPC64LE: define{{.*}} { i64, i64 } @wrapper_cplx_i64({ i64, i64 } %0) diff --git a/tests/codegen-llvm/stack-protector.rs b/tests/codegen-llvm/stack-protector.rs index 8ab25b470cda1..1d8657b0b6226 100644 --- a/tests/codegen-llvm/stack-protector.rs +++ b/tests/codegen-llvm/stack-protector.rs @@ -1,8 +1,8 @@ //@ revisions: all strong basic none //@ ignore-nvptx64 stack protector not supported -//@ [all] compile-flags: -Z stack-protector=all -//@ [strong] compile-flags: -Z stack-protector=strong -//@ [basic] compile-flags: -Z stack-protector=basic +//@ [all] compile-flags: -Z stack-protector=all -Z allow-partial-mitigations=stack-protector +//@ [strong] compile-flags: -Z stack-protector=strong -Z allow-partial-mitigations=stack-protector +//@ [basic] compile-flags: -Z stack-protector=basic -Z allow-partial-mitigations=stack-protector #![crate_type = "lib"] diff --git a/tests/run-make/staticlib-rename-internal-symbols-coff/decorated_lib.rs b/tests/run-make/staticlib-rename-internal-symbols-coff/decorated_lib.rs new file mode 100644 index 0000000000000..698a9a8168f85 --- /dev/null +++ b/tests/run-make/staticlib-rename-internal-symbols-coff/decorated_lib.rs @@ -0,0 +1,38 @@ +#![crate_type = "staticlib"] +#![feature(abi_vectorcall)] + +#[no_mangle] +pub extern "C" fn decorated_cdecl(a: i32, b: i32) -> i32 { + a + b +} + +// stdcall/fastcall are decorated only on x86; elsewhere they are deprecated aliases for "C". +#[cfg(target_arch = "x86")] +#[no_mangle] +pub extern "stdcall" fn decorated_stdcall(a: i32, b: i32) -> i32 { + a + b +} + +#[cfg(target_arch = "x86")] +#[no_mangle] +pub extern "fastcall" fn decorated_fastcall(a: i32, b: i32) -> i32 { + a + b +} + +// vectorcall is x86/x86_64-only and MSVC-only (GCC does not support it). A single `u64` +// argument is 8 bytes on both x86 (4-byte pointer width, rounded up) and x86_64, so its `@@N` +// decoration suffix is a stable `@@8` regardless of target. +#[cfg(all(target_env = "msvc", any(target_arch = "x86", target_arch = "x86_64")))] +#[no_mangle] +pub extern "vectorcall" fn decorated_vectorcall(x: u64) -> u64 { + x +} + +fn internal_decorated_helper() -> i32 { + 1 +} + +#[no_mangle] +pub extern "C" fn decorated_calls_internal() -> i32 { + internal_decorated_helper() + 1 +} diff --git a/tests/run-make/staticlib-rename-internal-symbols-coff/rmake.rs b/tests/run-make/staticlib-rename-internal-symbols-coff/rmake.rs index 0b3f445a6ec70..12ddd353bc24d 100644 --- a/tests/run-make/staticlib-rename-internal-symbols-coff/rmake.rs +++ b/tests/run-make/staticlib-rename-internal-symbols-coff/rmake.rs @@ -1,3 +1,8 @@ +//! Tests that `-Zstaticlib-rename-internal-symbols` renames internal symbols on COFF targets +//! while leaving exported symbols untouched, taking COFF decoration (i686 cdecl `_` / +//! stdcall `_@N` / fastcall `@N` / vectorcall `@@N`, Arm64EC text `#`) into account so decorated +//! exported symbols are neither renamed nor missed. + //@ only-windows //@ ignore-cross-compile @@ -7,9 +12,12 @@ use run_make_support::object::read::archive::ArchiveFile; use run_make_support::object::read::coff::ImageSymbol as _; use run_make_support::object::{File, pe}; use run_make_support::path_helpers::source_root; -use run_make_support::{cc, extra_c_flags, rfs, run, rustc, static_lib_name}; +use run_make_support::{ + cc, extra_c_flags, is_windows_msvc, rfs, run, rustc, static_lib_name, target, +}; -const EXPORTED: &[&str] = &["my_add", "my_hash_lookup", "call_internal", "my_safe_div"]; +/// The undecorated exported names of the base fixture (`lib.rs`). +const BASE_EXPORTED: &[&str] = &["my_add", "my_hash_lookup", "call_internal", "my_safe_div"]; fn main() { let hide_sibling = source_root().join("tests/run-make/staticlib-hide-internal-symbols"); @@ -24,65 +32,49 @@ fn main() { test_rs_suffix_present(); test_dual_staticlib_linking(); test_hide_and_rename(); + test_decorated_symbols(); } -fn test_basic_functionality() { - let lib_name = static_lib_name("lib"); - +/// Compile `.rs` into a staticlib under `-Zstaticlib-rename-internal-symbols`. +fn compile_staticlib(crate_name: &str) -> String { + let lib_name = static_lib_name(crate_name); rustc() - .input("lib.rs") + .input(format!("{crate_name}.rs")) .crate_type("staticlib") .arg("-Zstaticlib-rename-internal-symbols") .opt() .run(); + lib_name +} - cc().input("main.c").input(&lib_name).out_exe("main").args(extra_c_flags()).run(); - run("main"); +/// Link `main_c` against `libs` into `exe`, then run it. +fn link_and_run(main_c: &str, libs: &[&str], exe: &str) { + let mut cmd = cc(); + cmd.input(main_c); + for lib in libs { + cmd.input(*lib); + } + cmd.out_exe(exe).args(extra_c_flags()).run(); + run(exe); +} - rfs::remove_file(&lib_name); +fn test_basic_functionality() { + let lib = compile_staticlib("lib"); + link_and_run("main.c", &[lib.as_str()], "main"); + rfs::remove_file(&lib); } fn test_rs_suffix_present() { - let lib_name = static_lib_name("lib"); - - rustc() - .input("lib.rs") - .crate_type("staticlib") - .arg("-Zstaticlib-rename-internal-symbols") - .opt() - .run(); - - let data = rfs::read(&lib_name); - check_rename_symbols(&data); - - rfs::remove_file(&lib_name); + let lib = compile_staticlib("lib"); + let data = rfs::read(&lib); + check_rename_symbols(&data, BASE_EXPORTED, MatchMode::Undecorated); + rfs::remove_file(&lib); } fn test_dual_staticlib_linking() { - let liba_name = static_lib_name("liba"); - let libb_name = static_lib_name("libb"); - - rustc() - .input("liba.rs") - .crate_type("staticlib") - .arg("-Zstaticlib-rename-internal-symbols") - .opt() - .run(); - - rustc() - .input("libb.rs") - .crate_type("staticlib") - .arg("-Zstaticlib-rename-internal-symbols") - .opt() - .run(); - - cc().input("dual_main.c") - .input(&liba_name) - .input(&libb_name) - .out_exe("dual_main") - .args(extra_c_flags()) - .run(); - run("dual_main"); + let liba = compile_staticlib("liba"); + let libb = compile_staticlib("libb"); + link_and_run("dual_main.c", &[liba.as_str(), libb.as_str()], "dual_main"); } /// On COFF, hiding is unsupported and must only produce a warning, while @@ -103,15 +95,50 @@ fn test_hide_and_rename() { .assert_exit_code(0); let data = rfs::read(&lib_name); - check_rename_symbols(&data); - - cc().input("main.c").input(&lib_name).out_exe("main").args(extra_c_flags()).run(); - run("main"); + check_rename_symbols(&data, BASE_EXPORTED, MatchMode::Undecorated); + link_and_run("main.c", &[lib_name.as_str()], "main"); rfs::remove_file(&lib_name); } -fn check_rename_symbols(archive_data: &[u8]) { +/// Assert the stdcall/fastcall/vectorcall exports (`_@N` / `@N` / `@@N`) don't get renamed +/// into their undecorated form. +fn test_decorated_symbols() { + let lib = compile_staticlib("decorated_lib"); + let data = rfs::read(&lib); + check_rename_symbols(&data, &decorated_exports(), MatchMode::Raw); + rfs::remove_file(&lib); +} + +/// Raw decorated names `decorated_lib.rs` emits: i686 cdecl `_`, stdcall `_@N`, fastcall `@N`, +/// and vectorcall `@@N` (MSVC x86/x86_64 only). +fn decorated_exports() -> Vec<&'static str> { + let mut exports = if target().starts_with("i686") { + vec![ + "_decorated_cdecl", + "_decorated_calls_internal", + "_decorated_stdcall@8", + "@decorated_fastcall@8", + ] + } else { + vec!["decorated_cdecl", "decorated_calls_internal"] + }; + if is_windows_msvc() && (target().starts_with("i686") || target().starts_with("x86_64")) { + exports.push("decorated_vectorcall@@8"); + } + exports +} + +/// How exported symbol names are matched against the object file's symbol table. +#[derive(Clone, Copy)] +enum MatchMode { + /// Strip the target's leading prefix (`_` i686 cdecl, `#` Arm64EC text) before matching. + Undecorated, + /// Match raw object-file names verbatim. + Raw, +} + +fn check_rename_symbols(archive_data: &[u8], exported: &[&str], mode: MatchMode) { let archive = ArchiveFile::parse(archive_data).unwrap(); let mut found_exported = HashSet::new(); let mut found_rs_suffix = false; @@ -125,19 +152,29 @@ fn check_rename_symbols(archive_data: &[u8]) { // parse directly from the borrowed slice. let data = member.data(archive_data).unwrap(); match File::parse(data) { - Ok(File::Coff(f)) => { - check_coff_symbols(f.coff_header(), data, &mut found_exported, &mut found_rs_suffix) - } - Ok(File::CoffBig(f)) => { - check_coff_symbols(f.coff_header(), data, &mut found_exported, &mut found_rs_suffix) - } + Ok(File::Coff(f)) => check_coff_symbols( + f.coff_header(), + data, + exported, + mode, + &mut found_exported, + &mut found_rs_suffix, + ), + Ok(File::CoffBig(f)) => check_coff_symbols( + f.coff_header(), + data, + exported, + mode, + &mut found_exported, + &mut found_rs_suffix, + ), Ok(_) => panic!("unexpected object file format in archive member"), Err(e) => panic!("failed to parse archive member: {e}"), } } assert!(found_rs_suffix, "expected to find at least one renamed symbol with .rs suffix"); - for expected in EXPORTED { + for expected in exported { assert!( found_exported.contains(*expected), "expected to find exported symbol `{expected}` in archive" @@ -148,6 +185,8 @@ fn check_rename_symbols(archive_data: &[u8]) { fn check_coff_symbols( header: &Coff, data: &[u8], + exported: &[&str], + mode: MatchMode, found_exported: &mut HashSet, found_rs_suffix: &mut bool, ) { @@ -178,18 +217,19 @@ fn check_coff_symbols( let Ok(name_bytes) = symbol.name(strings) else { continue }; let Ok(mut name) = str::from_utf8(name_bytes).map(String::from) else { continue }; - // Adjust for various symbol decorations. - match header.machine() { - pe::IMAGE_FILE_MACHINE_I386 => { - name = name.strip_prefix('_').unwrap_or(&name).to_string(); - } - pe::IMAGE_FILE_MACHINE_ARM64EC => { - name = name.strip_prefix('#').unwrap_or(&name).to_string(); + if matches!(mode, MatchMode::Undecorated) { + match header.machine() { + pe::IMAGE_FILE_MACHINE_I386 => { + name = name.strip_prefix('_').unwrap_or(&name).to_string(); + } + pe::IMAGE_FILE_MACHINE_ARM64EC => { + name = name.strip_prefix('#').unwrap_or(&name).to_string(); + } + _ => {} } - _ => {} } - if EXPORTED.contains(&name.as_str()) { + if exported.contains(&name.as_str()) { assert!( !name.contains(".rs"), "exported symbol `{name}` should not contain .rs suffix" diff --git a/tests/ui-fulldeps/internal-lints/missing-generic-type-visitable-derive.rs b/tests/ui-fulldeps/internal-lints/missing-generic-type-visitable-derive.rs new file mode 100644 index 0000000000000..d92cb12cf9a54 --- /dev/null +++ b/tests/ui-fulldeps/internal-lints/missing-generic-type-visitable-derive.rs @@ -0,0 +1,130 @@ +//@ compile-flags: -Z unstable-options +// FIXME(bootstrap): Remove the ignore once we promote the next beta. +//@ ignore-stage1 + +#![crate_type = "lib"] +#![feature(rustc_private)] +#![deny(rustc::missing_generic_type_visitable_derive)] + +extern crate rustc_type_ir; +extern crate rustc_type_ir_macros; + +use rustc_type_ir::{GenericTypeVisitable, TypeVisitable}; +use rustc_type_ir::{Interner, TypeVisitor, VisitorResult}; +use rustc_type_ir_macros::{GenericTypeVisitable, TypeVisitable_Generic}; +use std::{fmt::Debug, hash::Hash}; + +// Should lint: `TypeVisitable` is implemented, but `GenericTypeVisitable` isn't + +#[derive(Debug, TypeVisitable_Generic)] +struct DerivesRegular; +//~^ ERROR missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable` + +#[derive(Debug)] +struct ImplsRegular; +//~^ ERROR missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable` + +impl TypeVisitable for ImplsRegular { + fn visit_with>(&self, _f: &mut F) -> F::Result { + F::Result::output() + } +} + +// Same but with an enum + +#[derive(Debug, TypeVisitable_Generic)] +enum EnumDerivesRegular {} +//~^ ERROR missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable` + +// Same but the type is generic, over the interner + +#[derive(TypeVisitable_Generic)] +struct GenericOverIDerivesRegular(I::Clause); +//~^ ERROR missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable` + +// manually hand-rolled `#[derive_where(Debug; I: Interner)]` +impl std::fmt::Debug for GenericOverIDerivesRegular { + fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { + todo!() + } +} + +// Same but the type is generic, over an unrelated type + +#[derive(TypeVisitable_Generic)] +struct GenericOverTDerivesRegular([T; 67]); +//~^ ERROR missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable` + +// manually hand-rolled `#[derive(Debug)]`, to avoid the spurious bound on `T` +impl Debug for GenericOverTDerivesRegular { + fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { + todo!() + } +} + +// Should not lint: both traits are implemented + +#[derive(Debug, TypeVisitable_Generic, GenericTypeVisitable)] +struct DerivesBoth; + +#[derive(Debug, GenericTypeVisitable)] +struct ImplsAndDerives; + +impl TypeVisitable for ImplsAndDerives { + fn visit_with>(&self, _f: &mut F) -> F::Result { + F::Result::output() + } +} + +#[derive(Debug, TypeVisitable_Generic)] +struct DerivesAndImpls; + +unsafe impl GenericTypeVisitable for DerivesAndImpls { + fn generic_visit_with(&self, _visitor: &mut V) {} +} + +#[derive(Debug)] +struct ImplsBoth; + +impl TypeVisitable for ImplsBoth { + fn visit_with>(&self, _f: &mut F) -> F::Result { + F::Result::output() + } +} + +unsafe impl GenericTypeVisitable for ImplsBoth { + fn generic_visit_with(&self, _visitor: &mut V) {} +} + +// Should not lint: `TypeVisitable` isn't implemented, so `GenericTypeVisitable` doesn't need to be +// either + +struct ImplsNone; + +// Should not lint: `GenericTypeVisitable` is implemented but `TypeVisitable` isn't -- weird, but +// okay for the purposes of this lint + +#[derive(GenericTypeVisitable)] +struct DerivesGeneric; + +struct ImplsGeneric; + +unsafe impl GenericTypeVisitable for ImplsGeneric { + fn generic_visit_with(&self, _visitor: &mut V) {} +} + +// FIXME(ada4a): this will currently lint, and suggest adding a derive, even though ther's already +// one present. The actual problem is that the item has a _field_ that doesn't implement the trait, +// which makes the impl generated by the derive on this item unusable due to unsatisfied bounds. +// +// There are two ways of solving this: +// - in the lint, emit a different suggestion -- namely, to add a derive to the problematic field's +// type -- if we see that the linted type already has a derive. +// - change the derive to add _assertions_ that the bound holds for each field type, and not just +// trait bounds on the impl. +#[derive(Debug)] +#[derive(TypeVisitable_Generic, GenericTypeVisitable)] +struct FieldDoesntImplGeneric { + //~^ ERROR missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable` + field: ImplsRegular, +} diff --git a/tests/ui-fulldeps/internal-lints/missing-generic-type-visitable-derive.stderr b/tests/ui-fulldeps/internal-lints/missing-generic-type-visitable-derive.stderr new file mode 100644 index 0000000000000..94e1297adab27 --- /dev/null +++ b/tests/ui-fulldeps/internal-lints/missing-generic-type-visitable-derive.stderr @@ -0,0 +1,65 @@ +error: missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable` + --> $DIR/missing-generic-type-visitable-derive.rs:20:1 + | +LL | struct DerivesRegular; + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `GenericTypeVisitable` is rust-analyzer's version of `TypeVisitable`; it should be implemented whenever the latter is + = help: mark the type with `#[derive(GenericTypeVisitable)]` + = help: or, if `GenericTypeVisitable` is derived, check whether all fields implement `GenericTypeVisitable` +note: the lint level is defined here + --> $DIR/missing-generic-type-visitable-derive.rs:7:9 + | +LL | #![deny(rustc::missing_generic_type_visitable_derive)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable` + --> $DIR/missing-generic-type-visitable-derive.rs:24:1 + | +LL | struct ImplsRegular; + | ^^^^^^^^^^^^^^^^^^^^ + | + = help: mark the type with `#[derive(GenericTypeVisitable)]` + = help: or, if `GenericTypeVisitable` is derived, check whether all fields implement `GenericTypeVisitable` + +error: missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable` + --> $DIR/missing-generic-type-visitable-derive.rs:36:1 + | +LL | enum EnumDerivesRegular {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: mark the type with `#[derive(GenericTypeVisitable)]` + = help: or, if `GenericTypeVisitable` is derived, check whether all fields implement `GenericTypeVisitable` + +error: missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable` + --> $DIR/missing-generic-type-visitable-derive.rs:42:1 + | +LL | struct GenericOverIDerivesRegular(I::Clause); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: mark the type with `#[derive(GenericTypeVisitable)]` + = help: or, if `GenericTypeVisitable` is derived, check whether all fields implement `GenericTypeVisitable` + +error: missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable` + --> $DIR/missing-generic-type-visitable-derive.rs:55:1 + | +LL | struct GenericOverTDerivesRegular([T; 67]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: mark the type with `#[derive(GenericTypeVisitable)]` + = help: or, if `GenericTypeVisitable` is derived, check whether all fields implement `GenericTypeVisitable` + +error: missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable` + --> $DIR/missing-generic-type-visitable-derive.rs:127:1 + | +LL | / struct FieldDoesntImplGeneric { +LL | | +LL | | field: ImplsRegular, +LL | | } + | |_^ + | + = help: mark the type with `#[derive(GenericTypeVisitable)]` + = help: or, if `GenericTypeVisitable` is derived, check whether all fields implement `GenericTypeVisitable` + +error: aborting due to 6 previous errors + diff --git a/tests/ui/abi/c-zst.aarch64-darwin.stderr b/tests/ui/abi/c-zst.aarch64-darwin.stderr index 2ed9ffdf791f6..9241ea32d9693 100644 --- a/tests/ui/abi/c-zst.aarch64-darwin.stderr +++ b/tests/ui/abi/c-zst.aarch64-darwin.stderr @@ -22,6 +22,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: 0, }, }, @@ -50,6 +51,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: 0, }, }, diff --git a/tests/ui/abi/c-zst.powerpc-linux.stderr b/tests/ui/abi/c-zst.powerpc-linux.stderr index 0c7a6b664526d..9241ea32d9693 100644 --- a/tests/ui/abi/c-zst.powerpc-linux.stderr +++ b/tests/ui/abi/c-zst.powerpc-linux.stderr @@ -22,21 +22,11 @@ error: fn_abi_of(pass_zst) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: 0, }, }, - mode: Indirect { - attrs: ArgAttributes { - regular: CapturesAddress | NoAlias | NonNull | NoUndef | NoFree, - arg_ext: None, - pointee_size: Size(0 bytes), - pointee_align: Some( - Align(1 bytes), - ), - }, - address_space: None, - mode: Pointer, - }, + mode: Ignore, }, ], ret: ArgAbi { @@ -61,6 +51,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: 0, }, }, diff --git a/tests/ui/abi/c-zst.s390x-linux.stderr b/tests/ui/abi/c-zst.s390x-linux.stderr index 0c7a6b664526d..9241ea32d9693 100644 --- a/tests/ui/abi/c-zst.s390x-linux.stderr +++ b/tests/ui/abi/c-zst.s390x-linux.stderr @@ -22,21 +22,11 @@ error: fn_abi_of(pass_zst) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: 0, }, }, - mode: Indirect { - attrs: ArgAttributes { - regular: CapturesAddress | NoAlias | NonNull | NoUndef | NoFree, - arg_ext: None, - pointee_size: Size(0 bytes), - pointee_align: Some( - Align(1 bytes), - ), - }, - address_space: None, - mode: Pointer, - }, + mode: Ignore, }, ], ret: ArgAbi { @@ -61,6 +51,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: 0, }, }, diff --git a/tests/ui/abi/c-zst.sparc-linux.stderr b/tests/ui/abi/c-zst.sparc-linux.stderr index 0c7a6b664526d..da26a7b651ddd 100644 --- a/tests/ui/abi/c-zst.sparc-linux.stderr +++ b/tests/ui/abi/c-zst.sparc-linux.stderr @@ -22,6 +22,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: 0, }, }, @@ -61,6 +62,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: 0, }, }, diff --git a/tests/ui/abi/c-zst.sparc-none.stderr b/tests/ui/abi/c-zst.sparc-none.stderr index 0c7a6b664526d..da26a7b651ddd 100644 --- a/tests/ui/abi/c-zst.sparc-none.stderr +++ b/tests/ui/abi/c-zst.sparc-none.stderr @@ -22,6 +22,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: 0, }, }, @@ -61,6 +62,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: 0, }, }, diff --git a/tests/ui/abi/c-zst.sparc64-linux.stderr b/tests/ui/abi/c-zst.sparc64-linux.stderr index 0c7a6b664526d..9241ea32d9693 100644 --- a/tests/ui/abi/c-zst.sparc64-linux.stderr +++ b/tests/ui/abi/c-zst.sparc64-linux.stderr @@ -22,21 +22,11 @@ error: fn_abi_of(pass_zst) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: 0, }, }, - mode: Indirect { - attrs: ArgAttributes { - regular: CapturesAddress | NoAlias | NonNull | NoUndef | NoFree, - arg_ext: None, - pointee_size: Size(0 bytes), - pointee_align: Some( - Align(1 bytes), - ), - }, - address_space: None, - mode: Pointer, - }, + mode: Ignore, }, ], ret: ArgAbi { @@ -61,6 +51,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: 0, }, }, diff --git a/tests/ui/abi/c-zst.x86_64-linux.stderr b/tests/ui/abi/c-zst.x86_64-linux.stderr index 2ed9ffdf791f6..9241ea32d9693 100644 --- a/tests/ui/abi/c-zst.x86_64-linux.stderr +++ b/tests/ui/abi/c-zst.x86_64-linux.stderr @@ -22,6 +22,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: 0, }, }, @@ -50,6 +51,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: 0, }, }, diff --git a/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr b/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr index 0c7a6b664526d..9241ea32d9693 100644 --- a/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr +++ b/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr @@ -22,21 +22,11 @@ error: fn_abi_of(pass_zst) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: 0, }, }, - mode: Indirect { - attrs: ArgAttributes { - regular: CapturesAddress | NoAlias | NonNull | NoUndef | NoFree, - arg_ext: None, - pointee_size: Size(0 bytes), - pointee_align: Some( - Align(1 bytes), - ), - }, - address_space: None, - mode: Pointer, - }, + mode: Ignore, }, ], ret: ArgAbi { @@ -61,6 +51,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: 0, }, }, diff --git a/tests/ui/abi/debug.generic.stderr b/tests/ui/abi/debug.generic.stderr index fd72327d42fd7..6f2b69f80ae45 100644 --- a/tests/ui/abi/debug.generic.stderr +++ b/tests/ui/abi/debug.generic.stderr @@ -52,6 +52,7 @@ error: fn_abi_of(test) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -90,6 +91,7 @@ error: fn_abi_of(test) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -136,6 +138,7 @@ error: fn_abi_of(test_unsized) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -182,6 +185,7 @@ error: fn_abi_of(test_unsized) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -231,6 +235,7 @@ error: fn_abi_of(TestFnPtr) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -263,6 +268,7 @@ error: fn_abi_of(TestFnPtr) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -306,6 +312,7 @@ error: fn_abi_of(test_generic) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -341,6 +348,7 @@ error: fn_abi_of(test_generic) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -384,6 +392,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -419,6 +428,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -450,6 +460,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -485,6 +496,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -525,6 +537,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -564,6 +577,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -598,6 +612,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -637,6 +652,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -674,6 +690,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -709,6 +726,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -740,6 +758,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -775,6 +794,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -812,6 +832,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -847,6 +868,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -878,6 +900,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -913,6 +936,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -970,6 +994,7 @@ error: fn_abi_of(assoc_test) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -1007,6 +1032,7 @@ error: fn_abi_of(assoc_test) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, diff --git a/tests/ui/abi/debug.loongarch64.stderr b/tests/ui/abi/debug.loongarch64.stderr index 15d76f6e32078..2159753e15fcd 100644 --- a/tests/ui/abi/debug.loongarch64.stderr +++ b/tests/ui/abi/debug.loongarch64.stderr @@ -52,6 +52,7 @@ error: fn_abi_of(test) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -90,6 +91,7 @@ error: fn_abi_of(test) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -136,6 +138,7 @@ error: fn_abi_of(test_unsized) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -182,6 +185,7 @@ error: fn_abi_of(test_unsized) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -231,6 +235,7 @@ error: fn_abi_of(TestFnPtr) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -263,6 +268,7 @@ error: fn_abi_of(TestFnPtr) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -306,6 +312,7 @@ error: fn_abi_of(test_generic) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -341,6 +348,7 @@ error: fn_abi_of(test_generic) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -384,6 +392,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -419,6 +428,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -450,6 +460,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -485,6 +496,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -525,6 +537,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -564,6 +577,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -598,6 +612,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -637,6 +652,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -674,6 +690,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -709,6 +726,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -740,6 +758,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -775,6 +794,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -812,6 +832,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -847,6 +868,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -878,6 +900,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -913,6 +936,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -970,6 +994,7 @@ error: fn_abi_of(assoc_test) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -1007,6 +1032,7 @@ error: fn_abi_of(assoc_test) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, diff --git a/tests/ui/abi/debug.riscv64.stderr b/tests/ui/abi/debug.riscv64.stderr index 15d76f6e32078..2159753e15fcd 100644 --- a/tests/ui/abi/debug.riscv64.stderr +++ b/tests/ui/abi/debug.riscv64.stderr @@ -52,6 +52,7 @@ error: fn_abi_of(test) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -90,6 +91,7 @@ error: fn_abi_of(test) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -136,6 +138,7 @@ error: fn_abi_of(test_unsized) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -182,6 +185,7 @@ error: fn_abi_of(test_unsized) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -231,6 +235,7 @@ error: fn_abi_of(TestFnPtr) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -263,6 +268,7 @@ error: fn_abi_of(TestFnPtr) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -306,6 +312,7 @@ error: fn_abi_of(test_generic) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -341,6 +348,7 @@ error: fn_abi_of(test_generic) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -384,6 +392,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -419,6 +428,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -450,6 +460,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -485,6 +496,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -525,6 +537,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -564,6 +577,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -598,6 +612,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -637,6 +652,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -674,6 +690,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -709,6 +726,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -740,6 +758,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -775,6 +794,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -812,6 +832,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -847,6 +868,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -878,6 +900,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -913,6 +936,7 @@ error: ABIs are not compatible }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -970,6 +994,7 @@ error: fn_abi_of(assoc_test) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, @@ -1007,6 +1032,7 @@ error: fn_abi_of(assoc_test) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: $SEED, }, }, diff --git a/tests/ui/abi/numbers-arithmetic/x86-64-sysv64-arg-ext.other.stderr b/tests/ui/abi/numbers-arithmetic/x86-64-sysv64-arg-ext.other.stderr index cbe389c42d40a..f8e8cbfae6af5 100644 --- a/tests/ui/abi/numbers-arithmetic/x86-64-sysv64-arg-ext.other.stderr +++ b/tests/ui/abi/numbers-arithmetic/x86-64-sysv64-arg-ext.other.stderr @@ -19,6 +19,7 @@ error: fn_abi_of(i8) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: 71776123356184577, }, }, @@ -51,6 +52,7 @@ error: fn_abi_of(i8) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: 71776123356184577, }, }, @@ -96,6 +98,7 @@ error: fn_abi_of(u8) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: 71776127651151873, }, }, @@ -128,6 +131,7 @@ error: fn_abi_of(u8) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: 71776127651151873, }, }, @@ -173,6 +177,7 @@ error: fn_abi_of(i16) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), + repr_c: false, randomization_seed: 18446462603027808258, }, }, @@ -205,6 +210,7 @@ error: fn_abi_of(i16) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), + repr_c: false, randomization_seed: 18446462603027808258, }, }, @@ -250,6 +256,7 @@ error: fn_abi_of(u16) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), + repr_c: false, randomization_seed: 18446462607322775554, }, }, @@ -282,6 +289,7 @@ error: fn_abi_of(u16) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), + repr_c: false, randomization_seed: 18446462607322775554, }, }, @@ -327,6 +335,7 @@ error: fn_abi_of(i32) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: false, randomization_seed: 18446462603027873795, }, }, @@ -359,6 +368,7 @@ error: fn_abi_of(i32) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: false, randomization_seed: 18446462603027873795, }, }, @@ -404,6 +414,7 @@ error: fn_abi_of(u32) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: false, randomization_seed: 18446462607322841091, }, }, @@ -436,6 +447,7 @@ error: fn_abi_of(u32) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: false, randomization_seed: 18446462607322841091, }, }, diff --git a/tests/ui/abi/pass-indirectly-attr.stderr b/tests/ui/abi/pass-indirectly-attr.stderr index 76d07c553a1a0..6231c8b2682da 100644 --- a/tests/ui/abi/pass-indirectly-attr.stderr +++ b/tests/ui/abi/pass-indirectly-attr.stderr @@ -35,6 +35,7 @@ error: fn_abi_of(extern_c) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: true, randomization_seed: $SEED, }, }, @@ -74,6 +75,7 @@ error: fn_abi_of(extern_c) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, }, }, @@ -117,6 +119,7 @@ error: fn_abi_of(extern_rust) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: true, randomization_seed: $SEED, }, }, @@ -165,6 +168,7 @@ error: fn_abi_of(extern_rust) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, }, }, diff --git a/tests/ui/abi/stack-protector.rs b/tests/ui/abi/stack-protector.rs index 6a2b0d0854c4a..560b29576f3ab 100644 --- a/tests/ui/abi/stack-protector.rs +++ b/tests/ui/abi/stack-protector.rs @@ -1,7 +1,7 @@ //@ run-pass //@ only-x86_64-unknown-linux-gnu //@ revisions: ssp no-ssp -//@ [ssp] compile-flags: -Z stack-protector=all +//@ [ssp] compile-flags: -Z stack-protector=all -Z allow-partial-mitigations=stack-protector //@ compile-flags: -C opt-level=2 //@ compile-flags: -g //@ ignore-backends: gcc diff --git a/tests/ui/abi/sysv64-zst.stderr b/tests/ui/abi/sysv64-zst.stderr index 82d3793c35328..5fc85190db529 100644 --- a/tests/ui/abi/sysv64-zst.stderr +++ b/tests/ui/abi/sysv64-zst.stderr @@ -22,6 +22,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: 0, }, }, @@ -50,6 +51,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: $SOME_ALIGN, + repr_c: false, randomization_seed: 0, }, }, diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.control-flow-guard-future-allow-reset-by-mitigation.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error-control-flow-guard.control-flow-guard-future-allow-reset-by-mitigation.stderr similarity index 100% rename from tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.control-flow-guard-future-allow-reset-by-mitigation.stderr rename to tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error-control-flow-guard.control-flow-guard-future-allow-reset-by-mitigation.stderr diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error-control-flow-guard.rs b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error-control-flow-guard.rs new file mode 100644 index 0000000000000..5d111e87281e4 --- /dev/null +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error-control-flow-guard.rs @@ -0,0 +1,22 @@ +// ignore-tidy-file-linelength +//@ revisions: control-flow-guard-future-allow-reset-by-mitigation +//@ check-fail +//@ ignore-nvptx64 stack protector is not supported +//@ ignore-wasm32-unknown-unknown stack protector is not supported +//@ edition:future + +// msvc has an extra unwind dependency of std, normalize it in the error messages +//@ normalize-stderr: "\b(unwind|libc)\b" -> "unwind/libc" + +// put the test for control-flow-guard in its own file since it does not have the future-compat warning, +// and you can't do negative revisions in compiletest + +// check that `-C control-flow-guard` overrides the `-Z allow-partial-mitigations=control-flow-guard` (to the default, which is deny at edition=future) +//@ [control-flow-guard-future-allow-reset-by-mitigation] compile-flags: -Z unstable-options -Z allow-partial-mitigations=control-flow-guard -C control-flow-guard=on + +fn main() {} +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.rs b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.rs index 3d8b39145ec8d..25a88a08e638e 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.rs +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.rs @@ -1,6 +1,7 @@ // ignore-tidy-file-linelength -//@ revisions: stack-protector-future stack-protector-future-explicit-deny stack-protector-future-deny-reset-by-mitigation stack-protector-allow-then-deny stack-protector-but-allow-control-flow-guard control-flow-guard-future-allow-reset-by-mitigation stack-protector-future-allow-reset-by-mitigation stack-protector-future-deny-allow-reset-by-mitigation +//@ revisions: stack-protector-future stack-protector-future-explicit-deny stack-protector-future-deny-reset-by-mitigation stack-protector-allow-then-deny stack-protector-but-allow-control-flow-guard stack-protector-future-allow-reset-by-mitigation stack-protector-future-deny-allow-reset-by-mitigation //@ check-fail +//@ compile-flags: -D future-incompatible //@ ignore-nvptx64 stack protector is not supported //@ ignore-wasm32-unknown-unknown stack protector is not supported //@ edition:future @@ -25,9 +26,6 @@ // check that allowing an unrelated mitigation (control-flow-guard) does not allow a different mitigation (stack-protector) //@ [stack-protector-but-allow-control-flow-guard] compile-flags: -Z unstable-options -Z stack-protector=all -Z allow-partial-mitigations=control-flow-guard -// check that `-C control-flow-guard` overrides the `-Z allow-partial-mitigations=control-flow-guard` (to the default, which is deny at edition=future) -//@ [control-flow-guard-future-allow-reset-by-mitigation] compile-flags: -Z unstable-options -Z allow-partial-mitigations=control-flow-guard -C control-flow-guard=on - // check that `-Z stack-protector` overrides the `-Z allow-partial-mitigations=stack-protector` (to the default, which is deny at edition=future) //@ [stack-protector-future-allow-reset-by-mitigation] compile-flags: -Z unstable-options -Z allow-partial-mitigations=stack-protector -Z stack-protector=all @@ -40,3 +38,8 @@ fn main() {} //~? ERROR that is not compiled with //~? ERROR that is not compiled with //~? ERROR that is not compiled with +//~? WARN this was previously accepted +//~? WARN this was previously accepted +//~? WARN this was previously accepted +//~? WARN this was previously accepted +//~? WARN this was previously accepted diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-allow-then-deny.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-allow-then-deny.stderr index cb791558ad1bb..29a39a09478bd 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-allow-then-deny.stderr +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-allow-then-deny.stderr @@ -2,26 +2,38 @@ error: your program uses the crate `std`, that is not compiled with `stack-prote | = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + = note: `-D partial-stack-protector` implied by `-D future-incompatible` + = help: to override `-D future-incompatible` add `#[allow(partial_stack_protector)]` error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled | = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled | = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled | = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled | = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: aborting due to 5 previous errors diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-but-allow-control-flow-guard.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-but-allow-control-flow-guard.stderr index cb791558ad1bb..29a39a09478bd 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-but-allow-control-flow-guard.stderr +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-but-allow-control-flow-guard.stderr @@ -2,26 +2,38 @@ error: your program uses the crate `std`, that is not compiled with `stack-prote | = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + = note: `-D partial-stack-protector` implied by `-D future-incompatible` + = help: to override `-D future-incompatible` add `#[allow(partial_stack_protector)]` error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled | = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled | = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled | = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled | = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: aborting due to 5 previous errors diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-allow-reset-by-mitigation.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-allow-reset-by-mitigation.stderr index cb791558ad1bb..29a39a09478bd 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-allow-reset-by-mitigation.stderr +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-allow-reset-by-mitigation.stderr @@ -2,26 +2,38 @@ error: your program uses the crate `std`, that is not compiled with `stack-prote | = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + = note: `-D partial-stack-protector` implied by `-D future-incompatible` + = help: to override `-D future-incompatible` add `#[allow(partial_stack_protector)]` error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled | = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled | = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled | = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled | = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: aborting due to 5 previous errors diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-deny-allow-reset-by-mitigation.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-deny-allow-reset-by-mitigation.stderr index cb791558ad1bb..29a39a09478bd 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-deny-allow-reset-by-mitigation.stderr +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-deny-allow-reset-by-mitigation.stderr @@ -2,26 +2,38 @@ error: your program uses the crate `std`, that is not compiled with `stack-prote | = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + = note: `-D partial-stack-protector` implied by `-D future-incompatible` + = help: to override `-D future-incompatible` add `#[allow(partial_stack_protector)]` error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled | = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled | = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled | = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled | = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: aborting due to 5 previous errors diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-deny-reset-by-mitigation.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-deny-reset-by-mitigation.stderr index cb791558ad1bb..29a39a09478bd 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-deny-reset-by-mitigation.stderr +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-deny-reset-by-mitigation.stderr @@ -2,26 +2,38 @@ error: your program uses the crate `std`, that is not compiled with `stack-prote | = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + = note: `-D partial-stack-protector` implied by `-D future-incompatible` + = help: to override `-D future-incompatible` add `#[allow(partial_stack_protector)]` error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled | = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled | = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled | = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled | = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: aborting due to 5 previous errors diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-explicit-deny.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-explicit-deny.stderr index cb791558ad1bb..29a39a09478bd 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-explicit-deny.stderr +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-explicit-deny.stderr @@ -2,26 +2,38 @@ error: your program uses the crate `std`, that is not compiled with `stack-prote | = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + = note: `-D partial-stack-protector` implied by `-D future-incompatible` + = help: to override `-D future-incompatible` add `#[allow(partial_stack_protector)]` error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled | = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled | = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled | = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled | = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: aborting due to 5 previous errors diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future.stderr index cb791558ad1bb..29a39a09478bd 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future.stderr +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future.stderr @@ -2,26 +2,38 @@ error: your program uses the crate `std`, that is not compiled with `stack-prote | = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + = note: `-D partial-stack-protector` implied by `-D future-incompatible` + = help: to override `-D future-incompatible` add `#[allow(partial_stack_protector)]` error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled | = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled | = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled | = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled | = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 error: aborting due to 5 previous errors diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.both.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.both.stderr index 2d7f3f904101a..1fd11ccd9a054 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.both.stderr +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.both.stderr @@ -1,52 +1,64 @@ -error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled - | - = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled - = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` - error: your program uses the crate `std`, that is not compiled with `control-flow-guard` enabled | = note: recompile `std` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` -error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled - | - = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled - = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` - error: your program uses the crate `core`, that is not compiled with `control-flow-guard` enabled | = note: recompile `core` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` -error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled - | - = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled - = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` - error: your program uses the crate `alloc`, that is not compiled with `control-flow-guard` enabled | = note: recompile `alloc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` -error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled - | - = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled - = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` - error: your program uses the crate `compiler_builtins`, that is not compiled with `control-flow-guard` enabled | = note: recompile `compiler_builtins` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` -error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled - | - = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled - = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` - error: your program uses the crate `unwind/libc`, that is not compiled with `control-flow-guard` enabled | = note: recompile `unwind/libc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` +error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + = note: `-D partial-stack-protector` implied by `-D future-incompatible` + = help: to override `-D future-incompatible` add `#[allow(partial_stack_protector)]` + +error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + error: aborting due to 10 previous errors diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.enable-separately-disable-together.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.enable-separately-disable-together.stderr index 2d7f3f904101a..1fd11ccd9a054 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.enable-separately-disable-together.stderr +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.enable-separately-disable-together.stderr @@ -1,52 +1,64 @@ -error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled - | - = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled - = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` - error: your program uses the crate `std`, that is not compiled with `control-flow-guard` enabled | = note: recompile `std` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` -error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled - | - = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled - = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` - error: your program uses the crate `core`, that is not compiled with `control-flow-guard` enabled | = note: recompile `core` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` -error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled - | - = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled - = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` - error: your program uses the crate `alloc`, that is not compiled with `control-flow-guard` enabled | = note: recompile `alloc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` -error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled - | - = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled - = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` - error: your program uses the crate `compiler_builtins`, that is not compiled with `control-flow-guard` enabled | = note: recompile `compiler_builtins` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` -error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled - | - = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled - = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` - error: your program uses the crate `unwind/libc`, that is not compiled with `control-flow-guard` enabled | = note: recompile `unwind/libc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` +error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + = note: `-D partial-stack-protector` implied by `-D future-incompatible` + = help: to override `-D future-incompatible` add `#[allow(partial_stack_protector)]` + +error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + error: aborting due to 10 previous errors diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.enable-together-disable-separately.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.enable-together-disable-separately.stderr index 2d7f3f904101a..1fd11ccd9a054 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.enable-together-disable-separately.stderr +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.enable-together-disable-separately.stderr @@ -1,52 +1,64 @@ -error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled - | - = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled - = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` - error: your program uses the crate `std`, that is not compiled with `control-flow-guard` enabled | = note: recompile `std` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` -error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled - | - = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled - = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` - error: your program uses the crate `core`, that is not compiled with `control-flow-guard` enabled | = note: recompile `core` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` -error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled - | - = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled - = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` - error: your program uses the crate `alloc`, that is not compiled with `control-flow-guard` enabled | = note: recompile `alloc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` -error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled - | - = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled - = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` - error: your program uses the crate `compiler_builtins`, that is not compiled with `control-flow-guard` enabled | = note: recompile `compiler_builtins` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` -error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled - | - = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled - = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` - error: your program uses the crate `unwind/libc`, that is not compiled with `control-flow-guard` enabled | = note: recompile `unwind/libc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` +error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + = note: `-D partial-stack-protector` implied by `-D future-incompatible` + = help: to override `-D future-incompatible` add `#[allow(partial_stack_protector)]` + +error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + error: aborting due to 10 previous errors diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.rs b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.rs index 8562bd1660034..77ee181b2dadf 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.rs +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.rs @@ -1,6 +1,7 @@ // ignore-tidy-file-linelength //@ revisions: both enable-separately-disable-together enable-together-disable-separately //@ check-fail +//@ compile-flags: -D future-incompatible //@ ignore-nvptx64 stack protector is not supported //@ ignore-wasm32-unknown-unknown stack protector is not supported //@ edition:future @@ -29,3 +30,8 @@ fn main() {} //~? ERROR that is not compiled with //~? ERROR that is not compiled with //~? ERROR that is not compiled with +//~? WARN this was previously accepted +//~? WARN this was previously accepted +//~? WARN this was previously accepted +//~? WARN this was previously accepted +//~? WARN this was previously accepted diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition-control-flow-guard.control-flow-2024-explicit-deny.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition-control-flow-guard.control-flow-2024-explicit-deny.stderr new file mode 100644 index 0000000000000..bdb8962a408a7 --- /dev/null +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition-control-flow-guard.control-flow-2024-explicit-deny.stderr @@ -0,0 +1,27 @@ +error: your program uses the crate `std`, that is not compiled with `control-flow-guard` enabled + | + = note: recompile `std` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` + +error: your program uses the crate `core`, that is not compiled with `control-flow-guard` enabled + | + = note: recompile `core` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` + +error: your program uses the crate `alloc`, that is not compiled with `control-flow-guard` enabled + | + = note: recompile `alloc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` + +error: your program uses the crate `compiler_builtins`, that is not compiled with `control-flow-guard` enabled + | + = note: recompile `compiler_builtins` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` + +error: your program uses the crate `unwind/libc`, that is not compiled with `control-flow-guard` enabled + | + = note: recompile `unwind/libc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` + +error: aborting due to 5 previous errors + diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition-control-flow-guard.rs b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition-control-flow-guard.rs new file mode 100644 index 0000000000000..8ee4ae63a3963 --- /dev/null +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition-control-flow-guard.rs @@ -0,0 +1,25 @@ +// ignore-tidy-file-linelength +//@ revisions: control-flow-2024-explicit-deny +//@ check-fail +//@ ignore-nvptx64 stack protector is not supported +//@ ignore-wasm32-unknown-unknown stack protector is not supported +//@ edition: 2024 + +// msvc has an extra unwind dependency of std, normalize it in the error messages +//@ normalize-stderr: "\b(unwind|libc)\b" -> "unwind/libc" + +// check that in edition 2024, it is still possible to explicitly +// disallow partial mitigations (in edition=future, they are +// disallowed by default) + +// put the test for control-flow-guard in its own file since it does not have the future-compat warning, +// and you can't do negative revisions in compiletest + +//@ [control-flow-2024-explicit-deny] compile-flags: -C control-flow-guard=on -Z deny-partial-mitigations=control-flow-guard + +fn main() {} +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition.rs b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition.rs index f400319f39efe..38df00d66da88 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition.rs +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition.rs @@ -1,6 +1,7 @@ // ignore-tidy-file-linelength -//@ revisions: control-flow-2024-explicit-deny +//@ revisions: stack-protector-2024 stack-protector-2024-allow-deny-reset-by-mitigation stack-protector-2024-deny-reset-by-mitigation //@ check-fail +//@ compile-flags: -D future-incompatible //@ ignore-nvptx64 stack protector is not supported //@ ignore-wasm32-unknown-unknown stack protector is not supported //@ edition: 2024 @@ -12,8 +13,14 @@ // disallow partial mitigations (in edition=future, they are // disallowed by default) -//@ [control-flow-2024-explicit-deny] compile-flags: -C control-flow-guard=on -Z deny-partial-mitigations=control-flow-guard +// check that explicit deny of stack-protector works in edition 2024 +//@ [stack-protector-2024-deny-reset-by-mitigation] compile-flags: -Z deny-partial-mitigations=stack-protector -Z stack-protector=all +// check that this is the case even if there was an "allow" then a "deny" +//@ [stack-protector-2024-allow-deny-reset-by-mitigation] compile-flags: -Z unstable-options -Z allow-partial-mitigations=stack-protector -Z deny-partial-mitigations=stack-protector -Z stack-protector=all + +// check that stack-protector is partial-denied in edition 2024 +//@ [stack-protector-2024] compile-flags: -Z stack-protector=all fn main() {} //~? ERROR that is not compiled with @@ -21,3 +28,8 @@ fn main() {} //~? ERROR that is not compiled with //~? ERROR that is not compiled with //~? ERROR that is not compiled with +//~? WARN this was previously accepted +//~? WARN this was previously accepted +//~? WARN this was previously accepted +//~? WARN this was previously accepted +//~? WARN this was previously accepted diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition.stack-protector-2024-allow-deny-reset-by-mitigation.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition.stack-protector-2024-allow-deny-reset-by-mitigation.stderr new file mode 100644 index 0000000000000..29a39a09478bd --- /dev/null +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition.stack-protector-2024-allow-deny-reset-by-mitigation.stderr @@ -0,0 +1,39 @@ +error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + = note: `-D partial-stack-protector` implied by `-D future-incompatible` + = help: to override `-D future-incompatible` add `#[allow(partial_stack_protector)]` + +error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +error: aborting due to 5 previous errors + diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition.stack-protector-2024-deny-reset-by-mitigation.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition.stack-protector-2024-deny-reset-by-mitigation.stderr new file mode 100644 index 0000000000000..29a39a09478bd --- /dev/null +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition.stack-protector-2024-deny-reset-by-mitigation.stderr @@ -0,0 +1,39 @@ +error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + = note: `-D partial-stack-protector` implied by `-D future-incompatible` + = help: to override `-D future-incompatible` add `#[allow(partial_stack_protector)]` + +error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +error: aborting due to 5 previous errors + diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition.stack-protector-2024.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition.stack-protector-2024.stderr new file mode 100644 index 0000000000000..29a39a09478bd --- /dev/null +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition.stack-protector-2024.stderr @@ -0,0 +1,39 @@ +error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + = note: `-D partial-stack-protector` implied by `-D future-incompatible` + = help: to override `-D future-incompatible` add `#[allow(partial_stack_protector)]` + +error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +error: aborting due to 5 previous errors + diff --git a/tests/ui/allow-partial-mitigations/ok-allow-partial-mitigations-current-edition.rs b/tests/ui/allow-partial-mitigations/ok-allow-partial-mitigations-current-edition.rs index 0c34633d9ea17..9400c0d66c6a7 100644 --- a/tests/ui/allow-partial-mitigations/ok-allow-partial-mitigations-current-edition.rs +++ b/tests/ui/allow-partial-mitigations/ok-allow-partial-mitigations-current-edition.rs @@ -1,5 +1,5 @@ // ignore-tidy-file-linelength -//@ revisions: control-flow-guard-2024-default control-flow-guard-2024-deny-reset-by-mitigation stack-protector-2024-deny-reset-by-mitigation stack-protector-2024-allow-deny-reset-by-mitigation +//@ revisions: control-flow-guard-2024-default control-flow-guard-2024-deny-reset-by-mitigation stack-protector-2024-explicit-allow //@ check-pass //@ ignore-nvptx64 stack protector is not supported //@ ignore-wasm32-unknown-unknown stack protector is not supported @@ -15,11 +15,7 @@ // test that -C control-flow-guard=on resets -Z deny-partial-mitigations=control-flow-guard //@ [control-flow-guard-2024-deny-reset-by-mitigation] compile-flags: -Z deny-partial-mitigations=control-flow-guard -C control-flow-guard=on -// same but for stack-protector, to match the stack-protector-future-deny-reset-by-mitigation test in -// err-allow-partial-mitigations-1-error (which has the same args but on edition=future). -//@ [stack-protector-2024-deny-reset-by-mitigation] compile-flags: -Z deny-partial-mitigations=stack-protector -Z stack-protector=all - -// check that this is the case even if there was an "allow" then a "deny" -//@ [stack-protector-2024-allow-deny-reset-by-mitigation] compile-flags: -Z unstable-options -Z allow-partial-mitigations=stack-protector -Z deny-partial-mitigations=stack-protector -Z stack-protector=all +// also test that stack protector is fine in edition 2024 with an explicit allow +//@ [stack-protector-2024-explicit-allow] compile-flags: -Z stack-protector=all -Z allow-partial-mitigations=stack-protector fn main() {} diff --git a/tests/ui/allow-partial-mitigations/ok-allow-partial-mitigations-minicore.rs b/tests/ui/allow-partial-mitigations/ok-allow-partial-mitigations-minicore.rs index bc8aaa3cb2e61..b267b57c37b00 100644 --- a/tests/ui/allow-partial-mitigations/ok-allow-partial-mitigations-minicore.rs +++ b/tests/ui/allow-partial-mitigations/ok-allow-partial-mitigations-minicore.rs @@ -3,6 +3,7 @@ //@ add-minicore //@ edition:future //@ revisions: default deny +//@ compile-flags: -D future-incompatible //@[default] compile-flags: -Z unstable-options -Z stack-protector=all //@[deny] compile-flags: -Z deny-partial-mitigations=stack-protector -Z unstable-options -Z stack-protector=all diff --git a/tests/ui/allow-partial-mitigations/ok-allow-partial-mitigations.rs b/tests/ui/allow-partial-mitigations/ok-allow-partial-mitigations.rs index f2c4477eef396..7120de9b1357f 100644 --- a/tests/ui/allow-partial-mitigations/ok-allow-partial-mitigations.rs +++ b/tests/ui/allow-partial-mitigations/ok-allow-partial-mitigations.rs @@ -1,18 +1,34 @@ // ignore-tidy-file-linelength -//@ revisions: stack-protector-explicit-allow stack-protector-and-control-flow-guard-explicit-allow stack-protector-deny-then-allow +//@ revisions: stack-protector-explicit-allow stack-protector-and-control-flow-guard-explicit-allow stack-protector-deny-then-allow stack-protector-future-warning //@ check-pass //@ edition:future //@ ignore-nvptx64 stack protector is not supported //@ ignore-wasm32-unknown-unknown stack protector is not supported +// msvc has an extra unwind dependency of std, normalize it in the error messages +//@ normalize-stderr: "\b(unwind|libc)\b" -> "unwind/libc" + // requesting both stack-protector and control-flow-guard and then allow-partial-mitigations it -//@ [stack-protector-and-control-flow-guard-explicit-allow] compile-flags: -Z unstable-options -Z stack-protector=all -C control-flow-guard=on -Z allow-partial-mitigations=stack-protector,control-flow-guard +//@ [stack-protector-and-control-flow-guard-explicit-allow] compile-flags: -D future-incompatible -Z unstable-options -Z stack-protector=all -C control-flow-guard=on -Z allow-partial-mitigations=stack-protector,control-flow-guard // requesting stack-protector and then allow-partial-mitigations it -//@ [stack-protector-explicit-allow] compile-flags: -Z unstable-options -Z stack-protector=all -Z allow-partial-mitigations=stack-protector +//@ [stack-protector-explicit-allow] compile-flags: -D future-incompatible -Z unstable-options -Z stack-protector=all -Z allow-partial-mitigations=stack-protector // testing that the later allow-partial-mitigations overrides the earlier deny-partial-mitigations // see also the stack-protector-allow-then-deny test (in the error tests) for the other order -//@ [stack-protector-deny-then-allow] compile-flags: -Z unstable-options -Z stack-protector=all -Z deny-partial-mitigations=stack-protector -Z allow-partial-mitigations=stack-protector +//@ [stack-protector-deny-then-allow] compile-flags: -D future-incompatible -Z unstable-options -Z stack-protector=all -Z deny-partial-mitigations=stack-protector -Z allow-partial-mitigations=stack-protector + +// Test that without -D future-incompatible you get a warning +//@ [stack-protector-future-warning] compile-flags: -Z unstable-options -Z stack-protector=all -Z deny-partial-mitigations=stack-protector fn main() {} +//[stack-protector-future-warning]~? WARN that is not compiled with +//[stack-protector-future-warning]~? WARN that is not compiled with +//[stack-protector-future-warning]~? WARN that is not compiled with +//[stack-protector-future-warning]~? WARN that is not compiled with +//[stack-protector-future-warning]~? WARN that is not compiled with +//[stack-protector-future-warning]~? WARN this was previously accepted +//[stack-protector-future-warning]~? WARN this was previously accepted +//[stack-protector-future-warning]~? WARN this was previously accepted +//[stack-protector-future-warning]~? WARN this was previously accepted +//[stack-protector-future-warning]~? WARN this was previously accepted diff --git a/tests/ui/allow-partial-mitigations/ok-allow-partial-mitigations.stack-protector-future-warning.stderr b/tests/ui/allow-partial-mitigations/ok-allow-partial-mitigations.stack-protector-future-warning.stderr new file mode 100644 index 0000000000000..ca4dc7b780a36 --- /dev/null +++ b/tests/ui/allow-partial-mitigations/ok-allow-partial-mitigations.stack-protector-future-warning.stderr @@ -0,0 +1,38 @@ +warning: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + = note: `#[warn(partial_stack_protector)]` (part of `#[warn(future_incompatible)]`) on by default + +warning: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +warning: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +warning: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +warning: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled + | + = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled + = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154613 + +warning: 5 warnings emitted + diff --git a/tests/ui/any/hrtb.next.stderr b/tests/ui/any/hrtb.next.stderr index 385b3c3cf2212..69d8f93f6a166 100644 --- a/tests/ui/any/hrtb.next.stderr +++ b/tests/ui/any/hrtb.next.stderr @@ -1,6 +1,8 @@ error[E0080]: evaluation panicked: called `Option::unwrap()` on a `None` value --> $DIR/hrtb.rs:15:25 | +LL | const _: () = { +LL | let x: Option<*const dyn for<'a> Foo<'a, 'a>> = None; LL | let _dy: &dyn Bar = try_as_dyn(&x).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here diff --git a/tests/ui/any/hrtb.old.stderr b/tests/ui/any/hrtb.old.stderr index 385b3c3cf2212..69d8f93f6a166 100644 --- a/tests/ui/any/hrtb.old.stderr +++ b/tests/ui/any/hrtb.old.stderr @@ -1,6 +1,8 @@ error[E0080]: evaluation panicked: called `Option::unwrap()` on a `None` value --> $DIR/hrtb.rs:15:25 | +LL | const _: () = { +LL | let x: Option<*const dyn for<'a> Foo<'a, 'a>> = None; LL | let _dy: &dyn Bar = try_as_dyn(&x).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here diff --git a/tests/ui/any/hrtb2.next.stderr b/tests/ui/any/hrtb2.next.stderr index dfe000dc503a8..842f42e5680e0 100644 --- a/tests/ui/any/hrtb2.next.stderr +++ b/tests/ui/any/hrtb2.next.stderr @@ -1,6 +1,8 @@ error[E0080]: evaluation panicked: called `Option::unwrap()` on a `None` value --> $DIR/hrtb2.rs:15:25 | +LL | const _: () = { +LL | let x: Option<*const dyn Foo<'_>> = None; LL | let _dy: &dyn Bar = try_as_dyn(&x).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here diff --git a/tests/ui/any/hrtb2.old.stderr b/tests/ui/any/hrtb2.old.stderr index dfe000dc503a8..842f42e5680e0 100644 --- a/tests/ui/any/hrtb2.old.stderr +++ b/tests/ui/any/hrtb2.old.stderr @@ -1,6 +1,8 @@ error[E0080]: evaluation panicked: called `Option::unwrap()` on a `None` value --> $DIR/hrtb2.rs:15:25 | +LL | const _: () = { +LL | let x: Option<*const dyn Foo<'_>> = None; LL | let _dy: &dyn Bar = try_as_dyn(&x).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here diff --git a/tests/ui/any/try_as_dyn_generic_trait.next.stderr b/tests/ui/any/try_as_dyn_generic_trait.next.stderr index 99382f9a4032c..61ea708d650db 100644 --- a/tests/ui/any/try_as_dyn_generic_trait.next.stderr +++ b/tests/ui/any/try_as_dyn_generic_trait.next.stderr @@ -1,6 +1,8 @@ error[E0080]: evaluation panicked: called `Option::unwrap()` on a `None` value --> $DIR/try_as_dyn_generic_trait.rs:22:51 | +LL | const _: () = { +LL | let payload: Payload = std::ptr::null(); LL | let convert: &dyn Convert<&'static Payload> = try_as_dyn(&payload).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here diff --git a/tests/ui/any/try_as_dyn_generic_trait.old.stderr b/tests/ui/any/try_as_dyn_generic_trait.old.stderr index 99382f9a4032c..61ea708d650db 100644 --- a/tests/ui/any/try_as_dyn_generic_trait.old.stderr +++ b/tests/ui/any/try_as_dyn_generic_trait.old.stderr @@ -1,6 +1,8 @@ error[E0080]: evaluation panicked: called `Option::unwrap()` on a `None` value --> $DIR/try_as_dyn_generic_trait.rs:22:51 | +LL | const _: () = { +LL | let payload: Payload = std::ptr::null(); LL | let convert: &dyn Convert<&'static Payload> = try_as_dyn(&payload).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here diff --git a/tests/ui/associated-consts/assoc-const-panic-in-match-91514.stderr b/tests/ui/associated-consts/assoc-const-panic-in-match-91514.stderr index 38b0901aa14c9..4fb847bebefdf 100644 --- a/tests/ui/associated-consts/assoc-const-panic-in-match-91514.stderr +++ b/tests/ui/associated-consts/assoc-const-panic-in-match-91514.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/assoc-const-panic-in-match-91514.rs:15:23 | +LL | impl S { LL | const CONST: u8 = panic!(); | ^^^^^^^^ evaluation of `S::CONST` failed here diff --git a/tests/ui/associated-consts/associated-const-in-trait.rs b/tests/ui/associated-consts/associated-const-in-trait.rs index da68a0fa97c82..90ad596b23ee1 100644 --- a/tests/ui/associated-consts/associated-const-in-trait.rs +++ b/tests/ui/associated-consts/associated-const-in-trait.rs @@ -8,7 +8,6 @@ impl dyn Trait { //~^ ERROR the trait `Trait` is not dyn compatible [E0038] const fn n() -> usize { Self::N } //~^ ERROR the trait `Trait` is not dyn compatible [E0038] - //~| ERROR the trait `Trait` is not dyn compatible [E0038] } fn main() {} diff --git a/tests/ui/associated-consts/associated-const-in-trait.stderr b/tests/ui/associated-consts/associated-const-in-trait.stderr index 4085f8c990785..64ac88856fdc4 100644 --- a/tests/ui/associated-consts/associated-const-in-trait.stderr +++ b/tests/ui/associated-consts/associated-const-in-trait.stderr @@ -30,22 +30,6 @@ LL | const N: usize; | ^ ...because it contains associated const `N` = help: consider moving `N` to another trait -error[E0038]: the trait `Trait` is not dyn compatible - --> $DIR/associated-const-in-trait.rs:9:29 - | -LL | const fn n() -> usize { Self::N } - | ^^^^^^^ `Trait` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/associated-const-in-trait.rs:4:11 - | -LL | trait Trait { - | ----- this trait is not dyn compatible... -LL | const N: usize; - | ^ ...because it contains associated const `N` - = help: consider moving `N` to another trait - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/associated-consts/defaults-not-assumed-fail.stderr b/tests/ui/associated-consts/defaults-not-assumed-fail.stderr index 8b38905e1c576..0aa8ba32863e3 100644 --- a/tests/ui/associated-consts/defaults-not-assumed-fail.stderr +++ b/tests/ui/associated-consts/defaults-not-assumed-fail.stderr @@ -1,6 +1,8 @@ error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow --> $DIR/defaults-not-assumed-fail.rs:9:19 | +LL | trait Tr { +... LL | const B: u8 = Self::A + 1; | ^^^^^^^^^^^ evaluation of `<() as Tr>::B` failed here diff --git a/tests/ui/associated-inherent-types/ice-normalize-inherent-assoc-const.stderr b/tests/ui/associated-inherent-types/ice-normalize-inherent-assoc-const.stderr index 5ce8a67bc7810..27cd39f4fb1cb 100644 --- a/tests/ui/associated-inherent-types/ice-normalize-inherent-assoc-const.stderr +++ b/tests/ui/associated-inherent-types/ice-normalize-inherent-assoc-const.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: not yet implemented --> $DIR/ice-normalize-inherent-assoc-const.rs:10:28 | +LL | impl Foo { LL | const ASSOC_C: usize = todo!(); | ^^^^^^^ evaluation of `Foo::ASSOC_C` failed here diff --git a/tests/ui/associated-types/hr-associated-type-bound-object.rs b/tests/ui/associated-types/hr-associated-type-bound-object.rs index 825e129dbbda1..62ed7c7edfe79 100644 --- a/tests/ui/associated-types/hr-associated-type-bound-object.rs +++ b/tests/ui/associated-types/hr-associated-type-bound-object.rs @@ -8,8 +8,6 @@ fn f<'a, T: X<'a> + ?Sized>(x: &>::U) { //~^ ERROR the trait bound `for<'b> >::U: Clone` is not satisfied <>::U>::clone(x); //~^ ERROR the trait bound `for<'b> >::U: Clone` is not satisfied - //~| ERROR the trait bound `for<'b> >::U: Clone` is not satisfied - //~| ERROR the trait bound `for<'b> >::U: Clone` is not satisfied //~| ERROR the trait bound `>::U: Clone` is not satisfied } diff --git a/tests/ui/associated-types/hr-associated-type-bound-object.stderr b/tests/ui/associated-types/hr-associated-type-bound-object.stderr index d1563c923bc7a..0a6831ad8801b 100644 --- a/tests/ui/associated-types/hr-associated-type-bound-object.stderr +++ b/tests/ui/associated-types/hr-associated-type-bound-object.stderr @@ -48,42 +48,6 @@ help: consider further restricting the associated type LL | fn f<'a, T: X<'a> + ?Sized>(x: &>::U) where >::U: Clone { | ++++++++++++++++++++++++++++ -error[E0277]: the trait bound `for<'b> >::U: Clone` is not satisfied - --> $DIR/hr-associated-type-bound-object.rs:9:5 - | -LL | <>::U>::clone(x); - | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'b> Clone` is not implemented for `>::U` - | -note: required by a bound in `X` - --> $DIR/hr-associated-type-bound-object.rs:3:33 - | -LL | trait X<'a> -LL | where -LL | for<'b> >::U: Clone, - | ^^^^^ required by this bound in `X` -help: consider further restricting the associated type - | -LL | fn f<'a, T: X<'a> + ?Sized>(x: &>::U) where for<'b> >::U: Clone { - | ++++++++++++++++++++++++++++++++++++ - -error[E0277]: the trait bound `for<'b> >::U: Clone` is not satisfied - --> $DIR/hr-associated-type-bound-object.rs:9:5 - | -LL | <>::U>::clone(x); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'b> Clone` is not implemented for `>::U` - | -note: required by a bound in `X` - --> $DIR/hr-associated-type-bound-object.rs:3:33 - | -LL | trait X<'a> -LL | where -LL | for<'b> >::U: Clone, - | ^^^^^ required by this bound in `X` -help: consider further restricting the associated type - | -LL | fn f<'a, T: X<'a> + ?Sized>(x: &>::U) where for<'b> >::U: Clone { - | ++++++++++++++++++++++++++++++++++++ - -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/associated-types/hr-associated-type-bound-param-2.rs b/tests/ui/associated-types/hr-associated-type-bound-param-2.rs index d6546c24dc50b..7e40cec345f7e 100644 --- a/tests/ui/associated-types/hr-associated-type-bound-param-2.rs +++ b/tests/ui/associated-types/hr-associated-type-bound-param-2.rs @@ -9,8 +9,6 @@ where fn h(&self, x: &T::W) { ::clone(x); //~^ ERROR the trait bound `str: Clone` is not satisfied - //~| ERROR the trait bound `str: Clone` is not satisfied - //~| ERROR the trait bound `str: Clone` is not satisfied } } diff --git a/tests/ui/associated-types/hr-associated-type-bound-param-2.stderr b/tests/ui/associated-types/hr-associated-type-bound-param-2.stderr index f025798750a58..b1a7e8ac4062a 100644 --- a/tests/ui/associated-types/hr-associated-type-bound-param-2.stderr +++ b/tests/ui/associated-types/hr-associated-type-bound-param-2.stderr @@ -15,7 +15,7 @@ LL | for<'b> >::W: Clone, | ^^^^^ required by this bound in `Z` error[E0277]: the trait bound `str: Clone` is not satisfied - --> $DIR/hr-associated-type-bound-param-2.rs:18:14 + --> $DIR/hr-associated-type-bound-param-2.rs:16:14 | LL | type W = str; | ^^^ the trait `Clone` is not implemented for `str` @@ -67,39 +67,7 @@ LL | type W: ?Sized; | error[E0277]: the trait bound `str: Clone` is not satisfied - --> $DIR/hr-associated-type-bound-param-2.rs:10:9 - | -LL | ::clone(x); - | ^^^^^^^^^^^^^ the trait `Clone` is not implemented for `str` - | -help: the trait `Clone` is implemented for `String` - --> $SRC_DIR/alloc/src/string.rs:LL:COL -note: required by a bound in `Z` - --> $DIR/hr-associated-type-bound-param-2.rs:6:35 - | -LL | trait Z<'a, T: ?Sized> -... -LL | for<'b> >::W: Clone, - | ^^^^^ required by this bound in `Z` - -error[E0277]: the trait bound `str: Clone` is not satisfied - --> $DIR/hr-associated-type-bound-param-2.rs:10:9 - | -LL | ::clone(x); - | ^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `str` - | -help: the trait `Clone` is implemented for `String` - --> $SRC_DIR/alloc/src/string.rs:LL:COL -note: required by a bound in `Z` - --> $DIR/hr-associated-type-bound-param-2.rs:6:35 - | -LL | trait Z<'a, T: ?Sized> -... -LL | for<'b> >::W: Clone, - | ^^^^^ required by this bound in `Z` - -error[E0277]: the trait bound `str: Clone` is not satisfied - --> $DIR/hr-associated-type-bound-param-2.rs:23:10 + --> $DIR/hr-associated-type-bound-param-2.rs:21:10 | LL | 1u16.h("abc"); | ^ the trait `Clone` is not implemented for `str` @@ -117,6 +85,6 @@ LL | for<'b> >::W: Clone, LL | fn h(&self, x: &T::W) { | -error: aborting due to 7 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/async-closures/async-future-out-must-be-sized.rs b/tests/ui/async-await/async-closures/async-future-out-must-be-sized.rs index e5d70e30eb5f6..2daed6b09dcc9 100644 --- a/tests/ui/async-await/async-closures/async-future-out-must-be-sized.rs +++ b/tests/ui/async-await/async-closures/async-future-out-must-be-sized.rs @@ -16,5 +16,4 @@ async fn is_async_fn(f: impl AsyncFn()) { fn main() { is_async_fn(foo()); //~^ ERROR the size for values of type `dyn Future` cannot be known at compilation time - //~| ERROR the size for values of type `dyn Future` cannot be known at compilation time } diff --git a/tests/ui/async-await/async-closures/async-future-out-must-be-sized.stderr b/tests/ui/async-await/async-closures/async-future-out-must-be-sized.stderr index f993247d8b90a..1168a854f5d32 100644 --- a/tests/ui/async-await/async-closures/async-future-out-must-be-sized.stderr +++ b/tests/ui/async-await/async-closures/async-future-out-must-be-sized.stderr @@ -13,19 +13,6 @@ note: required by a bound in `is_async_fn` LL | async fn is_async_fn(f: impl AsyncFn()) { | ^^^^^^^^^ required by this bound in `is_async_fn` -error[E0277]: the size for values of type `dyn Future` cannot be known at compilation time - --> $DIR/async-future-out-must-be-sized.rs:17:5 - | -LL | is_async_fn(foo()); - | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `dyn Future` -note: required by a bound in `is_async_fn` - --> $DIR/async-future-out-must-be-sized.rs:12:30 - | -LL | async fn is_async_fn(f: impl AsyncFn()) { - | ^^^^^^^^^ required by this bound in `is_async_fn` - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/attributes/doc_examples/rustc_comptime.stderr b/tests/ui/attributes/doc_examples/rustc_comptime.stderr index 20dd2597d929e..6ace103fdcfa5 100644 --- a/tests/ui/attributes/doc_examples/rustc_comptime.stderr +++ b/tests/ui/attributes/doc_examples/rustc_comptime.stderr @@ -1,14 +1,24 @@ -error: comptime fns can only be called at compile time +error: comptime functions can only be called at compile time --> $DIR/rustc_comptime.rs:10:5 | 10 | comptime(); // ERROR | ^^^^^^^^^^ + | +help: wrap the call in a const block to force compile time evaluation + | +10 | const { comptime() }; // ERROR + | +++++++ + -error: comptime fns can only be called at compile time +error: comptime functions can only be called at compile time --> $DIR/rustc_comptime.rs:18:5 | 18 | comptime(); | ^^^^^^^^^^ + | +help: wrap the call in a const block to force compile time evaluation + | +18 | const { comptime() }; + | +++++++ + error: aborting due to 2 previous errors diff --git a/tests/ui/attributes/doc_examples/rustc_dump_layout_debug.stderr b/tests/ui/attributes/doc_examples/rustc_dump_layout_debug.stderr index 1918a3696a4e1..a4e7092a8857c 100644 --- a/tests/ui/attributes/doc_examples/rustc_dump_layout_debug.stderr +++ b/tests/ui/attributes/doc_examples/rustc_dump_layout_debug.stderr @@ -16,6 +16,7 @@ error: layout_of(Union) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/rustc_dump_layout_debug.rs:8:1 diff --git a/tests/ui/box/into-boxed-slice-fail.rs b/tests/ui/box/into-boxed-slice-fail.rs index 49dbb170f8e78..db2e5623264e6 100644 --- a/tests/ui/box/into-boxed-slice-fail.rs +++ b/tests/ui/box/into-boxed-slice-fail.rs @@ -6,9 +6,7 @@ fn main() { let boxed_slice = Box::new([1,2,3]) as Box<[u8]>; let _ = Box::into_boxed_slice(boxed_slice); //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time - //~^^ ERROR the size for values of type `[u8]` cannot be known at compilation time let boxed_trait: Box = Box::new(5u8); let _ = Box::into_boxed_slice(boxed_trait); //~^ ERROR the size for values of type `dyn Debug` cannot be known at compilation time - //~^^ ERROR the size for values of type `dyn Debug` cannot be known at compilation time } diff --git a/tests/ui/box/into-boxed-slice-fail.stderr b/tests/ui/box/into-boxed-slice-fail.stderr index f102f666dc276..a66fa533c6f02 100644 --- a/tests/ui/box/into-boxed-slice-fail.stderr +++ b/tests/ui/box/into-boxed-slice-fail.stderr @@ -10,17 +10,8 @@ LL | let _ = Box::into_boxed_slice(boxed_slice); note: required by a bound in `Box::::into_boxed_slice` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL -error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/into-boxed-slice-fail.rs:7:13 - | -LL | let _ = Box::into_boxed_slice(boxed_slice); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[u8]` - = note: slice and array elements must have `Sized` type - error[E0277]: the size for values of type `dyn Debug` cannot be known at compilation time - --> $DIR/into-boxed-slice-fail.rs:11:35 + --> $DIR/into-boxed-slice-fail.rs:10:35 | LL | let _ = Box::into_boxed_slice(boxed_trait); | --------------------- ^^^^^^^^^^^ doesn't have a size known at compile-time @@ -31,15 +22,6 @@ LL | let _ = Box::into_boxed_slice(boxed_trait); note: required by a bound in `Box::::into_boxed_slice` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL -error[E0277]: the size for values of type `dyn Debug` cannot be known at compilation time - --> $DIR/into-boxed-slice-fail.rs:11:13 - | -LL | let _ = Box::into_boxed_slice(boxed_trait); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `dyn Debug` - = note: slice and array elements must have `Sized` type - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/c-variadic/pass-by-value-abi.aarch64.stderr b/tests/ui/c-variadic/pass-by-value-abi.aarch64.stderr index 59d4e18e4cd7c..052f21ad81f57 100644 --- a/tests/ui/c-variadic/pass-by-value-abi.aarch64.stderr +++ b/tests/ui/c-variadic/pass-by-value-abi.aarch64.stderr @@ -22,6 +22,7 @@ error: fn_abi_of(take_va_list) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), + repr_c: true, randomization_seed: $SEED, }, }, @@ -61,6 +62,7 @@ error: fn_abi_of(take_va_list) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, }, }, diff --git a/tests/ui/c-variadic/pass-by-value-abi.win.stderr b/tests/ui/c-variadic/pass-by-value-abi.win.stderr index d5da912a9b89a..08e196c7a88aa 100644 --- a/tests/ui/c-variadic/pass-by-value-abi.win.stderr +++ b/tests/ui/c-variadic/pass-by-value-abi.win.stderr @@ -22,6 +22,7 @@ error: fn_abi_of(take_va_list) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), + repr_c: false, randomization_seed: $SEED, }, }, @@ -57,6 +58,7 @@ error: fn_abi_of(take_va_list) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, }, }, diff --git a/tests/ui/c-variadic/pass-by-value-abi.x86_64.stderr b/tests/ui/c-variadic/pass-by-value-abi.x86_64.stderr index b7e29098d6fe6..a8aa8f15b497f 100644 --- a/tests/ui/c-variadic/pass-by-value-abi.x86_64.stderr +++ b/tests/ui/c-variadic/pass-by-value-abi.x86_64.stderr @@ -22,6 +22,7 @@ error: fn_abi_of(take_va_list) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), + repr_c: true, randomization_seed: $SEED, }, }, @@ -61,6 +62,7 @@ error: fn_abi_of(take_va_list) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, }, }, @@ -100,6 +102,7 @@ error: fn_abi_of(take_va_list_sysv64) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), + repr_c: true, randomization_seed: $SEED, }, }, @@ -139,6 +142,7 @@ error: fn_abi_of(take_va_list_sysv64) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, }, }, @@ -180,6 +184,7 @@ error: fn_abi_of(take_va_list_win64) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), + repr_c: true, randomization_seed: $SEED, }, }, @@ -219,6 +224,7 @@ error: fn_abi_of(take_va_list_win64) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, }, }, diff --git a/tests/ui/closures/unsized-return-suggest-ref-issue-152064.fixed b/tests/ui/closures/unsized-return-suggest-ref-issue-152064.fixed deleted file mode 100644 index 2e1d10fb2804c..0000000000000 --- a/tests/ui/closures/unsized-return-suggest-ref-issue-152064.fixed +++ /dev/null @@ -1,18 +0,0 @@ -#![allow(unused_variables, for_loops_over_fallibles)] -//@ run-rustfix - -fn main() { - // Basic case from the issue: str slice - let o = Some("Hello, world!"); - for s in o.map(|s| &s[3..8]) {} - //~^ ERROR the size for values of type `str` cannot be known at compilation time - //~| ERROR the size for values of type `str` cannot be known at compilation time - //~| ERROR `Option` is not an iterator - - // Byte slice case - let arr = Some(b"Hello, world!"); - for s in arr.map(|s| &s[3..8]) {} - //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time - //~| ERROR the size for values of type `[u8]` cannot be known at compilation time - //~| ERROR `Option<[u8]>` is not an iterator -} diff --git a/tests/ui/closures/unsized-return-suggest-ref-issue-152064.rs b/tests/ui/closures/unsized-return-suggest-ref-issue-152064.rs index 6a0573248ff8b..f88bf3c908685 100644 --- a/tests/ui/closures/unsized-return-suggest-ref-issue-152064.rs +++ b/tests/ui/closures/unsized-return-suggest-ref-issue-152064.rs @@ -1,18 +1,15 @@ #![allow(unused_variables, for_loops_over_fallibles)] -//@ run-rustfix fn main() { // Basic case from the issue: str slice let o = Some("Hello, world!"); for s in o.map(|s| s[3..8]) {} //~^ ERROR the size for values of type `str` cannot be known at compilation time - //~| ERROR the size for values of type `str` cannot be known at compilation time //~| ERROR `Option` is not an iterator // Byte slice case let arr = Some(b"Hello, world!"); for s in arr.map(|s| s[3..8]) {} //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time - //~| ERROR the size for values of type `[u8]` cannot be known at compilation time //~| ERROR `Option<[u8]>` is not an iterator } diff --git a/tests/ui/closures/unsized-return-suggest-ref-issue-152064.stderr b/tests/ui/closures/unsized-return-suggest-ref-issue-152064.stderr index c5e5e71cd8823..de08baa48461a 100644 --- a/tests/ui/closures/unsized-return-suggest-ref-issue-152064.stderr +++ b/tests/ui/closures/unsized-return-suggest-ref-issue-152064.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/unsized-return-suggest-ref-issue-152064.rs:7:16 + --> $DIR/unsized-return-suggest-ref-issue-152064.rs:6:16 | LL | for s in o.map(|s| s[3..8]) {} | ^^^ doesn't have a size known at compile-time @@ -8,22 +8,8 @@ LL | for s in o.map(|s| s[3..8]) {} note: required by an implicit `Sized` bound in `Option::::map` --> $SRC_DIR/core/src/option.rs:LL:COL -error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/unsized-return-suggest-ref-issue-152064.rs:7:14 - | -LL | for s in o.map(|s| s[3..8]) {} - | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `str` -note: required by an implicit `Sized` bound in `Option` - --> $SRC_DIR/core/src/option.rs:LL:COL -help: consider borrowing the value - | -LL | for s in o.map(|s| &s[3..8]) {} - | + - error[E0277]: `Option` is not an iterator - --> $DIR/unsized-return-suggest-ref-issue-152064.rs:7:14 + --> $DIR/unsized-return-suggest-ref-issue-152064.rs:6:14 | LL | for s in o.map(|s| s[3..8]) {} | ^^^^^^^^^^^^^^^^^^ `Option` is not an iterator @@ -41,7 +27,7 @@ help: the following other types implement trait `IntoIterator` = note: `&mut Option` error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/unsized-return-suggest-ref-issue-152064.rs:14:18 + --> $DIR/unsized-return-suggest-ref-issue-152064.rs:12:18 | LL | for s in arr.map(|s| s[3..8]) {} | ^^^ doesn't have a size known at compile-time @@ -50,22 +36,8 @@ LL | for s in arr.map(|s| s[3..8]) {} note: required by an implicit `Sized` bound in `Option::::map` --> $SRC_DIR/core/src/option.rs:LL:COL -error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/unsized-return-suggest-ref-issue-152064.rs:14:14 - | -LL | for s in arr.map(|s| s[3..8]) {} - | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[u8]` -note: required by an implicit `Sized` bound in `Option` - --> $SRC_DIR/core/src/option.rs:LL:COL -help: consider borrowing the value - | -LL | for s in arr.map(|s| &s[3..8]) {} - | + - error[E0277]: `Option<[u8]>` is not an iterator - --> $DIR/unsized-return-suggest-ref-issue-152064.rs:14:14 + --> $DIR/unsized-return-suggest-ref-issue-152064.rs:12:14 | LL | for s in arr.map(|s| s[3..8]) {} | ^^^^^^^^^^^^^^^^^^^^ `Option<[u8]>` is not an iterator @@ -82,6 +54,6 @@ help: the following other types implement trait `IntoIterator` | = note: `&mut Option` -error: aborting due to 6 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/comptime/comptime_method.rs b/tests/ui/comptime/comptime_method.rs index a55c950b01680..e5bd403d6168e 100644 --- a/tests/ui/comptime/comptime_method.rs +++ b/tests/ui/comptime/comptime_method.rs @@ -13,5 +13,5 @@ const _: () = { fn main() { Bar.boo(); - //~^ ERROR: comptime fns can only be called at compile time + //~^ ERROR: comptime functions can only be called at compile time } diff --git a/tests/ui/comptime/comptime_method.stderr b/tests/ui/comptime/comptime_method.stderr index f188ab7e4be58..0838a68168d8d 100644 --- a/tests/ui/comptime/comptime_method.stderr +++ b/tests/ui/comptime/comptime_method.stderr @@ -1,8 +1,13 @@ -error: comptime fns can only be called at compile time +error: comptime functions can only be called at compile time --> $DIR/comptime_method.rs:15:5 | LL | Bar.boo(); | ^^^^^^^^^ + | +help: wrap the call in a const block to force compile time evaluation + | +LL | const { Bar.boo() }; + | +++++++ + error: aborting due to 1 previous error diff --git a/tests/ui/comptime/not_callable.rs b/tests/ui/comptime/not_callable.rs index c06e643d5403e..be533c1118ed3 100644 --- a/tests/ui/comptime/not_callable.rs +++ b/tests/ui/comptime/not_callable.rs @@ -7,12 +7,12 @@ fn main() { // Ok const { foo() }; // Not Ok - foo(); //~ ERROR: comptime fns can only be called at compile time + foo(); //~ ERROR: comptime functions can only be called at compile time } const fn bar() { // Not Ok - foo(); //~ ERROR: comptime fns can only be called at compile time + foo(); //~ ERROR: comptime functions can only be called at compile time } #[rustc_comptime] diff --git a/tests/ui/comptime/not_callable.stderr b/tests/ui/comptime/not_callable.stderr index 8a2c3fb2bf00f..a53aa5bf12b3a 100644 --- a/tests/ui/comptime/not_callable.stderr +++ b/tests/ui/comptime/not_callable.stderr @@ -1,14 +1,24 @@ -error: comptime fns can only be called at compile time +error: comptime functions can only be called at compile time --> $DIR/not_callable.rs:10:5 | LL | foo(); | ^^^^^ + | +help: wrap the call in a const block to force compile time evaluation + | +LL | const { foo() }; + | +++++++ + -error: comptime fns can only be called at compile time +error: comptime functions can only be called at compile time --> $DIR/not_callable.rs:15:5 | LL | foo(); | ^^^^^ + | +help: wrap the call in a const block to force compile time evaluation + | +LL | const { foo() }; + | +++++++ + error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.rs b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.rs index e575d0dc9b405..58936f3e741ec 100644 --- a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.rs +++ b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.rs @@ -16,11 +16,11 @@ where { foo::<_, L>([(); L + 1 + L]); //~^ ERROR: mismatched types - //~^^ ERROR: unconstrained generic constant - //~^^^ ERROR: function takes 1 generic argument but 2 generic arguments were supplied - //~^^^^ ERROR: unconstrained generic constant - //~^^^^^ ERROR: unconstrained generic constant `L + 1 + L` - //~^^^^^^ ERROR: unconstrained generic constant `L + 1` + //~| ERROR: unconstrained generic constant + //~| ERROR: function takes 1 generic argument but 2 generic arguments were supplied + //~| ERROR: unconstrained generic constant + //~| ERROR: unconstrained generic constant `L + 1 + L` + //~| ERROR: unconstrained generic constant `L + 1` } fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.rs b/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.rs index 304c176e85ae9..083c3bf47aad7 100644 --- a/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.rs +++ b/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.rs @@ -7,8 +7,6 @@ fn user() { let _ = const_evaluatable_lib::test1::(); //~^ ERROR unconstrained generic constant //~| ERROR unconstrained generic constant - //~| ERROR unconstrained generic constant - //~| ERROR unconstrained generic constant } fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr b/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr index 5c2d9d22c48f0..c45509656ab36 100644 --- a/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr +++ b/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr @@ -32,34 +32,5 @@ help: try adding a `where` bound LL | fn user() where [(); std::mem::size_of::() - 1]: { | +++++++++++++++++++++++++++++++++++++++++ -error: unconstrained generic constant - --> $DIR/cross_crate_predicate.rs:7:13 - | -LL | let _ = const_evaluatable_lib::test1::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try adding a `where` bound - | -LL | fn user() where [(); std::mem::size_of::() - 1]: { - | +++++++++++++++++++++++++++++++++++++++++ - -error: unconstrained generic constant - --> $DIR/cross_crate_predicate.rs:7:13 - | -LL | let _ = const_evaluatable_lib::test1::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: required by a bound in `test1` - --> $DIR/auxiliary/const_evaluatable_lib.rs:5:10 - | -LL | pub fn test1() -> [u8; std::mem::size_of::() - 1] -LL | where -LL | [u8; std::mem::size_of::() - 1]: Sized, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `test1` -help: try adding a `where` bound - | -LL | fn user() where [(); std::mem::size_of::() - 1]: { - | +++++++++++++++++++++++++++++++++++++++++ - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/generic_const_exprs/dependence_lint.full.stderr b/tests/ui/const-generics/generic_const_exprs/dependence_lint.full.stderr index 810a87c35aed8..05c8f1e945ccc 100644 --- a/tests/ui/const-generics/generic_const_exprs/dependence_lint.full.stderr +++ b/tests/ui/const-generics/generic_const_exprs/dependence_lint.full.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/dependence_lint.rs:15:32 + --> $DIR/dependence_lint.rs:14:32 | LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce | ^ cannot perform const operation using `T` @@ -9,7 +9,7 @@ LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce = help: alternatively, you can use `#![feature(gca_const_items)]` and extract the expression into a `type const` item error: generic parameters may not be used in const operations - --> $DIR/dependence_lint.rs:22:37 + --> $DIR/dependence_lint.rs:21:37 | LL | let _: [u8; if true { size_of::() } else { 3 }]; // error on stable, error with gce | ^ cannot perform const operation using `T` @@ -29,7 +29,7 @@ LL | [0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_ = note: `#[warn(const_evaluatable_unchecked)]` (part of `#[warn(future_incompatible)]`) on by default warning: cannot use constants which depend on generic parameters in types - --> $DIR/dependence_lint.rs:18:9 + --> $DIR/dependence_lint.rs:17:9 | LL | [0; if false { size_of::() } else { 3 }]; // lint on stable, error with gce | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr b/tests/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr index 12ac980c97544..f6119c17bf47e 100644 --- a/tests/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr +++ b/tests/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr @@ -9,19 +9,8 @@ help: try adding a `where` bound LL | fn foo() where [(); size_of::<*mut T>()]: { | ++++++++++++++++++++++++++++++++ -error: unconstrained generic constant - --> $DIR/dependence_lint.rs:10:5 - | -LL | [0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_exprs` - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try adding a `where` bound - | -LL | fn foo() where [(); size_of::<*mut T>()]: { - | ++++++++++++++++++++++++++++++++ - error: overly complex generic constant - --> $DIR/dependence_lint.rs:18:9 + --> $DIR/dependence_lint.rs:17:9 | LL | [0; if false { size_of::() } else { 3 }]; // lint on stable, error with gce | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ control flow is not supported in generic constants @@ -29,7 +18,7 @@ LL | [0; if false { size_of::() } else { 3 }]; // lint on stable, error w = help: consider moving this anonymous constant into a `const` function error: unconstrained generic constant - --> $DIR/dependence_lint.rs:15:12 + --> $DIR/dependence_lint.rs:14:12 | LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -40,12 +29,12 @@ LL | fn foo() where [(); size_of::<*mut T>()]: { | ++++++++++++++++++++++++++++++++ error: overly complex generic constant - --> $DIR/dependence_lint.rs:22:17 + --> $DIR/dependence_lint.rs:21:17 | LL | let _: [u8; if true { size_of::() } else { 3 }]; // error on stable, error with gce | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ control flow is not supported in generic constants | = help: consider moving this anonymous constant into a `const` function -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors diff --git a/tests/ui/const-generics/generic_const_exprs/dependence_lint.rs b/tests/ui/const-generics/generic_const_exprs/dependence_lint.rs index 6b3c8f84be3d1..107466cd1d9ca 100644 --- a/tests/ui/const-generics/generic_const_exprs/dependence_lint.rs +++ b/tests/ui/const-generics/generic_const_exprs/dependence_lint.rs @@ -9,8 +9,7 @@ use std::mem::size_of; fn foo() { [0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_exprs` //[gce]~^ ERROR unconstrained - //[gce]~| ERROR unconstrained generic constant - //[full]~^^^ WARNING cannot use constants + //[full]~^^ WARNING cannot use constants //[full]~| WARNING this was previously accepted let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce //[full]~^ ERROR generic parameters may not be used diff --git a/tests/ui/const-generics/generic_const_exprs/simple_fail.stderr b/tests/ui/const-generics/generic_const_exprs/simple_fail.stderr index 94a91159e956f..5287137d0ec3b 100644 --- a/tests/ui/const-generics/generic_const_exprs/simple_fail.stderr +++ b/tests/ui/const-generics/generic_const_exprs/simple_fail.stderr @@ -1,6 +1,8 @@ error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow --> $DIR/simple_fail.rs:9:10 | +LL | fn test() -> Arr +LL | where LL | [u8; N - 1]: Sized, | ^^^^^ evaluation of `test::<0>::{constant#0}` failed here diff --git a/tests/ui/const-generics/issues/issue-100313.stderr b/tests/ui/const-generics/issues/issue-100313.stderr index 17bad92d8dfa5..723b87491e4cc 100644 --- a/tests/ui/const-generics/issues/issue-100313.stderr +++ b/tests/ui/const-generics/issues/issue-100313.stderr @@ -1,12 +1,17 @@ error[E0080]: writing to ALLOC$ID which is read-only --> $DIR/issue-100313.rs:18:5 | +LL | const _: () = { +LL | let x = T::<{ &true }>; LL | x.set_false(); | ^^^^^^^^^^^^^ evaluation of `_` failed inside this call | note: inside `T::<&true>::set_false` --> $DIR/issue-100313.rs:11:13 | +LL | impl T { +LL | const fn set_false(&self) { +LL | unsafe { LL | *(B as *const bool as *mut bool) = false; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here diff --git a/tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr b/tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr index 31a2accccd7fd..a6fb8aaa87a12 100644 --- a/tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr +++ b/tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr @@ -49,6 +49,8 @@ LL | fn get_flag() -> Option { error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory --> $DIR/invalid-patterns.rs:40:32 | +LL | fn main() { +... LL | get_flag::(); | ^^^^^^^^^^^^^^^^^^ evaluation of `main::{constant#7}` failed here | @@ -81,6 +83,8 @@ LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory --> $DIR/invalid-patterns.rs:44:58 | +LL | fn main() { +... LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); | ^^^^^^^^^^^^^^^^^^ evaluation of `main::{constant#11}` failed here | diff --git a/tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr b/tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr index 31a2accccd7fd..a6fb8aaa87a12 100644 --- a/tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr +++ b/tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr @@ -49,6 +49,8 @@ LL | fn get_flag() -> Option { error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory --> $DIR/invalid-patterns.rs:40:32 | +LL | fn main() { +... LL | get_flag::(); | ^^^^^^^^^^^^^^^^^^ evaluation of `main::{constant#7}` failed here | @@ -81,6 +83,8 @@ LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory --> $DIR/invalid-patterns.rs:44:58 | +LL | fn main() { +... LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); | ^^^^^^^^^^^^^^^^^^ evaluation of `main::{constant#11}` failed here | diff --git a/tests/ui/const-ptr/forbidden_slices.stderr b/tests/ui/const-ptr/forbidden_slices.stderr index e23b4e5b1aa75..8983a54cb08e4 100644 --- a/tests/ui/const-ptr/forbidden_slices.stderr +++ b/tests/ui/const-ptr/forbidden_slices.stderr @@ -108,6 +108,8 @@ LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC$ID which is only 4 bytes from the end of the allocation --> $DIR/forbidden_slices.rs:54:25 | +LL | pub static R2: &[u32] = unsafe { +LL | let ptr = &D0 as *const u32; LL | from_ptr_range(ptr..ptr.add(2)) // errors inside libcore | ^^^^^^^^^^ evaluation of `R2` failed here @@ -160,6 +162,8 @@ LL | pub static R7: &[u16] = unsafe { error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC$ID+0x1 which is only 7 bytes from the end of the allocation --> $DIR/forbidden_slices.rs:79:25 | +LL | pub static R8: &[u64] = unsafe { +LL | let ptr = (&D4 as *const [u32; 2] as *const u32).byte_add(1).cast::(); LL | from_ptr_range(ptr..ptr.add(1)) | ^^^^^^^^^^ evaluation of `R8` failed here diff --git a/tests/ui/const-ptr/out_of_bounds_read.stderr b/tests/ui/const-ptr/out_of_bounds_read.stderr index 8465d69db28e7..83bb4fe3226fa 100644 --- a/tests/ui/const-ptr/out_of_bounds_read.stderr +++ b/tests/ui/const-ptr/out_of_bounds_read.stderr @@ -1,18 +1,24 @@ error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID+0x4 which is at or beyond the end of the allocation of size 4 bytes --> $DIR/out_of_bounds_read.rs:8:33 | +LL | fn main() { +... LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) }; | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_READ` failed here error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID+0x4 which is at or beyond the end of the allocation of size 4 bytes --> $DIR/out_of_bounds_read.rs:10:39 | +LL | fn main() { +... LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; | ^^^^^^^^^^^^^^^^^^^ evaluation of `main::_CONST_READ` failed here error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID+0x4 which is at or beyond the end of the allocation of size 4 bytes --> $DIR/out_of_bounds_read.rs:12:37 | +LL | fn main() { +... LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_MUT_READ` failed here diff --git a/tests/ui/consts/assert-type-intrinsics.stderr b/tests/ui/consts/assert-type-intrinsics.stderr index 775b95ac30a40..70e6318b988de 100644 --- a/tests/ui/consts/assert-type-intrinsics.stderr +++ b/tests/ui/consts/assert-type-intrinsics.stderr @@ -1,18 +1,27 @@ error[E0080]: evaluation panicked: aborted execution: attempted to instantiate uninhabited type `!` --> $DIR/assert-type-intrinsics.rs:10:9 | +LL | fn main() { +... +LL | const _BAD1: () = unsafe { LL | MaybeUninit::::uninit().assume_init(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_BAD1` failed here error[E0080]: evaluation panicked: aborted execution: attempted to leave type `&i32` uninitialized, which is invalid --> $DIR/assert-type-intrinsics.rs:14:9 | +LL | fn main() { +... +LL | const _BAD2: () = { LL | intrinsics::assert_mem_uninitialized_valid::<&'static i32>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_BAD2` failed here error[E0080]: evaluation panicked: aborted execution: attempted to zero-initialize type `&i32`, which is invalid --> $DIR/assert-type-intrinsics.rs:18:9 | +LL | fn main() { +... +LL | const _BAD3: () = { LL | intrinsics::assert_zero_valid::<&'static i32>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_BAD3` failed here diff --git a/tests/ui/consts/assoc_const_generic_impl.stderr b/tests/ui/consts/assoc_const_generic_impl.stderr index fc8986a34c566..b7913fe4b5ca5 100644 --- a/tests/ui/consts/assoc_const_generic_impl.stderr +++ b/tests/ui/consts/assoc_const_generic_impl.stderr @@ -1,6 +1,7 @@ error[E0080]: index out of bounds: the length is 1 but the index is 4 --> $DIR/assoc_const_generic_impl.rs:9:33 | +LL | impl ZeroSized for T { LL | const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::()]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `::I_AM_ZERO_SIZED` failed here diff --git a/tests/ui/consts/const-assert-unchecked-ub.stderr b/tests/ui/consts/const-assert-unchecked-ub.stderr index d8e68fc9bee23..cd9918640c235 100644 --- a/tests/ui/consts/const-assert-unchecked-ub.stderr +++ b/tests/ui/consts/const-assert-unchecked-ub.stderr @@ -1,6 +1,8 @@ error[E0080]: `assume` called with `false` --> $DIR/const-assert-unchecked-ub.rs:3:5 | +LL | const _: () = unsafe { +LL | let n = u32::MAX.count_ones(); LL | std::hint::assert_unchecked(n < 32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here diff --git a/tests/ui/consts/const-compare-bytes-ub.stderr b/tests/ui/consts/const-compare-bytes-ub.stderr index 94098c1e26407..a3c4a824a6802 100644 --- a/tests/ui/consts/const-compare-bytes-ub.stderr +++ b/tests/ui/consts/const-compare-bytes-ub.stderr @@ -1,36 +1,53 @@ error[E0080]: memory access failed: attempting to access 1 byte, but got null pointer --> $DIR/const-compare-bytes-ub.rs:9:9 | +LL | fn main() { +LL | const LHS_NULL: i32 = unsafe { LL | compare_bytes(0 as *const u8, 2 as *const u8, 1) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::LHS_NULL` failed here error[E0080]: memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) --> $DIR/const-compare-bytes-ub.rs:13:9 | +LL | fn main() { +... +LL | const RHS_NULL: i32 = unsafe { LL | compare_bytes(1 as *const u8, 0 as *const u8, 1) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::RHS_NULL` failed here error[E0080]: memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) --> $DIR/const-compare-bytes-ub.rs:17:9 | +LL | fn main() { +... +LL | const DANGLING_PTR_NON_ZERO_LENGTH: i32 = unsafe { LL | compare_bytes(1 as *const u8, 2 as *const u8, 1) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::DANGLING_PTR_NON_ZERO_LENGTH` failed here error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID which is only 3 bytes from the end of the allocation --> $DIR/const-compare-bytes-ub.rs:21:9 | +LL | fn main() { +... +LL | const LHS_OUT_OF_BOUNDS: i32 = unsafe { LL | compare_bytes([1, 2, 3].as_ptr(), [1, 2, 3, 4].as_ptr(), 4) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::LHS_OUT_OF_BOUNDS` failed here error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID which is only 3 bytes from the end of the allocation --> $DIR/const-compare-bytes-ub.rs:25:9 | +LL | fn main() { +... +LL | const RHS_OUT_OF_BOUNDS: i32 = unsafe { LL | compare_bytes([1, 2, 3, 4].as_ptr(), [1, 2, 3].as_ptr(), 4) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::RHS_OUT_OF_BOUNDS` failed here error[E0080]: reading memory at ALLOC$ID[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory --> $DIR/const-compare-bytes-ub.rs:29:9 | +LL | fn main() { +... +LL | const LHS_UNINIT: i32 = unsafe { LL | compare_bytes(MaybeUninit::uninit().as_ptr(), [1].as_ptr(), 1) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::LHS_UNINIT` failed here | @@ -41,6 +58,9 @@ LL | compare_bytes(MaybeUninit::uninit().as_ptr(), [1].as_ptr(), 1) error[E0080]: reading memory at ALLOC$ID[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory --> $DIR/const-compare-bytes-ub.rs:33:9 | +LL | fn main() { +... +LL | const RHS_UNINIT: i32 = unsafe { LL | compare_bytes([1].as_ptr(), MaybeUninit::uninit().as_ptr(), 1) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::RHS_UNINIT` failed here | @@ -51,6 +71,9 @@ LL | compare_bytes([1].as_ptr(), MaybeUninit::uninit().as_ptr(), 1) error[E0080]: unable to turn pointer into integer --> $DIR/const-compare-bytes-ub.rs:37:9 | +LL | fn main() { +... +LL | const WITH_PROVENANCE: i32 = unsafe { LL | compare_bytes([&1].as_ptr().cast(), [&2].as_ptr().cast(), std::mem::size_of::()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::WITH_PROVENANCE` failed here | diff --git a/tests/ui/consts/const-deref-ptr.stderr b/tests/ui/consts/const-deref-ptr.stderr index aa89aedac318e..3d55b1e555241 100644 --- a/tests/ui/consts/const-deref-ptr.stderr +++ b/tests/ui/consts/const-deref-ptr.stderr @@ -1,6 +1,7 @@ error[E0080]: memory access failed: attempting to access 8 bytes, but got 0xdeadbeef[noalloc] which is a dangling pointer (it has no provenance) --> $DIR/const-deref-ptr.rs:4:30 | +LL | fn main() { LL | static C: u64 = unsafe { *(0xdeadbeef as *const u64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::C` failed here diff --git a/tests/ui/consts/const-err-enum-discriminant.32bit.stderr b/tests/ui/consts/const-err-enum-discriminant.32bit.stderr index 864364139594a..4cb4ae6293b8b 100644 --- a/tests/ui/consts/const-err-enum-discriminant.32bit.stderr +++ b/tests/ui/consts/const-err-enum-discriminant.32bit.stderr @@ -1,6 +1,7 @@ error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory --> $DIR/const-err-enum-discriminant.rs:10:21 | +LL | enum Bar { LL | Boo = [unsafe { Foo { b: () }.a }; 4][3], | ^^^^^^^^^^^^^^^ evaluation of `Bar::Boo::{constant#0}` failed here | diff --git a/tests/ui/consts/const-err-enum-discriminant.64bit.stderr b/tests/ui/consts/const-err-enum-discriminant.64bit.stderr index 9212299bffbd4..89c75600a6c08 100644 --- a/tests/ui/consts/const-err-enum-discriminant.64bit.stderr +++ b/tests/ui/consts/const-err-enum-discriminant.64bit.stderr @@ -1,6 +1,7 @@ error[E0080]: reading memory at ALLOC$ID[0x0..0x8], but memory is uninitialized at [0x0..0x8], and this operation requires initialized memory --> $DIR/const-err-enum-discriminant.rs:10:21 | +LL | enum Bar { LL | Boo = [unsafe { Foo { b: () }.a }; 4][3], | ^^^^^^^^^^^^^^^ evaluation of `Bar::Boo::{constant#0}` failed here | diff --git a/tests/ui/consts/const-err-late.stderr b/tests/ui/consts/const-err-late.stderr index 02be7bbe10c47..b2f693fa3d2c5 100644 --- a/tests/ui/consts/const-err-late.stderr +++ b/tests/ui/consts/const-err-late.stderr @@ -1,6 +1,7 @@ error[E0080]: index out of bounds: the length is 1 but the index is 1 --> $DIR/const-err-late.rs:14:21 | +LL | impl S { LL | const FOO: u8 = [5u8][1]; | ^^^^^^^^ evaluation of `S::::FOO` failed here @@ -13,6 +14,7 @@ LL | black_box((S::::FOO, S::::FOO)); error[E0080]: index out of bounds: the length is 1 but the index is 1 --> $DIR/const-err-late.rs:14:21 | +LL | impl S { LL | const FOO: u8 = [5u8][1]; | ^^^^^^^^ evaluation of `S::::FOO` failed here diff --git a/tests/ui/consts/const-eval-fail-too-big.stderr b/tests/ui/consts/const-eval-fail-too-big.stderr index d58efbf6d8c65..28c41bedc0c54 100644 --- a/tests/ui/consts/const-eval-fail-too-big.stderr +++ b/tests/ui/consts/const-eval-fail-too-big.stderr @@ -1,6 +1,8 @@ error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture --> $DIR/const-eval-fail-too-big.rs:4:28 | +LL | struct B< +LL | A: Sized = [(); { LL | let x = [0u8; !0usize]; | ^^^^^^^^^^^^^^ evaluation of `B::{constant#0}` failed here diff --git a/tests/ui/consts/const-eval/assign-to-static-within-other-static.stderr b/tests/ui/consts/const-eval/assign-to-static-within-other-static.stderr index b232cbf25e751..8d13f6fdccd37 100644 --- a/tests/ui/consts/const-eval/assign-to-static-within-other-static.stderr +++ b/tests/ui/consts/const-eval/assign-to-static-within-other-static.stderr @@ -1,6 +1,7 @@ error[E0080]: modifying a static's initial value from another static's initializer --> $DIR/assign-to-static-within-other-static.rs:8:5 | +LL | static BOO: () = unsafe { LL | FOO = 5; | ^^^^^^^ evaluation of `BOO` failed here diff --git a/tests/ui/consts/const-eval/c-variadic-fail.stderr b/tests/ui/consts/const-eval/c-variadic-fail.stderr index ccf2936324a9c..5a76c882df9aa 100644 --- a/tests/ui/consts/const-eval/c-variadic-fail.stderr +++ b/tests/ui/consts/const-eval/c-variadic-fail.stderr @@ -1,6 +1,8 @@ error[E0080]: more C-variadic arguments read than were passed --> $DIR/c-variadic-fail.rs:27:13 | +LL | unsafe fn read_too_many() { +... LL | const { read_n::<1>() } | ^^^^^^^^^^^^^ evaluation of `read_too_many::{constant#2}` failed inside this call | @@ -29,6 +31,8 @@ LL | const { read_n::<1>() } error[E0080]: more C-variadic arguments read than were passed --> $DIR/c-variadic-fail.rs:31:13 | +LL | unsafe fn read_too_many() { +... LL | const { read_n::<2>(1) } | ^^^^^^^^^^^^^^ evaluation of `read_too_many::{constant#3}` failed inside this call | @@ -57,6 +61,8 @@ LL | const { read_n::<2>(1) } error[E0080]: va_arg value mismatch: value `-1_i32` cannot be represented by type `u32` --> $DIR/c-variadic-fail.rs:71:13 | +LL | unsafe fn read_cast_numeric() { +... LL | const { read_as::(-1i32) }; | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_numeric::{constant#12}` failed inside this call | @@ -85,6 +91,8 @@ LL | const { read_as::(-1i32) }; error[E0080]: va_arg value mismatch: value `-2147483648_i32` cannot be represented by type `u32` --> $DIR/c-variadic-fail.rs:73:13 | +LL | unsafe fn read_cast_numeric() { +... LL | const { read_as::(i32::MIN) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_numeric::{constant#13}` failed inside this call | @@ -113,6 +121,8 @@ LL | const { read_as::(i32::MIN) }; error[E0080]: va_arg value mismatch: value `4294967295_u32` cannot be represented by type `i32` --> $DIR/c-variadic-fail.rs:75:13 | +LL | unsafe fn read_cast_numeric() { +... LL | const { read_as::(u32::MAX) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_numeric::{constant#14}` failed inside this call | @@ -141,6 +151,8 @@ LL | const { read_as::(u32::MAX) }; error[E0080]: va_arg value mismatch: value `2147483648_u32` cannot be represented by type `i32` --> $DIR/c-variadic-fail.rs:77:13 | +LL | unsafe fn read_cast_numeric() { +... LL | const { read_as::(i32::MAX as u32 + 1) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_numeric::{constant#15}` failed inside this call | @@ -169,6 +181,8 @@ LL | const { read_as::(i32::MAX as u32 + 1) }; error[E0080]: va_arg value mismatch: value `18446744073709551615_u64` cannot be represented by type `i64` --> $DIR/c-variadic-fail.rs:79:13 | +LL | unsafe fn read_cast_numeric() { +... LL | const { read_as::(u64::MAX) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_numeric::{constant#16}` failed inside this call | @@ -197,6 +211,8 @@ LL | const { read_as::(u64::MAX) }; error[E0080]: va_arg value mismatch: value `9223372036854775808_u64` cannot be represented by type `i64` --> $DIR/c-variadic-fail.rs:81:13 | +LL | unsafe fn read_cast_numeric() { +... LL | const { read_as::(i64::MAX as u64 + 1) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_numeric::{constant#17}` failed inside this call | @@ -225,6 +241,8 @@ LL | const { read_as::(i64::MAX as u64 + 1) }; error[E0080]: va_arg type mismatch: requested `i32` is incompatible with next argument of type `u64` --> $DIR/c-variadic-fail.rs:84:13 | +LL | unsafe fn read_cast_numeric() { +... LL | const { read_as::(1u64) }; | ^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_numeric::{constant#18}` failed inside this call | @@ -253,6 +271,8 @@ LL | const { read_as::(1u64) }; error[E0080]: va_arg type mismatch: requested `f64` is incompatible with next argument of type `i32` --> $DIR/c-variadic-fail.rs:87:13 | +LL | unsafe fn read_cast_numeric() { +... LL | const { read_as::(1i32) }; | ^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_numeric::{constant#19}` failed inside this call | @@ -281,6 +301,8 @@ LL | const { read_as::(1i32) }; error[E0080]: va_arg type mismatch: requested `*const u16` is incompatible with next argument of type `*const c_void` --> $DIR/c-variadic-fail.rs:110:13 | +LL | unsafe fn read_cast_pointer() { +... LL | const { read_as::<*const u16>(std::ptr::dangling::()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_pointer::{constant#12}` failed inside this call | @@ -309,6 +331,8 @@ LL | const { read_as::<*const u16>(std::ptr::dangling::()) }; error[E0080]: va_arg type mismatch: requested `*const c_void` is incompatible with next argument of type `*const u16` --> $DIR/c-variadic-fail.rs:112:13 | +LL | unsafe fn read_cast_pointer() { +... LL | const { read_as::<*const c_void>(std::ptr::dangling::()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_pointer::{constant#13}` failed inside this call | @@ -337,6 +361,8 @@ LL | const { read_as::<*const c_void>(std::ptr::dangling::()) }; error[E0080]: va_arg type mismatch: requested `*const u16` is incompatible with next argument of type `*const i32` --> $DIR/c-variadic-fail.rs:114:13 | +LL | unsafe fn read_cast_pointer() { +... LL | const { read_as::<*const u16>(std::ptr::dangling::()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_pointer::{constant#14}` failed inside this call | @@ -365,6 +391,8 @@ LL | const { read_as::<*const u16>(std::ptr::dangling::()) }; error[E0080]: va_arg type mismatch: requested `*const u8` is incompatible with next argument of type `usize` --> $DIR/c-variadic-fail.rs:117:13 | +LL | unsafe fn read_cast_pointer() { +... LL | const { read_as::<*const u8>(1usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_pointer::{constant#15}` failed inside this call | @@ -393,6 +421,8 @@ LL | const { read_as::<*const u8>(1usize) }; error[E0080]: va_arg type mismatch: requested `*const fn(&())` is incompatible with next argument of type `*const for<'a> fn(&'a ())` --> $DIR/c-variadic-fail.rs:126:13 | +LL | unsafe fn read_cast_lifetime() { +... LL | const { read_as::<*const fn(&'static ())>(std::ptr::dangling:: fn(&'a ())>()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_lifetime::{constant#1}` failed inside this call | @@ -421,6 +451,10 @@ LL | const { read_as::<*const fn(&'static ())>(std::ptr::dangling:: error[E0080]: memory access failed: ALLOC$ID has been freed, so this pointer is dangling --> $DIR/c-variadic-fail.rs:139:13 | +LL | fn use_after_free() { +... +LL | const { +... LL | ap.next_arg::(); | ^^^^^^^^^^^^^^^^^^^^ evaluation of `use_after_free::{constant#0}` failed inside this call | @@ -454,12 +488,17 @@ LL | | }; error[E0080]: using ALLOC$ID as variable argument list pointer but it does not point to a variable argument list --> $DIR/c-variadic-fail.rs:161:22 | +LL | fn manual_copy_drop() { +... LL | const { unsafe { helper(1, 2, 3) } }; | ^^^^^^^^^^^^^^^ evaluation of `manual_copy_drop::{constant#0}` failed inside this call | note: inside `manual_copy_drop::helper` --> $DIR/c-variadic-fail.rs:158:9 | +LL | fn manual_copy_drop() { +LL | const unsafe extern "C" fn helper(ap: ...) { +... LL | drop(ap); | ^^^^^^^^ note: inside `std::mem::drop::>` @@ -486,12 +525,17 @@ LL | const { unsafe { helper(1, 2, 3) } }; error[E0080]: using ALLOC$ID as variable argument list pointer but it does not point to a variable argument list --> $DIR/c-variadic-fail.rs:177:22 | +LL | fn manual_copy_forget() { +... LL | const { unsafe { helper(1, 2, 3) } }; | ^^^^^^^^^^^^^^^ evaluation of `manual_copy_forget::{constant#0}` failed inside this call | note: inside `manual_copy_forget::helper` --> $DIR/c-variadic-fail.rs:174:9 | +LL | fn manual_copy_forget() { +LL | const unsafe extern "C" fn helper(ap: ...) { +... LL | drop(ap); | ^^^^^^^^ note: inside `std::mem::drop::>` @@ -518,12 +562,17 @@ LL | const { unsafe { helper(1, 2, 3) } }; error[E0080]: using ALLOC$ID as variable argument list pointer but it does not point to a variable argument list --> $DIR/c-variadic-fail.rs:190:22 | +LL | fn manual_copy_read() { +... LL | const { unsafe { helper(1, 2, 3) } }; | ^^^^^^^^^^^^^^^ evaluation of `manual_copy_read::{constant#0}` failed inside this call | note: inside `manual_copy_read::helper` --> $DIR/c-variadic-fail.rs:187:17 | +LL | fn manual_copy_read() { +LL | const unsafe extern "C" fn helper(mut ap: ...) { +... LL | let _ = ap.next_arg::(); | ^^^^^^^^^^^^^^^^^^^^ note: inside `VaList::<'_>::next_arg::` @@ -546,6 +595,9 @@ LL | const { unsafe { helper(1, 2, 3) } }; error[E0080]: pointer not dereferenceable: pointer must point to some allocation, but got null pointer --> $DIR/c-variadic-fail.rs:198:5 | +LL | fn drop_of_invalid() { +LL | const { +... LL | } | ^ evaluation of `drop_of_invalid::{constant#0}` failed inside this call | diff --git a/tests/ui/consts/const-eval/const-eval-overflow-3.stderr b/tests/ui/consts/const-eval/const-eval-overflow-3.stderr index aeb88716f1689..387b06b1dacac 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-3.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-3.stderr @@ -1,6 +1,8 @@ error[E0080]: attempt to compute `i8::MAX + 1_i8`, which would overflow --> $DIR/const-eval-overflow-3.rs:18:11 | +LL | const A_I8_I +LL | : [u32; (i8::MAX as usize) + 1] LL | = [0; (i8::MAX + 1) as usize]; | ^^^^^^^^^^^^^ evaluation of `A_I8_I::{constant#1}` failed here diff --git a/tests/ui/consts/const-eval/const-eval-overflow-4.stderr b/tests/ui/consts/const-eval/const-eval-overflow-4.stderr index daabb33e0f319..8b9538069eabc 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-4.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-4.stderr @@ -1,6 +1,7 @@ error[E0080]: attempt to compute `i8::MAX + 1_i8`, which would overflow --> $DIR/const-eval-overflow-4.rs:11:13 | +LL | const A_I8_T LL | : [u32; (i8::MAX as i8 + 1i8) as usize] | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `A_I8_T::{constant#0}` failed here diff --git a/tests/ui/consts/const-eval/const-eval-overflow2.stderr b/tests/ui/consts/const-eval/const-eval-overflow2.stderr index 6ec3fa73cb702..752731ad4e485 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow2.stderr @@ -1,48 +1,62 @@ error[E0080]: attempt to compute `i8::MIN - 1_i8`, which would overflow --> $DIR/const-eval-overflow2.rs:12:6 | +LL | const VALS_I8: (i8,) = +LL | ( LL | i8::MIN - 1, | ^^^^^^^^^^^ evaluation of `VALS_I8` failed here error[E0080]: attempt to compute `i16::MIN - 1_i16`, which would overflow --> $DIR/const-eval-overflow2.rs:18:6 | +LL | const VALS_I16: (i16,) = +LL | ( LL | i16::MIN - 1, | ^^^^^^^^^^^^ evaluation of `VALS_I16` failed here error[E0080]: attempt to compute `i32::MIN - 1_i32`, which would overflow --> $DIR/const-eval-overflow2.rs:24:6 | +LL | const VALS_I32: (i32,) = +LL | ( LL | i32::MIN - 1, | ^^^^^^^^^^^^ evaluation of `VALS_I32` failed here error[E0080]: attempt to compute `i64::MIN - 1_i64`, which would overflow --> $DIR/const-eval-overflow2.rs:30:6 | +LL | const VALS_I64: (i64,) = +LL | ( LL | i64::MIN - 1, | ^^^^^^^^^^^^ evaluation of `VALS_I64` failed here error[E0080]: attempt to compute `0_u8 - 1_u8`, which would overflow --> $DIR/const-eval-overflow2.rs:36:6 | +LL | const VALS_U8: (u8,) = +LL | ( LL | u8::MIN - 1, | ^^^^^^^^^^^ evaluation of `VALS_U8` failed here error[E0080]: attempt to compute `0_u16 - 1_u16`, which would overflow --> $DIR/const-eval-overflow2.rs:41:6 | +LL | const VALS_U16: (u16,) = ( LL | u16::MIN - 1, | ^^^^^^^^^^^^ evaluation of `VALS_U16` failed here error[E0080]: attempt to compute `0_u32 - 1_u32`, which would overflow --> $DIR/const-eval-overflow2.rs:46:6 | +LL | const VALS_U32: (u32,) = ( LL | u32::MIN - 1, | ^^^^^^^^^^^^ evaluation of `VALS_U32` failed here error[E0080]: attempt to compute `0_u64 - 1_u64`, which would overflow --> $DIR/const-eval-overflow2.rs:52:6 | +LL | const VALS_U64: (u64,) = +LL | ( LL | u64::MIN - 1, | ^^^^^^^^^^^^ evaluation of `VALS_U64` failed here diff --git a/tests/ui/consts/const-eval/const-eval-overflow2b.stderr b/tests/ui/consts/const-eval/const-eval-overflow2b.stderr index 5b8e559d046f9..508d5db2b1c71 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2b.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow2b.stderr @@ -1,48 +1,62 @@ error[E0080]: attempt to compute `i8::MAX + 1_i8`, which would overflow --> $DIR/const-eval-overflow2b.rs:12:6 | +LL | const VALS_I8: (i8,) = +LL | ( LL | i8::MAX + 1, | ^^^^^^^^^^^ evaluation of `VALS_I8` failed here error[E0080]: attempt to compute `i16::MAX + 1_i16`, which would overflow --> $DIR/const-eval-overflow2b.rs:18:6 | +LL | const VALS_I16: (i16,) = +LL | ( LL | i16::MAX + 1, | ^^^^^^^^^^^^ evaluation of `VALS_I16` failed here error[E0080]: attempt to compute `i32::MAX + 1_i32`, which would overflow --> $DIR/const-eval-overflow2b.rs:24:6 | +LL | const VALS_I32: (i32,) = +LL | ( LL | i32::MAX + 1, | ^^^^^^^^^^^^ evaluation of `VALS_I32` failed here error[E0080]: attempt to compute `i64::MAX + 1_i64`, which would overflow --> $DIR/const-eval-overflow2b.rs:30:6 | +LL | const VALS_I64: (i64,) = +LL | ( LL | i64::MAX + 1, | ^^^^^^^^^^^^ evaluation of `VALS_I64` failed here error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow --> $DIR/const-eval-overflow2b.rs:36:6 | +LL | const VALS_U8: (u8,) = +LL | ( LL | u8::MAX + 1, | ^^^^^^^^^^^ evaluation of `VALS_U8` failed here error[E0080]: attempt to compute `u16::MAX + 1_u16`, which would overflow --> $DIR/const-eval-overflow2b.rs:41:6 | +LL | const VALS_U16: (u16,) = ( LL | u16::MAX + 1, | ^^^^^^^^^^^^ evaluation of `VALS_U16` failed here error[E0080]: attempt to compute `u32::MAX + 1_u32`, which would overflow --> $DIR/const-eval-overflow2b.rs:46:6 | +LL | const VALS_U32: (u32,) = ( LL | u32::MAX + 1, | ^^^^^^^^^^^^ evaluation of `VALS_U32` failed here error[E0080]: attempt to compute `u64::MAX + 1_u64`, which would overflow --> $DIR/const-eval-overflow2b.rs:52:6 | +LL | const VALS_U64: (u64,) = +LL | ( LL | u64::MAX + 1, | ^^^^^^^^^^^^ evaluation of `VALS_U64` failed here diff --git a/tests/ui/consts/const-eval/const-eval-overflow2c.stderr b/tests/ui/consts/const-eval/const-eval-overflow2c.stderr index 99eeadf6b0d35..3a271d8b7667a 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2c.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow2c.stderr @@ -1,48 +1,62 @@ error[E0080]: attempt to compute `i8::MIN * 2_i8`, which would overflow --> $DIR/const-eval-overflow2c.rs:12:6 | +LL | const VALS_I8: (i8,) = +LL | ( LL | i8::MIN * 2, | ^^^^^^^^^^^ evaluation of `VALS_I8` failed here error[E0080]: attempt to compute `i16::MIN * 2_i16`, which would overflow --> $DIR/const-eval-overflow2c.rs:18:6 | +LL | const VALS_I16: (i16,) = +LL | ( LL | i16::MIN * 2, | ^^^^^^^^^^^^ evaluation of `VALS_I16` failed here error[E0080]: attempt to compute `i32::MIN * 2_i32`, which would overflow --> $DIR/const-eval-overflow2c.rs:24:6 | +LL | const VALS_I32: (i32,) = +LL | ( LL | i32::MIN * 2, | ^^^^^^^^^^^^ evaluation of `VALS_I32` failed here error[E0080]: attempt to compute `i64::MIN * 2_i64`, which would overflow --> $DIR/const-eval-overflow2c.rs:30:6 | +LL | const VALS_I64: (i64,) = +LL | ( LL | i64::MIN * 2, | ^^^^^^^^^^^^ evaluation of `VALS_I64` failed here error[E0080]: attempt to compute `u8::MAX * 2_u8`, which would overflow --> $DIR/const-eval-overflow2c.rs:36:6 | +LL | const VALS_U8: (u8,) = +LL | ( LL | u8::MAX * 2, | ^^^^^^^^^^^ evaluation of `VALS_U8` failed here error[E0080]: attempt to compute `u16::MAX * 2_u16`, which would overflow --> $DIR/const-eval-overflow2c.rs:41:6 | +LL | const VALS_U16: (u16,) = ( LL | u16::MAX * 2, | ^^^^^^^^^^^^ evaluation of `VALS_U16` failed here error[E0080]: attempt to compute `u32::MAX * 2_u32`, which would overflow --> $DIR/const-eval-overflow2c.rs:46:6 | +LL | const VALS_U32: (u32,) = ( LL | u32::MAX * 2, | ^^^^^^^^^^^^ evaluation of `VALS_U32` failed here error[E0080]: attempt to compute `u64::MAX * 2_u64`, which would overflow --> $DIR/const-eval-overflow2c.rs:52:6 | +LL | const VALS_U64: (u64,) = +LL | ( LL | u64::MAX * 2, | ^^^^^^^^^^^^ evaluation of `VALS_U64` failed here diff --git a/tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr b/tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr index f68ef6f96988f..5d2e16c69eda5 100644 --- a/tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr +++ b/tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr @@ -1,6 +1,7 @@ error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:27:49 | +LL | fn main() { LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_USIZE_UNION` failed here | @@ -10,6 +11,8 @@ LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 } error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:30:43 | +LL | fn main() { +... LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_U8_UNION` failed here | @@ -19,6 +22,8 @@ LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_ error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:33:45 | +LL | fn main() { +... LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_U16_UNION` failed here | @@ -28,6 +33,8 @@ LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uin error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:36:45 | +LL | fn main() { +... LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_U32_UNION` failed here | @@ -37,6 +44,8 @@ LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uin error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:39:45 | +LL | fn main() { +... LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_U64_UNION` failed here | @@ -46,6 +55,8 @@ LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uin error[E0080]: reading memory at ALLOC$ID[0x0..0x10], but memory is uninitialized at [0x8..0x10], and this operation requires initialized memory --> $DIR/const-pointer-values-in-various-types.rs:42:47 | +LL | fn main() { +... LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_U128_UNION` failed here | @@ -56,6 +67,8 @@ LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.u error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:45:43 | +LL | fn main() { +... LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_I8_UNION` failed here | @@ -65,6 +78,8 @@ LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:48:45 | +LL | fn main() { +... LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_I16_UNION` failed here | @@ -74,6 +89,8 @@ LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:51:45 | +LL | fn main() { +... LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_I32_UNION` failed here | @@ -83,6 +100,8 @@ LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:54:45 | +LL | fn main() { +... LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_I64_UNION` failed here | @@ -92,6 +111,8 @@ LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int error[E0080]: reading memory at ALLOC$ID[0x0..0x10], but memory is uninitialized at [0x8..0x10], and this operation requires initialized memory --> $DIR/const-pointer-values-in-various-types.rs:57:47 | +LL | fn main() { +... LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_I128_UNION` failed here | @@ -102,6 +123,8 @@ LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.i error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:60:45 | +LL | fn main() { +... LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_F32_UNION` failed here | @@ -111,6 +134,8 @@ LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.flo error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:63:45 | +LL | fn main() { +... LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_F64_UNION` failed here | @@ -120,6 +145,8 @@ LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.flo error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:66:47 | +LL | fn main() { +... LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_BOOL_UNION` failed here | @@ -129,6 +156,8 @@ LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.t error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:69:47 | +LL | fn main() { +... LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_CHAR_UNION` failed here | @@ -138,6 +167,8 @@ LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.c error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:72:39 | +LL | fn main() { +... LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_U8_UNION` failed here | @@ -147,6 +178,8 @@ LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:75:41 | +LL | fn main() { +... LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_U16_UNION` failed here | @@ -156,6 +189,8 @@ LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 } error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:78:41 | +LL | fn main() { +... LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_U32_UNION` failed here | @@ -165,6 +200,8 @@ LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 } error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:81:41 | +LL | fn main() { +... LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_U64_UNION` failed here | @@ -174,6 +211,8 @@ LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 } error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:84:43 | +LL | fn main() { +... LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_U128_UNION` failed here | @@ -183,6 +222,8 @@ LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_12 error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:87:39 | +LL | fn main() { +... LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_I8_UNION` failed here | @@ -192,6 +233,8 @@ LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:90:41 | +LL | fn main() { +... LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_I16_UNION` failed here | @@ -201,6 +244,8 @@ LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:93:41 | +LL | fn main() { +... LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_I32_UNION` failed here | @@ -210,6 +255,8 @@ LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:96:41 | +LL | fn main() { +... LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_I64_UNION` failed here | @@ -219,6 +266,8 @@ LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:99:43 | +LL | fn main() { +... LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_I128_UNION` failed here | @@ -228,6 +277,8 @@ LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:102:41 | +LL | fn main() { +... LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_F32_UNION` failed here | @@ -237,6 +288,8 @@ LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:105:41 | +LL | fn main() { +... LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_F64_UNION` failed here | @@ -246,6 +299,8 @@ LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:108:43 | +LL | fn main() { +... LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_BOOL_UNION` failed here | @@ -255,6 +310,8 @@ LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_ error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:111:43 | +LL | fn main() { +... LL | const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_CHAR_UNION` failed here | diff --git a/tests/ui/consts/const-eval/do_not_const_check.stderr b/tests/ui/consts/const-eval/do_not_const_check.stderr index 507999df218d1..7b91d75298e06 100644 --- a/tests/ui/consts/const-eval/do_not_const_check.stderr +++ b/tests/ui/consts/const-eval/do_not_const_check.stderr @@ -1,12 +1,14 @@ error[E0080]: calling non-const function `mostly_harmless` --> $DIR/do_not_const_check.rs:9:5 | +LL | const _: () = { LL | mostly_harmless(); | ^^^^^^^^^^^^^^^^^ evaluation of `_` failed here error[E0080]: calling non-const function `integer_min::` --> $DIR/do_not_const_check.rs:22:5 | +LL | const _: () = { LL | integer_min(0, 1); | ^^^^^^^^^^^^^^^^^ evaluation of `_` failed here diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr index e9b7f99ee6d99..199716284c235 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr @@ -12,6 +12,8 @@ LL | const _X: &'static u8 = unsafe { error[E0080]: memory access failed: ALLOC$ID has been freed, so this pointer is dangling --> $DIR/dealloc_intrinsic_dangling.rs:23:5 | +LL | const _Y: u8 = unsafe { +... LL | *reference | ^^^^^^^^^^ evaluation of `_Y` failed here diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr index eb73857143877..5514dadc17a94 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr @@ -1,6 +1,8 @@ error[E0080]: memory access failed: ALLOC$ID has been freed, so this pointer is dangling --> $DIR/dealloc_intrinsic_duplicate.rs:9:5 | +LL | const _X: () = unsafe { +... LL | intrinsics::const_deallocate(ptr, 4, 4); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_X` failed here diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr index cc7f14d6ddb35..5c1bee05e619c 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr @@ -1,24 +1,32 @@ error[E0080]: incorrect layout on deallocation: ALLOC$ID has size 4 and alignment 4, but gave size 4 and alignment 2 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:8:5 | +LL | const _X: () = unsafe { +LL | let ptr = intrinsics::const_allocate(4, 4); LL | intrinsics::const_deallocate(ptr, 4, 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_X` failed here error[E0080]: incorrect layout on deallocation: ALLOC$ID has size 4 and alignment 4, but gave size 2 and alignment 4 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:13:5 | +LL | const _Y: () = unsafe { +LL | let ptr = intrinsics::const_allocate(4, 4); LL | intrinsics::const_deallocate(ptr, 2, 4); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_Y` failed here error[E0080]: incorrect layout on deallocation: ALLOC$ID has size 4 and alignment 4, but gave size 3 and alignment 4 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:19:5 | +LL | const _Z: () = unsafe { +LL | let ptr = intrinsics::const_allocate(4, 4); LL | intrinsics::const_deallocate(ptr, 3, 4); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_Z` failed here error[E0080]: invalid align passed to `const_deallocate`: 3 is not a power of 2 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:25:5 | +LL | const _W: () = unsafe { +LL | let ptr = intrinsics::const_allocate(4, 4); LL | intrinsics::const_deallocate(ptr, 4, 3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_W` failed here diff --git a/tests/ui/consts/const-eval/heap/make-global-dangling.stderr b/tests/ui/consts/const-eval/heap/make-global-dangling.stderr index 48c2796d0bf21..5d9f1f5e2e8e3 100644 --- a/tests/ui/consts/const-eval/heap/make-global-dangling.stderr +++ b/tests/ui/consts/const-eval/heap/make-global-dangling.stderr @@ -1,12 +1,14 @@ error[E0080]: pointer not dereferenceable: pointer must point to some allocation, but got null pointer --> $DIR/make-global-dangling.rs:9:8 | +LL | const Y: &u32 = unsafe { LL | &*(intrinsics::const_make_global(std::ptr::null_mut()) as *const u32) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `Y` failed here error[E0080]: pointer not dereferenceable: pointer must point to some allocation, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) --> $DIR/make-global-dangling.rs:14:8 | +LL | const Z: &u32 = unsafe { LL | &*(intrinsics::const_make_global(std::ptr::dangling_mut()) as *const u32) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `Z` failed here diff --git a/tests/ui/consts/const-eval/heap/make-global-other.stderr b/tests/ui/consts/const-eval/heap/make-global-other.stderr index f97c25bdc4957..9c34b45f13c96 100644 --- a/tests/ui/consts/const-eval/heap/make-global-other.stderr +++ b/tests/ui/consts/const-eval/heap/make-global-other.stderr @@ -1,6 +1,7 @@ error[E0080]: pointer passed to `const_make_global` does not point to a heap allocation: ALLOC$ID --> $DIR/make-global-other.rs:11:8 | +LL | const Y: &i32 = unsafe { LL | &*(intrinsics::const_make_global(X as *const i32 as *mut u8) as *const i32) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `Y` failed here diff --git a/tests/ui/consts/const-eval/heap/make-global-twice.stderr b/tests/ui/consts/const-eval/heap/make-global-twice.stderr index a499299d5297f..31bb1b13aebaa 100644 --- a/tests/ui/consts/const-eval/heap/make-global-twice.stderr +++ b/tests/ui/consts/const-eval/heap/make-global-twice.stderr @@ -1,6 +1,8 @@ error[E0080]: attempting to call `const_make_global` twice on the same allocation ALLOC$ID --> $DIR/make-global-twice.rs:13:5 | +LL | const Y: &i32 = unsafe { +... LL | intrinsics::const_make_global(ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `Y` failed here diff --git a/tests/ui/consts/const-eval/heap/ptr_made_global_mutated.stderr b/tests/ui/consts/const-eval/heap/ptr_made_global_mutated.stderr index 8e56ff1cbb7c6..c894a9f9121e4 100644 --- a/tests/ui/consts/const-eval/heap/ptr_made_global_mutated.stderr +++ b/tests/ui/consts/const-eval/heap/ptr_made_global_mutated.stderr @@ -1,6 +1,8 @@ error[E0080]: writing to ALLOC$ID which is read-only --> $DIR/ptr_made_global_mutated.rs:10:5 | +LL | const A: &u8 = unsafe { +... LL | *(ptr as *mut u8) = 2; | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `A` failed here diff --git a/tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr b/tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr index 495cc0eb8921b..3f14fd9aa5ef1 100644 --- a/tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr +++ b/tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr @@ -1,6 +1,7 @@ error[E0080]: index out of bounds: the length is 0 but the index is 0 --> $DIR/index-out-of-bounds-never-type.rs:9:61 | +LL | impl PrintName { LL | const VOID: ! = { let x = 0 * std::mem::size_of::(); [][x] }; | ^^^^^ evaluation of `PrintName::<()>::VOID` failed here diff --git a/tests/ui/consts/const-eval/issue-43197.stderr b/tests/ui/consts/const-eval/issue-43197.stderr index c525fd1c13bed..1f1ec51198c7b 100644 --- a/tests/ui/consts/const-eval/issue-43197.stderr +++ b/tests/ui/consts/const-eval/issue-43197.stderr @@ -1,12 +1,15 @@ error[E0080]: attempt to compute `0_u32 - 1_u32`, which would overflow --> $DIR/issue-43197.rs:6:20 | +LL | fn main() { LL | const X: u32 = 0 - 1; | ^^^^^ evaluation of `main::X` failed here error[E0080]: attempt to compute `0_u32 - 1_u32`, which would overflow --> $DIR/issue-43197.rs:8:24 | +LL | fn main() { +... LL | const Y: u32 = foo(0 - 1); | ^^^^^ evaluation of `main::Y` failed here diff --git a/tests/ui/consts/const-eval/issue-44578.stderr b/tests/ui/consts/const-eval/issue-44578.stderr index 7625664f9ed65..cfd5cc4e67433 100644 --- a/tests/ui/consts/const-eval/issue-44578.stderr +++ b/tests/ui/consts/const-eval/issue-44578.stderr @@ -1,6 +1,7 @@ error[E0080]: index out of bounds: the length is 1 but the index is 1 --> $DIR/issue-44578.rs:14:24 | +LL | impl Foo for Bar { LL | const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of ` as Foo>::AMT` failed here diff --git a/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr b/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr index 6c0d6cf8b2153..2b1901a74f5b3 100644 --- a/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr +++ b/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr @@ -1,6 +1,7 @@ error[E0080]: index out of bounds: the length is 3 but the index is 42 --> $DIR/issue-50814-2.rs:17:24 | +LL | impl Foo for A { LL | const BAR: usize = [5, 6, 7][T::BOO]; | ^^^^^^^^^^^^^^^^^ evaluation of ` as Foo<()>>::BAR` failed here diff --git a/tests/ui/consts/const-eval/issue-50814-2.normal.stderr b/tests/ui/consts/const-eval/issue-50814-2.normal.stderr index 749c9dde1ce19..a812289d1d6cb 100644 --- a/tests/ui/consts/const-eval/issue-50814-2.normal.stderr +++ b/tests/ui/consts/const-eval/issue-50814-2.normal.stderr @@ -1,6 +1,7 @@ error[E0080]: index out of bounds: the length is 3 but the index is 42 --> $DIR/issue-50814-2.rs:17:24 | +LL | impl Foo for A { LL | const BAR: usize = [5, 6, 7][T::BOO]; | ^^^^^^^^^^^^^^^^^ evaluation of ` as Foo<()>>::BAR` failed here diff --git a/tests/ui/consts/const-eval/issue-50814.stderr b/tests/ui/consts/const-eval/issue-50814.stderr index 1287c83ae0ff8..1dcde371e99c3 100644 --- a/tests/ui/consts/const-eval/issue-50814.stderr +++ b/tests/ui/consts/const-eval/issue-50814.stderr @@ -1,6 +1,7 @@ error[E0080]: attempt to compute `u8::MAX + u8::MAX`, which would overflow --> $DIR/issue-50814.rs:16:21 | +LL | impl Unsigned for Sum { LL | const MAX: u8 = A::MAX + B::MAX; | ^^^^^^^^^^^^^^^ evaluation of ` as Unsigned>::MAX` failed here @@ -13,6 +14,7 @@ LL | &Sum::::MAX error[E0080]: attempt to compute `u8::MAX + u8::MAX`, which would overflow --> $DIR/issue-50814.rs:16:21 | +LL | impl Unsigned for Sum { LL | const MAX: u8 = A::MAX + B::MAX; | ^^^^^^^^^^^^^^^ evaluation of ` as Unsigned>::MAX` failed here | diff --git a/tests/ui/consts/const-eval/issue-85155.stderr b/tests/ui/consts/const-eval/issue-85155.stderr index dfc784bc7a4f3..f08456ddb3834 100644 --- a/tests/ui/consts/const-eval/issue-85155.stderr +++ b/tests/ui/consts/const-eval/issue-85155.stderr @@ -1,6 +1,8 @@ error[E0080]: attempt to divide `1_usize` by zero --> $DIR/auxiliary/post_monomorphization_error.rs:7:17 | +LL | impl ValidateConstImm { +LL | pub(crate) const VALID: () = { LL | let _ = 1 / ((IMM >= MIN && IMM <= MAX) as usize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `post_monomorphization_error::ValidateConstImm::<2, 0, 1>::VALID` failed here diff --git a/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.stderr b/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.stderr index d2c1e4fde9c0e..8f7983e448df0 100644 --- a/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.stderr +++ b/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.stderr @@ -1,6 +1,8 @@ error[E0080]: `extern type` field does not have a known offset --> $DIR/issue-91827-extern-types-field-offset.rs:38:17 | +LL | const OFFSET: () = unsafe { +... LL | let field = &x.a; | ^^^^ evaluation of `OFFSET` failed here diff --git a/tests/ui/consts/const-eval/mod-static-with-const-fn.stderr b/tests/ui/consts/const-eval/mod-static-with-const-fn.stderr index f8a6fa24a3624..ecfac002f8def 100644 --- a/tests/ui/consts/const-eval/mod-static-with-const-fn.stderr +++ b/tests/ui/consts/const-eval/mod-static-with-const-fn.stderr @@ -1,6 +1,7 @@ error[E0080]: modifying a static's initial value from another static's initializer --> $DIR/mod-static-with-const-fn.rs:14:5 | +LL | static BAR: () = unsafe { LL | *FOO.0.get() = 5; | ^^^^^^^^^^^^^^^^ evaluation of `BAR` failed here diff --git a/tests/ui/consts/const-eval/panic-assoc-never-type.stderr b/tests/ui/consts/const-eval/panic-assoc-never-type.stderr index 18cf327d9cd40..c1908805b7c92 100644 --- a/tests/ui/consts/const-eval/panic-assoc-never-type.stderr +++ b/tests/ui/consts/const-eval/panic-assoc-never-type.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/panic-assoc-never-type.rs:9:21 | +LL | impl PrintName { LL | const VOID: ! = panic!(); | ^^^^^^^^ evaluation of `PrintName::VOID` failed here diff --git a/tests/ui/consts/const-eval/ptr_fragments_mixed.stderr b/tests/ui/consts/const-eval/ptr_fragments_mixed.stderr index a9be41f10d410..79d4ebf1a9ec7 100644 --- a/tests/ui/consts/const-eval/ptr_fragments_mixed.stderr +++ b/tests/ui/consts/const-eval/ptr_fragments_mixed.stderr @@ -1,6 +1,8 @@ error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID --> $DIR/ptr_fragments_mixed.rs:19:9 | +LL | const APTR: *const u8 = { +... LL | y | ^ evaluation of `APTR` failed here | @@ -10,6 +12,8 @@ LL | y error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID --> $DIR/ptr_fragments_mixed.rs:33:9 | +LL | const BPTR: *const u8 = { +... LL | y | ^ evaluation of `BPTR` failed here | diff --git a/tests/ui/consts/const-eval/raw-pointer-ub.stderr b/tests/ui/consts/const-eval/raw-pointer-ub.stderr index 5769f46022ff1..340074594f952 100644 --- a/tests/ui/consts/const-eval/raw-pointer-ub.stderr +++ b/tests/ui/consts/const-eval/raw-pointer-ub.stderr @@ -1,18 +1,24 @@ error[E0080]: accessing memory based on pointer with alignment 1, but alignment 4 is required --> $DIR/raw-pointer-ub.rs:4:16 | +LL | const MISALIGNED_LOAD: () = unsafe { +... LL | let _val = *ptr; | ^^^^ evaluation of `MISALIGNED_LOAD` failed here error[E0080]: accessing memory based on pointer with alignment 1, but alignment 4 is required --> $DIR/raw-pointer-ub.rs:11:5 | +LL | const MISALIGNED_STORE: () = unsafe { +... LL | *ptr = 0; | ^^^^^^^^ evaluation of `MISALIGNED_STORE` failed here error[E0080]: accessing memory with alignment 1, but alignment 4 is required --> $DIR/raw-pointer-ub.rs:19:5 | +LL | const MISALIGNED_COPY: () = unsafe { +... LL | y.copy_to_nonoverlapping(&mut z, 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `MISALIGNED_COPY` failed inside this call | @@ -22,12 +28,16 @@ note: inside `std::ptr::copy_nonoverlapping::` error[E0080]: accessing memory based on pointer with alignment 4, but alignment 16 is required --> $DIR/raw-pointer-ub.rs:33:16 | +LL | const MISALIGNED_FIELD: () = unsafe { +... LL | let _val = (*ptr).0; | ^^^^^^^^ evaluation of `MISALIGNED_FIELD` failed here error[E0080]: memory access failed: attempting to access 8 bytes, but got ALLOC$ID which is only 4 bytes from the end of the allocation --> $DIR/raw-pointer-ub.rs:40:16 | +LL | const OOB: () = unsafe { +... LL | let _val = *ptr; | ^^^^ evaluation of `OOB` failed here diff --git a/tests/ui/consts/const-eval/read_partial_ptr.stderr b/tests/ui/consts/const-eval/read_partial_ptr.stderr index c2d220b2e1e21..3f9f08ac6f1a9 100644 --- a/tests/ui/consts/const-eval/read_partial_ptr.stderr +++ b/tests/ui/consts/const-eval/read_partial_ptr.stderr @@ -1,6 +1,8 @@ error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID --> $DIR/read_partial_ptr.rs:10:13 | +LL | const PARTIAL_OVERWRITE: () = { +... LL | let x = *p; | ^^ evaluation of `PARTIAL_OVERWRITE` failed here | @@ -10,6 +12,8 @@ LL | let x = *p; error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID --> $DIR/read_partial_ptr.rs:23:13 | +LL | const PTR_BYTES_SWAP: () = { +... LL | let x = *p; | ^^ evaluation of `PTR_BYTES_SWAP` failed here | @@ -19,6 +23,8 @@ LL | let x = *p; error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID --> $DIR/read_partial_ptr.rs:34:13 | +LL | const PTR_BYTES_REPEAT: () = { +... LL | let x = *p; | ^^ evaluation of `PTR_BYTES_REPEAT` failed here | @@ -28,6 +34,8 @@ LL | let x = *p; error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID --> $DIR/read_partial_ptr.rs:46:13 | +LL | const PTR_BYTES_MIX: () = { +... LL | let x = *p; | ^^ evaluation of `PTR_BYTES_MIX` failed here | diff --git a/tests/ui/consts/const-eval/shift_overflow.stderr b/tests/ui/consts/const-eval/shift_overflow.stderr index 8c32ddb59081f..8e0efcea6e1ce 100644 --- a/tests/ui/consts/const-eval/shift_overflow.stderr +++ b/tests/ui/consts/const-eval/shift_overflow.stderr @@ -1,6 +1,8 @@ error[E0080]: attempt to shift left by `4294967296_u64`, which would overflow --> $DIR/shift_overflow.rs:3:9 | +LL | enum Foo { +LL | // test that we detect overflows for non-u32 discriminants LL | X = 1 << ((u32::MAX as u64) + 1), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `Foo::X::{constant#0}` failed here diff --git a/tests/ui/consts/const-eval/ub-enum-overwrite.stderr b/tests/ui/consts/const-eval/ub-enum-overwrite.stderr index bda771bd38e88..4563c7ac72dff 100644 --- a/tests/ui/consts/const-eval/ub-enum-overwrite.stderr +++ b/tests/ui/consts/const-eval/ub-enum-overwrite.stderr @@ -1,6 +1,8 @@ error[E0080]: reading memory at ALLOC$ID[0x1..0x2], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory --> $DIR/ub-enum-overwrite.rs:11:14 | +LL | const _: u8 = { +... LL | unsafe { *p } | ^^ evaluation of `_` failed here | diff --git a/tests/ui/consts/const-eval/ub-enum.stderr b/tests/ui/consts/const-eval/ub-enum.stderr index 8f0b90dcfca75..3694481ba2cec 100644 --- a/tests/ui/consts/const-eval/ub-enum.stderr +++ b/tests/ui/consts/const-eval/ub-enum.stderr @@ -123,6 +123,8 @@ LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { error[E0080]: read discriminant of an uninhabited enum variant --> $DIR/ub-enum.rs:105:9 | +LL | const TEST_ICE_89765: () = { +... LL | std::mem::discriminant(&*(&() as *const () as *const Never)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `TEST_ICE_89765` failed inside this call | diff --git a/tests/ui/consts/const-eval/ub-invalid-values.stderr b/tests/ui/consts/const-eval/ub-invalid-values.stderr index 3a3b9bc16b850..f4dbdf9ee1462 100644 --- a/tests/ui/consts/const-eval/ub-invalid-values.stderr +++ b/tests/ui/consts/const-eval/ub-invalid-values.stderr @@ -1,6 +1,8 @@ error[E0080]: interpreting an invalid 8-bit value as a bool: 0x03 --> $DIR/ub-invalid-values.rs:8:5 | +LL | const _: () = { +LL | let v = 3_u8; LL | bool_cast(&v as *const u8 as *const bool); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed inside this call | diff --git a/tests/ui/consts/const-eval/ub-nonnull.stderr b/tests/ui/consts/const-eval/ub-nonnull.stderr index d34425ea79ad9..a8031cf09421e 100644 --- a/tests/ui/consts/const-eval/ub-nonnull.stderr +++ b/tests/ui/consts/const-eval/ub-nonnull.stderr @@ -12,6 +12,8 @@ LL | const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 255 bytes, but got ALLOC$ID which is only 1 byte from the end of the allocation --> $DIR/ub-nonnull.rs:24:29 | +LL | const OUT_OF_BOUNDS_PTR: NonNull = { unsafe { +... LL | let out_of_bounds_ptr = &(*ptr)[255]; | ^^^^^^^^^^^^ evaluation of `OUT_OF_BOUNDS_PTR` failed here diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.stderr b/tests/ui/consts/const-eval/ub-ref-ptr.stderr index f1f219243c385..9824e10af44c5 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-ref-ptr.stderr @@ -181,6 +181,8 @@ LL | const MAYBE_NULL_FN_PTR: fn() = unsafe { mem::transmute({ error[E0080]: accessing memory based on pointer with alignment 1, but alignment 4 is required --> $DIR/ub-ref-ptr.rs:77:5 | +LL | const UNALIGNED_READ: () = unsafe { +... LL | ptr.read(); | ^^^^^^^^^^ evaluation of `UNALIGNED_READ` failed here diff --git a/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr b/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr index 052ddb527a546..f3e25d3972e00 100644 --- a/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr +++ b/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr @@ -27,6 +27,8 @@ error[E0080]: evaluation panicked: unsafe precondition(s) violated: slice::get_u This indicates a bug in the program. This Undefined Behavior check is optional, and cannot be relied on for safety. --> $DIR/ub-slice-get-unchecked.rs:20:13 | +LL | const INDEX_OOB_MUT: () = unsafe { +LL | let mut array = ARRAY; LL | let _ = array.get_unchecked_mut(9); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `INDEX_OOB_MUT` failed here diff --git a/tests/ui/consts/const-eval/ub-uninhabit.stderr b/tests/ui/consts/const-eval/ub-uninhabit.stderr index a1bf930651dba..d9ffc4264a124 100644 --- a/tests/ui/consts/const-eval/ub-uninhabit.stderr +++ b/tests/ui/consts/const-eval/ub-uninhabit.stderr @@ -24,6 +24,8 @@ LL | const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init }; error[E0080]: constructing invalid value of type !: encountered a value of the never type `!` --> $DIR/ub-uninhabit.rs:31:16 | +LL | const READ_NEVER: () = unsafe { +... LL | let _val = intrinsics::read_via_copy(ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `READ_NEVER` failed here diff --git a/tests/ui/consts/const-eval/ub-write-through-immutable.stderr b/tests/ui/consts/const-eval/ub-write-through-immutable.stderr index 13b2585d4dc98..5f94f7a038f63 100644 --- a/tests/ui/consts/const-eval/ub-write-through-immutable.stderr +++ b/tests/ui/consts/const-eval/ub-write-through-immutable.stderr @@ -1,12 +1,16 @@ error[E0080]: writing through a pointer that was derived from a shared (immutable) reference --> $DIR/ub-write-through-immutable.rs:10:5 | +LL | const WRITE_AFTER_CAST: () = unsafe { +... LL | *ptr = 0; | ^^^^^^^^ evaluation of `WRITE_AFTER_CAST` failed here error[E0080]: writing through a pointer that was derived from a shared (immutable) reference --> $DIR/ub-write-through-immutable.rs:16:5 | +LL | const WRITE_AFTER_TRANSMUTE: () = unsafe { +... LL | *ptr = 0; | ^^^^^^^^ evaluation of `WRITE_AFTER_TRANSMUTE` failed here diff --git a/tests/ui/consts/const-eval/union-const-eval-field.stderr b/tests/ui/consts/const-eval/union-const-eval-field.stderr index e86e1fa22a7e5..be688cb9b908e 100644 --- a/tests/ui/consts/const-eval/union-const-eval-field.stderr +++ b/tests/ui/consts/const-eval/union-const-eval-field.stderr @@ -1,6 +1,7 @@ error[E0080]: reading memory at ALLOC$ID[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory --> $DIR/union-const-eval-field.rs:30:37 | +LL | const fn read_field3() -> Field3 { LL | const FIELD3: Field3 = unsafe { UNION.field3 }; | ^^^^^^^^^^^^ evaluation of `read_field3::FIELD3` failed here | diff --git a/tests/ui/consts/const-eval/union-ice.stderr b/tests/ui/consts/const-eval/union-ice.stderr index 6a4927e42d240..48305537a1f88 100644 --- a/tests/ui/consts/const-eval/union-ice.stderr +++ b/tests/ui/consts/const-eval/union-ice.stderr @@ -11,6 +11,8 @@ LL | const FIELD3: Field3 = unsafe { UNION.field3 }; error[E0080]: reading memory at ALLOC$ID[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory --> $DIR/union-ice.rs:19:17 | +LL | const FIELD_PATH: Struct = Struct { +LL | a: 42, LL | b: unsafe { UNION.field3 }, | ^^^^^^^^^^^^ evaluation of `FIELD_PATH` failed here | @@ -21,6 +23,8 @@ LL | b: unsafe { UNION.field3 }, error[E0080]: reading memory at ALLOC$ID[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory --> $DIR/union-ice.rs:31:18 | +LL | const FIELD_PATH2: Struct2 = Struct2 { +... LL | unsafe { UNION.field3 }, | ^^^^^^^^^^^^ evaluation of `FIELD_PATH2` failed here | diff --git a/tests/ui/consts/const-len-underflow-subspans.stderr b/tests/ui/consts/const-len-underflow-subspans.stderr index 51825a03db88e..a98a7af31e7a4 100644 --- a/tests/ui/consts/const-len-underflow-subspans.stderr +++ b/tests/ui/consts/const-len-underflow-subspans.stderr @@ -1,6 +1,7 @@ error[E0080]: attempt to compute `1_usize - 2_usize`, which would overflow --> $DIR/const-len-underflow-subspans.rs:8:17 | +LL | fn main() { LL | let a: [i8; ONE - TWO] = unimplemented!(); | ^^^^^^^^^ evaluation of `main::{constant#0}` failed here diff --git a/tests/ui/consts/const-ptr-is-null.stderr b/tests/ui/consts/const-ptr-is-null.stderr index b532ed9d4c5fa..f274def63a5d8 100644 --- a/tests/ui/consts/const-ptr-is-null.stderr +++ b/tests/ui/consts/const-ptr-is-null.stderr @@ -1,6 +1,8 @@ error[E0080]: evaluation panicked: null-ness of this pointer cannot be determined in const context --> $DIR/const-ptr-is-null.rs:22:14 | +LL | const MAYBE_NULL: () = { +... LL | assert!(!ptr.wrapping_sub(512).is_null()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `MAYBE_NULL` failed inside this call | diff --git a/tests/ui/consts/const_refs_to_static_fail.stderr b/tests/ui/consts/const_refs_to_static_fail.stderr index 1c514f337817f..8fce264e02b23 100644 --- a/tests/ui/consts/const_refs_to_static_fail.stderr +++ b/tests/ui/consts/const_refs_to_static_fail.stderr @@ -1,12 +1,14 @@ error[E0080]: constant accesses mutable global memory --> $DIR/const_refs_to_static_fail.rs:14:13 | +LL | const C1_READ: () = unsafe { LL | assert!(*C1.get() == 0); | ^^^^^^^^^ evaluation of `C1_READ` failed here error[E0080]: constant accesses mutable global memory --> $DIR/const_refs_to_static_fail.rs:18:13 | +LL | const C2_READ: () = unsafe { LL | assert!(*C2 == 0); | ^^^ evaluation of `C2_READ` failed here diff --git a/tests/ui/consts/const_transmute_type_id.stderr b/tests/ui/consts/const_transmute_type_id.stderr index 85bd4ea2736a9..aac866e8352ed 100644 --- a/tests/ui/consts/const_transmute_type_id.stderr +++ b/tests/ui/consts/const_transmute_type_id.stderr @@ -1,6 +1,8 @@ error[E0080]: unable to turn pointer into integer --> $DIR/const_transmute_type_id.rs:7:27 | +LL | const _: () = { +LL | let id = TypeId::of::(); LL | let id: u8 = unsafe { (&raw const id).cast::().read() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here | diff --git a/tests/ui/consts/const_transmute_type_id2.stderr b/tests/ui/consts/const_transmute_type_id2.stderr index 9c103c5c2ba6b..d371061230c25 100644 --- a/tests/ui/consts/const_transmute_type_id2.stderr +++ b/tests/ui/consts/const_transmute_type_id2.stderr @@ -1,6 +1,8 @@ error[E0080]: pointer not dereferenceable: pointer must point to some allocation, but got [noalloc] which is a dangling pointer (it has no provenance) --> $DIR/const_transmute_type_id2.rs:10:13 | +LL | const _: () = { +... LL | assert!(a == b); | ^^^^^^ evaluation of `_` failed inside this call | diff --git a/tests/ui/consts/const_transmute_type_id3.stderr b/tests/ui/consts/const_transmute_type_id3.stderr index 679b048c1ab73..7c77df8fae858 100644 --- a/tests/ui/consts/const_transmute_type_id3.stderr +++ b/tests/ui/consts/const_transmute_type_id3.stderr @@ -1,6 +1,8 @@ error[E0080]: pointer not dereferenceable: pointer must point to some allocation, but got 0x3e7[noalloc] which is a dangling pointer (it has no provenance) --> $DIR/const_transmute_type_id3.rs:15:13 | +LL | const _: () = { +... LL | assert!(a == b); | ^^^^^^ evaluation of `_` failed inside this call | diff --git a/tests/ui/consts/const_transmute_type_id4.stderr b/tests/ui/consts/const_transmute_type_id4.stderr index 4060f086cbac4..46b7e763029eb 100644 --- a/tests/ui/consts/const_transmute_type_id4.stderr +++ b/tests/ui/consts/const_transmute_type_id4.stderr @@ -1,6 +1,8 @@ error[E0080]: invalid `TypeId` value: not all bytes carry type id metadata --> $DIR/const_transmute_type_id4.rs:12:13 | +LL | const _: () = { +... LL | assert!(a == b); | ^^^^^^ evaluation of `_` failed inside this call | diff --git a/tests/ui/consts/const_transmute_type_id5.stderr b/tests/ui/consts/const_transmute_type_id5.stderr index ac057d829562f..8d499c7d8f05e 100644 --- a/tests/ui/consts/const_transmute_type_id5.stderr +++ b/tests/ui/consts/const_transmute_type_id5.stderr @@ -1,6 +1,8 @@ error[E0080]: invalid `TypeId` value: the hash does not match the type id metadata --> $DIR/const_transmute_type_id5.rs:16:13 | +LL | const _: () = { +... LL | assert!(b == b); | ^^^^^^ evaluation of `_` failed inside this call | diff --git a/tests/ui/consts/const_transmute_type_id6.stderr b/tests/ui/consts/const_transmute_type_id6.stderr index fd3ac663505fc..fa1f0a910b275 100644 --- a/tests/ui/consts/const_transmute_type_id6.stderr +++ b/tests/ui/consts/const_transmute_type_id6.stderr @@ -1,6 +1,8 @@ error[E0080]: invalid `TypeId` value: not all bytes carry type id metadata --> $DIR/const_transmute_type_id6.rs:12:5 | +LL | const X: bool = { +... LL | id == id | ^^^^^^^^ evaluation of `X` failed inside this call | diff --git a/tests/ui/consts/copy-intrinsic.stderr b/tests/ui/consts/copy-intrinsic.stderr index 4c56304e4c157..1bcf94d203c82 100644 --- a/tests/ui/consts/copy-intrinsic.stderr +++ b/tests/ui/consts/copy-intrinsic.stderr @@ -1,24 +1,32 @@ error[E0080]: memory access failed: attempting to access 4 bytes, but got 0x100[noalloc] which is a dangling pointer (it has no provenance) --> $DIR/copy-intrinsic.rs:20:5 | +LL | const COPY_OOB_1: () = unsafe { +... LL | copy_nonoverlapping(0x100 as *const i32, dangle, 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `COPY_OOB_1` failed here error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID+0x28 which is at or beyond the end of the allocation of size 4 bytes --> $DIR/copy-intrinsic.rs:28:5 | +LL | const COPY_OOB_2: () = unsafe { +... LL | copy_nonoverlapping(dangle, 0x100 as *mut i32, 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `COPY_OOB_2` failed here error[E0080]: overflow computing total size of `copy` --> $DIR/copy-intrinsic.rs:34:5 | +LL | const COPY_SIZE_OVERFLOW: () = unsafe { +... LL | copy(&x, &mut y, 1usize << (mem::size_of::() * 8 - 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `COPY_SIZE_OVERFLOW` failed here error[E0080]: overflow computing total size of `copy_nonoverlapping` --> $DIR/copy-intrinsic.rs:39:5 | +LL | const COPY_NONOVERLAPPING_SIZE_OVERFLOW: () = unsafe { +... LL | copy_nonoverlapping(&x, &mut y, 1usize << (mem::size_of::() * 8 - 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `COPY_NONOVERLAPPING_SIZE_OVERFLOW` failed here diff --git a/tests/ui/consts/eval-enum.stderr b/tests/ui/consts/eval-enum.stderr index d647485bc5dcb..6ed0c069165f7 100644 --- a/tests/ui/consts/eval-enum.stderr +++ b/tests/ui/consts/eval-enum.stderr @@ -1,12 +1,15 @@ error[E0080]: attempt to divide `1_isize` by zero --> $DIR/eval-enum.rs:2:15 | +LL | enum Test { LL | DivZero = 1 / 0, | ^^^^^ evaluation of `Test::DivZero::{constant#0}` failed here error[E0080]: attempt to calculate the remainder of `1_isize` with a divisor of zero --> $DIR/eval-enum.rs:4:15 | +LL | enum Test { +... LL | RemZero = 1 % 0, | ^^^^^ evaluation of `Test::RemZero::{constant#0}` failed here diff --git a/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr b/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr index 870f89733409b..a290d1b82cbed 100644 --- a/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr +++ b/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr @@ -1,12 +1,14 @@ error[E0080]: constructing invalid value of type bool: encountered 0x03, but expected a boolean --> $DIR/detect-extra-ub.rs:29:20 | +LL | const INVALID_BOOL: () = unsafe { LL | let _x: bool = transmute(3u8); | ^^^^^^^^^^^^^^ evaluation of `INVALID_BOOL` failed here error[E0080]: constructing invalid value of type usize: encountered a pointer, but expected an integer --> $DIR/detect-extra-ub.rs:34:21 | +LL | const INVALID_PTR_IN_INT: () = unsafe { LL | let _x: usize = transmute(&3u8); | ^^^^^^^^^^^^^^^ evaluation of `INVALID_PTR_IN_INT` failed here | @@ -16,6 +18,7 @@ LL | let _x: usize = transmute(&3u8); error[E0080]: constructing invalid value of type PtrSizedEnum: at ., encountered a pointer, but expected an integer --> $DIR/detect-extra-ub.rs:39:28 | +LL | const INVALID_PTR_IN_ENUM: () = unsafe { LL | let _x: PtrSizedEnum = transmute(&3u8); | ^^^^^^^^^^^^^^^ evaluation of `INVALID_PTR_IN_ENUM` failed here | @@ -25,6 +28,8 @@ LL | let _x: PtrSizedEnum = transmute(&3u8); error[E0080]: constructing invalid value of type (usize, usize): at .0, encountered a pointer, but expected an integer --> $DIR/detect-extra-ub.rs:45:30 | +LL | const INVALID_SLICE_TO_USIZE_TRANSMUTE: () = unsafe { +LL | let x: &[u8] = &[0; 32]; LL | let _x: (usize, usize) = transmute(x); | ^^^^^^^^^^^^ evaluation of `INVALID_SLICE_TO_USIZE_TRANSMUTE` failed here | @@ -34,12 +39,14 @@ LL | let _x: (usize, usize) = transmute(x); error[E0080]: constructing invalid value of type &u32: encountered an unaligned reference (required 4 byte alignment but found 1) --> $DIR/detect-extra-ub.rs:50:20 | +LL | const UNALIGNED_PTR: () = unsafe { LL | let _x: &u32 = transmute(&[0u8; 4]); | ^^^^^^^^^^^^^^^^^^^^ evaluation of `UNALIGNED_PTR` failed here error[E0080]: constructing invalid value of type fn(): encountered a maybe-null function pointer --> $DIR/detect-extra-ub.rs:56:20 | +LL | const MAYBE_NULL_FN_PTR: () = unsafe { LL | let _x: fn() = transmute({ | ____________________^ LL | | @@ -52,12 +59,16 @@ LL | | }); error[E0080]: constructing invalid value of type UninhDiscriminant: at ., encountered an uninhabited enum variant --> $DIR/detect-extra-ub.rs:67:13 | +LL | const UNINHABITED_VARIANT: () = unsafe { +... LL | let v = *addr_of!(data).cast::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNINHABITED_VARIANT` failed here error[E0080]: constructing invalid value of type [*const u8; 2]: at [0], encountered a partial pointer or a mix of pointers --> $DIR/detect-extra-ub.rs:86:16 | +LL | const PARTIAL_POINTER: () = unsafe { +... LL | let _val = *(&mem as *const Align as *const [*const u8; 2]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `PARTIAL_POINTER` failed here | @@ -67,6 +78,8 @@ LL | let _val = *(&mem as *const Align as *const [*const u8; 2]); error[E0080]: constructing invalid value of type &[u8]: encountered invalid reference metadata: slice is bigger than largest supported object --> $DIR/detect-extra-ub.rs:100:16 | +LL | const OVERSIZED_REF: () = { unsafe { +LL | let slice: *const [u8] = transmute((1usize, usize::MAX)); LL | let _val = &*slice; | ^^^^^^^ evaluation of `OVERSIZED_REF` failed here diff --git a/tests/ui/consts/issue-64506.stderr b/tests/ui/consts/issue-64506.stderr index 822c3a5c70dd6..6d7237644a8c3 100644 --- a/tests/ui/consts/issue-64506.stderr +++ b/tests/ui/consts/issue-64506.stderr @@ -1,6 +1,8 @@ error[E0080]: constructing invalid value of type ChildStdin: at .inner, encountered a value of zero-variant enum `AnonPipe` --> $DIR/issue-64506.rs:16:22 | +LL | const FOO: () = { +... LL | let x = unsafe { Foo { b: () }.a }; | ^^^^^^^^^^^^^^^ evaluation of `FOO` failed here diff --git a/tests/ui/consts/issue-miri-1910.stderr b/tests/ui/consts/issue-miri-1910.stderr index 140b1861bb42a..af4e3f3fc5352 100644 --- a/tests/ui/consts/issue-miri-1910.stderr +++ b/tests/ui/consts/issue-miri-1910.stderr @@ -1,6 +1,8 @@ error[E0080]: unable to turn pointer into integer --> $DIR/issue-miri-1910.rs:7:5 | +LL | const C: () = unsafe { +... LL | (&foo as *const _ as *const u8).add(one_and_a_half_pointers).read(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `C` failed here | diff --git a/tests/ui/consts/large_const_alloc.stderr b/tests/ui/consts/large_const_alloc.stderr index a0b21555608d8..d07eb64d2325b 100644 --- a/tests/ui/consts/large_const_alloc.stderr +++ b/tests/ui/consts/large_const_alloc.stderr @@ -1,12 +1,15 @@ error[E0080]: tried to allocate more memory than available to compiler --> $DIR/large_const_alloc.rs:11:13 | +LL | const FOO: () = { +LL | // 128 TiB, unlikely anyone has that much RAM LL | let x = [0_u8; (1 << 47) - 1]; | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `FOO` failed here error[E0080]: tried to allocate more memory than available to compiler --> $DIR/large_const_alloc.rs:16:13 | +LL | static FOO2: () = { LL | let x = [0_u8; (1 << 47) - 1]; | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `FOO2` failed here diff --git a/tests/ui/consts/miri_unleashed/assoc_const.stderr b/tests/ui/consts/miri_unleashed/assoc_const.stderr index 29f371373aef9..589fc8424c602 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const.stderr +++ b/tests/ui/consts/miri_unleashed/assoc_const.stderr @@ -1,6 +1,7 @@ error[E0080]: calling non-const function `::drop` --> $DIR/assoc_const.rs:19:31 | +LL | trait Bar> { LL | const F: u32 = (U::X, 42).1; | ^ evaluation of `>::F` failed inside this call | diff --git a/tests/ui/consts/miri_unleashed/assoc_const_2.stderr b/tests/ui/consts/miri_unleashed/assoc_const_2.stderr index a38fe346da6d7..535f025412add 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const_2.stderr +++ b/tests/ui/consts/miri_unleashed/assoc_const_2.stderr @@ -1,6 +1,7 @@ error[E0080]: attempt to divide `100_u32` by zero --> $DIR/assoc_const_2.rs:11:20 | +LL | trait Bar { LL | const F: u32 = 100 / U::X; | ^^^^^^^^^^ evaluation of `>::F` failed here diff --git a/tests/ui/consts/miri_unleashed/box.stderr b/tests/ui/consts/miri_unleashed/box.stderr index 25b717660ea0e..5a333e9103e22 100644 --- a/tests/ui/consts/miri_unleashed/box.stderr +++ b/tests/ui/consts/miri_unleashed/box.stderr @@ -1,6 +1,7 @@ error[E0080]: calling non-const function `Box::::new` --> $DIR/box.rs:8:11 | +LL | static TEST_BAD: &mut i32 = { LL | &mut *(Box::new(0)) | ^^^^^^^^^^^^^ evaluation of `TEST_BAD` failed here 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 e718aac5329a4..75aba2e3535c0 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr @@ -1,6 +1,8 @@ error[E0080]: constant accesses mutable global memory --> $DIR/const_refers_to_static.rs:11:5 | +LL | const MUTATE_INTERIOR_MUT: usize = { +LL | static FOO: AtomicUsize = AtomicUsize::new(0); LL | FOO.fetch_add(1, Ordering::Relaxed) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `MUTATE_INTERIOR_MUT` failed inside this call | @@ -16,6 +18,8 @@ note: inside `atomic::atomic_add::` error[E0080]: constant accesses mutable global memory --> $DIR/const_refers_to_static.rs:16:14 | +LL | const READ_INTERIOR_MUT: usize = { +LL | static FOO: AtomicUsize = AtomicUsize::new(0); LL | unsafe { *(&FOO as *const _ as *const usize) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `READ_INTERIOR_MUT` failed here diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr index 1ec49bff3e894..480240843720d 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr @@ -1,6 +1,8 @@ error[E0080]: constant accesses mutable global memory --> $DIR/const_refers_to_static_cross_crate.rs:27:15 | +LL | const U8_MUT3: &u8 = { +LL | unsafe { LL | match static_cross_crate::OPT_ZERO { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `U8_MUT3` failed here diff --git a/tests/ui/consts/miri_unleashed/drop.stderr b/tests/ui/consts/miri_unleashed/drop.stderr index 6e2afda763171..81e203bf19b7e 100644 --- a/tests/ui/consts/miri_unleashed/drop.stderr +++ b/tests/ui/consts/miri_unleashed/drop.stderr @@ -1,6 +1,8 @@ error[E0080]: calling non-const function `::drop` --> $DIR/drop.rs:23:1 | +LL | static TEST_BAD: () = { +LL | let _v: NotConstDestruct = NotConstDestruct; LL | }; | ^ evaluation of `TEST_BAD` failed inside this call | diff --git a/tests/ui/consts/miri_unleashed/extern-static.stderr b/tests/ui/consts/miri_unleashed/extern-static.stderr index 57b4f07b2fc88..8b1581dd08061 100644 --- a/tests/ui/consts/miri_unleashed/extern-static.stderr +++ b/tests/ui/consts/miri_unleashed/extern-static.stderr @@ -1,12 +1,14 @@ error[E0080]: cannot access extern static `DATA` --> $DIR/extern-static.rs:11:25 | +LL | static TEST_READ: () = { LL | unsafe { let _val = DATA; } | ^^^^ evaluation of `TEST_READ` failed here error[E0080]: cannot access extern static `DATA` --> $DIR/extern-static.rs:15:14 | +LL | static TEST_WRITE: () = { LL | unsafe { DATA = 0; } | ^^^^^^^^ evaluation of `TEST_WRITE` failed here diff --git a/tests/ui/consts/miri_unleashed/inline_asm.stderr b/tests/ui/consts/miri_unleashed/inline_asm.stderr index 49e54825695ee..f8d7387b9d9e3 100644 --- a/tests/ui/consts/miri_unleashed/inline_asm.stderr +++ b/tests/ui/consts/miri_unleashed/inline_asm.stderr @@ -1,6 +1,7 @@ error[E0080]: inline assembly is not supported --> $DIR/inline_asm.rs:10:14 | +LL | static TEST_BAD: () = { LL | unsafe { asm!("nop"); } | ^^^^^^^^^^^ evaluation of `TEST_BAD` failed here diff --git a/tests/ui/consts/miri_unleashed/mutating_global.stderr b/tests/ui/consts/miri_unleashed/mutating_global.stderr index f97f88a4b90a7..b133ead7716aa 100644 --- a/tests/ui/consts/miri_unleashed/mutating_global.stderr +++ b/tests/ui/consts/miri_unleashed/mutating_global.stderr @@ -1,6 +1,8 @@ error[E0080]: modifying a static's initial value from another static's initializer --> $DIR/mutating_global.rs:9:9 | +LL | static MUTATING_GLOBAL: () = { +LL | unsafe { LL | GLOBAL = 99 | ^^^^^^^^^^^ evaluation of `MUTATING_GLOBAL` failed here diff --git a/tests/ui/consts/miri_unleashed/ptr_arith.stderr b/tests/ui/consts/miri_unleashed/ptr_arith.stderr index 661a8de6a15c8..738fd03d92063 100644 --- a/tests/ui/consts/miri_unleashed/ptr_arith.stderr +++ b/tests/ui/consts/miri_unleashed/ptr_arith.stderr @@ -1,12 +1,15 @@ error[E0080]: exposing pointers is not possible at compile-time --> $DIR/ptr_arith.rs:7:13 | +LL | static PTR_INT_CAST: () = { LL | let x = &0 as *const _ as usize; | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `PTR_INT_CAST` failed here error[E0080]: unable to turn pointer into integer --> $DIR/ptr_arith.rs:14:14 | +LL | static PTR_INT_TRANSMUTE: () = unsafe { +LL | let x: usize = std::mem::transmute(&0); LL | let _v = x + 0; | ^ evaluation of `PTR_INT_TRANSMUTE` failed here | diff --git a/tests/ui/consts/miri_unleashed/tls.stderr b/tests/ui/consts/miri_unleashed/tls.stderr index 08e069dc3ff3f..089297cb576eb 100644 --- a/tests/ui/consts/miri_unleashed/tls.stderr +++ b/tests/ui/consts/miri_unleashed/tls.stderr @@ -1,12 +1,14 @@ error[E0080]: cannot access thread local static `A` --> $DIR/tls.rs:11:25 | +LL | static TEST_BAD: () = { LL | unsafe { let _val = A; } | ^ evaluation of `TEST_BAD` failed here error[E0080]: cannot access thread local static `A` --> $DIR/tls.rs:19:26 | +LL | static TEST_BAD_REF: () = { LL | unsafe { let _val = &A; } | ^ evaluation of `TEST_BAD_REF` failed here diff --git a/tests/ui/consts/missing_span_in_backtrace.stderr b/tests/ui/consts/missing_span_in_backtrace.stderr index ccba98050e79a..7af55684861bc 100644 --- a/tests/ui/consts/missing_span_in_backtrace.stderr +++ b/tests/ui/consts/missing_span_in_backtrace.stderr @@ -1,12 +1,14 @@ error[E0080]: memory access failed: attempting to access 1 byte, but got ALLOC$ID+0x4 which is at or beyond the end of the allocation of size 4 bytes --> $DIR/missing_span_in_backtrace.rs:16:9 | -16 | / ... ptr::swap_nonoverlapping( -17 | | ... &mut x1 as *mut _ as *mut MaybeUninit, -18 | | ... &mut x2 as *mut _ as *mut MaybeUninit, -19 | | ... 10, -20 | | ... ); - | |_______^ evaluation of `X` failed inside this call +10 | const X: () = { +... +16 | / ptr::swap_nonoverlapping( +17 | | &mut x1 as *mut _ as *mut MaybeUninit, +18 | | &mut x2 as *mut _ as *mut MaybeUninit, +19 | | 10, +20 | | ); + | |_________^ evaluation of `X` failed inside this call | note: inside `swap_nonoverlapping::compiletime::>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL diff --git a/tests/ui/consts/mono-reachable-invalid-const.stderr b/tests/ui/consts/mono-reachable-invalid-const.stderr index e357fd096fdfa..ae00aaec6f974 100644 --- a/tests/ui/consts/mono-reachable-invalid-const.stderr +++ b/tests/ui/consts/mono-reachable-invalid-const.stderr @@ -1,6 +1,9 @@ error[E0080]: index out of bounds: the length is 1 but the index is 1 --> $DIR/mono-reachable-invalid-const.rs:8:9 | +LL | impl Bar { +LL | const ASSERT: bool = { +LL | let b = std::convert::identity(1); LL | ["oops"][b]; | ^^^^^^^^^^^ evaluation of `Bar::<0>::ASSERT` failed here diff --git a/tests/ui/consts/offset_from_ub.stderr b/tests/ui/consts/offset_from_ub.stderr index 558e1ea02c6da..95e1819bad46d 100644 --- a/tests/ui/consts/offset_from_ub.stderr +++ b/tests/ui/consts/offset_from_ub.stderr @@ -1,12 +1,15 @@ error[E0080]: `ptr_offset_from` called on two different pointers that are not both derived from the same allocation --> $DIR/offset_from_ub.rs:20:27 | +LL | pub const DIFFERENT_ALLOC: usize = { +... LL | let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `DIFFERENT_ALLOC` failed here error[E0080]: `ptr_offset_from` called on two different pointers that are not both derived from the same allocation --> $DIR/offset_from_ub.rs:26:14 | +LL | pub const NOT_PTR: usize = { LL | unsafe { (42 as *const u8).offset_from(&5u8) as usize } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `NOT_PTR` failed inside this call | @@ -16,66 +19,88 @@ note: inside `std::ptr::const_ptr::::offset_from` error[E0080]: exact_div: 1_isize cannot be divided by 2_isize without remainder --> $DIR/offset_from_ub.rs:34:14 | +LL | pub const NOT_MULTIPLE_OF_SIZE: isize = { +... LL | unsafe { ptr_offset_from(field_ptr, base_ptr as *const u16) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `NOT_MULTIPLE_OF_SIZE` failed here error[E0080]: `ptr_offset_from` called on two different pointers that are not both derived from the same allocation --> $DIR/offset_from_ub.rs:42:14 | +LL | pub const DIFFERENT_INT: isize = { +... LL | unsafe { ptr_offset_from(ptr2, ptr1) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `DIFFERENT_INT` failed here error[E0080]: `ptr_offset_from` called on two different pointers where the memory range between them is not in-bounds of an allocation --> $DIR/offset_from_ub.rs:51:14 | +LL | const OUT_OF_BOUNDS_1: isize = { +... LL | unsafe { ptr_offset_from(end_ptr, start_ptr) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `OUT_OF_BOUNDS_1` failed here error[E0080]: `ptr_offset_from` called on two different pointers where the memory range between them is not in-bounds of an allocation --> $DIR/offset_from_ub.rs:60:14 | +LL | const OUT_OF_BOUNDS_2: isize = { +... LL | unsafe { ptr_offset_from(start_ptr, end_ptr) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `OUT_OF_BOUNDS_2` failed here error[E0080]: `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation --> $DIR/offset_from_ub.rs:69:14 | +LL | pub const DIFFERENT_ALLOC_UNSIGNED: usize = { +... LL | unsafe { ptr_offset_from_unsigned(field_ptr, base_ptr) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `DIFFERENT_ALLOC_UNSIGNED` failed here error[E0080]: `ptr_offset_from` called when first pointer is too far ahead of second --> $DIR/offset_from_ub.rs:76:14 | +LL | pub const TOO_FAR_APART1: isize = { +... LL | unsafe { ptr_offset_from(ptr2, ptr1) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `TOO_FAR_APART1` failed here error[E0080]: `ptr_offset_from` called when first pointer is too far before second --> $DIR/offset_from_ub.rs:82:14 | +LL | pub const TOO_FAR_APART2: isize = { +... LL | unsafe { ptr_offset_from(ptr1, ptr2) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `TOO_FAR_APART2` failed here error[E0080]: `ptr_offset_from` called when first pointer is too far before second --> $DIR/offset_from_ub.rs:90:14 | +LL | pub const TOO_FAR_APART3: isize = { +... LL | unsafe { ptr_offset_from(ptr1, ptr2) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `TOO_FAR_APART3` failed here error[E0080]: `ptr_offset_from_unsigned` called when first pointer has smaller offset than second: 0 < 8 --> $DIR/offset_from_ub.rs:97:14 | +LL | const WRONG_ORDER_UNSIGNED: usize = { +... LL | unsafe { ptr_offset_from_unsigned(p, p.add(2)) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `WRONG_ORDER_UNSIGNED` failed here error[E0080]: `ptr_offset_from_unsigned` called when first pointer is too far ahead of second --> $DIR/offset_from_ub.rs:104:14 | +LL | pub const TOO_FAR_APART_UNSIGNED: usize = { +... LL | unsafe { ptr_offset_from_unsigned(ptr2, ptr1) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `TOO_FAR_APART_UNSIGNED` failed here error[E0080]: `ptr_offset_from` called on two different pointers that are not both derived from the same allocation --> $DIR/offset_from_ub.rs:112:14 | +LL | pub const OFFSET_VERY_FAR1: isize = { +... LL | unsafe { ptr2.offset_from(ptr1) } | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `OFFSET_VERY_FAR1` failed inside this call | @@ -85,6 +110,8 @@ note: inside `std::ptr::const_ptr::::offset_from` error[E0080]: `ptr_offset_from` called when first pointer is too far before second --> $DIR/offset_from_ub.rs:118:14 | +LL | pub const OFFSET_VERY_FAR2: isize = { +... LL | unsafe { ptr1.offset_from(ptr2.wrapping_offset(1)) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `OFFSET_VERY_FAR2` failed inside this call | diff --git a/tests/ui/consts/qualif-indirect-mutation-fail.stderr b/tests/ui/consts/qualif-indirect-mutation-fail.stderr index 9bf679f8a5348..aef0bed72d892 100644 --- a/tests/ui/consts/qualif-indirect-mutation-fail.stderr +++ b/tests/ui/consts/qualif-indirect-mutation-fail.stderr @@ -10,6 +10,8 @@ LL | }; error[E0080]: calling non-const function `::drop` --> $DIR/qualif-indirect-mutation-fail.rs:24:1 | +LL | pub const A1: () = { +... LL | }; | ^ evaluation of `A1` failed inside this call | @@ -29,6 +31,8 @@ LL | }; error[E0080]: calling non-const function `::drop` --> $DIR/qualif-indirect-mutation-fail.rs:35:1 | +LL | pub const A2: () = { +... LL | }; | ^ evaluation of `A2` failed inside this call | diff --git a/tests/ui/consts/recursive-static-write.stderr b/tests/ui/consts/recursive-static-write.stderr index f5b5c49317cfc..fe1433b05c298 100644 --- a/tests/ui/consts/recursive-static-write.stderr +++ b/tests/ui/consts/recursive-static-write.stderr @@ -1,12 +1,16 @@ error[E0080]: encountered static that tried to access itself during initialization --> $DIR/recursive-static-write.rs:13:9 | +LL | static S: Foo = Foo { +... LL | (&raw const S.x).cast_mut().write(1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `S` failed here error[E0080]: encountered static that tried to access itself during initialization --> $DIR/recursive-static-write.rs:20:9 | +LL | static mut S2: Foo = Foo { +... LL | S2.x = 1; | ^^^^^^^^ evaluation of `S2` failed here diff --git a/tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr b/tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr index 7d7bbbc5e36c7..263478b4c4770 100644 --- a/tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-called-fn.rs:10:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-called-fn.opt.stderr b/tests/ui/consts/required-consts/collect-in-called-fn.opt.stderr index 7d7bbbc5e36c7..263478b4c4770 100644 --- a/tests/ui/consts/required-consts/collect-in-called-fn.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-called-fn.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-called-fn.rs:10:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-closure.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-closure.noopt.stderr index 239e9cb147238..4e257309d3805 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-closure.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-closure.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-closure.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-closure.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-closure.opt.stderr index 239e9cb147238..4e257309d3805 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-closure.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-closure.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-closure.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-drop.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-drop.noopt.stderr index 38e169c97016d..d288535f3d914 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-drop.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-drop.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-drop.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-drop.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-drop.opt.stderr index 38e169c97016d..d288535f3d914 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-drop.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-drop.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-drop.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.noopt.stderr index e1a82fd52310b..179d852380121 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn-behind-assoc-type.rs:10:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.opt.stderr index e1a82fd52310b..179d852380121 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn-behind-assoc-type.rs:10:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.noopt.stderr index 1d2af342a4435..e3d55977c1aa3 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn-behind-generic.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.opt.stderr index 1d2af342a4435..e3d55977c1aa3 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn-behind-generic.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr index 42a4ca2fd9d7c..dab9944fb90eb 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn-behind-opaque-type.rs:11:23 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `m::Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr index 42a4ca2fd9d7c..dab9944fb90eb 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn-behind-opaque-type.rs:11:23 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `m::Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn.noopt.stderr index f253a7cbbee38..79f40eed2789e 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn.opt.stderr index f253a7cbbee38..79f40eed2789e 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.noopt.stderr index b962630ca016c..9216dea4b30fc 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fnptr-in-const.rs:9:22 | +LL | impl Late { LL | const FAIL: () = panic!(); | ^^^^^^^^ evaluation of `Late::::FAIL` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.opt.stderr index b962630ca016c..9216dea4b30fc 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fnptr-in-const.rs:9:22 | +LL | impl Late { LL | const FAIL: () = panic!(); | ^^^^^^^^ evaluation of `Late::::FAIL` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fnptr.noopt.stderr index 29e6711153c9e..b709a91b3a918 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fnptr.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fnptr.opt.stderr index 29e6711153c9e..b709a91b3a918 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fnptr.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-move.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-move.noopt.stderr index 9f652e26f242f..9535bbb707c36 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-move.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-move.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-move.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-move.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-move.opt.stderr index 9f652e26f242f..9535bbb707c36 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-move.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-move.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-move.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-vtable.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-vtable.noopt.stderr index 0c12c0de19747..794277890eabe 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-vtable.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-vtable.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-vtable.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-vtable.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-vtable.opt.stderr index 0c12c0de19747..794277890eabe 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-vtable.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-vtable.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-vtable.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr b/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr index 9f65e4f91be95..d8a9c72f022e8 100644 --- a/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-promoted-const.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr b/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr index 9f65e4f91be95..d8a9c72f022e8 100644 --- a/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-promoted-const.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/interpret-in-const-called-fn.noopt.stderr b/tests/ui/consts/required-consts/interpret-in-const-called-fn.noopt.stderr index c9fd476bd8b72..19acde4aac041 100644 --- a/tests/ui/consts/required-consts/interpret-in-const-called-fn.noopt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-const-called-fn.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/interpret-in-const-called-fn.rs:8:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/interpret-in-const-called-fn.opt.stderr b/tests/ui/consts/required-consts/interpret-in-const-called-fn.opt.stderr index c9fd476bd8b72..19acde4aac041 100644 --- a/tests/ui/consts/required-consts/interpret-in-const-called-fn.opt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-const-called-fn.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/interpret-in-const-called-fn.rs:8:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr b/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr index 12c5acd02a490..d50cec24abf4e 100644 --- a/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr @@ -1,6 +1,8 @@ error[E0080]: entering unreachable code --> $DIR/interpret-in-promoted.rs:15:28 | +LL | pub const FOO: () = unsafe { +... LL | let _x: &'static () = &ub(); | ^^^^ evaluation of `FOO` failed inside this call | diff --git a/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr b/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr index 12c5acd02a490..d50cec24abf4e 100644 --- a/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr @@ -1,6 +1,8 @@ error[E0080]: entering unreachable code --> $DIR/interpret-in-promoted.rs:15:28 | +LL | pub const FOO: () = unsafe { +... LL | let _x: &'static () = &ub(); | ^^^^ evaluation of `FOO` failed inside this call | diff --git a/tests/ui/consts/required-consts/interpret-in-static.noopt.stderr b/tests/ui/consts/required-consts/interpret-in-static.noopt.stderr index 8b8d375250d21..cd8351dde5e2b 100644 --- a/tests/ui/consts/required-consts/interpret-in-static.noopt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-static.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/interpret-in-static.rs:8:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/interpret-in-static.opt.stderr b/tests/ui/consts/required-consts/interpret-in-static.opt.stderr index 8b8d375250d21..cd8351dde5e2b 100644 --- a/tests/ui/consts/required-consts/interpret-in-static.opt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-static.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/interpret-in-static.rs:8:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/slice-index-overflow-issue-130284.stderr b/tests/ui/consts/slice-index-overflow-issue-130284.stderr index 63c355b4b0f4d..c28c546c0dfb2 100644 --- a/tests/ui/consts/slice-index-overflow-issue-130284.stderr +++ b/tests/ui/consts/slice-index-overflow-issue-130284.stderr @@ -1,6 +1,8 @@ error[E0080]: overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize` --> $DIR/slice-index-overflow-issue-130284.rs:7:20 | +LL | const C: () = { +... LL | let _ice = (*fat)[usize::MAX - 1]; | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `C` failed here diff --git a/tests/ui/consts/static_mut_containing_mut_ref2.stderr b/tests/ui/consts/static_mut_containing_mut_ref2.stderr index 556a4d956ed4b..6b67ed1656bf9 100644 --- a/tests/ui/consts/static_mut_containing_mut_ref2.stderr +++ b/tests/ui/consts/static_mut_containing_mut_ref2.stderr @@ -1,6 +1,7 @@ error[E0080]: modifying a static's initial value from another static's initializer --> $DIR/static_mut_containing_mut_ref2.rs:6:5 | +LL | pub static mut STDERR_BUFFER: () = unsafe { LL | *(&mut STDERR_BUFFER_SPACE) = 42; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `STDERR_BUFFER` failed here diff --git a/tests/ui/consts/uninhabited-const-issue-61744.stderr b/tests/ui/consts/uninhabited-const-issue-61744.stderr index cae4f8c33239f..df12f760748b7 100644 --- a/tests/ui/consts/uninhabited-const-issue-61744.stderr +++ b/tests/ui/consts/uninhabited-const-issue-61744.stderr @@ -1,6 +1,7 @@ error[E0080]: reached the configured maximum number of stack frames --> $DIR/uninhabited-const-issue-61744.rs:13:36 | +LL | trait Const { LL | const CONSTANT: i32 = unsafe { fake_type() }; | ^^^^^^^^^^^ evaluation of `::CONSTANT` failed inside this call | diff --git a/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-1.stderr b/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-1.stderr index 73e1578242675..6e0de1071e721 100644 --- a/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-1.stderr +++ b/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-1.stderr @@ -1,5 +1,6 @@ error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL | = note: evaluation of ` as std::mem::SizedTypeProperties>::SIZE` failed here diff --git a/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-2.stderr b/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-2.stderr index 4ce1e2e407e9d..212320a60a1db 100644 --- a/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-2.stderr +++ b/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-2.stderr @@ -1,5 +1,6 @@ error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL | = note: evaluation of ` as std::mem::SizedTypeProperties>::SIZE` failed here diff --git a/tests/ui/derives/auxiliary/derive-no-generics.rs b/tests/ui/derives/auxiliary/derive-no-generics.rs index ea9a2e5b1c89a..affa9ac44d616 100644 --- a/tests/ui/derives/auxiliary/derive-no-generics.rs +++ b/tests/ui/derives/auxiliary/derive-no-generics.rs @@ -32,3 +32,53 @@ pub fn derive(item: TokenStream) -> TokenStream { }; tokens } + +#[proc_macro_derive(B)] +pub fn derive_2(item: TokenStream) -> TokenStream { + let mut tokens = item.into_iter(); + let _enum = tokens.next(); + let name = tokens.next().unwrap(); + let _ = tokens.next().unwrap(); + let _ = tokens.next().unwrap(); + let _ = tokens.next().unwrap(); + let TokenTree::Group(group) = tokens.next().unwrap() else { panic!() }; + let mut group = group.stream().into_iter(); + let variant = group.next().unwrap(); + let TokenTree::Group(args) = group.next().unwrap() else { panic!() }; + let arg = args.stream().into_iter().next().unwrap(); + let tokens = quote! { + trait X {} + impl X for $name {} + + impl $name { + fn foo(&self) { + if let Self :: $variant(val) = self { + let _: T = val; + } + } + } + + }; + tokens +} + +#[proc_macro_derive(C)] +pub fn derive_3(item: TokenStream) -> TokenStream { + let mut tokens = item.into_iter(); + let _enum = tokens.next(); + let name = tokens.next().unwrap(); + let _ = tokens.next().unwrap(); + let _ = tokens.next().unwrap(); + let _ = tokens.next().unwrap(); + let TokenTree::Group(group) = tokens.next().unwrap() else { panic!() }; + let mut group = group.stream().into_iter(); + let variant = group.next().unwrap(); + let TokenTree::Group(args) = group.next().unwrap() else { panic!() }; + let arg = args.stream().into_iter().next().unwrap(); + let tokens = quote! { + fn foo(val: $name<$arg>) { + $name :: $variant($arg) = val; + } + }; + tokens +} diff --git a/tests/ui/derives/derive-macro-unsupported-type-params.rs b/tests/ui/derives/derive-macro-unsupported-type-params.rs index d80064b4eb094..0ee096b5ad734 100644 --- a/tests/ui/derives/derive-macro-unsupported-type-params.rs +++ b/tests/ui/derives/derive-macro-unsupported-type-params.rs @@ -11,3 +11,18 @@ enum A { Variant(T), //~^ ERROR: cannot find type `T` in this scope } + +// Resolution error comes entirely from within the derive macro: +#[derive(B)] //~ ERROR: cannot find type `T` in this scope +enum B { + //~^ ERROR: missing generics for enum `B` + //~| ERROR: missing generics for enum `B` + Variant(T), +} + +#[derive(C)] +enum C { + Variant(T), + //~^ ERROR: cannot find value `T` in this scope + //~| ERROR: cannot find type `T` in this scope +} diff --git a/tests/ui/derives/derive-macro-unsupported-type-params.stderr b/tests/ui/derives/derive-macro-unsupported-type-params.stderr index e57490e79cc9f..28f844f6d39ac 100644 --- a/tests/ui/derives/derive-macro-unsupported-type-params.stderr +++ b/tests/ui/derives/derive-macro-unsupported-type-params.stderr @@ -1,6 +1,46 @@ error[E0425]: cannot find type `T` in this scope --> $DIR/derive-macro-unsupported-type-params.rs:11:13 | +LL | #[derive(A)] + | - in this derive macro +... +LL | Variant(T), + | ^ not found in this scope + +error[E0425]: cannot find type `T` in this scope + --> $DIR/derive-macro-unsupported-type-params.rs:16:10 + | +LL | #[derive(B)] + | ^ not found in this scope + | + = note: this error originates in the derive macro `B` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0425]: cannot find type `T` in this scope + --> $DIR/derive-macro-unsupported-type-params.rs:25:13 + | +LL | #[derive(C)] + | - in this derive macro +LL | enum C { +LL | Variant(T), + | ^ not found in this scope + | +note: similarly named enum `A` defined here + --> $DIR/derive-macro-unsupported-type-params.rs:8:1 + | +LL | enum A { + | ^^^^^^^^^ +help: an enum with a similar name exists + | +LL - Variant(T), +LL + Variant(A), + | + +error[E0425]: cannot find value `T` in this scope + --> $DIR/derive-macro-unsupported-type-params.rs:25:13 + | +LL | #[derive(C)] + | - in this derive macro +LL | enum C { LL | Variant(T), | ^ not found in this scope @@ -22,7 +62,25 @@ LL | enum A { | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 3 previous errors +error[E0107]: missing generics for enum `B` + --> $DIR/derive-macro-unsupported-type-params.rs:17:6 + | +LL | #[derive(B)] + | - this derive macro might not support items with generic parameters +LL | enum B { + | ^ + +error[E0107]: missing generics for enum `B` + --> $DIR/derive-macro-unsupported-type-params.rs:17:6 + | +LL | #[derive(B)] + | - this derive macro might not support items with generic parameters +LL | enum B { + | ^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 8 previous errors Some errors have detailed explanations: E0107, E0425. For more information about an error, try `rustc --explain E0107`. diff --git a/tests/ui/dyn-compatibility/assoc_type_bounds_sized_used.rs b/tests/ui/dyn-compatibility/assoc_type_bounds_sized_used.rs index 8243803c86d70..80c2863418929 100644 --- a/tests/ui/dyn-compatibility/assoc_type_bounds_sized_used.rs +++ b/tests/ui/dyn-compatibility/assoc_type_bounds_sized_used.rs @@ -10,8 +10,6 @@ trait Bop { fn bop() { let _ = ::Bar::default(); //~^ ERROR: the size for values of type `T` cannot be known at compilation time - //~| ERROR: the size for values of type `T` cannot be known at compilation time - //~| ERROR: the size for values of type `T` cannot be known at compilation time } fn main() { diff --git a/tests/ui/dyn-compatibility/assoc_type_bounds_sized_used.stderr b/tests/ui/dyn-compatibility/assoc_type_bounds_sized_used.stderr index 26f00fc72f868..9eb4e5bf5ef05 100644 --- a/tests/ui/dyn-compatibility/assoc_type_bounds_sized_used.stderr +++ b/tests/ui/dyn-compatibility/assoc_type_bounds_sized_used.stderr @@ -24,58 +24,6 @@ help: consider relaxing the implicit `Sized` restriction LL | type Bar: Default + ?Sized | ++++++++ -error[E0277]: the size for values of type `T` cannot be known at compilation time - --> $DIR/assoc_type_bounds_sized_used.rs:11:13 - | -LL | fn bop() { - | - this type parameter needs to be `Sized` -LL | let _ = ::Bar::default(); - | ^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | -note: required by a bound in `Bop::Bar` - --> $DIR/assoc_type_bounds_sized_used.rs:7:15 - | -LL | trait Bop { -LL | type Bar: Default -LL | where -LL | Self: Sized; - | ^^^^^ required by this bound in `Bop::Bar` -help: consider removing the `?Sized` bound to make the type parameter `Sized` - | -LL - fn bop() { -LL + fn bop() { - | -help: consider relaxing the implicit `Sized` restriction - | -LL | type Bar: Default + ?Sized - | ++++++++ - -error[E0277]: the size for values of type `T` cannot be known at compilation time - --> $DIR/assoc_type_bounds_sized_used.rs:11:13 - | -LL | fn bop() { - | - this type parameter needs to be `Sized` -LL | let _ = ::Bar::default(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | -note: required by a bound in `Bop::Bar` - --> $DIR/assoc_type_bounds_sized_used.rs:7:15 - | -LL | trait Bop { -LL | type Bar: Default -LL | where -LL | Self: Sized; - | ^^^^^ required by this bound in `Bop::Bar` -help: consider removing the `?Sized` bound to make the type parameter `Sized` - | -LL - fn bop() { -LL + fn bop() { - | -help: consider relaxing the implicit `Sized` restriction - | -LL | type Bar: Default + ?Sized - | ++++++++ - -error: aborting due to 3 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-compatibility/dispatchability-placeholder-does-not-satisfy-bounds.rs b/tests/ui/dyn-compatibility/dispatchability-placeholder-does-not-satisfy-bounds.rs new file mode 100644 index 0000000000000..c899c66056839 --- /dev/null +++ b/tests/ui/dyn-compatibility/dispatchability-placeholder-does-not-satisfy-bounds.rs @@ -0,0 +1,24 @@ +//! Tests for specific instances of that don't +//! pass yet. See `dispatchability-placeholder-satisfies-bounds.rs` for context. +// FIXME(@dianne): this should be gone soon +//@ known-bug: unknown + +trait HasAssoc { + type Assoc; +} + +trait Parent {} + +trait NotDynCompatible +where + // We need to be able to normalize this for RustaceansAreAwesome in order to prove + // `<(RustaceansAreAwesome,) as HasAssoc>::Assoc: Owned` for the projection in the argument to + // the `Self: Parent<...>` supertrait bound. Currently a projection clause for it is missing + // from the `ParamEnv`. + (Self,): HasAssoc, + Self: Parent<<<(Self,) as HasAssoc>::Assoc as ToOwned>::Owned>, +{ + fn f(&self); +} + +fn main() {} diff --git a/tests/ui/dyn-compatibility/dispatchability-placeholder-does-not-satisfy-bounds.stderr b/tests/ui/dyn-compatibility/dispatchability-placeholder-does-not-satisfy-bounds.stderr new file mode 100644 index 0000000000000..3b2b8c62e8994 --- /dev/null +++ b/tests/ui/dyn-compatibility/dispatchability-placeholder-does-not-satisfy-bounds.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `<(RustaceansAreAwesome,) as HasAssoc>::Assoc: Clone` is not satisfied + --> $DIR/dispatchability-placeholder-does-not-satisfy-bounds.rs:21:5 + | +LL | fn f(&self); + | ^^^^^^^^^^^^ the trait `Clone` is not implemented for `<(RustaceansAreAwesome,) as HasAssoc>::Assoc` + | + = note: required for `<(RustaceansAreAwesome,) as HasAssoc>::Assoc` to implement `ToOwned` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-compatibility/dispatchability-placeholder-satisfies-bounds.rs b/tests/ui/dyn-compatibility/dispatchability-placeholder-satisfies-bounds.rs index 421b9a512c1e4..611e1cb59d4ab 100644 --- a/tests/ui/dyn-compatibility/dispatchability-placeholder-satisfies-bounds.rs +++ b/tests/ui/dyn-compatibility/dispatchability-placeholder-satisfies-bounds.rs @@ -1,11 +1,15 @@ -//! Regression tests for . When checking whether -//! method receivers for a trait `Trait` are dynamically dispatchable, we use a placeholder type in -//! place of `dyn Trait` to avoid a cycle (as that would require determining whether `Trait` is dyn- -//! compatible). This placeholder must satisfy `Trait`'s where-bounds to avoid errors in param- -//! environment normalization. +//! Regression tests for and similar. When +//! checking whether method receivers for a trait `Trait` are dynamically dispatchable, we (at the +//! time of writing) use a placeholder type called `RustaceansAreAwesome` in place of `dyn Trait` to +//! avoid a cycle (as using `dyn Trait` requires determining whether `Trait` is dyn-compatible). We +//! assume that `RustaceansAreAwesome` implements `Trait`, so when normalizing the param-environment +//! we construct, we may have to prove obligations for aliases encountered in arguments to super- +//! trait bounds. It's possible for these to only be provable using clauses from `Trait` or its +//! supertraits that would be necessary for `RustaceansAreAwesome` to implement `Trait`. //@ check-pass -// Test 1 +// This works for `Self: Super<...Ty::::Assoc...>` after the `where`. +// We need to assume `(Args, RustaceansAreAwesome::Output): SignatureToFnPtr`. use std::ops::Deref; @@ -22,7 +26,8 @@ where fn method(&self); } -// Test 2 +// This works for `Trait: Super<...Ty::Assoc...>` before the `where`. +// We need to assume `A: Associator`. trait Associator { type Point; @@ -34,4 +39,60 @@ trait Trait + ?Sized>: Marker { fn method(&self); } +// Regression test for : we need to be careful with +// projection clauses involving `RustaceansAreAwesome`. Here, if we simply assumed that +// `::RowIndex == ::RowIndex`, we'd end up with +// ambiguity, as we also assume `::RowIndex == ::RowIndex`.`Self` +// stands in for the `Self` type of the impl we're imagining dispatching to (pretending +// `RustaceansAreAwesome` is a trait object). + +pub trait Matrix { + type Coordinates; +} + +pub trait Matrix2D: Matrix::RowIndex> { + type RowIndex; +} + +pub trait Transposable>: Matrix2D { + fn transpose(&self) -> T; +} + +// An example where we can't add any additional projections without introducing ambiguity: we don't +// want to assume `<() as HasAssoc>::Assoc` is both `Self` and `RustaceansAreAwesome`. At the time +// of writing, we let `<() as HasAssoc>::Assoc` normalize to `Self` during receiver dispatchability +// checking. This should be fine, since to call methods on a `dyn TechnicallyDynCompatible`, we'd +// need `<() as HasAssoc>::Assoc` to be `dyn TechnicallyDynCompatible`. This is the same reasoning +// that lets us assume `RustaceansAreAwesome` implements its trait at all: to use the trait object, +// it must implement the trait; otherwise, receiver dispatchability doesn't mean much. + +trait HasAssoc { + type Assoc; +} + +impl HasAssoc for () { + type Assoc = (); +} + +trait Parent {} + +trait TechnicallyDynCompatible +where + (): HasAssoc, + Self: Parent<<() as HasAssoc>::Assoc>, +{ + fn f(&self) {} +} + +// Since we have `TechnincallyDynCompatible` defined, let's keep its dyn-compatibility from breaking +// accidentally (and also sanity-check the above comment). + +impl Parent<()> for () {} +impl TechnicallyDynCompatible for () {} + +fn technically_dyn_compatible_is_dyn_compatible() { + let x: &dyn TechnicallyDynCompatible = &(); + // We can't call `x.f()` since `<() as HasAssoc>::Assoc` isn't `dyn TechnicallyDynCompatible`. +} + fn main() {} diff --git a/tests/ui/enum-discriminant/eval-error.stderr b/tests/ui/enum-discriminant/eval-error.stderr index 5f9b5e3b71edd..a90038f0682b3 100644 --- a/tests/ui/enum-discriminant/eval-error.stderr +++ b/tests/ui/enum-discriminant/eval-error.stderr @@ -45,6 +45,8 @@ LL | a: Box, error[E0080]: the type `Foo` has an unknown layout --> $DIR/eval-error.rs:9:30 | +LL | enum Bar { +LL | Boo = { LL | let _: Option = None; | ^^^^ evaluation of `Bar::Boo::{constant#0}` failed here diff --git a/tests/ui/enum-discriminant/wrapping_niche.stderr b/tests/ui/enum-discriminant/wrapping_niche.stderr index 603a56770c497..a057c8ee5e177 100644 --- a/tests/ui/enum-discriminant/wrapping_niche.stderr +++ b/tests/ui/enum-discriminant/wrapping_niche.stderr @@ -61,6 +61,7 @@ error: layout_of(UnsignedAroundZero) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), + repr_c: false, randomization_seed: 2648004449468912780, } --> $DIR/wrapping_niche.rs:8:1 @@ -131,6 +132,7 @@ error: layout_of(SignedAroundZero) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), + repr_c: false, randomization_seed: 10738146848450213996, } --> $DIR/wrapping_niche.rs:17:1 diff --git a/tests/ui/error-codes/E0080.stderr b/tests/ui/error-codes/E0080.stderr index c78454620d18e..1bc7fccbb58c3 100644 --- a/tests/ui/error-codes/E0080.stderr +++ b/tests/ui/error-codes/E0080.stderr @@ -1,12 +1,15 @@ error[E0080]: attempt to shift left by `500_i32`, which would overflow --> $DIR/E0080.rs:2:9 | +LL | enum Enum { LL | X = (1 << 500), | ^^^^^^^^^^ evaluation of `Enum::X::{constant#0}` failed here error[E0080]: attempt to divide `1_isize` by zero --> $DIR/E0080.rs:3:9 | +LL | enum Enum { +LL | X = (1 << 500), LL | Y = (1 / 0), | ^^^^^^^ evaluation of `Enum::Y::{constant#0}` failed here diff --git a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return_.stderr b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return_.stderr index 5102f278f0273..34da52e79c4df 100644 --- a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return_.stderr +++ b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return_.stderr @@ -12,11 +12,17 @@ LL | inner(0, n) note: [... 125 additional calls inside `inner` ...] --> $DIR/ctfe-id-unlimited.rs:17:41 | +LL | const fn rec_id(n: u32) -> u32 { +LL | const fn inner(acc: u32, n: u32) -> u32 { +... LL | #[cfg(return_)] _ => return inner(acc + 1, n - 1), | ^^^^^^^^^^^^^^^^^^^^^ note: inside `inner` --> $DIR/ctfe-id-unlimited.rs:17:41 | +LL | const fn rec_id(n: u32) -> u32 { +LL | const fn inner(acc: u32, n: u32) -> u32 { +... LL | #[cfg(return_)] _ => return inner(acc + 1, n - 1), | ^^^^^^^^^^^^^^^^^^^^^ the failure occurred here diff --git a/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.stderr b/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.stderr index a9f11ac31c3e8..69949260f30b4 100644 --- a/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.stderr +++ b/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.stderr @@ -1,6 +1,8 @@ error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow --> $DIR/unsatisfied-evaluatable-bounds.rs:8:10 | +LL | const POSITIVE: usize = N +LL | where LL | [(); N - 1]:; | ^^^^^ evaluation of `POSITIVE::<0>::{constant#0}` failed here diff --git a/tests/ui/generics/post_monomorphization_error_backtrace.stderr b/tests/ui/generics/post_monomorphization_error_backtrace.stderr index 6953414f0c235..eb16778867845 100644 --- a/tests/ui/generics/post_monomorphization_error_backtrace.stderr +++ b/tests/ui/generics/post_monomorphization_error_backtrace.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: assertion failed: std::mem::size_of::() == 0 --> $DIR/post_monomorphization_error_backtrace.rs:6:23 | +LL | impl F { LL | const V: () = assert!(std::mem::size_of::() == 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `assert_zst::F::::V` failed here @@ -19,6 +20,7 @@ LL | assert_zst::() error[E0080]: evaluation panicked: assertion failed: std::mem::size_of::() == 0 --> $DIR/post_monomorphization_error_backtrace.rs:6:23 | +LL | impl F { LL | const V: () = assert!(std::mem::size_of::() == 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `assert_zst::F::::V` failed here diff --git a/tests/ui/impl-trait/normalize-hir-typeck/switch-int-terminator-126680.next.stderr b/tests/ui/impl-trait/normalize-hir-typeck/switch-int-terminator-126680.next.stderr deleted file mode 100644 index 47550ef9db818..0000000000000 --- a/tests/ui/impl-trait/normalize-hir-typeck/switch-int-terminator-126680.next.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0391]: cycle detected when computing type of `Bar::{opaque#0}` - --> $DIR/switch-int-terminator-126680.rs:17:12 - | -LL | type Bar = impl Sized; - | ^^^^^^^^^^ - | - = note: ...which requires computing type of opaque `Bar::{opaque#0}`... -note: ...which requires borrow-checking `foo`... - --> $DIR/switch-int-terminator-126680.rs:26:1 - | -LL | fn foo() -> Struct { - | ^^^^^^^^^^^^^^^^^^ - = note: ...which requires promoting constants in MIR for `foo`... - = note: ...which requires normalizing `fn(Bar)`... - = note: ...which again requires computing type of `Bar::{opaque#0}`, completing the cycle - = note: cycle used when checking that `Bar::{opaque#0}` is well-formed - = note: for more information, see and - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/normalize-hir-typeck/switch-int-terminator-126680.rs b/tests/ui/impl-trait/normalize-hir-typeck/switch-int-terminator-126680.rs index bb8e34ff35140..b11ae025100bc 100644 --- a/tests/ui/impl-trait/normalize-hir-typeck/switch-int-terminator-126680.rs +++ b/tests/ui/impl-trait/normalize-hir-typeck/switch-int-terminator-126680.rs @@ -1,7 +1,7 @@ //@ revisions: old next //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver -//@[next] known-bug: trait-system-refactor-initiative#303 +//@[next] check-pass //@[old] failure-status: 101 //@[old] dont-check-compiler-stderr //@[old] known-bug: #126680 diff --git a/tests/ui/impl-trait/normalize-hir-typeck/trait-upcasting-131886.next.stderr b/tests/ui/impl-trait/normalize-hir-typeck/trait-upcasting-131886.next.stderr deleted file mode 100644 index e46f78337a6f3..0000000000000 --- a/tests/ui/impl-trait/normalize-hir-typeck/trait-upcasting-131886.next.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0391]: cycle detected when computing type of `Tait::{opaque#0}` - --> $DIR/trait-upcasting-131886.rs:15:13 - | -LL | type Tait = impl Sized; - | ^^^^^^^^^^ - | - = note: ...which requires computing type of opaque `Tait::{opaque#0}`... -note: ...which requires borrow-checking `test_correct3`... - --> $DIR/trait-upcasting-131886.rs:21:1 - | -LL | fn test_correct3(x: &dyn Foo) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: ...which requires promoting constants in MIR for `test_correct3`... - = note: ...which again requires computing type of `Tait::{opaque#0}`, completing the cycle - = note: cycle used when checking that `Tait::{opaque#0}` is well-formed - = note: for more information, see and - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/normalize-hir-typeck/trait-upcasting-131886.rs b/tests/ui/impl-trait/normalize-hir-typeck/trait-upcasting-131886.rs index 3f506a7f5f65e..986c1efa5e385 100644 --- a/tests/ui/impl-trait/normalize-hir-typeck/trait-upcasting-131886.rs +++ b/tests/ui/impl-trait/normalize-hir-typeck/trait-upcasting-131886.rs @@ -1,7 +1,7 @@ //@ revisions: old next //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver -//@[next] known-bug: trait-system-refactor-initiative#303 +//@[next] check-pass //@[old] failure-status: 101 //@[old] dont-check-compiler-stderr //@[old] known-bug: #131886 @@ -9,8 +9,7 @@ #![feature(type_alias_impl_trait)] // This ICEd in MIR validation with the old solver. It's fixed by normalizing -// opaque types with the new solver. This should compile, but currently fails -// with a query cycle error. +// opaque types with the new solver. This should compile without a query cycle. type Tait = impl Sized; diff --git a/tests/ui/inline-const/const-expr-generic-err.stderr b/tests/ui/inline-const/const-expr-generic-err.stderr index 26039ba6d4449..b2f22407e189a 100644 --- a/tests/ui/inline-const/const-expr-generic-err.stderr +++ b/tests/ui/inline-const/const-expr-generic-err.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: assertion failed: std::mem::size_of::() == 0 --> $DIR/const-expr-generic-err.rs:4:13 | +LL | fn foo() { LL | const { assert!(std::mem::size_of::() == 0); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `foo::::{constant#0}` failed here @@ -19,6 +20,7 @@ LL | foo::(); error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow --> $DIR/const-expr-generic-err.rs:8:13 | +LL | fn bar() -> usize { LL | const { N - 1 } | ^^^^^ evaluation of `bar::<0>::{constant#0}` failed here diff --git a/tests/ui/inline-const/required-const.stderr b/tests/ui/inline-const/required-const.stderr index a517ea2fec0f1..e050a95bd00cd 100644 --- a/tests/ui/inline-const/required-const.stderr +++ b/tests/ui/inline-const/required-const.stderr @@ -1,6 +1,8 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/required-const.rs:6:17 | +LL | fn foo() { +LL | if false { LL | const { panic!() } | ^^^^^^^^ evaluation of `foo::::{constant#0}` failed here diff --git a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr index 268527c0e5bf8..943a555df5e20 100644 --- a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr +++ b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr @@ -1,6 +1,7 @@ error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory --> $DIR/intrinsic-raw_eq-const-bad.rs:5:5 | +LL | const RAW_EQ_PADDING: bool = unsafe { LL | std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `RAW_EQ_PADDING` failed here | @@ -11,6 +12,7 @@ LL | std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16)) error[E0080]: unable to turn pointer into integer --> $DIR/intrinsic-raw_eq-const-bad.rs:10:5 | +LL | const RAW_EQ_PTR: bool = unsafe { LL | std::intrinsics::raw_eq(&(&0), &(&1)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `RAW_EQ_PTR` failed here | @@ -20,6 +22,8 @@ LL | std::intrinsics::raw_eq(&(&0), &(&1)) error[E0080]: accessing memory with alignment 1, but alignment 4 is required --> $DIR/intrinsic-raw_eq-const-bad.rs:17:5 | +LL | const RAW_EQ_NOT_ALIGNED: bool = unsafe { +... LL | std::intrinsics::raw_eq(aref, aref) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `RAW_EQ_NOT_ALIGNED` failed here diff --git a/tests/ui/iterators/collect-into-slice.rs b/tests/ui/iterators/collect-into-slice.rs index c90cfa4e90d3a..462110d788106 100644 --- a/tests/ui/iterators/collect-into-slice.rs +++ b/tests/ui/iterators/collect-into-slice.rs @@ -6,14 +6,11 @@ fn main() { let some_generated_vec = (0..10).collect(); //~^ ERROR the size for values of type `[i32]` cannot be known at compilation time //~| NOTE required by a bound introduced by this call - //~| ERROR the size for values of type `[i32]` cannot be known at compilation time //~| ERROR a slice of type `[i32]` cannot be built since `[i32]` has no definite size //~| NOTE try explicitly collecting into a `Vec<{integer}>` - //~| NOTE required by an implicit `Sized` bound in `collect` //~| NOTE required by a bound in `collect` //~| NOTE all local variables must have a statically known size //~| NOTE doesn't have a size known at compile-time - //~| NOTE doesn't have a size known at compile-time process_slice(&some_generated_vec); let some_generated_vec = (0..10).collect(); diff --git a/tests/ui/iterators/collect-into-slice.stderr b/tests/ui/iterators/collect-into-slice.stderr index b5444a71cc177..f910bae958240 100644 --- a/tests/ui/iterators/collect-into-slice.stderr +++ b/tests/ui/iterators/collect-into-slice.stderr @@ -19,18 +19,8 @@ LL | let some_generated_vec = (0..10).collect(); = help: the trait `Sized` is not implemented for `[i32]` = note: all local variables must have a statically known size -error[E0277]: the size for values of type `[i32]` cannot be known at compilation time - --> $DIR/collect-into-slice.rs:6:38 - | -LL | let some_generated_vec = (0..10).collect(); - | ^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[i32]` -note: required by an implicit `Sized` bound in `collect` - --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL - error[E0277]: a slice of type `&[i32]` cannot be built since we need to store the elements somewhere - --> $DIR/collect-into-slice.rs:19:31 + --> $DIR/collect-into-slice.rs:16:31 | LL | let some_generated_vec = (0..10).collect(); | ^^^^^ ------- required by a bound introduced by this call @@ -41,6 +31,6 @@ LL | let some_generated_vec = (0..10).collect(); note: required by a bound in `collect` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/iterators/iter-macro-not-async-closure.current.stderr b/tests/ui/iterators/iter-macro-not-async-closure.current.stderr index c896d226a7715..ca20bbf4e3150 100644 --- a/tests/ui/iterators/iter-macro-not-async-closure.current.stderr +++ b/tests/ui/iterators/iter-macro-not-async-closure.current.stderr @@ -12,42 +12,6 @@ note: required by a bound in `call_async_once` LL | async fn call_async_once(f: impl AsyncFnOnce()) { | ^^^^^^^^^^^^^ required by this bound in `call_async_once` -error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:25:21: 25:28}: AsyncFnOnce()` is not satisfied - --> $DIR/iter-macro-not-async-closure.rs:31:18 - | -LL | let x = pin!(call_async_once(f)); - | ^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:25:21: 25:28}` - | -note: required by a bound in `call_async_once` - --> $DIR/iter-macro-not-async-closure.rs:20:34 - | -LL | async fn call_async_once(f: impl AsyncFnOnce()) { - | ^^^^^^^^^^^^^ required by this bound in `call_async_once` - -error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:25:21: 25:28}: AsyncFnOnce()` is not satisfied - --> $DIR/iter-macro-not-async-closure.rs:31:13 - | -LL | let x = pin!(call_async_once(f)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:25:21: 25:28}` - | -note: required by a bound in `call_async_once` - --> $DIR/iter-macro-not-async-closure.rs:20:34 - | -LL | async fn call_async_once(f: impl AsyncFnOnce()) { - | ^^^^^^^^^^^^^ required by this bound in `call_async_once` - -error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:25:21: 25:28}: AsyncFnOnce()` is not satisfied - --> $DIR/iter-macro-not-async-closure.rs:31:13 - | -LL | let x = pin!(call_async_once(f)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:25:21: 25:28}` - | -note: required by a bound in `call_async_once` - --> $DIR/iter-macro-not-async-closure.rs:20:34 - | -LL | async fn call_async_once(f: impl AsyncFnOnce()) { - | ^^^^^^^^^^^^^ required by this bound in `call_async_once` - error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:25:21: 25:28}: AsyncFnOnce()` is not satisfied --> $DIR/iter-macro-not-async-closure.rs:31:13 | @@ -61,7 +25,7 @@ LL | async fn call_async_once(f: impl AsyncFnOnce()) { | ^^^^^^^^^^^^^ required by this bound in `call_async_once` error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:25:21: 25:28}: AsyncFnOnce()` is not satisfied - --> $DIR/iter-macro-not-async-closure.rs:37:5 + --> $DIR/iter-macro-not-async-closure.rs:34:5 | LL | x.poll(&mut Context::from_waker(Waker::noop())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:25:21: 25:28}` @@ -72,6 +36,6 @@ note: required by a bound in `call_async_once` LL | async fn call_async_once(f: impl AsyncFnOnce()) { | ^^^^^^^^^^^^^ required by this bound in `call_async_once` -error: aborting due to 6 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/iterators/iter-macro-not-async-closure.rs b/tests/ui/iterators/iter-macro-not-async-closure.rs index 3cf9e2237d2e7..1736423065396 100644 --- a/tests/ui/iterators/iter-macro-not-async-closure.rs +++ b/tests/ui/iterators/iter-macro-not-async-closure.rs @@ -30,10 +30,7 @@ fn main() { let x = pin!(call_async_once(f)); //[current]~^ ERROR AsyncFnOnce()` is not satisfied - //[current]~^^ ERROR AsyncFnOnce()` is not satisfied - //[current]~^^^ ERROR AsyncFnOnce()` is not satisfied - //[current]~^^^^ ERROR AsyncFnOnce()` is not satisfied - //[current]~^^^^^ ERROR AsyncFnOnce()` is not satisfied + //[current]~| ERROR AsyncFnOnce()` is not satisfied x.poll(&mut Context::from_waker(Waker::noop())); //[current]~^ ERROR AsyncFnOnce()` is not satisfied } diff --git a/tests/ui/layout/debug.stderr b/tests/ui/layout/debug.stderr index baaffa7c9de42..0618810d223f3 100644 --- a/tests/ui/layout/debug.stderr +++ b/tests/ui/layout/debug.stderr @@ -81,6 +81,7 @@ error: layout_of(E) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/debug.rs:8:1 @@ -117,6 +118,7 @@ error: layout_of(S) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/debug.rs:11:1 @@ -142,6 +144,7 @@ error: layout_of(U) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/debug.rs:14:1 @@ -216,6 +219,7 @@ error: layout_of(Result) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/debug.rs:17:1 @@ -239,6 +243,7 @@ error: layout_of(i32) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/debug.rs:20:1 @@ -264,6 +269,7 @@ error: layout_of(V) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/debug.rs:27:1 @@ -289,6 +295,7 @@ error: layout_of(W) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/debug.rs:33:1 @@ -314,6 +321,7 @@ error: layout_of(Y) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/debug.rs:39:1 @@ -339,6 +347,7 @@ error: layout_of(P1) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/debug.rs:46:1 @@ -364,6 +373,7 @@ error: layout_of(P2) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/debug.rs:50:1 @@ -389,6 +399,7 @@ error: layout_of(P3) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/debug.rs:58:1 @@ -414,6 +425,7 @@ error: layout_of(P4) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/debug.rs:62:1 @@ -439,6 +451,7 @@ error: layout_of(P5) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/debug.rs:66:1 @@ -464,6 +477,7 @@ error: layout_of(MaybeUninit) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/debug.rs:69:1 @@ -559,6 +573,7 @@ error: layout_of(Option) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/debug.rs:93:1 @@ -633,6 +648,7 @@ error: layout_of(Option) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/debug.rs:96:1 diff --git a/tests/ui/layout/hexagon-enum.stderr b/tests/ui/layout/hexagon-enum.stderr index d0d954029b8bf..6a4be0887698f 100644 --- a/tests/ui/layout/hexagon-enum.stderr +++ b/tests/ui/layout/hexagon-enum.stderr @@ -41,6 +41,7 @@ error: layout_of(A) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/hexagon-enum.rs:19:1 @@ -91,6 +92,7 @@ error: layout_of(B) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/hexagon-enum.rs:23:1 @@ -141,6 +143,7 @@ error: layout_of(C) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/hexagon-enum.rs:27:1 @@ -191,6 +194,7 @@ error: layout_of(P) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/hexagon-enum.rs:31:1 @@ -241,6 +245,7 @@ error: layout_of(T) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/hexagon-enum.rs:37:1 diff --git a/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr b/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr index b08e37dbd7472..dbb861d4a3bed 100644 --- a/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr +++ b/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr @@ -20,6 +20,7 @@ LL | struct MySlice(T); error[E0080]: the type `MySlice<[bool]>` has an unknown layout --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL | = note: evaluation of `::ALIGN` failed here diff --git a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr index 4e2e66ba53df4..42f407abd5ed2 100644 --- a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr +++ b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr @@ -59,6 +59,7 @@ error: layout_of(MissingPayloadField) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:17:1 @@ -133,6 +134,7 @@ error: layout_of(CommonPayloadField) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:26:1 @@ -207,6 +209,7 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:34:1 @@ -297,6 +300,7 @@ error: layout_of(NicheFirst) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:42:1 @@ -387,6 +391,7 @@ error: layout_of(NicheSecond) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:51:1 diff --git a/tests/ui/layout/issue-96185-overaligned-enum.stderr b/tests/ui/layout/issue-96185-overaligned-enum.stderr index 00848642f045f..4cfb601a82292 100644 --- a/tests/ui/layout/issue-96185-overaligned-enum.stderr +++ b/tests/ui/layout/issue-96185-overaligned-enum.stderr @@ -53,6 +53,7 @@ error: layout_of(Aligned1) = Layout { Align(8 bytes), ), unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/issue-96185-overaligned-enum.rs:9:1 @@ -115,6 +116,7 @@ error: layout_of(Aligned2) = Layout { Align(1 bytes), ), unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/issue-96185-overaligned-enum.rs:17:1 diff --git a/tests/ui/layout/thumb-enum.stderr b/tests/ui/layout/thumb-enum.stderr index 6e010a6bc658f..88e18c72168e6 100644 --- a/tests/ui/layout/thumb-enum.stderr +++ b/tests/ui/layout/thumb-enum.stderr @@ -41,6 +41,7 @@ error: layout_of(A) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/thumb-enum.rs:19:1 @@ -91,6 +92,7 @@ error: layout_of(B) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/thumb-enum.rs:23:1 @@ -141,6 +143,7 @@ error: layout_of(C) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/thumb-enum.rs:27:1 @@ -191,6 +194,7 @@ error: layout_of(P) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/thumb-enum.rs:31:1 @@ -241,6 +245,7 @@ error: layout_of(T) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/thumb-enum.rs:37:1 diff --git a/tests/ui/layout/too-big-no-dce.stderr b/tests/ui/layout/too-big-no-dce.stderr index a4b01dda0a444..5533602d3f393 100644 --- a/tests/ui/layout/too-big-no-dce.stderr +++ b/tests/ui/layout/too-big-no-dce.stderr @@ -1,5 +1,6 @@ error[E0080]: values of the type `[u32; NUMBER]` are too big for the target architecture --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL | = note: evaluation of `<[u32; NUMBER] as std::mem::SizedTypeProperties>::SIZE` failed here diff --git a/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.stderr b/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.stderr index cad73b603c1ed..2c26523335209 100644 --- a/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.stderr +++ b/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.stderr @@ -1,6 +1,8 @@ error[E0080]: entering unreachable code --> $DIR/uncomputable-due-to-trivial-bounds-ice-135138.rs:7:10 | +LL | fn return_str() +... LL | [(); { let _a: Option = None; 0 }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `return_str::{constant#0}` failed here diff --git a/tests/ui/layout/unknown-when-no-type-parameter.stderr b/tests/ui/layout/unknown-when-no-type-parameter.stderr index 7c382c7a85502..b4be04dbe17da 100644 --- a/tests/ui/layout/unknown-when-no-type-parameter.stderr +++ b/tests/ui/layout/unknown-when-no-type-parameter.stderr @@ -1,6 +1,8 @@ error[E0080]: entering unreachable code --> $DIR/unknown-when-no-type-parameter.rs:11:10 | +LL | fn foo() +... LL | [(); size_of::<<() as Project>::Assoc>()]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `foo::{constant#0}` failed here diff --git a/tests/ui/layout/unknown-when-ptr-metadata-is-DST.stderr b/tests/ui/layout/unknown-when-ptr-metadata-is-DST.stderr index 888e2574119d6..ff52e5f07e080 100644 --- a/tests/ui/layout/unknown-when-ptr-metadata-is-DST.stderr +++ b/tests/ui/layout/unknown-when-ptr-metadata-is-DST.stderr @@ -1,6 +1,8 @@ error[E0080]: entering unreachable code --> $DIR/unknown-when-ptr-metadata-is-DST.rs:8:10 | +LL | fn return_str() +... LL | [(); { let _a: Option<&str> = None; 0 }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `return_str::{constant#0}` failed here diff --git a/tests/ui/layout/zero-sized-array-enum-niche.stderr b/tests/ui/layout/zero-sized-array-enum-niche.stderr index 9022151911d37..b3b7fc7e0909d 100644 --- a/tests/ui/layout/zero-sized-array-enum-niche.stderr +++ b/tests/ui/layout/zero-sized-array-enum-niche.stderr @@ -65,6 +65,7 @@ error: layout_of(Result<[u32; 0], bool>) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/zero-sized-array-enum-niche.rs:14:1 @@ -153,6 +154,7 @@ error: layout_of(MultipleAlignments) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/zero-sized-array-enum-niche.rs:22:1 @@ -227,6 +229,7 @@ error: layout_of(Result<[u32; 0], Packed>>) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/zero-sized-array-enum-niche.rs:38:1 @@ -305,6 +308,7 @@ error: layout_of(Result<[u32; 0], Packed>) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/zero-sized-array-enum-niche.rs:45:1 diff --git a/tests/ui/limits/issue-17913.32bit.stderr b/tests/ui/limits/issue-17913.32bit.stderr index 6ddde4b891836..8b109ad703c75 100644 --- a/tests/ui/limits/issue-17913.32bit.stderr +++ b/tests/ui/limits/issue-17913.32bit.stderr @@ -3,6 +3,7 @@ error: values of the type `[&usize; usize::MAX]` are too big for the target arch error[E0080]: values of the type `[&usize; usize::MAX]` are too big for the target architecture --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL | = note: evaluation of `<[&usize; usize::MAX] as std::mem::SizedTypeProperties>::SIZE` failed here diff --git a/tests/ui/limits/issue-17913.64bit.stderr b/tests/ui/limits/issue-17913.64bit.stderr index d35d697d5f3f3..8ffa2c1966966 100644 --- a/tests/ui/limits/issue-17913.64bit.stderr +++ b/tests/ui/limits/issue-17913.64bit.stderr @@ -3,6 +3,7 @@ error: values of the type `[&usize; usize::MAX]` are too big for the target arch error[E0080]: values of the type `[&usize; usize::MAX]` are too big for the target architecture --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL | = note: evaluation of `<[&usize; usize::MAX] as std::mem::SizedTypeProperties>::SIZE` failed here diff --git a/tests/ui/limits/issue-55878.stderr b/tests/ui/limits/issue-55878.stderr index 994e43854f825..acae67709e6b1 100644 --- a/tests/ui/limits/issue-55878.stderr +++ b/tests/ui/limits/issue-55878.stderr @@ -1,5 +1,6 @@ error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL | = note: evaluation of `<[u8; usize::MAX] as std::mem::SizedTypeProperties>::SIZE` failed here diff --git a/tests/ui/limits/issue-75158-64.stderr b/tests/ui/limits/issue-75158-64.stderr index bab0e1b777c28..6832f04caaac4 100644 --- a/tests/ui/limits/issue-75158-64.stderr +++ b/tests/ui/limits/issue-75158-64.stderr @@ -1,5 +1,6 @@ error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL | = note: evaluation of ` as std::mem::SizedTypeProperties>::SIZE` failed here diff --git a/tests/ui/limits/vtable-try-as-dyn.full-debuginfo.stderr b/tests/ui/limits/vtable-try-as-dyn.full-debuginfo.stderr index c6a53d4face4f..16e4572c83e5b 100644 --- a/tests/ui/limits/vtable-try-as-dyn.full-debuginfo.stderr +++ b/tests/ui/limits/vtable-try-as-dyn.full-debuginfo.stderr @@ -1,5 +1,6 @@ error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture --> $SRC_DIR/core/src/any.rs:LL:COL + ::: $SRC_DIR/core/src/any.rs:LL:COL | = note: evaluation of `std::any::try_as_dyn::<'_, [u8; usize::MAX], dyn Trait>::{constant#0}` failed inside this call note: inside `TypeId::trait_info_of::<'_, dyn Trait>` diff --git a/tests/ui/limits/vtable-try-as-dyn.no-debuginfo.stderr b/tests/ui/limits/vtable-try-as-dyn.no-debuginfo.stderr index c6a53d4face4f..16e4572c83e5b 100644 --- a/tests/ui/limits/vtable-try-as-dyn.no-debuginfo.stderr +++ b/tests/ui/limits/vtable-try-as-dyn.no-debuginfo.stderr @@ -1,5 +1,6 @@ error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture --> $SRC_DIR/core/src/any.rs:LL:COL + ::: $SRC_DIR/core/src/any.rs:LL:COL | = note: evaluation of `std::any::try_as_dyn::<'_, [u8; usize::MAX], dyn Trait>::{constant#0}` failed inside this call note: inside `TypeId::trait_info_of::<'_, dyn Trait>` diff --git a/tests/ui/macros/tokenstream-ice-issue-149954.stderr b/tests/ui/macros/tokenstream-ice-issue-149954.stderr index b1a589e76c323..45377188bff9b 100644 --- a/tests/ui/macros/tokenstream-ice-issue-149954.stderr +++ b/tests/ui/macros/tokenstream-ice-issue-149954.stderr @@ -82,13 +82,14 @@ LL | A: A<{ struct A> ; enum A } error[E0404]: expected trait, found struct `A` --> $DIR/tokenstream-ice-issue-149954.rs:10:16 | +LL | #[derive(Debug)] + | ----- in this derive macro +... LL | A: A<{ struct A> ; enum A } | ________________^ ... | LL | | >; | |_________^ not a trait - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0404]: expected trait, found type parameter `A` --> $DIR/tokenstream-ice-issue-149954.rs:10:32 diff --git a/tests/ui/methods/bad-wf-when-selecting-method.rs b/tests/ui/methods/bad-wf-when-selecting-method.rs index 1f1a10f420462..c54ab963c2cfa 100644 --- a/tests/ui/methods/bad-wf-when-selecting-method.rs +++ b/tests/ui/methods/bad-wf-when-selecting-method.rs @@ -11,7 +11,6 @@ trait Trait { fn test(t: T) { Wrapper(t).needs_sized(); //~^ ERROR the trait bound `T: Wf` is not satisfied - //~| ERROR the trait bound `T: Wf` is not satisfied //~| ERROR the method `needs_sized` exists for struct `Wrapper`, but its trait bounds were not satisfied } diff --git a/tests/ui/methods/bad-wf-when-selecting-method.stderr b/tests/ui/methods/bad-wf-when-selecting-method.stderr index e6d500349670c..7a8a1fe3ab546 100644 --- a/tests/ui/methods/bad-wf-when-selecting-method.stderr +++ b/tests/ui/methods/bad-wf-when-selecting-method.stderr @@ -16,22 +16,6 @@ help: consider restricting type parameter `T` with trait `Wf` LL | fn test(t: T) { | ++++ -error[E0277]: the trait bound `T: Wf` is not satisfied - --> $DIR/bad-wf-when-selecting-method.rs:12:5 - | -LL | Wrapper(t).needs_sized(); - | ^^^^^^^^^^ the trait `Wf` is not implemented for `T` - | -note: required by a bound in `Wrapper` - --> $DIR/bad-wf-when-selecting-method.rs:5:19 - | -LL | struct Wrapper, U>(T); - | ^^^^^^^^^^^^^ required by this bound in `Wrapper` -help: consider restricting type parameter `T` with trait `Wf` - | -LL | fn test(t: T) { - | ++++ - error[E0599]: the method `needs_sized` exists for struct `Wrapper`, but its trait bounds were not satisfied --> $DIR/bad-wf-when-selecting-method.rs:12:16 | @@ -48,7 +32,7 @@ help: consider restricting the type parameter to satisfy the trait bound LL | fn test(t: T) where T: Wf { | +++++++++++ -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0277, E0599. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/pattern/usefulness/issue-119493-type-error-ice.stderr b/tests/ui/pattern/usefulness/issue-119493-type-error-ice.stderr index 06e13aa2ea01d..b9def607e0b46 100644 --- a/tests/ui/pattern/usefulness/issue-119493-type-error-ice.stderr +++ b/tests/ui/pattern/usefulness/issue-119493-type-error-ice.stderr @@ -7,13 +7,10 @@ LL | struct Foo(NonExistent); error[E0425]: cannot find type `NonExistent` in this scope --> $DIR/issue-119493-type-error-ice.rs:5:16 | +LL | #[derive(Copy, Clone)] + | ----- in this derive macro LL | struct Foo(NonExistent); | ^^^^^^^^^^^ not found in this scope - | -help: you might be missing a type parameter - | -LL | struct Foo(NonExistent); - | +++++++++++++ error[E0658]: `impl Trait` in type aliases is unstable --> $DIR/issue-119493-type-error-ice.rs:9:14 diff --git a/tests/ui/pattern/usefulness/issue-119778-type-error-ice.stderr b/tests/ui/pattern/usefulness/issue-119778-type-error-ice.stderr index 7da384d613efb..9bcf4a9ce8d42 100644 --- a/tests/ui/pattern/usefulness/issue-119778-type-error-ice.stderr +++ b/tests/ui/pattern/usefulness/issue-119778-type-error-ice.stderr @@ -12,13 +12,10 @@ LL | struct Foo([u8; S]); error[E0425]: cannot find value `S` in this scope --> $DIR/issue-119778-type-error-ice.rs:5:21 | +LL | #[derive(Copy, Clone)] + | ----- in this derive macro LL | struct Foo([u8; S]); | ^ not found in this scope - | -help: you might be missing a const parameter - | -LL | struct Foo([u8; S]); - | +++++++++++++++++++++ error[E0658]: `impl Trait` in type aliases is unstable --> $DIR/issue-119778-type-error-ice.rs:9:14 diff --git a/tests/ui/reflection/reflection_methods_in_runtime_code.rs b/tests/ui/reflection/reflection_methods_in_runtime_code.rs index 4204fb3ad16f4..0f1fcd1768e27 100644 --- a/tests/ui/reflection/reflection_methods_in_runtime_code.rs +++ b/tests/ui/reflection/reflection_methods_in_runtime_code.rs @@ -5,5 +5,5 @@ trait Trait {} fn main() { // Test the (lack of) usability of comptime fns in runtime code. std::any::TypeId::of::<[u8; usize::MAX]>().trait_info_of::(); - //~^ ERROR: comptime fns can only be called at compile time + //~^ ERROR: comptime functions can only be called at compile time } diff --git a/tests/ui/reflection/reflection_methods_in_runtime_code.stderr b/tests/ui/reflection/reflection_methods_in_runtime_code.stderr index ff83c50754254..05e87ec2a69aa 100644 --- a/tests/ui/reflection/reflection_methods_in_runtime_code.stderr +++ b/tests/ui/reflection/reflection_methods_in_runtime_code.stderr @@ -1,8 +1,13 @@ -error: comptime fns can only be called at compile time +error: comptime functions can only be called at compile time --> $DIR/reflection_methods_in_runtime_code.rs:7:5 | LL | std::any::TypeId::of::<[u8; usize::MAX]>().trait_info_of::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: wrap the call in a const block to force compile time evaluation + | +LL | const { std::any::TypeId::of::<[u8; usize::MAX]>().trait_info_of::() }; + | +++++++ + error: aborting due to 1 previous error diff --git a/tests/ui/reflection/trait_info_of_too_big.stderr b/tests/ui/reflection/trait_info_of_too_big.stderr index 8d8557670e816..c28f7684d2e56 100644 --- a/tests/ui/reflection/trait_info_of_too_big.stderr +++ b/tests/ui/reflection/trait_info_of_too_big.stderr @@ -1,6 +1,7 @@ error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture --> $DIR/trait_info_of_too_big.rs:14:5 | +LL | const _: () = const { LL | TypeId::of::<[u8; usize::MAX]>().trait_info_of_trait_type_id(TypeId::of::()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_::{constant#0}` failed inside this call | @@ -12,6 +13,7 @@ note: inside `type_info::::size` error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture --> $DIR/trait_info_of_too_big.rs:18:5 | +LL | const _: () = const { LL | TypeId::of::<[u8; usize::MAX]>().trait_info_of::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_::{constant#0}` failed inside this call | diff --git a/tests/ui/reflection/variant_index_out_of_bounds.stderr b/tests/ui/reflection/variant_index_out_of_bounds.stderr index 177b662d84b7b..b8f7317d4af7c 100644 --- a/tests/ui/reflection/variant_index_out_of_bounds.stderr +++ b/tests/ui/reflection/variant_index_out_of_bounds.stderr @@ -1,6 +1,7 @@ error[E0080]: indexing out of bounds: the len is 2 but the index is 2 --> $DIR/variant_index_out_of_bounds.rs:8:5 | +LL | const _: () = const { LL | TypeId::of::>().fields(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_::{constant#0}` failed inside this call | @@ -20,6 +21,7 @@ LL | | }; error[E0080]: indexing out of bounds: the len is 0 but the index is 1 --> $DIR/variant_index_out_of_bounds.rs:13:5 | +LL | const _: () = const { LL | TypeId::of::>().field(0, 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_::{constant#0}` failed inside this call | diff --git a/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr b/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr index 6bf346df58a49..20b6a373e06d5 100644 --- a/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr +++ b/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr @@ -45,6 +45,7 @@ error: layout_of(Univariant) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/repr-c-dead-variants.rs:44:1 @@ -119,6 +120,7 @@ error: layout_of(TwoVariants) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/repr-c-dead-variants.rs:51:1 @@ -191,6 +193,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { Align(8 bytes), ), unadjusted_abi_align: Align(8 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/repr-c-dead-variants.rs:63:1 diff --git a/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr b/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr index 512efbb7e579d..9c04825c0dd94 100644 --- a/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr +++ b/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr @@ -45,6 +45,7 @@ error: layout_of(Univariant) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/repr-c-dead-variants.rs:44:1 @@ -119,6 +120,7 @@ error: layout_of(TwoVariants) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/repr-c-dead-variants.rs:51:1 @@ -191,6 +193,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { Align(8 bytes), ), unadjusted_abi_align: Align(8 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/repr-c-dead-variants.rs:63:1 diff --git a/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr b/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr index 6bf346df58a49..20b6a373e06d5 100644 --- a/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr +++ b/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr @@ -45,6 +45,7 @@ error: layout_of(Univariant) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/repr-c-dead-variants.rs:44:1 @@ -119,6 +120,7 @@ error: layout_of(TwoVariants) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/repr-c-dead-variants.rs:51:1 @@ -191,6 +193,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { Align(8 bytes), ), unadjusted_abi_align: Align(8 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/repr-c-dead-variants.rs:63:1 diff --git a/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr b/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr index 6bf346df58a49..20b6a373e06d5 100644 --- a/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr +++ b/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr @@ -45,6 +45,7 @@ error: layout_of(Univariant) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/repr-c-dead-variants.rs:44:1 @@ -119,6 +120,7 @@ error: layout_of(TwoVariants) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/repr-c-dead-variants.rs:51:1 @@ -191,6 +193,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { Align(8 bytes), ), unadjusted_abi_align: Align(8 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/repr-c-dead-variants.rs:63:1 diff --git a/tests/ui/repr/repr-c-int-dead-variants.stderr b/tests/ui/repr/repr-c-int-dead-variants.stderr index ed4e41182cc8c..11889120ac3d1 100644 --- a/tests/ui/repr/repr-c-int-dead-variants.stderr +++ b/tests/ui/repr/repr-c-int-dead-variants.stderr @@ -45,6 +45,7 @@ error: layout_of(UnivariantU8) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/repr-c-int-dead-variants.rs:15:1 @@ -119,6 +120,7 @@ error: layout_of(TwoVariantsU8) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/repr-c-int-dead-variants.rs:22:1 @@ -191,6 +193,7 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout { Align(8 bytes), ), unadjusted_abi_align: Align(8 bytes), + repr_c: true, randomization_seed: $SEED, } --> $DIR/repr-c-int-dead-variants.rs:34:1 diff --git a/tests/ui/simd/const-err-trumps-simd-err.stderr b/tests/ui/simd/const-err-trumps-simd-err.stderr index 93d1fce637f2f..2e396c81a688e 100644 --- a/tests/ui/simd/const-err-trumps-simd-err.stderr +++ b/tests/ui/simd/const-err-trumps-simd-err.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: assertion failed: LANE < 4 --> $DIR/const-err-trumps-simd-err.rs:17:13 | +LL | fn get_elem(a: int8x4_t) -> u8 { LL | const { assert!(LANE < 4); } // the error should be here... | ^^^^^^^^^^^^^^^^^ evaluation of `get_elem::<4>::{constant#0}` failed here diff --git a/tests/ui/sized/unsized-inference.rs b/tests/ui/sized/unsized-inference.rs new file mode 100644 index 0000000000000..1484b1f2d80ba --- /dev/null +++ b/tests/ui/sized/unsized-inference.rs @@ -0,0 +1,9 @@ +// Issue #84346. +use std::fmt::Display; + +fn main() { + let x = vec![1, 2, 3]; + let y: Vec = x.into_iter().collect(); + //~^ ERROR: the size for values of type `dyn std::fmt::Display` cannot be known at compilation time + //~| ERROR: a value of type `Vec` cannot be built from an iterator over elements of type `{integer}` +} diff --git a/tests/ui/sized/unsized-inference.stderr b/tests/ui/sized/unsized-inference.stderr new file mode 100644 index 0000000000000..dd8873430cee3 --- /dev/null +++ b/tests/ui/sized/unsized-inference.stderr @@ -0,0 +1,32 @@ +error[E0277]: the size for values of type `dyn std::fmt::Display` cannot be known at compilation time + --> $DIR/unsized-inference.rs:6:12 + | +LL | let y: Vec = x.into_iter().collect(); + | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `dyn std::fmt::Display` +note: required by an implicit `Sized` bound in `Vec` + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + +error[E0277]: a value of type `Vec` cannot be built from an iterator over elements of type `{integer}` + --> $DIR/unsized-inference.rs:6:45 + | +LL | let y: Vec = x.into_iter().collect(); + | ^^^^^^^ value of type `Vec` cannot be built from `std::iter::Iterator` + | + = help: the trait `FromIterator<{integer}>` is not implemented for `Vec` +help: the trait `FromIterator` is implemented for `Vec` + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL +note: the method call chain might not have had the expected associated types + --> $DIR/unsized-inference.rs:6:33 + | +LL | let x = vec![1, 2, 3]; + | ------------- this expression has type `Vec<{integer}>` +LL | let y: Vec = x.into_iter().collect(); + | ^^^^^^^^^^^ `Iterator::Item` is `{integer}` here +note: required by a bound in `collect` + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/sized/unsized-return-type-in-call.rs b/tests/ui/sized/unsized-return-type-in-call.rs new file mode 100644 index 0000000000000..a3ea0fd3c244e --- /dev/null +++ b/tests/ui/sized/unsized-return-type-in-call.rs @@ -0,0 +1,12 @@ +// Issue #105753. +trait T {} + +fn foo() -> dyn T { + //~^ ERROR: return type cannot be a trait object without pointer indirection + todo!() +} + +fn main() { + let x = foo(); + //~^ ERROR: the size for values of type `dyn T` cannot be known at compilation time +} diff --git a/tests/ui/sized/unsized-return-type-in-call.stderr b/tests/ui/sized/unsized-return-type-in-call.stderr new file mode 100644 index 0000000000000..8fad01645d84b --- /dev/null +++ b/tests/ui/sized/unsized-return-type-in-call.stderr @@ -0,0 +1,31 @@ +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/unsized-return-type-in-call.rs:4:13 + | +LL | fn foo() -> dyn T { + | ^^^^^ doesn't have a size known at compile-time + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL - fn foo() -> dyn T { +LL + fn foo() -> impl T { + | +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL ~ fn foo() -> Box { +LL | +LL ~ Box::new(todo!()) + | + +error[E0277]: the size for values of type `dyn T` cannot be known at compilation time + --> $DIR/unsized-return-type-in-call.rs:10:9 + | +LL | let x = foo(); + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `dyn T` + = note: all local variables must have a statically known size + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0277, E0746. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/structs/ice-missing-field-fn-sig-closure.rs b/tests/ui/structs/ice-missing-field-fn-sig-closure.rs index 6878dd85ff847..dde3fba2e5a46 100644 --- a/tests/ui/structs/ice-missing-field-fn-sig-closure.rs +++ b/tests/ui/structs/ice-missing-field-fn-sig-closure.rs @@ -10,7 +10,6 @@ fn main() { let c = |_: Wrapper<()>| {}; //~ ERROR the trait bound `(): Context` is not satisfied c(Wrapper { /* missing */ }); //~^ ERROR the trait bound `(): Context` is not satisfied - //~^^ ERROR missing field `container` in initializer of `Wrapper<_>` - //~^^^ ERROR the trait bound `(): Context` is not satisfied - //~^^^^ ERROR the trait bound `(): Context` is not satisfied + //~| ERROR missing field `container` in initializer of `Wrapper<_>` + //~| ERROR the trait bound `(): Context` is not satisfied } diff --git a/tests/ui/structs/ice-missing-field-fn-sig-closure.stderr b/tests/ui/structs/ice-missing-field-fn-sig-closure.stderr index 8e5b2fa931e4f..67048b657f17f 100644 --- a/tests/ui/structs/ice-missing-field-fn-sig-closure.stderr +++ b/tests/ui/structs/ice-missing-field-fn-sig-closure.stderr @@ -38,23 +38,6 @@ error[E0063]: missing field `container` in initializer of `Wrapper<_>` LL | c(Wrapper { /* missing */ }); | ^^^^^^^ missing `container` -error[E0277]: the trait bound `(): Context` is not satisfied - --> $DIR/ice-missing-field-fn-sig-closure.rs:11:7 - | -LL | c(Wrapper { /* missing */ }); - | ^^^^^^^ the trait `Context` is not implemented for `()` - | -help: this trait has no implementations, consider adding one - --> $DIR/ice-missing-field-fn-sig-closure.rs:4:1 - | -LL | trait Context {} - | ^^^^^^^^^^^^^ -note: required by a bound in `Wrapper` - --> $DIR/ice-missing-field-fn-sig-closure.rs:5:19 - | -LL | struct Wrapper { - | ^^^^^^^ required by this bound in `Wrapper` - error[E0277]: the trait bound `(): Context` is not satisfied --> $DIR/ice-missing-field-fn-sig-closure.rs:11:5 | @@ -72,7 +55,7 @@ note: required by a bound in `Wrapper` LL | struct Wrapper { | ^^^^^^^ required by this bound in `Wrapper` -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0063, E0277. For more information about an error, try `rustc --explain E0063`. diff --git a/tests/ui/structs/ice-missing-field-fn-sig.rs b/tests/ui/structs/ice-missing-field-fn-sig.rs index 9ba48f6a6e795..41467d91449e8 100644 --- a/tests/ui/structs/ice-missing-field-fn-sig.rs +++ b/tests/ui/structs/ice-missing-field-fn-sig.rs @@ -7,8 +7,7 @@ struct Wrapper { fn foobar(_: Wrapper<()>) { //~ ERROR the trait bound `(): Context` is not satisfied foobar(Wrapper { /* missing */ }) //~^ ERROR the trait bound `(): Context` is not satisfied -//~^^ ERROR missing field `container` in initializer of `Wrapper<_>` -//~^^^ ERROR the trait bound `(): Context` is not satisfied +//~| ERROR missing field `container` in initializer of `Wrapper<_>` } fn main() {} diff --git a/tests/ui/structs/ice-missing-field-fn-sig.stderr b/tests/ui/structs/ice-missing-field-fn-sig.stderr index 7be7886b2d975..5d8ed5bbf5eb5 100644 --- a/tests/ui/structs/ice-missing-field-fn-sig.stderr +++ b/tests/ui/structs/ice-missing-field-fn-sig.stderr @@ -38,24 +38,7 @@ error[E0063]: missing field `container` in initializer of `Wrapper<_>` LL | foobar(Wrapper { /* missing */ }) | ^^^^^^^ missing `container` -error[E0277]: the trait bound `(): Context` is not satisfied - --> $DIR/ice-missing-field-fn-sig.rs:8:12 - | -LL | foobar(Wrapper { /* missing */ }) - | ^^^^^^^ the trait `Context` is not implemented for `()` - | -help: this trait has no implementations, consider adding one - --> $DIR/ice-missing-field-fn-sig.rs:3:1 - | -LL | trait Context {} - | ^^^^^^^^^^^^^ -note: required by a bound in `Wrapper` - --> $DIR/ice-missing-field-fn-sig.rs:4:19 - | -LL | struct Wrapper { - | ^^^^^^^ required by this bound in `Wrapper` - -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0063, E0277. For more information about an error, try `rustc --explain E0063`. diff --git a/tests/ui/suggestions/mut-borrow-needed-by-trait.rs b/tests/ui/suggestions/mut-borrow-needed-by-trait.rs index 66e1e77c905e0..1686a7dddb137 100644 --- a/tests/ui/suggestions/mut-borrow-needed-by-trait.rs +++ b/tests/ui/suggestions/mut-borrow-needed-by-trait.rs @@ -16,7 +16,6 @@ fn main() { let fp = BufWriter::new(fp); //~^ ERROR the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied - //~| ERROR the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied writeln!(fp, "hello world").unwrap(); //~ ERROR the method } diff --git a/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr b/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr index 5ba7fcb2479bb..6b2d315c96aac 100644 --- a/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr +++ b/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr @@ -10,24 +10,14 @@ LL | let fp = BufWriter::new(fp); note: required by a bound in `BufWriter::::new` --> $SRC_DIR/alloc/src/io/buffered/bufwriter.rs:LL:COL -error[E0277]: the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied - --> $DIR/mut-borrow-needed-by-trait.rs:17:14 - | -LL | let fp = BufWriter::new(fp); - | ^^^^^^^^^^^^^^^^^^ the trait `std::io::Write` is not implemented for `&dyn std::io::Write` - | - = note: `std::io::Write` is implemented for `&mut dyn std::io::Write`, but not for `&dyn std::io::Write` -note: required by a bound in `BufWriter` - --> $SRC_DIR/alloc/src/io/buffered/bufwriter.rs:LL:COL - error[E0599]: the method `write_fmt` exists for struct `BufWriter<&dyn std::io::Write>`, but its trait bounds were not satisfied - --> $DIR/mut-borrow-needed-by-trait.rs:21:14 + --> $DIR/mut-borrow-needed-by-trait.rs:20:14 | LL | writeln!(fp, "hello world").unwrap(); | ---------^^---------------- method cannot be called on `BufWriter<&dyn std::io::Write>` due to unsatisfied trait bounds | note: must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method - --> $DIR/mut-borrow-needed-by-trait.rs:21:14 + --> $DIR/mut-borrow-needed-by-trait.rs:20:14 | LL | writeln!(fp, "hello world").unwrap(); | ^^ @@ -35,7 +25,7 @@ LL | writeln!(fp, "hello world").unwrap(); `&dyn std::io::Write: std::io::Write` which is required by `BufWriter<&dyn std::io::Write>: std::io::Write` -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0277, E0599. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/issue-50480.stderr b/tests/ui/traits/issue-50480.stderr index e7a93dc52579e..a8b6ff4d0d924 100644 --- a/tests/ui/traits/issue-50480.stderr +++ b/tests/ui/traits/issue-50480.stderr @@ -18,24 +18,18 @@ LL | struct Foo(N, NotDefined, ::Item, Vec, String); error[E0425]: cannot find type `N` in this scope --> $DIR/issue-50480.rs:2:12 | +LL | #[derive(Clone, Copy)] + | ----- in this derive macro LL | struct Foo(N, NotDefined, ::Item, Vec, String); | ^ not found in this scope - | -help: you might be missing a type parameter - | -LL | struct Foo(N, NotDefined, ::Item, Vec, String); - | +++ error[E0425]: cannot find type `NotDefined` in this scope --> $DIR/issue-50480.rs:2:15 | +LL | #[derive(Clone, Copy)] + | ----- in this derive macro LL | struct Foo(N, NotDefined, ::Item, Vec, String); | ^^^^^^^^^^ not found in this scope - | -help: you might be missing a type parameter - | -LL | struct Foo(N, NotDefined, ::Item, Vec, String); - | ++++++++++++ error[E0425]: cannot find type `N` in this scope --> $DIR/issue-50480.rs:12:18 diff --git a/tests/ui/traits/negative-impls/negated-auto-traits-error.rs b/tests/ui/traits/negative-impls/negated-auto-traits-error.rs index 4bdad5dc591c5..523876c9f2a4f 100644 --- a/tests/ui/traits/negative-impls/negated-auto-traits-error.rs +++ b/tests/ui/traits/negative-impls/negated-auto-traits-error.rs @@ -22,7 +22,6 @@ fn dummy() { Outer(TestType); //~^ ERROR `dummy::TestType` cannot be sent between threads safely - //~| ERROR `dummy::TestType` cannot be sent between threads safely } fn dummy1b() { diff --git a/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr b/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr index 64e9dae2633b8..60b6c712341c7 100644 --- a/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr +++ b/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr @@ -17,25 +17,8 @@ note: required by a bound in `Outer` LL | struct Outer(T); | ^^^^ required by this bound in `Outer` -error[E0277]: `dummy::TestType` cannot be sent between threads safely - --> $DIR/negated-auto-traits-error.rs:23:5 - | -LL | Outer(TestType); - | ^^^^^^^^^^^^^^^ `dummy::TestType` cannot be sent between threads safely - | -help: the trait `Send` is not implemented for `dummy::TestType` - --> $DIR/negated-auto-traits-error.rs:20:5 - | -LL | struct TestType; - | ^^^^^^^^^^^^^^^ -note: required by a bound in `Outer` - --> $DIR/negated-auto-traits-error.rs:10:17 - | -LL | struct Outer(T); - | ^^^^ required by this bound in `Outer` - error[E0277]: `dummy1b::TestType` cannot be sent between threads safely - --> $DIR/negated-auto-traits-error.rs:32:13 + --> $DIR/negated-auto-traits-error.rs:31:13 | LL | is_send(TestType); | ------- ^^^^^^^^ `dummy1b::TestType` cannot be sent between threads safely @@ -43,7 +26,7 @@ LL | is_send(TestType); | required by a bound introduced by this call | help: the trait `Send` is not implemented for `dummy1b::TestType` - --> $DIR/negated-auto-traits-error.rs:29:5 + --> $DIR/negated-auto-traits-error.rs:28:5 | LL | struct TestType; | ^^^^^^^^^^^^^^^ @@ -54,7 +37,7 @@ LL | fn is_send(_: T) {} | ^^^^ required by this bound in `is_send` error[E0277]: `dummy1c::TestType` cannot be sent between threads safely - --> $DIR/negated-auto-traits-error.rs:40:13 + --> $DIR/negated-auto-traits-error.rs:39:13 | LL | is_send((8, TestType)); | ------- ^^^^^^^^^^^^^ `dummy1c::TestType` cannot be sent between threads safely @@ -62,7 +45,7 @@ LL | is_send((8, TestType)); | required by a bound introduced by this call | help: within `({integer}, dummy1c::TestType)`, the trait `Send` is not implemented for `dummy1c::TestType` - --> $DIR/negated-auto-traits-error.rs:37:5 + --> $DIR/negated-auto-traits-error.rs:36:5 | LL | struct TestType; | ^^^^^^^^^^^^^^^ @@ -74,7 +57,7 @@ LL | fn is_send(_: T) {} | ^^^^ required by this bound in `is_send` error[E0277]: `dummy2::TestType` cannot be sent between threads safely - --> $DIR/negated-auto-traits-error.rs:48:13 + --> $DIR/negated-auto-traits-error.rs:47:13 | LL | is_send(Box::new(TestType)); | ------- ^^^^^^^^^^^^^^^^^^ the trait `Send` is not implemented for `std::ptr::Unique` @@ -96,7 +79,7 @@ LL | is_send(&Box::new(TestType)); | + error[E0277]: `dummy3::TestType` cannot be sent between threads safely - --> $DIR/negated-auto-traits-error.rs:56:13 + --> $DIR/negated-auto-traits-error.rs:55:13 | LL | is_send(Box::new(Outer2(TestType))); | ------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ `dummy3::TestType` cannot be sent between threads safely @@ -104,7 +87,7 @@ LL | is_send(Box::new(Outer2(TestType))); | required by a bound introduced by this call | help: within `Outer2`, the trait `Send` is not implemented for `dummy3::TestType` - --> $DIR/negated-auto-traits-error.rs:53:5 + --> $DIR/negated-auto-traits-error.rs:52:5 | LL | struct TestType; | ^^^^^^^^^^^^^^^ @@ -123,7 +106,7 @@ LL | fn is_send(_: T) {} | ^^^^ required by this bound in `is_send` error[E0277]: `main::TestType` cannot be sent between threads safely - --> $DIR/negated-auto-traits-error.rs:66:20 + --> $DIR/negated-auto-traits-error.rs:65:20 | LL | is_sync(Outer2(TestType)); | ------- ^^^^^^^^ `main::TestType` cannot be sent between threads safely @@ -131,7 +114,7 @@ LL | is_sync(Outer2(TestType)); | required by a bound introduced by this call | help: the trait `Send` is not implemented for `main::TestType` - --> $DIR/negated-auto-traits-error.rs:61:5 + --> $DIR/negated-auto-traits-error.rs:60:5 | LL | struct TestType; | ^^^^^^^^^^^^^^^ @@ -148,6 +131,6 @@ note: required by a bound in `is_sync` LL | fn is_sync(_: T) {} | ^^^^ required by this bound in `is_sync` -error: aborting due to 7 previous errors +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-issue-162440.rs b/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-issue-162440.rs index 9b6562ff578bf..1cd0445289fbb 100644 --- a/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-issue-162440.rs +++ b/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-issue-162440.rs @@ -8,5 +8,4 @@ fn main() { Some([0]).map(|s| s[..]); //~^ ERROR the size for values of type `[{integer}]` cannot be known at compilation time //~| ERROR the size for values of type `[{integer}]` cannot be known at compilation time - //~| ERROR the size for values of type `[{integer}]` cannot be known at compilation time } diff --git a/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-issue-162440.stderr b/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-issue-162440.stderr index 4aed7e179b8ef..40338cf23f004 100644 --- a/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-issue-162440.stderr +++ b/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-issue-162440.stderr @@ -17,25 +17,6 @@ LL | Some([0]).map(|s| s[..]); = help: the trait `Sized` is not implemented for `[{integer}]` = note: the return type of a function must have a statically known size -error[E0277]: the size for values of type `[{integer}]` cannot be known at compilation time - --> $DIR/closure-capture-uninferred-upvars-issue-162440.rs:8:19 - | -LL | Some([0]).map(|s| s[..]); - | --- ---^^^^^^ - | | | - | | doesn't have a size known at compile-time - | | within this `{closure@$DIR/closure-capture-uninferred-upvars-issue-162440.rs:8:19: 8:22}` - | required by a bound introduced by this call - | - = help: within `{closure@$DIR/closure-capture-uninferred-upvars-issue-162440.rs:8:19: 8:22}`, the trait `Sized` is not implemented for `[{integer}]` -note: required because it's used within this closure - --> $DIR/closure-capture-uninferred-upvars-issue-162440.rs:8:19 - | -LL | Some([0]).map(|s| s[..]); - | ^^^ -note: required by a bound in `Option::::map` - --> $SRC_DIR/core/src/option.rs:LL:COL - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-with-capture.rs b/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-with-capture.rs index ff4a9b67a3fee..62c6884a321ce 100644 --- a/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-with-capture.rs +++ b/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-with-capture.rs @@ -8,7 +8,6 @@ fn main() { Some([0]).map(|s| { //~^ ERROR the size for values of type `[{integer}]` cannot be known at compilation time - //~| ERROR the size for values of type `[{integer}]` cannot be known at compilation time //~| ERROR the size for values of type `[{integer}]` cannot be known at compilation time let _ = &x; s[..] diff --git a/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-with-capture.stderr b/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-with-capture.stderr index b19dca701f2fb..05a3a44504246 100644 --- a/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-with-capture.stderr +++ b/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-with-capture.stderr @@ -13,7 +13,9 @@ error[E0277]: the size for values of type `[{integer}]` cannot be known at compi | LL | Some([0]).map(|s| { | _______________________^ -... | +LL | | +LL | | +LL | | let _ = &x; LL | | s[..] LL | | }); | |_____^ doesn't have a size known at compile-time @@ -21,29 +23,6 @@ LL | | }); = help: the trait `Sized` is not implemented for `[{integer}]` = note: the return type of a function must have a statically known size -error[E0277]: the size for values of type `[{integer}]` cannot be known at compilation time - --> $DIR/closure-capture-uninferred-upvars-with-capture.rs:9:19 - | -LL | Some([0]).map(|s| { - | --- ^-- - | | | - | _______________|___within this `{closure@$DIR/closure-capture-uninferred-upvars-with-capture.rs:9:19: 9:22}` - | | | - | | required by a bound introduced by this call -... | -LL | | s[..] -LL | | }); - | |_____^ doesn't have a size known at compile-time - | - = help: within `{closure@$DIR/closure-capture-uninferred-upvars-with-capture.rs:9:19: 9:22}`, the trait `Sized` is not implemented for `[{integer}]` -note: required because it's used within this closure - --> $DIR/closure-capture-uninferred-upvars-with-capture.rs:9:19 - | -LL | Some([0]).map(|s| { - | ^^^ -note: required by a bound in `Option::::map` - --> $SRC_DIR/core/src/option.rs:LL:COL - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/opaques/implied-bounds-opaque-hidden-in-closure-sig.current.stderr b/tests/ui/traits/next-solver/opaques/implied-bounds-opaque-hidden-in-closure-sig.current.stderr index 1189f62601759..15516922d9276 100644 --- a/tests/ui/traits/next-solver/opaques/implied-bounds-opaque-hidden-in-closure-sig.current.stderr +++ b/tests/ui/traits/next-solver/opaques/implied-bounds-opaque-hidden-in-closure-sig.current.stderr @@ -19,44 +19,6 @@ LL | struct RequiresWf(F) LL | F::Output: Trait, | ^^^^^ required by this bound in `RequiresWf` -error[E0277]: the trait bound `impl Sized: Trait` is not satisfied - --> $DIR/implied-bounds-opaque-hidden-in-closure-sig.rs:35:14 - | -LL | (|_| ())(RequiresWf(opaque)); - | ^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `impl Sized` - | -help: the trait `Trait` is implemented for `()` - --> $DIR/implied-bounds-opaque-hidden-in-closure-sig.rs:17:1 - | -LL | impl Trait for () { - | ^^^^^^^^^^^^^^^^^ -note: required by a bound in `RequiresWf` - --> $DIR/implied-bounds-opaque-hidden-in-closure-sig.rs:31:16 - | -LL | struct RequiresWf(F) -... -LL | F::Output: Trait, - | ^^^^^ required by this bound in `RequiresWf` - -error[E0277]: the trait bound `impl Sized: Trait` is not satisfied - --> $DIR/implied-bounds-opaque-hidden-in-closure-sig.rs:35:7 - | -LL | (|_| ())(RequiresWf(opaque)); - | ^ the trait `Trait` is not implemented for `impl Sized` - | -help: the trait `Trait` is implemented for `()` - --> $DIR/implied-bounds-opaque-hidden-in-closure-sig.rs:17:1 - | -LL | impl Trait for () { - | ^^^^^^^^^^^^^^^^^ -note: required by a bound in `RequiresWf` - --> $DIR/implied-bounds-opaque-hidden-in-closure-sig.rs:31:16 - | -LL | struct RequiresWf(F) -... -LL | F::Output: Trait, - | ^^^^^ required by this bound in `RequiresWf` - error[E0277]: the trait bound `impl Sized: Trait` is not satisfied --> $DIR/implied-bounds-opaque-hidden-in-closure-sig.rs:35:5 | @@ -76,6 +38,6 @@ LL | struct RequiresWf(F) LL | F::Output: Trait, | ^^^^^ required by this bound in `RequiresWf` -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/opaques/implied-bounds-opaque-hidden-in-closure-sig.rs b/tests/ui/traits/next-solver/opaques/implied-bounds-opaque-hidden-in-closure-sig.rs index 6fe74f0d4f9d3..324c99b5bab92 100644 --- a/tests/ui/traits/next-solver/opaques/implied-bounds-opaque-hidden-in-closure-sig.rs +++ b/tests/ui/traits/next-solver/opaques/implied-bounds-opaque-hidden-in-closure-sig.rs @@ -35,8 +35,6 @@ fn opaque() -> impl Sized { (|_| ())(RequiresWf(opaque)); //[current]~^ ERROR the trait bound `impl Sized: Trait` is not satisfied //[current]~| ERROR the trait bound `impl Sized: Trait` is not satisfied - //[current]~| ERROR the trait bound `impl Sized: Trait` is not satisfied - //[current]~| ERROR the trait bound `impl Sized: Trait` is not satisfied } fn main() {} diff --git a/tests/ui/traits/next-solver/overflow/incorrect-old-solver-caching-ice-148095.next.stderr b/tests/ui/traits/next-solver/overflow/incorrect-old-solver-caching-ice-148095.next.stderr index c285c42d380e8..021573324c9e5 100644 --- a/tests/ui/traits/next-solver/overflow/incorrect-old-solver-caching-ice-148095.next.stderr +++ b/tests/ui/traits/next-solver/overflow/incorrect-old-solver-caching-ice-148095.next.stderr @@ -93,15 +93,6 @@ help: consider extending the `where` clause, but there might be an alternative b LL | Quantity:, f32: Mul | +++++++++++++ -error[E0277]: cannot multiply `f32` by `S` - | - = help: the trait `Mul` is not implemented for `f32` -help: consider extending the `where` clause, but there might be an alternative better way to express this requirement - --> $DIR/incorrect-old-solver-caching-ice-148095.rs:27:28 - | -LL | Quantity:, f32: Mul - | +++++++++++++ - error: the type `Quantity<>::Output>` is not well-formed --> $DIR/incorrect-old-solver-caching-ice-148095.rs:30:21 | @@ -120,7 +111,7 @@ help: consider extending the `where` clause, but there might be an alternative b LL | Quantity:, f32: Mul | +++++++++++++ -error: aborting due to 11 previous errors +error: aborting due to 10 previous errors Some errors have detailed explanations: E0207, E0276, E0277. For more information about an error, try `rustc --explain E0207`. diff --git a/tests/ui/traits/trivial-const-with-impossible-bounds.stderr b/tests/ui/traits/trivial-const-with-impossible-bounds.stderr index c5cf6626cc7a1..72c7c25f537c0 100644 --- a/tests/ui/traits/trivial-const-with-impossible-bounds.stderr +++ b/tests/ui/traits/trivial-const-with-impossible-bounds.stderr @@ -1,6 +1,7 @@ error[E0080]: entering unreachable code --> $DIR/trivial-const-with-impossible-bounds.rs:5:5 | +LL | impl Dummy where for<'a> &'a mut i32: Copy { LL | const C: usize = 1; | ^^^^^^^^^^^^^^^^^^^ evaluation of `Dummy::C` failed here diff --git a/tests/ui/transmutability/uninhabited.stderr b/tests/ui/transmutability/uninhabited.stderr index 5f66d85446d5e..3ddd3a32bca67 100644 --- a/tests/ui/transmutability/uninhabited.stderr +++ b/tests/ui/transmutability/uninhabited.stderr @@ -41,6 +41,10 @@ LL | | }> error[E0080]: evaluation panicked: assertion failed: false --> $DIR/uninhabited.rs:41:9 | +LL | fn yawning_void_struct() { +... +LL | const _: () = { +... LL | assert!(false); | ^^^^^^^^^^^^^^ evaluation of `yawning_void_struct::_` failed here @@ -67,6 +71,10 @@ LL | | }> error[E0080]: evaluation panicked: assertion failed: false --> $DIR/uninhabited.rs:61:9 | +LL | fn yawning_void_enum() { +... +LL | const _: () = { +... LL | assert!(false); | ^^^^^^^^^^^^^^ evaluation of `yawning_void_enum::_` failed here @@ -93,6 +101,10 @@ LL | | }> error[E0080]: evaluation panicked: assertion failed: false --> $DIR/uninhabited.rs:83:9 | +LL | fn distant_void() { +... +LL | const _: () = { +... LL | assert!(false); | ^^^^^^^^^^^^^^ evaluation of `distant_void::_` failed here diff --git a/tests/ui/type-alias-impl-trait/struct-assignment-validity.next.stderr b/tests/ui/type-alias-impl-trait/struct-assignment-validity.next.stderr deleted file mode 100644 index 78724a5ccec1c..0000000000000 --- a/tests/ui/type-alias-impl-trait/struct-assignment-validity.next.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0391]: cycle detected when computing type of `::Assoc::{opaque#0}` - --> $DIR/struct-assignment-validity.rs:21:18 - | -LL | type Assoc = impl std::fmt::Debug; - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: ...which requires computing type of opaque `::Assoc::{opaque#0}`... -note: ...which requires borrow-checking `::foo`... - --> $DIR/struct-assignment-validity.rs:22:5 - | -LL | / fn foo() -> Foo -LL | | where -LL | | Self::Assoc:, - | |_____________________^ - = note: ...which requires promoting constants in MIR for `::foo`... - = note: ...which requires normalizing `::Assoc`... - = note: ...which again requires computing type of `::Assoc::{opaque#0}`, completing the cycle - = note: cycle used when checking that `::Assoc::{opaque#0}` is well-formed - = note: for more information, see and - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/type-alias-impl-trait/struct-assignment-validity.rs b/tests/ui/type-alias-impl-trait/struct-assignment-validity.rs index 608c804be9c94..8005edbf1636e 100644 --- a/tests/ui/type-alias-impl-trait/struct-assignment-validity.rs +++ b/tests/ui/type-alias-impl-trait/struct-assignment-validity.rs @@ -1,7 +1,7 @@ //@ revisions: old next //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver -//@[next] known-bug: trait-system-refactor-initiative#303 +//@[next] check-pass //@ compile-flags: -Zvalidate-mir //@[old] check-pass diff --git a/tests/ui/type-alias-impl-trait/typing-env-before-borrowck.rs b/tests/ui/type-alias-impl-trait/typing-env-before-borrowck.rs new file mode 100644 index 0000000000000..5219ee821b189 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/typing-env-before-borrowck.rs @@ -0,0 +1,10 @@ +//@ compile-flags: -Zvalidate-mir -Znext-solver=globally +//@ check-pass + +struct Opaque(F, F::Output); + +fn f() -> impl Sized { + Opaque(f, ()); +} + +fn main() {} diff --git a/tests/ui/type-inference/snapshot-infer-leakage/leak-infer-ice-120254.next.stderr b/tests/ui/type-inference/snapshot-infer-leakage/leak-infer-ice-120254.next.stderr index 39deff902a1a0..b96467228aa8d 100644 --- a/tests/ui/type-inference/snapshot-infer-leakage/leak-infer-ice-120254.next.stderr +++ b/tests/ui/type-inference/snapshot-infer-leakage/leak-infer-ice-120254.next.stderr @@ -1,25 +1,11 @@ error[E0277]: the trait bound `E: Dbg` is not satisfied - --> $DIR/leak-infer-ice-120254.rs:33:28 + --> $DIR/leak-infer-ice-120254.rs:31:28 | LL | fn record_err(self, _: ::Checkpoint) -> () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Dbg` is not implemented for `E` | note: required for `Foo` to implement `Bar` - --> $DIR/leak-infer-ice-120254.rs:24:22 - | -LL | impl Bar for Foo { - | --- ^^^ ^^^^^^^^^ - | | - | unsatisfied trait bound introduced here -help: consider restricting type parameter `E` with trait `Dbg` - | -LL | impl Foo { - | +++++ - -error[E0277]: the trait bound `E: Dbg` is not satisfied - | -note: required for `Foo` to implement `Bar` - --> $DIR/leak-infer-ice-120254.rs:24:22 + --> $DIR/leak-infer-ice-120254.rs:22:22 | LL | impl Bar for Foo { | --- ^^^ ^^^^^^^^^ @@ -31,19 +17,19 @@ LL | impl Foo { | +++++ error: the type ` as Bar>::Checkpoint` is not well-formed - --> $DIR/leak-infer-ice-120254.rs:33:28 + --> $DIR/leak-infer-ice-120254.rs:31:28 | LL | fn record_err(self, _: ::Checkpoint) -> () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `E: Dbg` is not satisfied - --> $DIR/leak-infer-ice-120254.rs:33:28 + --> $DIR/leak-infer-ice-120254.rs:31:28 | LL | fn record_err(self, _: ::Checkpoint) -> () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Dbg` is not implemented for `E` | note: required for `Foo` to implement `Bar` - --> $DIR/leak-infer-ice-120254.rs:24:22 + --> $DIR/leak-infer-ice-120254.rs:22:22 | LL | impl Bar for Foo { | --- ^^^ ^^^^^^^^^ @@ -55,6 +41,6 @@ help: consider restricting type parameter `E` with trait `Dbg` LL | impl Foo { | +++++ -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/type-inference/snapshot-infer-leakage/leak-infer-ice-120254.rs b/tests/ui/type-inference/snapshot-infer-leakage/leak-infer-ice-120254.rs index 0299381e17312..ccf1ed3d9826f 100644 --- a/tests/ui/type-inference/snapshot-infer-leakage/leak-infer-ice-120254.rs +++ b/tests/ui/type-inference/snapshot-infer-leakage/leak-infer-ice-120254.rs @@ -5,8 +5,6 @@ //@[old] dont-check-compiler-stderr //@[old] known-bug: #120254 -//[next]~^^^^^^^ ERROR: the trait bound `E: Dbg` is not satisfied - // Regression test for #120254. This no longer reproduces with the new solver // even though the underlying issue has not been fixed. diff --git a/tests/ui/type/pattern_types/non_null.stderr b/tests/ui/type/pattern_types/non_null.stderr index d5e5beb6e5e40..cac076dfc56cf 100644 --- a/tests/ui/type/pattern_types/non_null.stderr +++ b/tests/ui/type/pattern_types/non_null.stderr @@ -27,6 +27,7 @@ error: layout_of(pattern_type!(*const T is !null)) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/non_null.rs:11:1 @@ -95,6 +96,7 @@ error: layout_of(Option) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/non_null.rs:14:1 @@ -133,6 +135,7 @@ error: layout_of(pattern_type!(*const [u8] is !null)) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/non_null.rs:17:1 diff --git a/tests/ui/type/pattern_types/or_patterns.stderr b/tests/ui/type/pattern_types/or_patterns.stderr index 35ae6b384ea75..b29033446abae 100644 --- a/tests/ui/type/pattern_types/or_patterns.stderr +++ b/tests/ui/type/pattern_types/or_patterns.stderr @@ -68,6 +68,7 @@ error: layout_of(pattern_type!(i8 is (i8::MIN..=-1 | 1..))) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/or_patterns.rs:17:1 @@ -104,6 +105,7 @@ error: layout_of(pattern_type!(i8 is (i8::MIN..=-2 | 0..))) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/or_patterns.rs:21:1 diff --git a/tests/ui/type/pattern_types/range_patterns.stderr b/tests/ui/type/pattern_types/range_patterns.stderr index a12d3aeb6b35b..fd5f1ab323546 100644 --- a/tests/ui/type/pattern_types/range_patterns.stderr +++ b/tests/ui/type/pattern_types/range_patterns.stderr @@ -27,6 +27,7 @@ error: layout_of(NonZero) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/range_patterns.rs:11:1 @@ -63,6 +64,7 @@ error: layout_of(pattern_type!(u32 is 1..)) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/range_patterns.rs:13:1 @@ -131,6 +133,7 @@ error: layout_of(Option) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/range_patterns.rs:15:1 @@ -199,6 +202,7 @@ error: layout_of(Option>) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/range_patterns.rs:17:1 @@ -235,6 +239,7 @@ error: layout_of(NonZeroU32New) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/range_patterns.rs:19:1 @@ -299,6 +304,7 @@ error: layout_of(pattern_type!(i8 is -10..=10)) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/range_patterns.rs:32:1 @@ -335,6 +341,7 @@ error: layout_of(pattern_type!(i8 is i8::MIN..=0)) = Layout { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: $SEED, } --> $DIR/range_patterns.rs:35:1