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_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 025c64896edb7..998351e3f2825 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -1115,7 +1115,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/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_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_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_next_trait_solver/src/solve/assembly/structural_traits.rs b/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs index c92fdea176670..a7e02f07661c6 100644 --- a/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs +++ b/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs @@ -440,6 +440,10 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_async_callable Result<(ty::Binder>, Vec), NoSolution> { match self_ty.kind() { ty::CoroutineClosure(def_id, args) => { + if !cx.coroutine_is_async(cx.coroutine_for_closure(def_id)) { + return Err(NoSolution); + } + let args = args.as_coroutine_closure(); let kind_ty = args.kind_ty(); let sig = args.coroutine_closure_sig().skip_binder(); 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/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/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_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/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/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/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/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/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/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/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/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/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/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/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/generator_capture_2.current.stderr b/tests/ui/iterators/generator_capture_2.current.stderr index f4d0e9ff33240..da3e9288eda26 100644 --- a/tests/ui/iterators/generator_capture_2.current.stderr +++ b/tests/ui/iterators/generator_capture_2.current.stderr @@ -1,8 +1,8 @@ error[E0382]: use of moved value: `f` - --> $DIR/generator_capture_2.rs:27:17 + --> $DIR/generator_capture_2.rs:26:17 | LL | let f = { - | - move occurs because `f` has type `{gen closure@$DIR/generator_capture_2.rs:16:17: 16:24}`, which does not implement the `Copy` trait + | - move occurs because `f` has type `{gen closure@$DIR/generator_capture_2.rs:15:17: 15:24}`, which does not implement the `Copy` trait ... LL | let mut i = f(); | --- `f` moved due to this call @@ -11,7 +11,7 @@ LL | let mut i = f(); | ^ value used here after move | note: this value implements `FnOnce`, which causes it to be moved when called - --> $DIR/generator_capture_2.rs:22:17 + --> $DIR/generator_capture_2.rs:21:17 | LL | let mut i = f(); | ^ diff --git a/tests/ui/iterators/generator_capture_2.next.stderr b/tests/ui/iterators/generator_capture_2.next.stderr new file mode 100644 index 0000000000000..da3e9288eda26 --- /dev/null +++ b/tests/ui/iterators/generator_capture_2.next.stderr @@ -0,0 +1,25 @@ +error[E0382]: use of moved value: `f` + --> $DIR/generator_capture_2.rs:26:17 + | +LL | let f = { + | - move occurs because `f` has type `{gen closure@$DIR/generator_capture_2.rs:15:17: 15:24}`, which does not implement the `Copy` trait +... +LL | let mut i = f(); + | --- `f` moved due to this call +... +LL | let mut i = f(); + | ^ value used here after move + | +note: this value implements `FnOnce`, which causes it to be moved when called + --> $DIR/generator_capture_2.rs:21:17 + | +LL | let mut i = f(); + | ^ +help: consider cloning the value if the performance cost is acceptable + | +LL | let mut i = f.clone()(); + | ++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/iterators/generator_capture_2.rs b/tests/ui/iterators/generator_capture_2.rs index 5277dbb203732..af80475e05419 100644 --- a/tests/ui/iterators/generator_capture_2.rs +++ b/tests/ui/iterators/generator_capture_2.rs @@ -1,8 +1,7 @@ //@ revisions: current next //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver -//@[next] known-bug: trait-system-refactor-initiative#302 -//@[next] check-pass +//@check-fail // This test exercises lending behavior for iterator closures which is not yet supported. @@ -24,7 +23,7 @@ fn main() { assert_eq!(i.next(), Some('o')); assert_eq!(i.next(), Some('o')); assert_eq!(i.next(), None); - let mut i = f(); //[current]~ ERROR use of moved value: `f` + let mut i = f(); //~ ERROR use of moved value: `f` assert_eq!(i.next(), Some('f')); assert_eq!(i.next(), Some('o')); assert_eq!(i.next(), Some('o')); diff --git a/tests/ui/iterators/iter-macro-not-async-closure-simplified.narrow.stderr b/tests/ui/iterators/iter-macro-not-async-closure-simplified.narrow.stderr index 7aaff4c7bf679..c337681c97346 100644 --- a/tests/ui/iterators/iter-macro-not-async-closure-simplified.narrow.stderr +++ b/tests/ui/iterators/iter-macro-not-async-closure-simplified.narrow.stderr @@ -1,14 +1,14 @@ -error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:25:21: 25:28}: AsyncFnOnce()` is not satisfied - --> $DIR/iter-macro-not-async-closure-simplified.rs:31:21 +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:24:21: 24:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure-simplified.rs:30:21 | LL | call_async_once(f); | --------------- ^ unsatisfied trait bound | | | required by a bound introduced by this call | - = help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:25:21: 25:28}` + = help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:24:21: 24:28}` note: required by a bound in `call_async_once` - --> $DIR/iter-macro-not-async-closure-simplified.rs:22:28 + --> $DIR/iter-macro-not-async-closure-simplified.rs:21:28 | LL | ...pl AsyncFnOnce()) {} | ^^^^^^^^^^^^^ required by this bound in `call_async_once` diff --git a/tests/ui/iterators/iter-macro-not-async-closure-simplified.next.stderr b/tests/ui/iterators/iter-macro-not-async-closure-simplified.next.stderr new file mode 100644 index 0000000000000..93086b18009fa --- /dev/null +++ b/tests/ui/iterators/iter-macro-not-async-closure-simplified.next.stderr @@ -0,0 +1,18 @@ +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:24:21: 24:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure-simplified.rs:30:21 + | +LL | call_async_once(f); + | --------------- ^ unsatisfied trait bound + | | + | required by a bound introduced by this call + | + = help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:24:21: 24:28}` +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure-simplified.rs:21:28 + | +LL | fn call_async_once(_: impl AsyncFnOnce()) {} + | ^^^^^^^^^^^^^ required by this bound in `call_async_once` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/iterators/iter-macro-not-async-closure-simplified.rs b/tests/ui/iterators/iter-macro-not-async-closure-simplified.rs index e8c31f0eed879..d0782474f09c2 100644 --- a/tests/ui/iterators/iter-macro-not-async-closure-simplified.rs +++ b/tests/ui/iterators/iter-macro-not-async-closure-simplified.rs @@ -12,8 +12,7 @@ //@[narrow] compile-flags: --diagnostic-width=20 //@[wide] compile-flags: --diagnostic-width=300 //@[next] compile-flags: -Znext-solver -//@[next] known-bug: trait-system-refactor-initiative#302 -//@[next] check-pass +//@check-fail #![feature(yield_expr, iter_macro)] @@ -29,5 +28,5 @@ fn main() { }}; call_async_once(f); - //[narrow,wide]~^ ERROR AsyncFnOnce()` is not satisfied + //~^ ERROR AsyncFnOnce()` is not satisfied } diff --git a/tests/ui/iterators/iter-macro-not-async-closure-simplified.wide.stderr b/tests/ui/iterators/iter-macro-not-async-closure-simplified.wide.stderr index 60a94e070eaba..6a2e8a115f23e 100644 --- a/tests/ui/iterators/iter-macro-not-async-closure-simplified.wide.stderr +++ b/tests/ui/iterators/iter-macro-not-async-closure-simplified.wide.stderr @@ -1,13 +1,13 @@ -error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:25:21: 25:28}: AsyncFnOnce()` is not satisfied - --> $DIR/iter-macro-not-async-closure-simplified.rs:31:21 +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:24:21: 24:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure-simplified.rs:30:21 | LL | call_async_once(f); - | --------------- ^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:25:21: 25:28}` + | --------------- ^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:24:21: 24:28}` | | | required by a bound introduced by this call | note: required by a bound in `call_async_once` - --> $DIR/iter-macro-not-async-closure-simplified.rs:22:28 + --> $DIR/iter-macro-not-async-closure-simplified.rs:21:28 | LL | fn call_async_once(_: impl AsyncFnOnce()) {} | ^^^^^^^^^^^^^ required by this bound in `call_async_once` 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..606079a750fca 100644 --- a/tests/ui/iterators/iter-macro-not-async-closure.current.stderr +++ b/tests/ui/iterators/iter-macro-not-async-closure.current.stderr @@ -1,73 +1,73 @@ -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:34 +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:30:34 | 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}` + | --------------- ^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}` | | | required by a bound introduced by this call | note: required by a bound in `call_async_once` - --> $DIR/iter-macro-not-async-closure.rs:20:34 + --> $DIR/iter-macro-not-async-closure.rs:19: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:18 +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:30: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}` + | ^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}` | note: required by a bound in `call_async_once` - --> $DIR/iter-macro-not-async-closure.rs:20:34 + --> $DIR/iter-macro-not-async-closure.rs:19: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 +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:30: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}` + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}` | note: required by a bound in `call_async_once` - --> $DIR/iter-macro-not-async-closure.rs:20:34 + --> $DIR/iter-macro-not-async-closure.rs:19: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 +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:30: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}` + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}` | note: required by a bound in `call_async_once` - --> $DIR/iter-macro-not-async-closure.rs:20:34 + --> $DIR/iter-macro-not-async-closure.rs:19: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 +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:30: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}` + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}` | note: required by a bound in `call_async_once` - --> $DIR/iter-macro-not-async-closure.rs:20:34 + --> $DIR/iter-macro-not-async-closure.rs:19: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:37:5 +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:36: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}` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}` | note: required by a bound in `call_async_once` - --> $DIR/iter-macro-not-async-closure.rs:20:34 + --> $DIR/iter-macro-not-async-closure.rs:19:34 | LL | async fn call_async_once(f: impl AsyncFnOnce()) { | ^^^^^^^^^^^^^ required by this bound in `call_async_once` diff --git a/tests/ui/iterators/iter-macro-not-async-closure.next.stderr b/tests/ui/iterators/iter-macro-not-async-closure.next.stderr new file mode 100644 index 0000000000000..99c391a22140a --- /dev/null +++ b/tests/ui/iterators/iter-macro-not-async-closure.next.stderr @@ -0,0 +1,101 @@ +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:30:34 + | +LL | let x = pin!(call_async_once(f)); + | --------------- ^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:24:21: 24:28}` + | | + | required by a bound introduced by this call + | +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:19: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:24:21: 24:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:30: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:24:21: 24:28}` + | +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:19: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:24:21: 24:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:30: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:24:21: 24:28}` + | +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:19: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:24:21: 24:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:30: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:24:21: 24:28}` + | +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:19: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:24:21: 24:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:30: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:24:21: 24:28}` + | +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:19: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:24:21: 24:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:30: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:24:21: 24:28}` + | +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:19: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:24:21: 24:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:36: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:24:21: 24:28}` + | +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:19: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:24:21: 24:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:36:7 + | +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:24:21: 24:28}` + | +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:19:34 + | +LL | async fn call_async_once(f: impl AsyncFnOnce()) { + | ^^^^^^^^^^^^^ required by this bound in `call_async_once` + +error: aborting due to 8 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..690a65b3fa69c 100644 --- a/tests/ui/iterators/iter-macro-not-async-closure.rs +++ b/tests/ui/iterators/iter-macro-not-async-closure.rs @@ -1,8 +1,7 @@ //@ revisions: current next //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver -//@[next] known-bug: trait-system-refactor-initiative#302 -//@[next] check-pass +//@check-fail // This test ensures iterators created with the `iter!` macro are not // accidentally async closures. @@ -28,12 +27,12 @@ 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 - x.poll(&mut Context::from_waker(Waker::noop())); - //[current]~^ ERROR AsyncFnOnce()` is not satisfied + let x = pin!(call_async_once(f)); //[next]~ ERROR AsyncFnOnce()` is not satisfied + //~^ ERROR AsyncFnOnce()` is not satisfied + //~^^ ERROR AsyncFnOnce()` is not satisfied + //~^^^ ERROR AsyncFnOnce()` is not satisfied + //~^^^^ ERROR AsyncFnOnce()` is not satisfied + //~^^^^^ ERROR AsyncFnOnce()` is not satisfied + x.poll(&mut Context::from_waker(Waker::noop())); //[next]~ ERROR AsyncFnOnce()` is not satisfied + //~^ ERROR AsyncFnOnce()` is not satisfied } 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/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/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/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/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/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