diff --git a/compiler/rustc_abi/src/canon_abi.rs b/compiler/rustc_abi/src/canon_abi.rs new file mode 100644 index 0000000000000..2cf7648a859ea --- /dev/null +++ b/compiler/rustc_abi/src/canon_abi.rs @@ -0,0 +1,136 @@ +use std::fmt; + +#[cfg(feature = "nightly")] +use rustc_macros::HashStable_Generic; + +use crate::ExternAbi; + +/// Calling convention to determine codegen +/// +/// CanonAbi erases certain distinctions ExternAbi preserves, but remains target-dependent. +/// There are still both target-specific variants and aliasing variants, though much fewer. +/// The reason for this step is the frontend may wish to show an ExternAbi but implement that ABI +/// using a different ABI than the string per se, or describe irrelevant differences, e.g. +/// - extern "system" +/// - extern "cdecl" +/// - extern "C-unwind" +/// In that sense, this erases mere syntactic distinctions to create a canonical *directive*, +/// rather than picking the "actual" ABI. +#[derive(Copy, Clone, Debug)] +#[derive(PartialOrd, Ord, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "nightly", derive(HashStable_Generic))] +pub enum CanonAbi { + // NOTE: the use of nested variants for some ABIs is for many targets they don't matter, + // and this pushes the complexity of their reasoning to target-specific code, + // allowing a `match` to easily exhaustively ignore these subcategories of variants. + // Otherwise it is very tempting to avoid matching exhaustively! + C, + Rust, + RustCold, + + /// ABIs relevant to 32-bit Arm targets + Arm(ArmCall), + /// ABI relevant to GPUs: the entry point for a GPU kernel + GpuKernel, + + /// ABIs relevant to bare-metal interrupt targets + // FIXME(workingjubilee): a particular reason for this nesting is we might not need these? + // interrupt ABIs should have the same properties: + // - uncallable by Rust calls, as LLVM rejects it in most cases + // - uses a preserve-all-registers *callee* convention + // - should always return `-> !` (effectively... it can't use normal `ret`) + // what differs between targets is + // - allowed arguments: x86 differs slightly, having 2-3 arguments which are handled magically + // - may need special prologues/epilogues for some interrupts, without affecting "call ABI" + Interrupt(InterruptKind), + + /// ABIs relevant to Windows or x86 targets + X86(X86Call), +} + +impl fmt::Display for CanonAbi { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.to_erased_extern_abi().as_str().fmt(f) + } +} + +impl CanonAbi { + /// convert to the ExternAbi that *shares a string* with this CanonAbi + /// + /// A target-insensitive mapping of CanonAbi to ExternAbi, convenient for "forwarding" impls. + /// Importantly, the set of CanonAbi values is a logical *subset* of ExternAbi values, + /// so this is injective: if you take an ExternAbi to a CanonAbi and back, you have lost data. + const fn to_erased_extern_abi(self) -> ExternAbi { + match self { + CanonAbi::C => ExternAbi::C { unwind: false }, + CanonAbi::Rust => ExternAbi::Rust, + CanonAbi::RustCold => ExternAbi::RustCold, + CanonAbi::Arm(arm_call) => match arm_call { + ArmCall::Aapcs => ExternAbi::Aapcs { unwind: false }, + ArmCall::CCmseNonSecureCall => ExternAbi::CCmseNonSecureCall, + ArmCall::CCmseNonSecureEntry => ExternAbi::CCmseNonSecureEntry, + }, + CanonAbi::GpuKernel => ExternAbi::GpuKernel, + CanonAbi::Interrupt(interrupt_kind) => match interrupt_kind { + InterruptKind::Avr => ExternAbi::AvrInterrupt, + InterruptKind::AvrNonBlocking => ExternAbi::AvrNonBlockingInterrupt, + InterruptKind::Msp430 => ExternAbi::Msp430Interrupt, + InterruptKind::RiscvMachine => ExternAbi::RiscvInterruptM, + InterruptKind::RiscvSupervisor => ExternAbi::RiscvInterruptS, + InterruptKind::X86 => ExternAbi::X86Interrupt, + }, + CanonAbi::X86(x86_call) => match x86_call { + X86Call::Fastcall => ExternAbi::Fastcall { unwind: false }, + X86Call::Stdcall => ExternAbi::Stdcall { unwind: false }, + X86Call::SysV64 => ExternAbi::SysV64 { unwind: false }, + X86Call::Thiscall => ExternAbi::Thiscall { unwind: false }, + X86Call::Vectorcall => ExternAbi::Vectorcall { unwind: false }, + X86Call::Win64 => ExternAbi::Win64 { unwind: false }, + }, + } + } +} + +/// Callee codegen for interrupts +/// +/// This is named differently from the "Call" enums because it is different: +/// these "ABI" differences are not relevant to callers, since there is "no caller". +/// These only affect callee codegen. making their categorization as distinct ABIs a bit peculiar. +#[derive(Copy, Clone, Debug)] +#[derive(PartialOrd, Ord, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "nightly", derive(HashStable_Generic))] +pub enum InterruptKind { + Avr, + AvrNonBlocking, + Msp430, + RiscvMachine, + RiscvSupervisor, + X86, +} + +/// ABIs defined for x86-{32,64} +/// +/// One of SysV64 or Win64 may alias the C ABI, and arguably Win64 is cross-platform now? +#[derive(Clone, Copy, Debug)] +#[derive(PartialOrd, Ord, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "nightly", derive(HashStable_Generic))] +pub enum X86Call { + /// "fastcall" has both GNU and Windows variants + Fastcall, + /// "stdcall" has both GNU and Windows variants + Stdcall, + SysV64, + Thiscall, + Vectorcall, + Win64, +} + +/// ABIs defined for 32-bit Arm +#[derive(Copy, Clone, Debug)] +#[derive(PartialOrd, Ord, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "nightly", derive(HashStable_Generic))] +pub enum ArmCall { + Aapcs, + CCmseNonSecureCall, + CCmseNonSecureEntry, +} diff --git a/compiler/rustc_abi/src/extern_abi.rs b/compiler/rustc_abi/src/extern_abi.rs index 55f4845d21670..c48920e5f1bc4 100644 --- a/compiler/rustc_abi/src/extern_abi.rs +++ b/compiler/rustc_abi/src/extern_abi.rs @@ -7,6 +7,8 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd}; #[cfg(feature = "nightly")] use rustc_macros::{Decodable, Encodable}; +use crate::AbiFromStrErr; + #[cfg(test)] mod tests; @@ -99,11 +101,6 @@ macro_rules! abi_impls { } } -#[derive(Debug)] -pub enum AbiFromStrErr { - Unknown, -} - abi_impls! { ExternAbi = { C { unwind: false } =><= "C", diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index 59b74d2922145..b806d0aba31de 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -55,13 +55,14 @@ use rustc_index::{Idx, IndexSlice, IndexVec}; use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_Generic}; mod callconv; +mod canon_abi; +mod extern_abi; mod layout; #[cfg(test)] mod tests; -mod extern_abi; - pub use callconv::{Heterogeneous, HomogeneousAggregate, Reg, RegKind}; +pub use canon_abi::{ArmCall, CanonAbi, InterruptKind, X86Call}; pub use extern_abi::{ExternAbi, all_names}; #[cfg(feature = "nightly")] pub use layout::{FIRST_VARIANT, FieldIdx, Layout, TyAbiInterface, TyAndLayout, VariantIdx}; @@ -1895,3 +1896,11 @@ pub enum StructKind { /// A univariant, but with a prefix of an arbitrary size & alignment (e.g., enum tag). Prefixed(Size, Align), } + +#[derive(Clone, Debug)] +pub enum AbiFromStrErr { + /// not a known ABI + Unknown, + /// no "-unwind" variant can be used here + NoExplicitUnwind, +} diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 5c122ff0bbc50..c9a8adec31ae8 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -99,8 +99,15 @@ pub struct Path { impl PartialEq for Path { #[inline] - fn eq(&self, symbol: &Symbol) -> bool { - matches!(&self.segments[..], [segment] if segment.ident.name == *symbol) + fn eq(&self, name: &Symbol) -> bool { + if let [segment] = self.segments.as_ref() + && segment.args.is_none() + && segment.ident.name == *name + { + true + } else { + false + } } } @@ -120,17 +127,6 @@ impl Path { Path { segments: thin_vec![PathSegment::from_ident(ident)], span: ident.span, tokens: None } } - pub fn is_ident(&self, name: Symbol) -> bool { - if let [segment] = self.segments.as_ref() - && segment.args.is_none() - && segment.ident.name == name - { - true - } else { - false - } - } - pub fn is_global(&self) -> bool { self.segments.first().is_some_and(|segment| segment.ident.name == kw::PathRoot) } diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 9f3aed9216c2d..537d4a2a6af6a 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -1,4 +1,3 @@ -use std::assert_matches::assert_matches; use std::ops::ControlFlow; use std::sync::Arc; @@ -1199,11 +1198,13 @@ impl<'hir> LoweringContext<'_, 'hir> { let closure_def_id = self.local_def_id(closure_id); let (binder_clause, generic_params) = self.lower_closure_binder(binder); - assert_matches!( - coroutine_kind, - CoroutineKind::Async { .. }, - "only async closures are supported currently" - ); + let coroutine_desugaring = match coroutine_kind { + CoroutineKind::Async { .. } => hir::CoroutineDesugaring::Async, + CoroutineKind::Gen { .. } => hir::CoroutineDesugaring::Gen, + CoroutineKind::AsyncGen { span, .. } => { + span_bug!(span, "only async closures and `iter!` closures are supported currently") + } + }; let body = self.with_new_scopes(fn_decl_span, |this| { let inner_decl = @@ -1247,7 +1248,7 @@ impl<'hir> LoweringContext<'_, 'hir> { // Lower this as a `CoroutineClosure`. That will ensure that HIR typeck // knows that a `FnDecl` output type like `-> &str` actually means // "coroutine that returns &str", rather than directly returning a `&str`. - kind: hir::ClosureKind::CoroutineClosure(hir::CoroutineDesugaring::Async), + kind: hir::ClosureKind::CoroutineClosure(coroutine_desugaring), constness: hir::Constness::NotConst, }); hir::ExprKind::Closure(c) diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 915613a391374..3682d25d34147 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -477,11 +477,12 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) { for span in spans { if (!visitor.features.coroutines() && !span.allows_unstable(sym::coroutines)) && (!visitor.features.gen_blocks() && !span.allows_unstable(sym::gen_blocks)) + && (!visitor.features.yield_expr() && !span.allows_unstable(sym::yield_expr)) { #[allow(rustc::untranslatable_diagnostic)] - // Don't know which of the two features to include in the - // error message, so I am arbitrarily picking one. - feature_err(&visitor.sess, sym::coroutines, *span, "yield syntax is experimental") + // Emit yield_expr as the error, since that will be sufficient. You can think of it + // as coroutines and gen_blocks imply yield_expr. + feature_err(&visitor.sess, sym::yield_expr, *span, "yield syntax is experimental") .emit(); } } diff --git a/compiler/rustc_borrowck/src/type_check/input_output.rs b/compiler/rustc_borrowck/src/type_check/input_output.rs index c6b29fe36fd9c..0c46e0c0c2204 100644 --- a/compiler/rustc_borrowck/src/type_check/input_output.rs +++ b/compiler/rustc_borrowck/src/type_check/input_output.rs @@ -52,7 +52,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { assert_matches!( self.tcx().coroutine_kind(self.tcx().coroutine_for_closure(mir_def_id)), Some(hir::CoroutineKind::Desugared( - hir::CoroutineDesugaring::Async, + hir::CoroutineDesugaring::Async | hir::CoroutineDesugaring::Gen, hir::CoroutineSource::Closure )), "this needs to be modified if we're lowering non-async closures" diff --git a/compiler/rustc_builtin_macros/src/iter.rs b/compiler/rustc_builtin_macros/src/iter.rs new file mode 100644 index 0000000000000..7ad83903a1be7 --- /dev/null +++ b/compiler/rustc_builtin_macros/src/iter.rs @@ -0,0 +1,53 @@ +use rustc_ast::ptr::P; +use rustc_ast::tokenstream::TokenStream; +use rustc_ast::{CoroutineKind, DUMMY_NODE_ID, Expr, ast, token}; +use rustc_errors::PResult; +use rustc_expand::base::{self, DummyResult, ExpandResult, ExtCtxt, MacroExpanderResult}; +use rustc_span::Span; + +pub(crate) fn expand<'cx>( + cx: &'cx mut ExtCtxt<'_>, + sp: Span, + tts: TokenStream, +) -> MacroExpanderResult<'cx> { + let closure = match parse_closure(cx, sp, tts) { + Ok(parsed) => parsed, + Err(err) => { + return ExpandResult::Ready(DummyResult::any(sp, err.emit())); + } + }; + + ExpandResult::Ready(base::MacEager::expr(closure)) +} + +fn parse_closure<'a>( + cx: &mut ExtCtxt<'a>, + span: Span, + stream: TokenStream, +) -> PResult<'a, P> { + let mut closure_parser = cx.new_parser_from_tts(stream); + + let coroutine_kind = Some(CoroutineKind::Gen { + span, + closure_id: DUMMY_NODE_ID, + return_impl_trait_id: DUMMY_NODE_ID, + }); + + let mut closure = closure_parser.parse_expr()?; + match &mut closure.kind { + ast::ExprKind::Closure(c) => { + if let Some(kind) = c.coroutine_kind { + cx.dcx().span_err(kind.span(), "only plain closures allowed in `iter!`"); + } + c.coroutine_kind = coroutine_kind; + if closure_parser.token != token::Eof { + closure_parser.unexpected()?; + } + Ok(closure) + } + _ => { + cx.dcx().span_err(closure.span, "`iter!` body must be a closure"); + Err(closure_parser.unexpected().unwrap_err()) + } + } +} diff --git a/compiler/rustc_builtin_macros/src/lib.rs b/compiler/rustc_builtin_macros/src/lib.rs index 667d90429f287..aa52c3bd28157 100644 --- a/compiler/rustc_builtin_macros/src/lib.rs +++ b/compiler/rustc_builtin_macros/src/lib.rs @@ -47,6 +47,7 @@ mod errors; mod format; mod format_foreign; mod global_allocator; +mod iter; mod log_syntax; mod pattern_type; mod source_util; @@ -95,6 +96,7 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) { include: source_util::expand_include, include_bytes: source_util::expand_include_bytes, include_str: source_util::expand_include_str, + iter: iter::expand, line: source_util::expand_line, log_syntax: log_syntax::expand_log_syntax, module_path: source_util::expand_mod, diff --git a/compiler/rustc_codegen_cranelift/src/abi/mod.rs b/compiler/rustc_codegen_cranelift/src/abi/mod.rs index 5f7bf3821d77d..fe5b220117f3c 100644 --- a/compiler/rustc_codegen_cranelift/src/abi/mod.rs +++ b/compiler/rustc_codegen_cranelift/src/abi/mod.rs @@ -10,7 +10,7 @@ use std::mem; use cranelift_codegen::ir::{ArgumentPurpose, SigRef}; use cranelift_codegen::isa::CallConv; use cranelift_module::ModuleError; -use rustc_abi::ExternAbi; +use rustc_abi::{CanonAbi, ExternAbi, X86Call}; use rustc_codegen_ssa::base::is_call_from_compiler_builtins_to_upstream_monomorphization; use rustc_codegen_ssa::errors::CompilerBuiltinsCannotCall; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; @@ -19,7 +19,7 @@ use rustc_middle::ty::layout::FnAbiOf; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_session::Session; use rustc_span::source_map::Spanned; -use rustc_target::callconv::{Conv, FnAbi, PassMode}; +use rustc_target::callconv::{FnAbi, PassMode}; use smallvec::SmallVec; use self::pass_mode::*; @@ -42,32 +42,27 @@ fn clif_sig_from_fn_abi<'tcx>( Signature { params, returns, call_conv } } -pub(crate) fn conv_to_call_conv(sess: &Session, c: Conv, default_call_conv: CallConv) -> CallConv { +pub(crate) fn conv_to_call_conv( + sess: &Session, + c: CanonAbi, + default_call_conv: CallConv, +) -> CallConv { match c { - Conv::Rust | Conv::C => default_call_conv, - Conv::Cold | Conv::PreserveMost | Conv::PreserveAll => CallConv::Cold, - Conv::X86_64SysV => CallConv::SystemV, - Conv::X86_64Win64 => CallConv::WindowsFastcall, - - // Should already get a back compat warning - Conv::X86Fastcall | Conv::X86Stdcall | Conv::X86ThisCall | Conv::X86VectorCall => { - default_call_conv - } - - Conv::X86Intr | Conv::RiscvInterrupt { .. } => { - sess.dcx().fatal(format!("interrupt call conv {c:?} not yet implemented")) + CanonAbi::Rust | CanonAbi::C => default_call_conv, + CanonAbi::RustCold => CallConv::Cold, + + CanonAbi::X86(x86_call) => match x86_call { + X86Call::SysV64 => CallConv::SystemV, + X86Call::Win64 => CallConv::WindowsFastcall, + // Should already get a back compat warning + _ => default_call_conv, + }, + + CanonAbi::Interrupt(_) | CanonAbi::Arm(_) => { + sess.dcx().fatal("call conv {c:?} is not yet implemented") } - - Conv::ArmAapcs => sess.dcx().fatal("aapcs call conv not yet implemented"), - Conv::CCmseNonSecureCall => { - sess.dcx().fatal("C-cmse-nonsecure-call call conv is not yet implemented"); - } - Conv::CCmseNonSecureEntry => { - sess.dcx().fatal("C-cmse-nonsecure-entry call conv is not yet implemented"); - } - - Conv::Msp430Intr | Conv::GpuKernel | Conv::AvrInterrupt | Conv::AvrNonBlockingInterrupt => { - unreachable!("tried to use {c:?} call conv which only exists on an unsupported target"); + CanonAbi::GpuKernel => { + unreachable!("tried to use {c:?} call conv which only exists on an unsupported target") } } } @@ -610,7 +605,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( target: CallTarget, call_args: &mut Vec, ) { - if fn_abi.conv != Conv::C { + if fn_abi.conv != CanonAbi::C { fx.tcx.dcx().span_fatal( source_info.span, format!("Variadic call for non-C abi {:?}", fn_abi.conv), diff --git a/compiler/rustc_codegen_gcc/src/abi.rs b/compiler/rustc_codegen_gcc/src/abi.rs index 0c499ba623794..3d0c258f576d0 100644 --- a/compiler/rustc_codegen_gcc/src/abi.rs +++ b/compiler/rustc_codegen_gcc/src/abi.rs @@ -1,7 +1,7 @@ #[cfg(feature = "master")] use gccjit::FnAttribute; use gccjit::{ToLValue, ToRValue, Type}; -use rustc_abi::{Reg, RegKind}; +use rustc_abi::{ArmCall, CanonAbi, InterruptKind, Reg, RegKind, X86Call}; use rustc_codegen_ssa::traits::{AbiBuilderMethods, BaseTypeCodegenMethods}; use rustc_data_structures::fx::FxHashSet; use rustc_middle::bug; @@ -10,8 +10,6 @@ use rustc_middle::ty::layout::LayoutOf; #[cfg(feature = "master")] use rustc_session::config; use rustc_target::callconv::{ArgAttributes, CastTarget, FnAbi, PassMode}; -#[cfg(feature = "master")] -use rustc_target::callconv::{Conv, RiscvInterruptKind}; use crate::builder::Builder; use crate::context::CodegenCx; @@ -238,29 +236,16 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { } #[cfg(feature = "master")] -pub fn conv_to_fn_attribute<'gcc>(conv: Conv, arch: &str) -> Option> { +pub fn conv_to_fn_attribute<'gcc>(conv: CanonAbi, arch: &str) -> Option> { let attribute = match conv { - Conv::C | Conv::Rust => return None, - Conv::CCmseNonSecureCall => { - if arch == "arm" { - FnAttribute::ArmCmseNonsecureCall - } else { - return None; - } - } - Conv::CCmseNonSecureEntry => { - if arch == "arm" { - FnAttribute::ArmCmseNonsecureEntry - } else { - return None; - } - } - Conv::Cold => FnAttribute::Cold, - // NOTE: the preserve attributes are not yet implemented in GCC: - // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110899 - Conv::PreserveMost => return None, - Conv::PreserveAll => return None, - Conv::GpuKernel => { + CanonAbi::C | CanonAbi::Rust => return None, + CanonAbi::Arm(arm_call) => match arm_call { + ArmCall::CCmseNonSecureCall => FnAttribute::ArmCmseNonsecureCall, + ArmCall::CCmseNonSecureEntry => FnAttribute::ArmCmseNonsecureEntry, + ArmCall::Aapcs => FnAttribute::ArmPcs("aapcs"), + }, + CanonAbi::RustCold => FnAttribute::Cold, + CanonAbi::GpuKernel => { if arch == "amdgpu" { FnAttribute::GcnAmdGpuHsaKernel } else if arch == "nvptx64" { @@ -270,26 +255,24 @@ pub fn conv_to_fn_attribute<'gcc>(conv: Conv, arch: &str) -> Option FnAttribute::AvrSignal, - Conv::AvrNonBlockingInterrupt => FnAttribute::AvrInterrupt, - Conv::ArmAapcs => FnAttribute::ArmPcs("aapcs"), - Conv::Msp430Intr => FnAttribute::Msp430Interrupt, - Conv::RiscvInterrupt { kind } => { - let kind = match kind { - RiscvInterruptKind::Machine => "machine", - RiscvInterruptKind::Supervisor => "supervisor", - }; - FnAttribute::RiscvInterrupt(kind) - } - Conv::X86Fastcall => FnAttribute::X86FastCall, - Conv::X86Intr => FnAttribute::X86Interrupt, - Conv::X86Stdcall => FnAttribute::X86Stdcall, - Conv::X86ThisCall => FnAttribute::X86ThisCall, - // NOTE: the vectorcall calling convention is not yet implemented in GCC: - // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89485 - Conv::X86VectorCall => return None, - Conv::X86_64SysV => FnAttribute::X86SysvAbi, - Conv::X86_64Win64 => FnAttribute::X86MsAbi, + CanonAbi::Interrupt(interrupt_kind) => match interrupt_kind { + InterruptKind::Avr => FnAttribute::AvrSignal, + InterruptKind::AvrNonBlocking => FnAttribute::AvrInterrupt, + InterruptKind::Msp430 => FnAttribute::Msp430Interrupt, + InterruptKind::RiscvMachine => FnAttribute::RiscvInterrupt("machine"), + InterruptKind::RiscvSupervisor => FnAttribute::RiscvInterrupt("supervisor"), + InterruptKind::X86 => FnAttribute::X86Interrupt, + }, + CanonAbi::X86(x86_call) => match x86_call { + X86Call::Fastcall => FnAttribute::X86FastCall, + X86Call::Stdcall => FnAttribute::X86Stdcall, + X86Call::Thiscall => FnAttribute::X86ThisCall, + // // NOTE: the vectorcall calling convention is not yet implemented in GCC: + // // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89485 + X86Call::Vectorcall => return None, + X86Call::SysV64 => FnAttribute::X86SysvAbi, + X86Call::Win64 => FnAttribute::X86MsAbi, + }, }; Some(attribute) } diff --git a/compiler/rustc_codegen_gcc/src/int.rs b/compiler/rustc_codegen_gcc/src/int.rs index 9b5b0fde6e2f1..eb4acd8ade94d 100644 --- a/compiler/rustc_codegen_gcc/src/int.rs +++ b/compiler/rustc_codegen_gcc/src/int.rs @@ -3,11 +3,11 @@ //! 128-bit integers on 32-bit platforms and thus require to be handled manually. use gccjit::{BinaryOp, ComparisonOp, FunctionType, Location, RValue, ToRValue, Type, UnaryOp}; -use rustc_abi::{Endian, ExternAbi}; +use rustc_abi::{CanonAbi, Endian, ExternAbi}; use rustc_codegen_ssa::common::{IntPredicate, TypeKind}; use rustc_codegen_ssa::traits::{BackendTypes, BaseTypeCodegenMethods, BuilderMethods, OverflowOp}; use rustc_middle::ty::{self, Ty}; -use rustc_target::callconv::{ArgAbi, ArgAttributes, Conv, FnAbi, PassMode}; +use rustc_target::callconv::{ArgAbi, ArgAttributes, FnAbi, PassMode}; use crate::builder::{Builder, ToGccComp}; use crate::common::{SignType, TypeReflection}; @@ -397,7 +397,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { ret: arg_abi, c_variadic: false, fixed_count: 3, - conv: Conv::C, + conv: CanonAbi::C, can_unwind: false, }; fn_abi.adjust_for_foreign_abi(self.cx, ExternAbi::C { unwind: false }); diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs index c87e70864e5ad..119cd634f9827 100644 --- a/compiler/rustc_codegen_llvm/src/abi.rs +++ b/compiler/rustc_codegen_llvm/src/abi.rs @@ -2,7 +2,10 @@ use std::borrow::Borrow; use std::cmp; use libc::c_uint; -use rustc_abi::{BackendRepr, HasDataLayout, Primitive, Reg, RegKind, Size}; +use rustc_abi::{ + ArmCall, BackendRepr, CanonAbi, HasDataLayout, InterruptKind, Primitive, Reg, RegKind, Size, + X86Call, +}; use rustc_codegen_ssa::MemFlags; use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue}; use rustc_codegen_ssa::mir::place::{PlaceRef, PlaceValue}; @@ -12,7 +15,7 @@ use rustc_middle::ty::layout::LayoutOf; use rustc_middle::{bug, ty}; use rustc_session::config; use rustc_target::callconv::{ - ArgAbi, ArgAttribute, ArgAttributes, ArgExtension, CastTarget, Conv, FnAbi, PassMode, + ArgAbi, ArgAttribute, ArgAttributes, ArgExtension, CastTarget, FnAbi, PassMode, }; use rustc_target::spec::SanitizerSet; use smallvec::SmallVec; @@ -409,11 +412,17 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { if !self.can_unwind { func_attrs.push(llvm::AttributeKind::NoUnwind.create_attr(cx.llcx)); } - if let Conv::RiscvInterrupt { kind } = self.conv { - func_attrs.push(llvm::CreateAttrStringValue(cx.llcx, "interrupt", kind.as_str())); - } - if let Conv::CCmseNonSecureEntry = self.conv { - func_attrs.push(llvm::CreateAttrString(cx.llcx, "cmse_nonsecure_entry")) + match self.conv { + CanonAbi::Interrupt(InterruptKind::RiscvMachine) => { + func_attrs.push(llvm::CreateAttrStringValue(cx.llcx, "interrupt", "machine")) + } + CanonAbi::Interrupt(InterruptKind::RiscvSupervisor) => { + func_attrs.push(llvm::CreateAttrStringValue(cx.llcx, "interrupt", "supervisor")) + } + CanonAbi::Arm(ArmCall::CCmseNonSecureEntry) => { + func_attrs.push(llvm::CreateAttrString(cx.llcx, "cmse_nonsecure_entry")) + } + _ => (), } attributes::apply_to_llfn(llfn, llvm::AttributePlace::Function, &{ func_attrs }); @@ -600,7 +609,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { llvm::SetInstructionCallConv(callsite, cconv); } - if self.conv == Conv::CCmseNonSecureCall { + if self.conv == CanonAbi::Arm(ArmCall::CCmseNonSecureCall) { // This will probably get ignored on all targets but those supporting the TrustZone-M // extension (thumbv8m targets). let cmse_nonsecure_call = llvm::CreateAttrString(bx.cx.llcx, "cmse_nonsecure_call"); @@ -636,17 +645,11 @@ impl AbiBuilderMethods for Builder<'_, '_, '_> { } impl llvm::CallConv { - pub(crate) fn from_conv(conv: Conv, arch: &str) -> Self { + pub(crate) fn from_conv(conv: CanonAbi, arch: &str) -> Self { match conv { - Conv::C - | Conv::Rust - | Conv::CCmseNonSecureCall - | Conv::CCmseNonSecureEntry - | Conv::RiscvInterrupt { .. } => llvm::CCallConv, - Conv::Cold => llvm::ColdCallConv, - Conv::PreserveMost => llvm::PreserveMost, - Conv::PreserveAll => llvm::PreserveAll, - Conv::GpuKernel => { + CanonAbi::C | CanonAbi::Rust => llvm::CCallConv, + CanonAbi::RustCold => llvm::PreserveMost, + CanonAbi::GpuKernel => { if arch == "amdgpu" { llvm::AmdgpuKernel } else if arch == "nvptx64" { @@ -655,17 +658,25 @@ impl llvm::CallConv { panic!("Architecture {arch} does not support GpuKernel calling convention"); } } - Conv::AvrInterrupt => llvm::AvrInterrupt, - Conv::AvrNonBlockingInterrupt => llvm::AvrNonBlockingInterrupt, - Conv::ArmAapcs => llvm::ArmAapcsCallConv, - Conv::Msp430Intr => llvm::Msp430Intr, - Conv::X86Fastcall => llvm::X86FastcallCallConv, - Conv::X86Intr => llvm::X86_Intr, - Conv::X86Stdcall => llvm::X86StdcallCallConv, - Conv::X86ThisCall => llvm::X86_ThisCall, - Conv::X86VectorCall => llvm::X86_VectorCall, - Conv::X86_64SysV => llvm::X86_64_SysV, - Conv::X86_64Win64 => llvm::X86_64_Win64, + CanonAbi::Interrupt(interrupt_kind) => match interrupt_kind { + InterruptKind::Avr => llvm::AvrInterrupt, + InterruptKind::AvrNonBlocking => llvm::AvrNonBlockingInterrupt, + InterruptKind::Msp430 => llvm::Msp430Intr, + InterruptKind::RiscvMachine | InterruptKind::RiscvSupervisor => llvm::CCallConv, + InterruptKind::X86 => llvm::X86_Intr, + }, + CanonAbi::Arm(arm_call) => match arm_call { + ArmCall::Aapcs => llvm::ArmAapcsCallConv, + ArmCall::CCmseNonSecureCall | ArmCall::CCmseNonSecureEntry => llvm::CCallConv, + }, + CanonAbi::X86(x86_call) => match x86_call { + X86Call::Fastcall => llvm::X86FastcallCallConv, + X86Call::Stdcall => llvm::X86StdcallCallConv, + X86Call::SysV64 => llvm::X86_64_SysV, + X86Call::Thiscall => llvm::X86_ThisCall, + X86Call::Vectorcall => llvm::X86_VectorCall, + X86Call::Win64 => llvm::X86_64_Win64, + }, } } } diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index e26f999773dc7..92b9b6e132e74 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 rustc_abi::{CanonAbi, X86Call}; use rustc_ast::expand::allocator::{ALLOCATOR_METHODS, NO_ALLOC_SHIM_IS_UNSTABLE, global_fn_name}; use rustc_data_structures::unord::UnordMap; use rustc_hir::def::DefKind; @@ -14,7 +15,6 @@ use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, Instance, SymbolNam use rustc_middle::util::Providers; use rustc_session::config::{CrateType, OomStrategy}; use rustc_symbol_mangling::mangle_internal_symbol; -use rustc_target::callconv::Conv; use rustc_target::spec::{SanitizerSet, TlsModel}; use tracing::debug; @@ -652,7 +652,7 @@ pub(crate) fn symbol_name_for_instance_in_crate<'tcx>( fn calling_convention_for_symbol<'tcx>( tcx: TyCtxt<'tcx>, symbol: ExportedSymbol<'tcx>, -) -> (Conv, &'tcx [rustc_target::callconv::ArgAbi<'tcx, Ty<'tcx>>]) { +) -> (CanonAbi, &'tcx [rustc_target::callconv::ArgAbi<'tcx, Ty<'tcx>>]) { let instance = match symbol { ExportedSymbol::NonGeneric(def_id) | ExportedSymbol::Generic(def_id, _) if tcx.is_static(def_id) => @@ -683,7 +683,7 @@ fn calling_convention_for_symbol<'tcx>( }) .map(|fnabi| (fnabi.conv, &fnabi.args[..])) // FIXME(workingjubilee): why don't we know the convention here? - .unwrap_or((Conv::Rust, &[])) + .unwrap_or((CanonAbi::Rust, &[])) } /// This is the symbol name of the given instance as seen by the linker. @@ -717,14 +717,14 @@ pub(crate) fn linking_symbol_name_for_instance_in_crate<'tcx>( _ => return undecorated, }; - let (conv, args) = calling_convention_for_symbol(tcx, symbol); + let (callconv, args) = calling_convention_for_symbol(tcx, symbol); // Decorate symbols with prefixes, suffixes and total number of bytes of arguments. // Reference: https://docs.microsoft.com/en-us/cpp/build/reference/decorated-names?view=msvc-170 - let (prefix, suffix) = match conv { - Conv::X86Fastcall => ("@", "@"), - Conv::X86Stdcall => ("_", "@"), - Conv::X86VectorCall => ("", "@@"), + let (prefix, suffix) = match callconv { + CanonAbi::X86(X86Call::Fastcall) => ("@", "@"), + CanonAbi::X86(X86Call::Stdcall) => ("_", "@"), + CanonAbi::X86(X86Call::Vectorcall) => ("", "@@"), _ => { if let Some(prefix) = prefix { undecorated.insert(0, prefix); @@ -758,9 +758,9 @@ pub(crate) fn extend_exported_symbols<'tcx>( symbol: ExportedSymbol<'tcx>, instantiating_crate: CrateNum, ) { - let (conv, _) = calling_convention_for_symbol(tcx, symbol); + let (callconv, _) = calling_convention_for_symbol(tcx, symbol); - if conv != Conv::GpuKernel || tcx.sess.target.os != "amdhsa" { + if callconv != CanonAbi::GpuKernel || tcx.sess.target.os != "amdhsa" { return; } diff --git a/compiler/rustc_const_eval/messages.ftl b/compiler/rustc_const_eval/messages.ftl index 7d4afc9d3d952..5bce6fb7ab2a4 100644 --- a/compiler/rustc_const_eval/messages.ftl +++ b/compiler/rustc_const_eval/messages.ftl @@ -89,9 +89,9 @@ const_eval_dyn_call_not_a_method = `dyn` call trying to call something that is not a method const_eval_error = {$error_kind -> - [static] could not evaluate static initializer - [const] evaluation of constant value failed - [const_with_path] evaluation of `{$instance}` failed + [static] evaluation of static initializer failed here + [const] evaluation of constant value failed here + [const_with_path] evaluation of `{$instance}` failed here *[other] {""} } @@ -118,7 +118,7 @@ const_eval_frame_note_inner = inside {$where_ -> const_eval_frame_note_last = the failure occurred here const_eval_incompatible_calling_conventions = - calling a function with calling convention {$callee_conv} using calling convention {$caller_conv} + calling a function with calling convention "{$callee_conv}" using calling convention "{$caller_conv}" const_eval_incompatible_return_types = calling a function with return type {$callee_ty} passing return place of type {$caller_ty} diff --git a/compiler/rustc_const_eval/src/check_consts/check.rs b/compiler/rustc_const_eval/src/check_consts/check.rs index b67a3ce03a945..6167f8cd4b511 100644 --- a/compiler/rustc_const_eval/src/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/check_consts/check.rs @@ -589,12 +589,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { Rvalue::Aggregate(kind, ..) => { if let AggregateKind::Coroutine(def_id, ..) = kind.as_ref() - && let Some( - coroutine_kind @ hir::CoroutineKind::Desugared( - hir::CoroutineDesugaring::Async, - _, - ), - ) = self.tcx.coroutine_kind(def_id) + && let Some(coroutine_kind) = self.tcx.coroutine_kind(def_id) { self.check_op(ops::Coroutine(coroutine_kind)); } diff --git a/compiler/rustc_const_eval/src/check_consts/ops.rs b/compiler/rustc_const_eval/src/check_consts/ops.rs index 177ba56b165e4..d701646719ad9 100644 --- a/compiler/rustc_const_eval/src/check_consts/ops.rs +++ b/compiler/rustc_const_eval/src/check_consts/ops.rs @@ -486,24 +486,25 @@ impl<'tcx> NonConstOp<'tcx> for IntrinsicUnstable { pub(crate) struct Coroutine(pub hir::CoroutineKind); impl<'tcx> NonConstOp<'tcx> for Coroutine { fn status_in_item(&self, _: &ConstCx<'_, 'tcx>) -> Status { - if let hir::CoroutineKind::Desugared( - hir::CoroutineDesugaring::Async, - hir::CoroutineSource::Block, - ) = self.0 - { - Status::Unstable { + match self.0 { + hir::CoroutineKind::Desugared( + hir::CoroutineDesugaring::Async, + hir::CoroutineSource::Block, + ) + // FIXME(coroutines): eventually we want to gate const coroutine coroutines behind a + // different feature. + | hir::CoroutineKind::Coroutine(_) => Status::Unstable { gate: sym::const_async_blocks, gate_already_checked: false, safe_to_expose_on_stable: false, is_function_call: false, - } - } else { - Status::Forbidden + }, + _ => Status::Forbidden, } } fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { - let msg = format!("{:#}s are not allowed in {}s", self.0, ccx.const_kind()); + let msg = format!("{} are not allowed in {}s", self.0.to_plural_string(), ccx.const_kind()); if let Status::Unstable { gate, .. } = self.status_in_item(ccx) { ccx.tcx.sess.create_feature_err(errors::UnallowedOpInConstContext { span, msg }, gate) } else { diff --git a/compiler/rustc_const_eval/src/const_eval/error.rs b/compiler/rustc_const_eval/src/const_eval/error.rs index ffb32fa41eb53..08fc03d9c4647 100644 --- a/compiler/rustc_const_eval/src/const_eval/error.rs +++ b/compiler/rustc_const_eval/src/const_eval/error.rs @@ -1,6 +1,6 @@ use std::mem; -use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, Diagnostic, IntoDiagArg}; +use rustc_errors::{Diag, DiagArgName, DiagArgValue, DiagMessage, IntoDiagArg}; use rustc_middle::mir::AssertKind; use rustc_middle::mir::interpret::{Provenance, ReportedErrorInfo}; use rustc_middle::query::TyCtxtAt; @@ -131,10 +131,10 @@ pub fn get_span_and_frames<'tcx>( /// Create a diagnostic for a const eval error. /// -/// This will use the `mk` function for creating the error which will get passed labels according to -/// the `InterpError` and the span and a stacktrace of current execution according to -/// `get_span_and_frames`. -pub(super) fn report<'tcx, C, F, E>( +/// This will use the `mk` function for adding more information to the error. +/// You can use it to add a stacktrace of current execution according to +/// `get_span_and_frames` or just give context on where the const eval error happened. +pub(super) fn report<'tcx, C, F>( tcx: TyCtxt<'tcx>, error: InterpErrorKind<'tcx>, span: Span, @@ -143,8 +143,7 @@ pub(super) fn report<'tcx, C, F, E>( ) -> ErrorHandled where C: FnOnce() -> (Span, Vec), - F: FnOnce(Span, Vec) -> E, - E: Diagnostic<'tcx>, + F: FnOnce(&mut Diag<'_>, Span, Vec), { // Special handling for certain errors match error { @@ -163,8 +162,7 @@ where _ => { let (our_span, frames) = get_span_and_frames(); let span = span.substitute_dummy(our_span); - let err = mk(span, frames); - let mut err = tcx.dcx().create_err(err); + let mut err = tcx.dcx().struct_span_err(our_span, error.diagnostic_message()); // We allow invalid programs in infallible promoteds since invalid layouts can occur // anyway (e.g. due to size overflow). And we allow OOM as that can happen any time. let allowed_in_infallible = matches!( @@ -172,11 +170,9 @@ where InterpErrorKind::ResourceExhaustion(_) | InterpErrorKind::InvalidProgram(_) ); - let msg = error.diagnostic_message(); error.add_args(&mut err); - // Use *our* span to label the interp error - err.span_label(our_span, msg); + mk(&mut err, span, frames); let g = err.emit(); let reported = if allowed_in_infallible { ReportedErrorInfo::allowed_in_infallible(g) 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 a79ba6a634272..01625b91353b7 100644 --- a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs @@ -2,6 +2,7 @@ use std::sync::atomic::Ordering::Relaxed; use either::{Left, Right}; use rustc_abi::{self as abi, BackendRepr}; +use rustc_errors::E0080; use rustc_hir::def::DefKind; use rustc_middle::mir::interpret::{AllocId, ErrorHandled, InterpErrorInfo, ReportedErrorInfo}; use rustc_middle::mir::{self, ConstAlloc, ConstValue}; @@ -290,12 +291,18 @@ pub fn eval_to_const_value_raw_provider<'tcx>( |error| { let span = tcx.def_span(def_id); + // FIXME(oli-obk): why don't we have any tests for this code path? super::report( tcx, error.into_kind(), span, || (span, vec![]), - |span, _| errors::NullaryIntrinsicError { span }, + |diag, span, _| { + diag.span_label( + span, + crate::fluent_generated::const_eval_nullary_intrinsic_fail, + ); + }, ) }, ); @@ -443,11 +450,15 @@ fn report_eval_error<'tcx>( error, DUMMY_SP, || super::get_span_and_frames(ecx.tcx, ecx.stack()), - |span, frames| errors::ConstEvalError { - span, - error_kind: kind, - instance, - frame_notes: frames, + |diag, span, frames| { + // FIXME(oli-obk): figure out how to use structured diagnostics again. + diag.code(E0080); + diag.span_label(span, crate::fluent_generated::const_eval_error); + diag.arg("instance", instance); + diag.arg("error_kind", kind); + for frame in frames { + diag.subdiagnostic(frame); + } }, ) } @@ -477,6 +488,15 @@ fn report_validation_error<'tcx>( error, DUMMY_SP, || crate::const_eval::get_span_and_frames(ecx.tcx, ecx.stack()), - move |span, frames| errors::ValidationFailure { span, ub_note: (), frames, raw_bytes }, + move |diag, span, frames| { + // FIXME(oli-obk): figure out how to use structured diagnostics again. + diag.code(E0080); + diag.span_label(span, crate::fluent_generated::const_eval_validation_failure); + diag.note(crate::fluent_generated::const_eval_validation_failure_note); + for frame in frames { + diag.subdiagnostic(frame); + } + diag.subdiagnostic(raw_bytes); + }, ) } diff --git a/compiler/rustc_const_eval/src/errors.rs b/compiler/rustc_const_eval/src/errors.rs index 7c35e47bbf805..037cbf777e70b 100644 --- a/compiler/rustc_const_eval/src/errors.rs +++ b/compiler/rustc_const_eval/src/errors.rs @@ -439,38 +439,6 @@ pub struct LiveDrop<'tcx> { pub dropped_at: Span, } -#[derive(Diagnostic)] -#[diag(const_eval_error, code = E0080)] -pub struct ConstEvalError { - #[primary_span] - pub span: Span, - /// One of "const", "const_with_path", and "static" - pub error_kind: &'static str, - pub instance: String, - #[subdiagnostic] - pub frame_notes: Vec, -} - -#[derive(Diagnostic)] -#[diag(const_eval_nullary_intrinsic_fail)] -pub struct NullaryIntrinsicError { - #[primary_span] - pub span: Span, -} - -#[derive(Diagnostic)] -#[diag(const_eval_validation_failure, code = E0080)] -pub struct ValidationFailure { - #[primary_span] - pub span: Span, - #[note(const_eval_validation_failure_note)] - pub ub_note: (), - #[subdiagnostic] - pub frames: Vec, - #[subdiagnostic] - pub raw_bytes: RawBytesNote, -} - pub trait ReportErrorExt { /// Returns the diagnostic message for this error. fn diagnostic_message(&self) -> DiagMessage; diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 4f05e1c816c3d..433d5f9882937 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -2061,12 +2061,19 @@ impl CoroutineKind { CoroutineKind::Coroutine(mov) => mov, } } -} -impl CoroutineKind { pub fn is_fn_like(self) -> bool { matches!(self, CoroutineKind::Desugared(_, CoroutineSource::Fn)) } + + pub fn to_plural_string(&self) -> String { + match self { + CoroutineKind::Desugared(d, CoroutineSource::Fn) => format!("{d:#}fn bodies"), + CoroutineKind::Desugared(d, CoroutineSource::Block) => format!("{d:#}blocks"), + CoroutineKind::Desugared(d, CoroutineSource::Closure) => format!("{d:#}closure bodies"), + CoroutineKind::Coroutine(_) => "coroutines".to_string(), + } + } } impl fmt::Display for CoroutineKind { diff --git a/compiler/rustc_hir_typeck/src/closure.rs b/compiler/rustc_hir_typeck/src/closure.rs index b1cb3ef4d7967..cd3746be1d156 100644 --- a/compiler/rustc_hir_typeck/src/closure.rs +++ b/compiler/rustc_hir_typeck/src/closure.rs @@ -204,14 +204,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) } hir::ClosureKind::CoroutineClosure(kind) => { - // async closures always return the type ascribed after the `->` (if present), - // and yield `()`. let (bound_return_ty, bound_yield_ty) = match kind { + hir::CoroutineDesugaring::Gen => { + // `iter!` closures always return unit and yield the `Iterator::Item` type + // that we have to infer. + (tcx.types.unit, self.infcx.next_ty_var(expr_span)) + } hir::CoroutineDesugaring::Async => { + // async closures always return the type ascribed after the `->` (if present), + // and yield `()`. (bound_sig.skip_binder().output(), tcx.types.unit) } - hir::CoroutineDesugaring::Gen | hir::CoroutineDesugaring::AsyncGen => { - todo!("`gen` and `async gen` closures not supported yet") + hir::CoroutineDesugaring::AsyncGen => { + todo!("`async gen` closures not supported yet") } }; // Compute all of the variables that will be used to populate the coroutine. @@ -465,7 +470,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Some(trait_def_id) = trait_def_id { let found_kind = match closure_kind { - hir::ClosureKind::Closure => self.tcx.fn_trait_kind_from_def_id(trait_def_id), + hir::ClosureKind::Closure + // FIXME(iter_macro): Someday we'll probably want iterator closures instead of + // just using Fn* for iterators. + | hir::ClosureKind::CoroutineClosure(hir::CoroutineDesugaring::Gen) => { + self.tcx.fn_trait_kind_from_def_id(trait_def_id) + } hir::ClosureKind::CoroutineClosure(hir::CoroutineDesugaring::Async) => self .tcx .async_fn_trait_kind_from_def_id(trait_def_id) diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 5bc7559d29aa5..f4045eeea4d85 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -60,10 +60,6 @@ pub fn parse<'a>(sess: &'a Session) -> ast::Crate { guar.raise_fatal(); }); - if sess.opts.unstable_opts.input_stats { - input_stats::print_ast_stats(&krate, "PRE EXPANSION AST STATS", "ast-stats-1"); - } - rustc_builtin_macros::cmdline_attrs::inject( &mut krate, &sess.psess, @@ -298,7 +294,7 @@ fn early_lint_checks(tcx: TyCtxt<'_>, (): ()) { let mut lint_buffer = resolver.lint_buffer.steal(); if sess.opts.unstable_opts.input_stats { - input_stats::print_ast_stats(krate, "POST EXPANSION AST STATS", "ast-stats-2"); + input_stats::print_ast_stats(krate, "POST EXPANSION AST STATS", "ast-stats"); } // Needs to go *after* expansion to be able to check the results of macro expansion. diff --git a/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs b/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs index cfeaee0777610..5478e54a60624 100644 --- a/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs +++ b/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs @@ -1,6 +1,6 @@ //! This module ensures that if a function's ABI requires a particular target feature, //! that target feature is enabled both on the callee and all callers. -use rustc_abi::{BackendRepr, RegKind}; +use rustc_abi::{BackendRepr, CanonAbi, RegKind, X86Call}; use rustc_hir::{CRATE_HIR_ID, HirId}; use rustc_middle::mir::{self, Location, traversal}; use rustc_middle::ty::layout::LayoutCx; @@ -8,7 +8,7 @@ use rustc_middle::ty::{self, Instance, InstanceKind, Ty, TyCtxt, TypingEnv}; use rustc_session::lint::builtin::WASM_C_ABI; use rustc_span::def_id::DefId; use rustc_span::{DUMMY_SP, Span, Symbol, sym}; -use rustc_target::callconv::{ArgAbi, Conv, FnAbi, PassMode}; +use rustc_target::callconv::{ArgAbi, FnAbi, PassMode}; use rustc_target::spec::{HasWasmCAbiOpt, WasmCAbi}; use crate::errors; @@ -72,7 +72,7 @@ fn do_check_simd_vector_abi<'tcx>( } } // The `vectorcall` ABI is special in that it requires SSE2 no matter which types are being passed. - if abi.conv == Conv::X86VectorCall && !have_feature(sym::sse2) { + if abi.conv == CanonAbi::X86(X86Call::Vectorcall) && !have_feature(sym::sse2) { let (span, _hir_id) = loc(); tcx.dcx().emit_err(errors::AbiRequiredTargetFeature { span, @@ -128,7 +128,7 @@ fn do_check_wasm_abi<'tcx>( if !(tcx.sess.target.arch == "wasm32" && tcx.sess.target.os == "unknown" && tcx.wasm_c_abi_opt() == WasmCAbi::Legacy { with_lint: true } - && abi.conv == Conv::C) + && abi.conv == CanonAbi::C) { return; } diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 1a44f4af8a629..adfea3641e644 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -834,7 +834,7 @@ impl<'a> Parser<'a> { // guides recovery in case we write `&raw expr`. if borrow_kind == ast::BorrowKind::Ref && mutbl == ast::Mutability::Not - && matches!(&expr.kind, ExprKind::Path(None, p) if p.is_ident(kw::Raw)) + && matches!(&expr.kind, ExprKind::Path(None, p) if *p == kw::Raw) { self.expected_token_types.insert(TokenType::KwMut); self.expected_token_types.insert(TokenType::KwConst); diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index ccc3410674b46..c37cb0881c3f1 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -713,7 +713,7 @@ impl<'a> Parser<'a> { /// Parses the rest of a block expression or function body. /// Precondition: already parsed the '{'. - pub(crate) fn parse_block_tail( + pub fn parse_block_tail( &mut self, lo: Span, s: BlockCheckMode, diff --git a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/mod.rs b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/mod.rs index 562e288afaaf0..82e18ad497b0a 100644 --- a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/mod.rs +++ b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/mod.rs @@ -4,10 +4,11 @@ //! For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler, //! see design document in the tracking issue #89653. +use rustc_abi::CanonAbi; use rustc_data_structures::fx::FxHashMap; use rustc_middle::bug; use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeFoldable, TypeVisitableExt}; -use rustc_target::callconv::{Conv, FnAbi, PassMode}; +use rustc_target::callconv::{FnAbi, PassMode}; use tracing::instrument; mod encode; @@ -45,7 +46,7 @@ pub fn typeid_for_fnabi<'tcx>( let mut encode_ty_options = EncodeTyOptions::from_bits(options.bits()) .unwrap_or_else(|| bug!("typeid_for_fnabi: invalid option(s) `{:?}`", options.bits())); match fn_abi.conv { - Conv::C => { + CanonAbi::C => { encode_ty_options.insert(EncodeTyOptions::GENERALIZE_REPR_C); } _ => { diff --git a/compiler/rustc_smir/src/rustc_smir/convert/abi.rs b/compiler/rustc_smir/src/rustc_smir/convert/abi.rs index 7ccc785a40026..06dfaf079a334 100644 --- a/compiler/rustc_smir/src/rustc_smir/convert/abi.rs +++ b/compiler/rustc_smir/src/rustc_smir/convert/abi.rs @@ -2,8 +2,9 @@ #![allow(rustc::usage_of_qualified_ty)] +use rustc_abi::{ArmCall, CanonAbi, InterruptKind, X86Call}; use rustc_middle::ty; -use rustc_target::callconv::{self, Conv}; +use rustc_target::callconv; use stable_mir::abi::{ AddressSpace, ArgAbi, CallConvention, FieldsShape, FloatLength, FnAbi, IntegerLength, Layout, LayoutShape, PassMode, Primitive, Scalar, TagEncoding, TyAndLayout, ValueAbi, VariantsShape, @@ -69,7 +70,7 @@ impl<'tcx> Stable<'tcx> for callconv::FnAbi<'tcx, ty::Ty<'tcx>> { fn stable(&self, tables: &mut Tables<'_>) -> Self::T { assert!(self.args.len() >= self.fixed_count as usize); - assert!(!self.c_variadic || matches!(self.conv, Conv::C)); + assert!(!self.c_variadic || matches!(self.conv, CanonAbi::C)); FnAbi { args: self.args.as_ref().stable(tables), ret: self.ret.stable(tables), @@ -92,31 +93,37 @@ impl<'tcx> Stable<'tcx> for callconv::ArgAbi<'tcx, ty::Ty<'tcx>> { } } -impl<'tcx> Stable<'tcx> for callconv::Conv { +impl<'tcx> Stable<'tcx> for CanonAbi { type T = CallConvention; fn stable(&self, _tables: &mut Tables<'_>) -> Self::T { match self { - Conv::C => CallConvention::C, - Conv::Rust => CallConvention::Rust, - Conv::Cold => CallConvention::Cold, - Conv::PreserveMost => CallConvention::PreserveMost, - Conv::PreserveAll => CallConvention::PreserveAll, - Conv::ArmAapcs => CallConvention::ArmAapcs, - Conv::CCmseNonSecureCall => CallConvention::CCmseNonSecureCall, - Conv::CCmseNonSecureEntry => CallConvention::CCmseNonSecureEntry, - Conv::Msp430Intr => CallConvention::Msp430Intr, - Conv::X86Fastcall => CallConvention::X86Fastcall, - Conv::X86Intr => CallConvention::X86Intr, - Conv::X86Stdcall => CallConvention::X86Stdcall, - Conv::X86ThisCall => CallConvention::X86ThisCall, - Conv::X86VectorCall => CallConvention::X86VectorCall, - Conv::X86_64SysV => CallConvention::X86_64SysV, - Conv::X86_64Win64 => CallConvention::X86_64Win64, - Conv::GpuKernel => CallConvention::GpuKernel, - Conv::AvrInterrupt => CallConvention::AvrInterrupt, - Conv::AvrNonBlockingInterrupt => CallConvention::AvrNonBlockingInterrupt, - Conv::RiscvInterrupt { .. } => CallConvention::RiscvInterrupt, + CanonAbi::C => CallConvention::C, + CanonAbi::Rust => CallConvention::Rust, + CanonAbi::RustCold => CallConvention::Cold, + CanonAbi::Arm(arm_call) => match arm_call { + ArmCall::Aapcs => CallConvention::ArmAapcs, + ArmCall::CCmseNonSecureCall => CallConvention::CCmseNonSecureCall, + ArmCall::CCmseNonSecureEntry => CallConvention::CCmseNonSecureEntry, + }, + CanonAbi::GpuKernel => CallConvention::GpuKernel, + CanonAbi::Interrupt(interrupt_kind) => match interrupt_kind { + InterruptKind::Avr => CallConvention::AvrInterrupt, + InterruptKind::AvrNonBlocking => CallConvention::AvrNonBlockingInterrupt, + InterruptKind::Msp430 => CallConvention::Msp430Intr, + InterruptKind::RiscvMachine | InterruptKind::RiscvSupervisor => { + CallConvention::RiscvInterrupt + } + InterruptKind::X86 => CallConvention::X86Intr, + }, + CanonAbi::X86(x86_call) => match x86_call { + X86Call::Fastcall => CallConvention::X86Fastcall, + X86Call::Stdcall => CallConvention::X86Stdcall, + X86Call::SysV64 => CallConvention::X86_64SysV, + X86Call::Thiscall => CallConvention::X86ThisCall, + X86Call::Vectorcall => CallConvention::X86VectorCall, + X86Call::Win64 => CallConvention::X86_64Win64, + }, } } } diff --git a/compiler/rustc_target/src/callconv/arm.rs b/compiler/rustc_target/src/callconv/arm.rs index 0a5dcc6634759..70830fa07b6ea 100644 --- a/compiler/rustc_target/src/callconv/arm.rs +++ b/compiler/rustc_target/src/callconv/arm.rs @@ -1,6 +1,6 @@ -use rustc_abi::{HasDataLayout, TyAbiInterface}; +use rustc_abi::{ArmCall, CanonAbi, HasDataLayout, TyAbiInterface}; -use crate::callconv::{ArgAbi, Conv, FnAbi, Reg, RegKind, Uniform}; +use crate::callconv::{ArgAbi, FnAbi, Reg, RegKind, Uniform}; use crate::spec::HasTargetSpec; fn is_homogeneous_aggregate<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>) -> Option @@ -90,7 +90,7 @@ where // If this is a target with a hard-float ABI, and the function is not explicitly // `extern "aapcs"`, then we must use the VFP registers for homogeneous aggregates. let vfp = cx.target_spec().llvm_target.ends_with("hf") - && fn_abi.conv != Conv::ArmAapcs + && fn_abi.conv != CanonAbi::Arm(ArmCall::Aapcs) && !fn_abi.c_variadic; if !fn_abi.ret.is_ignore() { diff --git a/compiler/rustc_target/src/callconv/mod.rs b/compiler/rustc_target/src/callconv/mod.rs index 907614520a2cf..d2e49cea647b6 100644 --- a/compiler/rustc_target/src/callconv/mod.rs +++ b/compiler/rustc_target/src/callconv/mod.rs @@ -1,13 +1,12 @@ -use std::fmt::Display; -use std::str::FromStr; use std::{fmt, iter}; use rustc_abi::{ - AddressSpace, Align, BackendRepr, ExternAbi, HasDataLayout, Primitive, Reg, RegKind, Scalar, - Size, TyAbiInterface, TyAndLayout, + AddressSpace, Align, BackendRepr, CanonAbi, ExternAbi, HasDataLayout, Primitive, Reg, RegKind, + Scalar, Size, TyAbiInterface, TyAndLayout, }; use rustc_macros::HashStable_Generic; +pub use crate::spec::AbiMap; use crate::spec::{HasTargetSpec, HasWasmCAbiOpt, HasX86AbiOpt, RustcAbi, WasmCAbi}; mod aarch64; @@ -529,41 +528,6 @@ impl<'a, Ty> ArgAbi<'a, Ty> { } } -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)] -pub enum Conv { - // General language calling conventions, for which every target - // should have its own backend (e.g. LLVM) support. - C, - Rust, - - Cold, - PreserveMost, - PreserveAll, - - // Target-specific calling conventions. - ArmAapcs, - CCmseNonSecureCall, - CCmseNonSecureEntry, - - Msp430Intr, - - GpuKernel, - - X86Fastcall, - X86Intr, - X86Stdcall, - X86ThisCall, - X86VectorCall, - - X86_64SysV, - X86_64Win64, - - AvrInterrupt, - AvrNonBlockingInterrupt, - - RiscvInterrupt { kind: RiscvInterruptKind }, -} - #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)] pub enum RiscvInterruptKind { Machine, @@ -605,7 +569,7 @@ pub struct FnAbi<'a, Ty> { /// This can be used to know whether an argument is variadic or not. pub fixed_count: u32, /// The calling convention of this function. - pub conv: Conv, + pub conv: CanonAbi, /// Indicates if an unwind may happen across a call to this function. pub can_unwind: bool, } @@ -696,7 +660,6 @@ impl<'a, Ty> FnAbi<'a, Ty> { "sparc" => sparc::compute_abi_info(cx, self), "sparc64" => sparc64::compute_abi_info(cx, self), "nvptx64" => { - let abi = cx.target_spec().adjust_abi(abi, self.c_variadic); if abi == ExternAbi::PtxKernel || abi == ExternAbi::GpuKernel { nvptx64::compute_ptx_kernel_abi_info(cx, self) } else { @@ -863,70 +826,6 @@ impl<'a, Ty> FnAbi<'a, Ty> { } } -impl FromStr for Conv { - type Err = String; - - fn from_str(s: &str) -> Result { - match s { - "C" => Ok(Conv::C), - "Rust" => Ok(Conv::Rust), - "RustCold" => Ok(Conv::Rust), - "ArmAapcs" => Ok(Conv::ArmAapcs), - "CCmseNonSecureCall" => Ok(Conv::CCmseNonSecureCall), - "CCmseNonSecureEntry" => Ok(Conv::CCmseNonSecureEntry), - "Msp430Intr" => Ok(Conv::Msp430Intr), - "X86Fastcall" => Ok(Conv::X86Fastcall), - "X86Intr" => Ok(Conv::X86Intr), - "X86Stdcall" => Ok(Conv::X86Stdcall), - "X86ThisCall" => Ok(Conv::X86ThisCall), - "X86VectorCall" => Ok(Conv::X86VectorCall), - "X86_64SysV" => Ok(Conv::X86_64SysV), - "X86_64Win64" => Ok(Conv::X86_64Win64), - "GpuKernel" => Ok(Conv::GpuKernel), - "AvrInterrupt" => Ok(Conv::AvrInterrupt), - "AvrNonBlockingInterrupt" => Ok(Conv::AvrNonBlockingInterrupt), - "RiscvInterrupt(machine)" => { - Ok(Conv::RiscvInterrupt { kind: RiscvInterruptKind::Machine }) - } - "RiscvInterrupt(supervisor)" => { - Ok(Conv::RiscvInterrupt { kind: RiscvInterruptKind::Supervisor }) - } - _ => Err(format!("'{s}' is not a valid value for entry function call convention.")), - } - } -} - -fn conv_to_externabi(conv: &Conv) -> ExternAbi { - match conv { - Conv::C => ExternAbi::C { unwind: false }, - Conv::Rust => ExternAbi::Rust, - Conv::PreserveMost => ExternAbi::RustCold, - Conv::ArmAapcs => ExternAbi::Aapcs { unwind: false }, - Conv::CCmseNonSecureCall => ExternAbi::CCmseNonSecureCall, - Conv::CCmseNonSecureEntry => ExternAbi::CCmseNonSecureEntry, - Conv::Msp430Intr => ExternAbi::Msp430Interrupt, - Conv::GpuKernel => ExternAbi::GpuKernel, - Conv::X86Fastcall => ExternAbi::Fastcall { unwind: false }, - Conv::X86Intr => ExternAbi::X86Interrupt, - Conv::X86Stdcall => ExternAbi::Stdcall { unwind: false }, - Conv::X86ThisCall => ExternAbi::Thiscall { unwind: false }, - Conv::X86VectorCall => ExternAbi::Vectorcall { unwind: false }, - Conv::X86_64SysV => ExternAbi::SysV64 { unwind: false }, - Conv::X86_64Win64 => ExternAbi::Win64 { unwind: false }, - Conv::AvrInterrupt => ExternAbi::AvrInterrupt, - Conv::AvrNonBlockingInterrupt => ExternAbi::AvrNonBlockingInterrupt, - Conv::RiscvInterrupt { kind: RiscvInterruptKind::Machine } => ExternAbi::RiscvInterruptM, - Conv::RiscvInterrupt { kind: RiscvInterruptKind::Supervisor } => ExternAbi::RiscvInterruptS, - Conv::Cold | Conv::PreserveAll => unreachable!(), - } -} - -impl Display for Conv { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", conv_to_externabi(self)) - } -} - // Some types are used a lot. Make sure they don't unintentionally get bigger. #[cfg(target_pointer_width = "64")] mod size_asserts { diff --git a/compiler/rustc_target/src/json.rs b/compiler/rustc_target/src/json.rs index 8d6f8f4c6f67b..4fcc477921ba2 100644 --- a/compiler/rustc_target/src/json.rs +++ b/compiler/rustc_target/src/json.rs @@ -92,38 +92,6 @@ impl ToJson for Option { } } -impl ToJson for crate::callconv::Conv { - fn to_json(&self) -> Json { - let buf: String; - let s = match self { - Self::C => "C", - Self::Rust => "Rust", - Self::Cold => "Cold", - Self::PreserveMost => "PreserveMost", - Self::PreserveAll => "PreserveAll", - Self::ArmAapcs => "ArmAapcs", - Self::CCmseNonSecureCall => "CCmseNonSecureCall", - Self::CCmseNonSecureEntry => "CCmseNonSecureEntry", - Self::Msp430Intr => "Msp430Intr", - Self::X86Fastcall => "X86Fastcall", - Self::X86Intr => "X86Intr", - Self::X86Stdcall => "X86Stdcall", - Self::X86ThisCall => "X86ThisCall", - Self::X86VectorCall => "X86VectorCall", - Self::X86_64SysV => "X86_64SysV", - Self::X86_64Win64 => "X86_64Win64", - Self::GpuKernel => "GpuKernel", - Self::AvrInterrupt => "AvrInterrupt", - Self::AvrNonBlockingInterrupt => "AvrNonBlockingInterrupt", - Self::RiscvInterrupt { kind } => { - buf = format!("RiscvInterrupt({})", kind.as_str()); - &buf - } - }; - Json::String(s.to_owned()) - } -} - impl ToJson for TargetMetadata { fn to_json(&self) -> Json { json!({ @@ -140,3 +108,9 @@ impl ToJson for rustc_abi::Endian { self.as_str().to_json() } } + +impl ToJson for rustc_abi::CanonAbi { + fn to_json(&self) -> Json { + self.to_string().to_json() + } +} diff --git a/compiler/rustc_target/src/spec/abi_map.rs b/compiler/rustc_target/src/spec/abi_map.rs new file mode 100644 index 0000000000000..d9101f79f0461 --- /dev/null +++ b/compiler/rustc_target/src/spec/abi_map.rs @@ -0,0 +1,187 @@ +use rustc_abi::{ArmCall, CanonAbi, ExternAbi, InterruptKind, X86Call}; + +use crate::spec::Target; + +/// Mapping for ExternAbi to CanonAbi according to a Target +/// +/// A maybe-transitional structure circa 2025 for hosting future experiments in +/// encapsulating arch-specific ABI lowering details to make them more testable. +#[derive(Clone, Debug)] +pub struct AbiMap { + arch: Arch, + os: OsKind, +} + +#[derive(Copy, Clone, Debug)] +pub enum AbiMapping { + /// this ABI is exactly mapped for this platform + Direct(CanonAbi), + /// we don't yet warn on this, but we will + Deprecated(CanonAbi), + Invalid, +} + +impl AbiMapping { + pub fn into_option(self) -> Option { + match self { + Self::Direct(abi) | Self::Deprecated(abi) => Some(abi), + Self::Invalid => None, + } + } + + pub fn unwrap(self) -> CanonAbi { + self.into_option().unwrap() + } + + pub fn is_mapped(self) -> bool { + self.into_option().is_some() + } +} + +impl AbiMap { + pub fn from_target(target: &Target) -> Self { + // the purpose of this little exercise is to force listing what affects these mappings + let arch = match &*target.arch { + "aarch64" => Arch::Aarch64, + "amdgpu" => Arch::Amdgpu, + "arm" if target.llvm_target.starts_with("thumbv8m") => Arch::Arm(ArmVer::ThumbV8M), + "arm" => Arch::Arm(ArmVer::Other), + "avr" => Arch::Avr, + "msp430" => Arch::Msp430, + "nvptx64" => Arch::Nvptx, + "riscv32" | "riscv64" => Arch::Riscv, + "x86" => Arch::X86, + "x86_64" => Arch::X86_64, + _ => Arch::Other, + }; + let os = if target.is_like_windows { OsKind::Windows } else { OsKind::Other }; + AbiMap { arch, os } + } + + pub fn canonize_abi(&self, extern_abi: ExternAbi, has_c_varargs: bool) -> AbiMapping { + let AbiMap { os, arch } = *self; + + let canon_abi = match (extern_abi, arch) { + // infallible lowerings + (ExternAbi::C { .. }, _) => CanonAbi::C, + (ExternAbi::Rust | ExternAbi::RustCall, _) => CanonAbi::Rust, + (ExternAbi::Unadjusted, _) => CanonAbi::C, + + (ExternAbi::RustCold, _) if self.os == OsKind::Windows => CanonAbi::Rust, + (ExternAbi::RustCold, _) => CanonAbi::RustCold, + + (ExternAbi::System { .. }, Arch::X86) if os == OsKind::Windows && !has_c_varargs => { + CanonAbi::X86(X86Call::Stdcall) + } + (ExternAbi::System { .. }, _) => CanonAbi::C, + + // fallible lowerings + (ExternAbi::EfiApi, Arch::Arm(..)) => CanonAbi::Arm(ArmCall::Aapcs), + (ExternAbi::EfiApi, Arch::X86_64) => CanonAbi::X86(X86Call::Win64), + (ExternAbi::EfiApi, Arch::Aarch64 | Arch::Riscv | Arch::X86) => CanonAbi::C, + (ExternAbi::EfiApi, _) => return AbiMapping::Invalid, + + (ExternAbi::Aapcs { .. }, Arch::Arm(..)) => CanonAbi::Arm(ArmCall::Aapcs), + (ExternAbi::Aapcs { .. }, _) => return AbiMapping::Invalid, + + (ExternAbi::CCmseNonSecureCall, Arch::Arm(ArmVer::ThumbV8M)) => { + CanonAbi::Arm(ArmCall::CCmseNonSecureCall) + } + (ExternAbi::CCmseNonSecureEntry, Arch::Arm(ArmVer::ThumbV8M)) => { + CanonAbi::Arm(ArmCall::CCmseNonSecureEntry) + } + (ExternAbi::CCmseNonSecureCall | ExternAbi::CCmseNonSecureEntry, ..) => { + return AbiMapping::Invalid; + } + + (ExternAbi::Cdecl { .. }, Arch::X86) => CanonAbi::C, + (ExternAbi::Cdecl { .. }, _) => return AbiMapping::Deprecated(CanonAbi::C), + + (ExternAbi::Fastcall { .. }, Arch::X86) => CanonAbi::X86(X86Call::Fastcall), + (ExternAbi::Fastcall { .. }, _) if os == OsKind::Windows => { + return AbiMapping::Deprecated(CanonAbi::C); + } + (ExternAbi::Fastcall { .. }, _) => return AbiMapping::Invalid, + + (ExternAbi::Stdcall { .. }, Arch::X86) => CanonAbi::X86(X86Call::Stdcall), + (ExternAbi::Stdcall { .. }, _) if os == OsKind::Windows => { + return AbiMapping::Deprecated(CanonAbi::C); + } + (ExternAbi::Stdcall { .. }, _) => return AbiMapping::Invalid, + + (ExternAbi::Thiscall { .. }, Arch::X86) => CanonAbi::X86(X86Call::Thiscall), + (ExternAbi::Thiscall { .. }, _) => return AbiMapping::Invalid, + + (ExternAbi::Vectorcall { .. }, Arch::X86 | Arch::X86_64) => { + CanonAbi::X86(X86Call::Vectorcall) + } + (ExternAbi::Vectorcall { .. }, _) if os == OsKind::Windows => { + return AbiMapping::Deprecated(CanonAbi::C); + } + (ExternAbi::Vectorcall { .. }, _) => return AbiMapping::Invalid, + + (ExternAbi::SysV64 { .. }, Arch::X86_64) => CanonAbi::X86(X86Call::SysV64), + (ExternAbi::Win64 { .. }, Arch::X86_64) => CanonAbi::X86(X86Call::Win64), + (ExternAbi::SysV64 { .. } | ExternAbi::Win64 { .. }, _) => return AbiMapping::Invalid, + + (ExternAbi::PtxKernel, Arch::Nvptx) => CanonAbi::GpuKernel, + (ExternAbi::GpuKernel, Arch::Amdgpu | Arch::Nvptx) => CanonAbi::GpuKernel, + (ExternAbi::PtxKernel | ExternAbi::GpuKernel, _) => return AbiMapping::Invalid, + + (ExternAbi::AvrInterrupt, Arch::Avr) => CanonAbi::Interrupt(InterruptKind::Avr), + (ExternAbi::AvrNonBlockingInterrupt, Arch::Avr) => { + CanonAbi::Interrupt(InterruptKind::AvrNonBlocking) + } + (ExternAbi::Msp430Interrupt, Arch::Msp430) => { + CanonAbi::Interrupt(InterruptKind::Msp430) + } + (ExternAbi::RiscvInterruptM, Arch::Riscv) => { + CanonAbi::Interrupt(InterruptKind::RiscvMachine) + } + (ExternAbi::RiscvInterruptS, Arch::Riscv) => { + CanonAbi::Interrupt(InterruptKind::RiscvSupervisor) + } + (ExternAbi::X86Interrupt, Arch::X86 | Arch::X86_64) => { + CanonAbi::Interrupt(InterruptKind::X86) + } + ( + ExternAbi::AvrInterrupt + | ExternAbi::AvrNonBlockingInterrupt + | ExternAbi::Msp430Interrupt + | ExternAbi::RiscvInterruptM + | ExternAbi::RiscvInterruptS + | ExternAbi::X86Interrupt, + _, + ) => return AbiMapping::Invalid, + }; + + AbiMapping::Direct(canon_abi) + } +} + +#[derive(Debug, PartialEq, Copy, Clone)] +enum Arch { + Aarch64, + Amdgpu, + Arm(ArmVer), + Avr, + Msp430, + Nvptx, + Riscv, + X86, + X86_64, + /// Architectures which don't need other considerations for ABI lowering + Other, +} + +#[derive(Debug, PartialEq, Copy, Clone)] +enum OsKind { + Windows, + Other, +} + +#[derive(Debug, PartialEq, Copy, Clone)] +enum ArmVer { + ThumbV8M, + Other, +} diff --git a/compiler/rustc_target/src/spec/json.rs b/compiler/rustc_target/src/spec/json.rs index be71da76b4a35..54b06d9f9b47a 100644 --- a/compiler/rustc_target/src/spec/json.rs +++ b/compiler/rustc_target/src/spec/json.rs @@ -2,10 +2,12 @@ use std::borrow::Cow; use std::collections::BTreeMap; use std::str::FromStr; +use rustc_abi::ExternAbi; use serde_json::Value; use super::{Target, TargetKind, TargetOptions, TargetWarnings}; use crate::json::{Json, ToJson}; +use crate::spec::AbiMap; impl Target { /// Loads a target descriptor from a JSON object. @@ -515,18 +517,6 @@ impl Target { } } } ); - ($key_name:ident, Conv) => ( { - let name = (stringify!($key_name)).replace("_", "-"); - obj.remove(&name).and_then(|o| o.as_str().and_then(|s| { - match super::Conv::from_str(s) { - Ok(c) => { - base.$key_name = c; - Some(Ok(())) - } - Err(e) => Some(Err(e)) - } - })).unwrap_or(Ok(())) - } ); } if let Some(j) = obj.remove("target-endian") { @@ -660,9 +650,23 @@ impl Target { key!(supports_stack_protector, bool); key!(small_data_threshold_support, SmallDataThresholdSupport)?; key!(entry_name); - key!(entry_abi, Conv)?; key!(supports_xray, bool); + // we're going to run `update_from_cli`, but that won't change the target's AbiMap + // FIXME: better factor the Target definition so we enforce this on a type level + let abi_map = AbiMap::from_target(&base); + + if let Some(abi_str) = obj.remove("entry-abi") { + if let Json::String(abi_str) = abi_str { + match abi_str.parse::() { + Ok(abi) => base.options.entry_abi = abi_map.canonize_abi(abi, false).unwrap(), + Err(_) => return Err(format!("{abi_str} is not a valid ExternAbi")), + } + } else { + incorrect_type.push("entry-abi".to_owned()) + } + } + base.update_from_cli(); base.check_consistency(TargetKind::Json)?; diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 303be54a6d786..6529c2d72c827 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -43,7 +43,7 @@ use std::str::FromStr; use std::{fmt, io}; use rustc_abi::{ - Align, Endian, ExternAbi, Integer, Size, TargetDataLayout, TargetDataLayoutErrors, + Align, CanonAbi, Endian, ExternAbi, Integer, Size, TargetDataLayout, TargetDataLayoutErrors, }; use rustc_data_structures::fx::{FxHashSet, FxIndexSet}; use rustc_fs_util::try_canonicalize; @@ -53,15 +53,16 @@ use rustc_span::{Symbol, kw, sym}; use serde_json::Value; use tracing::debug; -use crate::callconv::Conv; use crate::json::{Json, ToJson}; use crate::spec::crt_objects::CrtObjects; pub mod crt_objects; +mod abi_map; mod base; mod json; +pub use abi_map::AbiMap; pub use base::apple; pub use base::avr::ef_avr_arch; @@ -2655,9 +2656,9 @@ pub struct TargetOptions { /// Default value is "main" pub entry_name: StaticCow, - /// The ABI of entry function. - /// Default value is `Conv::C`, i.e. C call convention - pub entry_abi: Conv, + /// The ABI of the entry function. + /// Default value is `CanonAbi::C` + pub entry_abi: CanonAbi, /// Whether the target supports XRay instrumentation. pub supports_xray: bool, @@ -2888,7 +2889,7 @@ impl Default for TargetOptions { generate_arange_section: true, supports_stack_protector: true, entry_name: "main".into(), - entry_abi: Conv::C, + entry_abi: CanonAbi::C, supports_xray: false, small_data_threshold_support: SmallDataThresholdSupport::DefaultForArch, } @@ -2914,114 +2915,9 @@ impl DerefMut for Target { } impl Target { - /// Given a function ABI, turn it into the correct ABI for this target. - pub fn adjust_abi(&self, abi: ExternAbi, c_variadic: bool) -> ExternAbi { - use ExternAbi::*; - match abi { - // On Windows, `extern "system"` behaves like msvc's `__stdcall`. - // `__stdcall` only applies on x86 and on non-variadic functions: - // https://learn.microsoft.com/en-us/cpp/cpp/stdcall?view=msvc-170 - System { unwind } => { - if self.is_like_windows && self.arch == "x86" && !c_variadic { - Stdcall { unwind } - } else { - C { unwind } - } - } - - EfiApi => { - if self.arch == "arm" { - Aapcs { unwind: false } - } else if self.arch == "x86_64" { - Win64 { unwind: false } - } else { - C { unwind: false } - } - } - - // See commentary in `is_abi_supported`. - Stdcall { unwind } | Thiscall { unwind } | Fastcall { unwind } => { - if self.arch == "x86" { abi } else { C { unwind } } - } - Vectorcall { unwind } => { - if ["x86", "x86_64"].contains(&&*self.arch) { - abi - } else { - C { unwind } - } - } - - // The Windows x64 calling convention we use for `extern "Rust"` - // - // expects the callee to save `xmm6` through `xmm15`, but `PreserveMost` - // (that we use by default for `extern "rust-cold"`) doesn't save any of those. - // So to avoid bloating callers, just use the Rust convention here. - RustCold if self.is_like_windows && self.arch == "x86_64" => Rust, - - abi => abi, - } - } - pub fn is_abi_supported(&self, abi: ExternAbi) -> bool { - use ExternAbi::*; - match abi { - Rust | C { .. } | System { .. } | RustCall | Unadjusted | Cdecl { .. } | RustCold => { - true - } - EfiApi => { - ["arm", "aarch64", "riscv32", "riscv64", "x86", "x86_64"].contains(&&self.arch[..]) - } - X86Interrupt => ["x86", "x86_64"].contains(&&self.arch[..]), - Aapcs { .. } => "arm" == self.arch, - CCmseNonSecureCall | CCmseNonSecureEntry => { - ["thumbv8m.main-none-eabi", "thumbv8m.main-none-eabihf", "thumbv8m.base-none-eabi"] - .contains(&&self.llvm_target[..]) - } - Win64 { .. } | SysV64 { .. } => self.arch == "x86_64", - PtxKernel => self.arch == "nvptx64", - GpuKernel => ["amdgpu", "nvptx64"].contains(&&self.arch[..]), - Msp430Interrupt => self.arch == "msp430", - RiscvInterruptM | RiscvInterruptS => ["riscv32", "riscv64"].contains(&&self.arch[..]), - AvrInterrupt | AvrNonBlockingInterrupt => self.arch == "avr", - Thiscall { .. } => self.arch == "x86", - // On windows these fall-back to platform native calling convention (C) when the - // architecture is not supported. - // - // This is I believe a historical accident that has occurred as part of Microsoft - // striving to allow most of the code to "just" compile when support for 64-bit x86 - // was added and then later again, when support for ARM architectures was added. - // - // This is well documented across MSDN. Support for this in Rust has been added in - // #54576. This makes much more sense in context of Microsoft's C++ than it does in - // Rust, but there isn't much leeway remaining here to change it back at the time this - // comment has been written. - // - // Following are the relevant excerpts from the MSDN documentation. - // - // > The __vectorcall calling convention is only supported in native code on x86 and - // x64 processors that include Streaming SIMD Extensions 2 (SSE2) and above. - // > ... - // > On ARM machines, __vectorcall is accepted and ignored by the compiler. - // - // -- https://docs.microsoft.com/en-us/cpp/cpp/vectorcall?view=msvc-160 - // - // > On ARM and x64 processors, __stdcall is accepted and ignored by the compiler; - // - // -- https://docs.microsoft.com/en-us/cpp/cpp/stdcall?view=msvc-160 - // - // > In most cases, keywords or compiler switches that specify an unsupported - // > convention on a particular platform are ignored, and the platform default - // > convention is used. - // - // -- https://docs.microsoft.com/en-us/cpp/cpp/argument-passing-and-naming-conventions - Stdcall { .. } | Fastcall { .. } | Vectorcall { .. } if self.is_like_windows => true, - // Outside of Windows we want to only support these calling conventions for the - // architectures for which these calling conventions are actually well defined. - Stdcall { .. } | Fastcall { .. } if self.arch == "x86" => true, - Vectorcall { .. } if ["x86", "x86_64"].contains(&&self.arch[..]) => true, - // Reject these calling conventions everywhere else. - Stdcall { .. } | Fastcall { .. } | Vectorcall { .. } => false, - } + let abi_map = AbiMap::from_target(self); + abi_map.canonize_abi(abi, false).is_mapped() } /// Minimum integer size in bits that this target can perform atomic diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_uefi.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_uefi.rs index 07f853dacaf28..0cf6a87946219 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_uefi.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_uefi.rs @@ -5,7 +5,8 @@ // The win64 ABI is used. It differs from the sysv64 ABI, so we must use a windows target with // LLVM. "x86_64-unknown-windows" is used to get the minimal subset of windows-specific features. -use crate::callconv::Conv; +use rustc_abi::{CanonAbi, X86Call}; + use crate::spec::{RustcAbi, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { @@ -13,7 +14,7 @@ pub(crate) fn target() -> Target { base.cpu = "x86-64".into(); base.plt_by_default = false; base.max_atomic_width = Some(64); - base.entry_abi = Conv::X86_64Win64; + base.entry_abi = CanonAbi::X86(X86Call::Win64); // We disable MMX and SSE for now, even though UEFI allows using them. Problem is, you have to // enable these CPU features explicitly before their first use, otherwise their instructions diff --git a/compiler/rustc_trait_selection/messages.ftl b/compiler/rustc_trait_selection/messages.ftl index 9b949a0a79545..8232da4df43ec 100644 --- a/compiler/rustc_trait_selection/messages.ftl +++ b/compiler/rustc_trait_selection/messages.ftl @@ -72,8 +72,6 @@ trait_selection_adjust_signature_remove_borrow = consider adjusting the signatur trait_selection_ascribe_user_type_prove_predicate = ...so that the where clause holds -trait_selection_async_closure_not_fn = async closure does not implement `{$kind}` because it captures state from its environment - trait_selection_await_both_futures = consider `await`ing on both `Future`s trait_selection_await_future = consider `await`ing on the `Future` trait_selection_await_note = calling an async function returns a future @@ -123,6 +121,8 @@ trait_selection_closure_kind_requirement = the requirement to implement `{$trait trait_selection_compare_impl_item_obligation = ...so that the definition in impl matches the definition from the trait trait_selection_consider_specifying_length = consider specifying the actual array length +trait_selection_coro_closure_not_fn = {$coro_kind}closure does not implement `{$kind}` because it captures state from its environment + trait_selection_data_flows = ...but data{$label_var1_exists -> [true] {" "}from `{$label_var1}` *[false] {""} diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index 9b5e421e0e481..fc5be11114401 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -42,9 +42,7 @@ use super::{ use crate::error_reporting::TypeErrCtxt; use crate::error_reporting::infer::TyCategory; use crate::error_reporting::traits::report_dyn_incompatibility; -use crate::errors::{ - AsyncClosureNotFn, ClosureFnMutLabel, ClosureFnOnceLabel, ClosureKindMismatch, -}; +use crate::errors::{ClosureFnMutLabel, ClosureFnOnceLabel, ClosureKindMismatch, CoroClosureNotFn}; use crate::infer::{self, InferCtxt, InferCtxtExt as _}; use crate::traits::query::evaluate_obligation::InferCtxtExt as _; use crate::traits::{ @@ -886,9 +884,18 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { // is unimplemented is because async closures don't implement `Fn`/`FnMut` // if they have captures. if has_self_borrows && expected_kind != ty::ClosureKind::FnOnce { - let mut err = self.dcx().create_err(AsyncClosureNotFn { + let coro_kind = match self + .tcx + .coroutine_kind(self.tcx.coroutine_for_closure(closure_def_id)) + .unwrap() + { + rustc_hir::CoroutineKind::Desugared(desugaring, _) => desugaring.to_string(), + coro => coro.to_string(), + }; + let mut err = self.dcx().create_err(CoroClosureNotFn { span: self.tcx.def_span(closure_def_id), kind: expected_kind.as_str(), + coro_kind, }); self.note_obligation_cause(&mut err, &obligation); return Some(err.emit()); diff --git a/compiler/rustc_trait_selection/src/errors.rs b/compiler/rustc_trait_selection/src/errors.rs index 779c861637a4e..0bea308ed5c7b 100644 --- a/compiler/rustc_trait_selection/src/errors.rs +++ b/compiler/rustc_trait_selection/src/errors.rs @@ -201,11 +201,12 @@ pub struct ClosureFnMutLabel { } #[derive(Diagnostic)] -#[diag(trait_selection_async_closure_not_fn)] -pub(crate) struct AsyncClosureNotFn { +#[diag(trait_selection_coro_closure_not_fn)] +pub(crate) struct CoroClosureNotFn { #[primary_span] pub span: Span, pub kind: &'static str, + pub coro_kind: String, } #[derive(Diagnostic)] diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index 7d869b27445cf..97ecf9702e620 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -11,7 +11,7 @@ use std::ops::ControlFlow; use hir::LangItem; use hir::def_id::DefId; use rustc_data_structures::fx::{FxHashSet, FxIndexSet}; -use rustc_hir as hir; +use rustc_hir::{self as hir, CoroutineDesugaring, CoroutineKind}; use rustc_infer::traits::{Obligation, PolyTraitObligation, SelectionError}; use rustc_middle::ty::fast_reject::DeepRejectCtxt; use rustc_middle::ty::{self, Ty, TypeVisitableExt, TypingMode, elaborate}; @@ -438,6 +438,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { } } + #[instrument(level = "debug", skip(self, candidates))] fn assemble_async_closure_candidates( &mut self, obligation: &PolyTraitObligation<'tcx>, @@ -446,15 +447,30 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let goal_kind = self.tcx().async_fn_trait_kind_from_def_id(obligation.predicate.def_id()).unwrap(); + debug!("self_ty = {:?}", obligation.self_ty().skip_binder().kind()); match *obligation.self_ty().skip_binder().kind() { - ty::CoroutineClosure(_, args) => { + ty::CoroutineClosure(def_id, args) => { if let Some(closure_kind) = args.as_coroutine_closure().kind_ty().to_opt_closure_kind() && !closure_kind.extends(goal_kind) { return; } - candidates.vec.push(AsyncClosureCandidate); + + // Make sure this is actually an async closure. + let Some(coroutine_kind) = + self.tcx().coroutine_kind(self.tcx().coroutine_for_closure(def_id)) + else { + bug!("coroutine with no kind"); + }; + + debug!(?coroutine_kind); + match coroutine_kind { + CoroutineKind::Desugared(CoroutineDesugaring::Async, _) => { + candidates.vec.push(AsyncClosureCandidate); + } + _ => (), + } } // Closures and fn pointers implement `AsyncFn*` if their return types // implement `Future`, which is checked later. diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index 2b49d7ac8b599..83d7416b03efa 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -13,7 +13,7 @@ use rustc_middle::ty::{self, InstanceKind, Ty, TyCtxt}; use rustc_session::config::OptLevel; use rustc_span::def_id::DefId; use rustc_target::callconv::{ - ArgAbi, ArgAttribute, ArgAttributes, ArgExtension, Conv, FnAbi, PassMode, RiscvInterruptKind, + AbiMap, ArgAbi, ArgAttribute, ArgAttributes, ArgExtension, FnAbi, PassMode, }; use tracing::debug; @@ -240,45 +240,6 @@ fn fn_sig_for_fn_abi<'tcx>( } } -#[inline] -fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: ExternAbi, c_variadic: bool) -> Conv { - use rustc_abi::ExternAbi::*; - match tcx.sess.target.adjust_abi(abi, c_variadic) { - Rust | RustCall => Conv::Rust, - - // This is intentionally not using `Conv::Cold`, as that has to preserve - // even SIMD registers, which is generally not a good trade-off. - RustCold => Conv::PreserveMost, - - // It's the ABI's job to select this, not ours. - System { .. } => bug!("system abi should be selected elsewhere"), - EfiApi => bug!("eficall abi should be selected elsewhere"), - - Stdcall { .. } => Conv::X86Stdcall, - Fastcall { .. } => Conv::X86Fastcall, - Vectorcall { .. } => Conv::X86VectorCall, - Thiscall { .. } => Conv::X86ThisCall, - C { .. } => Conv::C, - Unadjusted => Conv::C, - Win64 { .. } => Conv::X86_64Win64, - SysV64 { .. } => Conv::X86_64SysV, - Aapcs { .. } => Conv::ArmAapcs, - CCmseNonSecureCall => Conv::CCmseNonSecureCall, - CCmseNonSecureEntry => Conv::CCmseNonSecureEntry, - PtxKernel => Conv::GpuKernel, - Msp430Interrupt => Conv::Msp430Intr, - X86Interrupt => Conv::X86Intr, - GpuKernel => Conv::GpuKernel, - AvrInterrupt => Conv::AvrInterrupt, - AvrNonBlockingInterrupt => Conv::AvrNonBlockingInterrupt, - RiscvInterruptM => Conv::RiscvInterrupt { kind: RiscvInterruptKind::Machine }, - RiscvInterruptS => Conv::RiscvInterrupt { kind: RiscvInterruptKind::Supervisor }, - - // These API constants ought to be more specific... - Cdecl { .. } => Conv::C, - } -} - fn fn_abi_of_fn_ptr<'tcx>( tcx: TyCtxt<'tcx>, query: ty::PseudoCanonicalInput<'tcx, (ty::PolyFnSig<'tcx>, &'tcx ty::List>)>, @@ -529,7 +490,8 @@ fn fn_abi_new_uncached<'tcx>( }; let sig = tcx.normalize_erasing_regions(cx.typing_env, sig); - let conv = conv_from_spec_abi(cx.tcx(), sig.abi, sig.c_variadic); + let abi_map = AbiMap::from_target(&tcx.sess.target); + let conv = abi_map.canonize_abi(sig.abi, sig.c_variadic).unwrap(); let mut inputs = sig.inputs(); let extra_args = if sig.abi == ExternAbi::RustCall { diff --git a/library/alloc/Cargo.toml b/library/alloc/Cargo.toml index 365c9dc00dfc5..31b6014af7c17 100644 --- a/library/alloc/Cargo.toml +++ b/library/alloc/Cargo.toml @@ -32,7 +32,6 @@ optimize_for_size = ["core/optimize_for_size"] [lints.rust.unexpected_cfgs] level = "warn" check-cfg = [ - 'cfg(bootstrap)', 'cfg(no_global_oom_handling)', 'cfg(no_rc)', 'cfg(no_sync)', diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index abda5aefab645..30540f48aa105 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -66,7 +66,6 @@ )] #![doc(cfg_hide( not(test), - not(any(test, bootstrap)), no_global_oom_handling, not(no_global_oom_handling), not(no_rc), diff --git a/library/alloctests/Cargo.toml b/library/alloctests/Cargo.toml index 306375f5f01cc..07c45d1b82484 100644 --- a/library/alloctests/Cargo.toml +++ b/library/alloctests/Cargo.toml @@ -39,7 +39,6 @@ harness = false [lints.rust.unexpected_cfgs] level = "warn" check-cfg = [ - 'cfg(bootstrap)', 'cfg(no_global_oom_handling)', 'cfg(no_rc)', 'cfg(no_sync)', diff --git a/library/core/Cargo.toml b/library/core/Cargo.toml index 83ba17b93f519..f88661ee00151 100644 --- a/library/core/Cargo.toml +++ b/library/core/Cargo.toml @@ -29,7 +29,6 @@ debug_typeid = [] [lints.rust.unexpected_cfgs] level = "warn" check-cfg = [ - 'cfg(bootstrap)', 'cfg(no_fp_fmt_parse)', # core use #[path] imports to portable-simd `core_simd` crate # and to stdarch `core_arch` crate which messes-up with Cargo list diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs index d147cf889cc03..bde90464acba6 100644 --- a/library/core/src/intrinsics/mod.rs +++ b/library/core/src/intrinsics/mod.rs @@ -413,38 +413,7 @@ pub unsafe fn atomic_cxchgweak_seqcst_seqcst(dst: *mut T, old: T, src: /// [`atomic`] types via the `load` method. For example, [`AtomicBool::load`]. #[rustc_intrinsic] #[rustc_nounwind] -#[cfg(not(bootstrap))] pub unsafe fn atomic_load(src: *const T) -> T; -/// Loads the current value of the pointer. -/// `T` must be an integer or pointer type. -/// -/// The stabilized version of this intrinsic is available on the -/// [`atomic`] types via the `load` method by passing -/// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::load`]. -#[rustc_intrinsic] -#[rustc_nounwind] -#[cfg(bootstrap)] -pub unsafe fn atomic_load_seqcst(src: *const T) -> T; -/// Loads the current value of the pointer. -/// `T` must be an integer or pointer type. -/// -/// The stabilized version of this intrinsic is available on the -/// [`atomic`] types via the `load` method by passing -/// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::load`]. -#[rustc_intrinsic] -#[rustc_nounwind] -#[cfg(bootstrap)] -pub unsafe fn atomic_load_acquire(src: *const T) -> T; -/// Loads the current value of the pointer. -/// `T` must be an integer or pointer type. -/// -/// The stabilized version of this intrinsic is available on the -/// [`atomic`] types via the `load` method by passing -/// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::load`]. -#[rustc_intrinsic] -#[rustc_nounwind] -#[cfg(bootstrap)] -pub unsafe fn atomic_load_relaxed(src: *const T) -> T; /// Stores the value at the specified memory location. /// `T` must be an integer or pointer type. @@ -1767,7 +1736,6 @@ pub const unsafe fn arith_offset(dst: *const T, offset: isize) -> *const T; /// - `index < PtrMetadata(slice_ptr)`, so the indexing is in-bounds for the slice /// - the resulting offsetting is in-bounds of the allocated object, which is /// always the case for references, but needs to be upheld manually for pointers -#[cfg(not(bootstrap))] #[rustc_nounwind] #[rustc_intrinsic] pub const unsafe fn slice_get_unchecked< @@ -3710,7 +3678,7 @@ pub const fn minnumf128(x: f128, y: f128) -> f128; /// Therefore, implementations must not require the user to uphold /// any safety invariants. #[rustc_nounwind] -#[cfg_attr(not(bootstrap), rustc_intrinsic)] +#[rustc_intrinsic] pub const fn minimumf16(x: f16, y: f16) -> f16 { if x < y { x @@ -3731,7 +3699,7 @@ pub const fn minimumf16(x: f16, y: f16) -> f16 { /// Therefore, implementations must not require the user to uphold /// any safety invariants. #[rustc_nounwind] -#[cfg_attr(not(bootstrap), rustc_intrinsic)] +#[rustc_intrinsic] pub const fn minimumf32(x: f32, y: f32) -> f32 { if x < y { x @@ -3752,7 +3720,7 @@ pub const fn minimumf32(x: f32, y: f32) -> f32 { /// Therefore, implementations must not require the user to uphold /// any safety invariants. #[rustc_nounwind] -#[cfg_attr(not(bootstrap), rustc_intrinsic)] +#[rustc_intrinsic] pub const fn minimumf64(x: f64, y: f64) -> f64 { if x < y { x @@ -3773,7 +3741,7 @@ pub const fn minimumf64(x: f64, y: f64) -> f64 { /// Therefore, implementations must not require the user to uphold /// any safety invariants. #[rustc_nounwind] -#[cfg_attr(not(bootstrap), rustc_intrinsic)] +#[rustc_intrinsic] pub const fn minimumf128(x: f128, y: f128) -> f128 { if x < y { x @@ -3848,7 +3816,7 @@ pub const fn maxnumf128(x: f128, y: f128) -> f128; /// Therefore, implementations must not require the user to uphold /// any safety invariants. #[rustc_nounwind] -#[cfg_attr(not(bootstrap), rustc_intrinsic)] +#[rustc_intrinsic] pub const fn maximumf16(x: f16, y: f16) -> f16 { if x > y { x @@ -3868,7 +3836,7 @@ pub const fn maximumf16(x: f16, y: f16) -> f16 { /// Therefore, implementations must not require the user to uphold /// any safety invariants. #[rustc_nounwind] -#[cfg_attr(not(bootstrap), rustc_intrinsic)] +#[rustc_intrinsic] pub const fn maximumf32(x: f32, y: f32) -> f32 { if x > y { x @@ -3888,7 +3856,7 @@ pub const fn maximumf32(x: f32, y: f32) -> f32 { /// Therefore, implementations must not require the user to uphold /// any safety invariants. #[rustc_nounwind] -#[cfg_attr(not(bootstrap), rustc_intrinsic)] +#[rustc_intrinsic] pub const fn maximumf64(x: f64, y: f64) -> f64 { if x > y { x @@ -3908,7 +3876,7 @@ pub const fn maximumf64(x: f64, y: f64) -> f64 { /// Therefore, implementations must not require the user to uphold /// any safety invariants. #[rustc_nounwind] -#[cfg_attr(not(bootstrap), rustc_intrinsic)] +#[rustc_intrinsic] pub const fn maximumf128(x: f128, y: f128) -> f128 { if x > y { x diff --git a/library/core/src/iter/mod.rs b/library/core/src/iter/mod.rs index d62a445d704ae..b85841295dab1 100644 --- a/library/core/src/iter/mod.rs +++ b/library/core/src/iter/mod.rs @@ -420,6 +420,8 @@ pub use self::adapters::{Intersperse, IntersperseWith}; issue = "42168" )] pub use self::range::Step; +#[unstable(feature = "iter_macro", issue = "none", reason = "generators are unstable")] +pub use self::sources::iter; #[stable(feature = "iter_empty", since = "1.2.0")] pub use self::sources::{Empty, empty}; #[unstable( diff --git a/library/core/src/iter/sources.rs b/library/core/src/iter/sources.rs index 1eb4367b18372..fd9330201ff4e 100644 --- a/library/core/src/iter/sources.rs +++ b/library/core/src/iter/sources.rs @@ -1,6 +1,7 @@ mod empty; mod from_coroutine; mod from_fn; +mod generator; mod once; mod once_with; mod repeat; @@ -18,6 +19,8 @@ pub use self::empty::{Empty, empty}; pub use self::from_coroutine::{FromCoroutine, from_coroutine}; #[stable(feature = "iter_from_fn", since = "1.34.0")] pub use self::from_fn::{FromFn, from_fn}; +#[unstable(feature = "iter_macro", issue = "none", reason = "generators are unstable")] +pub use self::generator::iter; #[stable(feature = "iter_once", since = "1.2.0")] pub use self::once::{Once, once}; #[stable(feature = "iter_once_with", since = "1.43.0")] diff --git a/library/core/src/iter/sources/generator.rs b/library/core/src/iter/sources/generator.rs new file mode 100644 index 0000000000000..c94232e09eb86 --- /dev/null +++ b/library/core/src/iter/sources/generator.rs @@ -0,0 +1,29 @@ +/// Creates a new closure that returns an iterator where each iteration steps the given +/// generator to the next `yield` statement. +/// +/// Similar to [`iter::from_fn`], but allows arbitrary control flow. +/// +/// [`iter::from_fn`]: crate::iter::from_fn +/// +/// # Examples +/// +/// ``` +/// #![feature(iter_macro, coroutines)] +/// # #[cfg(not(bootstrap))] +/// # { +/// +/// let it = std::iter::iter!{|| { +/// yield 1; +/// yield 2; +/// yield 3; +/// } }(); +/// let v: Vec<_> = it.collect(); +/// assert_eq!(v, [1, 2, 3]); +/// # } +/// ``` +#[unstable(feature = "iter_macro", issue = "none", reason = "generators are unstable")] +#[allow_internal_unstable(coroutines, iter_from_coroutine)] +#[cfg_attr(not(bootstrap), rustc_builtin_macro)] +pub macro iter($($t:tt)*) { + /* compiler-builtin */ +} diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 989ab80b77d41..f2a5c40bada0b 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -187,7 +187,6 @@ // // Target features: // tidy-alphabetical-start -#![cfg_attr(bootstrap, feature(avx512_target_feature))] #![feature(aarch64_unstable_target_feature)] #![feature(arm_target_feature)] #![feature(hexagon_target_feature)] @@ -225,7 +224,6 @@ pub mod assert_matches { // We don't export this through #[macro_export] for now, to avoid breakage. #[unstable(feature = "autodiff", issue = "124509")] -#[cfg(not(bootstrap))] /// Unstable module containing the unstable `autodiff` macro. pub mod autodiff { #[unstable(feature = "autodiff", issue = "124509")] diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index e70a1dab6e9a9..d5efb03cfbcbf 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -1533,7 +1533,6 @@ pub(crate) mod builtin { #[unstable(feature = "autodiff", issue = "124509")] #[allow_internal_unstable(rustc_attrs)] #[rustc_builtin_macro] - #[cfg(not(bootstrap))] pub macro autodiff_forward($item:item) { /* compiler built-in */ } @@ -1552,7 +1551,6 @@ pub(crate) mod builtin { #[unstable(feature = "autodiff", issue = "124509")] #[allow_internal_unstable(rustc_attrs)] #[rustc_builtin_macro] - #[cfg(not(bootstrap))] pub macro autodiff_reverse($item:item) { /* compiler built-in */ } diff --git a/library/core/src/pin.rs b/library/core/src/pin.rs index aad073cc8cdd0..ba687434bf102 100644 --- a/library/core/src/pin.rs +++ b/library/core/src/pin.rs @@ -1092,7 +1092,6 @@ pub use self::unsafe_pinned::UnsafePinned; #[rustc_pub_transparent] #[derive(Copy, Clone)] pub struct Pin { - /// Only public for bootstrap. pointer: Ptr, } diff --git a/library/core/src/slice/index.rs b/library/core/src/slice/index.rs index 69160a911b212..f725c3fdd94cc 100644 --- a/library/core/src/slice/index.rs +++ b/library/core/src/slice/index.rs @@ -1,6 +1,5 @@ //! Indexing implementations for `[T]`. -#[cfg(not(bootstrap))] use crate::intrinsics::slice_get_unchecked; use crate::panic::const_panic; use crate::ub_checks::assert_unsafe_precondition; @@ -85,22 +84,6 @@ const fn slice_end_index_overflow_fail() -> ! { // Both the safe and unsafe public methods share these helpers, // which use intrinsics directly to get *no* extra checks. -#[cfg(bootstrap)] -#[inline(always)] -const unsafe fn get_noubcheck(ptr: *const [T], index: usize) -> *const T { - let ptr = ptr as *const T; - // SAFETY: The caller already checked these preconditions - unsafe { crate::intrinsics::offset(ptr, index) } -} - -#[cfg(bootstrap)] -#[inline(always)] -const unsafe fn get_mut_noubcheck(ptr: *mut [T], index: usize) -> *mut T { - let ptr = ptr as *mut T; - // SAFETY: The caller already checked these preconditions - unsafe { crate::intrinsics::offset(ptr, index) } -} - #[inline(always)] const unsafe fn get_offset_len_noubcheck( ptr: *const [T], @@ -231,16 +214,8 @@ unsafe impl SliceIndex<[T]> for usize { #[inline] fn get(self, slice: &[T]) -> Option<&T> { if self < slice.len() { - #[cfg(bootstrap)] - // SAFETY: `self` is checked to be in bounds. - unsafe { - Some(&*get_noubcheck(slice, self)) - } - #[cfg(not(bootstrap))] // SAFETY: `self` is checked to be in bounds. - unsafe { - Some(slice_get_unchecked(slice, self)) - } + unsafe { Some(slice_get_unchecked(slice, self)) } } else { None } @@ -249,16 +224,8 @@ unsafe impl SliceIndex<[T]> for usize { #[inline] fn get_mut(self, slice: &mut [T]) -> Option<&mut T> { if self < slice.len() { - #[cfg(bootstrap)] // SAFETY: `self` is checked to be in bounds. - unsafe { - Some(&mut *get_mut_noubcheck(slice, self)) - } - #[cfg(not(bootstrap))] - // SAFETY: `self` is checked to be in bounds. - unsafe { - Some(slice_get_unchecked(slice, self)) - } + unsafe { Some(slice_get_unchecked(slice, self)) } } else { None } @@ -280,14 +247,7 @@ unsafe impl SliceIndex<[T]> for usize { // Use intrinsics::assume instead of hint::assert_unchecked so that we don't check the // precondition of this function twice. crate::intrinsics::assume(self < slice.len()); - #[cfg(bootstrap)] - { - get_noubcheck(slice, self) - } - #[cfg(not(bootstrap))] - { - slice_get_unchecked(slice, self) - } + slice_get_unchecked(slice, self) } } @@ -300,16 +260,7 @@ unsafe impl SliceIndex<[T]> for usize { (this: usize = self, len: usize = slice.len()) => this < len ); // SAFETY: see comments for `get_unchecked` above. - unsafe { - #[cfg(bootstrap)] - { - get_mut_noubcheck(slice, self) - } - #[cfg(not(bootstrap))] - { - slice_get_unchecked(slice, self) - } - } + unsafe { slice_get_unchecked(slice, self) } } #[inline] diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index b43f3bad6e2c3..ea459f6d92d86 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -3822,23 +3822,6 @@ unsafe fn atomic_store(dst: *mut T, val: T, order: Ordering) { #[inline] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces -#[cfg(bootstrap)] -unsafe fn atomic_load(dst: *const T, order: Ordering) -> T { - // SAFETY: the caller must uphold the safety contract for `atomic_load`. - unsafe { - match order { - Relaxed => intrinsics::atomic_load_relaxed(dst), - Acquire => intrinsics::atomic_load_acquire(dst), - SeqCst => intrinsics::atomic_load_seqcst(dst), - Release => panic!("there is no such thing as a release load"), - AcqRel => panic!("there is no such thing as an acquire-release load"), - } - } -} - -#[inline] -#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces -#[cfg(not(bootstrap))] unsafe fn atomic_load(dst: *const T, order: Ordering) -> T { use intrinsics::AtomicOrdering; // SAFETY: the caller must uphold the safety contract for `atomic_load`. diff --git a/library/coretests/tests/num/mod.rs b/library/coretests/tests/num/mod.rs index fa05bbdd9b774..c68b569f86b3a 100644 --- a/library/coretests/tests/num/mod.rs +++ b/library/coretests/tests/num/mod.rs @@ -951,7 +951,6 @@ macro_rules! test_float { assert!(<$fty>::NAN.div_euclid(<$fty>::INFINITY).is_nan()); } #[test] - #[cfg(not(bootstrap))] fn floor() { $fassert!((0.0 as $fty).floor(), 0.0); $fassert!((0.0 as $fty).floor().is_sign_positive()); @@ -969,7 +968,6 @@ macro_rules! test_float { $fassert!(<$fty>::NEG_INFINITY.floor(), <$fty>::NEG_INFINITY); } #[test] - #[cfg(not(bootstrap))] fn ceil() { $fassert!((0.0 as $fty).ceil(), 0.0); $fassert!((0.0 as $fty).ceil().is_sign_positive()); @@ -986,7 +984,6 @@ macro_rules! test_float { $fassert!(<$fty>::NEG_INFINITY.ceil(), <$fty>::NEG_INFINITY); } #[test] - #[cfg(not(bootstrap))] fn round() { $fassert!((0.0 as $fty).round(), 0.0); $fassert!((0.0 as $fty).round().is_sign_positive()); @@ -1003,7 +1000,6 @@ macro_rules! test_float { $fassert!(<$fty>::NEG_INFINITY.round(), <$fty>::NEG_INFINITY); } #[test] - #[cfg(not(bootstrap))] fn round_ties_even() { $fassert!((0.0 as $fty).round_ties_even(), 0.0); $fassert!((0.0 as $fty).round_ties_even().is_sign_positive()); @@ -1022,7 +1018,6 @@ macro_rules! test_float { $fassert!(<$fty>::NEG_INFINITY.round_ties_even(), <$fty>::NEG_INFINITY); } #[test] - #[cfg(not(bootstrap))] fn trunc() { $fassert!((0.0 as $fty).trunc(), 0.0); $fassert!((0.0 as $fty).trunc().is_sign_positive()); @@ -1041,7 +1036,6 @@ macro_rules! test_float { $fassert!(<$fty>::NEG_INFINITY.trunc(), <$fty>::NEG_INFINITY); } #[test] - #[cfg(not(bootstrap))] fn fract() { $fassert!((0.0 as $fty).fract(), 0.0); $fassert!((0.0 as $fty).fract().is_sign_positive()); diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index 31371f06b3865..196b904d56a1e 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -157,7 +157,6 @@ test = true [lints.rust.unexpected_cfgs] level = "warn" check-cfg = [ - 'cfg(bootstrap)', # std use #[path] imports to portable-simd `std_float` crate # and to the `backtrace` crate which messes-up with Cargo list # of declared features, we therefor expect any feature cfg diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 74a3433986020..7c54e731edc62 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -235,12 +235,7 @@ test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))) )] #![doc(rust_logo)] -#![doc(cfg_hide( - not(test), - not(any(test, bootstrap)), - no_global_oom_handling, - not(no_global_oom_handling) -))] +#![doc(cfg_hide(not(test), no_global_oom_handling, not(no_global_oom_handling)))] // Don't link to std. We are std. #![no_std] // Tell the compiler to link to either panic_abort or panic_unwind @@ -276,12 +271,12 @@ // tidy-alphabetical-start // stabilization was reverted after it hit beta -#![cfg_attr(not(bootstrap), feature(autodiff))] #![feature(alloc_error_handler)] #![feature(allocator_internals)] #![feature(allow_internal_unsafe)] #![feature(allow_internal_unstable)] #![feature(asm_experimental_arch)] +#![feature(autodiff)] #![feature(cfg_sanitizer_cfi)] #![feature(cfg_target_thread_local)] #![feature(cfi_encoding)] @@ -641,7 +636,6 @@ pub mod simd { } #[unstable(feature = "autodiff", issue = "124509")] -#[cfg(not(bootstrap))] /// This module provides support for automatic differentiation. pub mod autodiff { /// This macro handles automatic differentiation. diff --git a/library/std/src/sys/thread_local/key/unix.rs b/library/std/src/sys/thread_local/key/unix.rs index 93bd0d1f66850..8fa24265e432a 100644 --- a/library/std/src/sys/thread_local/key/unix.rs +++ b/library/std/src/sys/thread_local/key/unix.rs @@ -25,7 +25,9 @@ pub type Key = libc::pthread_key_t; #[inline] pub fn create(dtor: Option) -> Key { let mut key = 0; - assert_eq!(unsafe { libc::pthread_key_create(&mut key, mem::transmute(dtor)) }, 0); + if unsafe { libc::pthread_key_create(&mut key, mem::transmute(dtor)) } != 0 { + rtabort!("out of TLS keys"); + } key } diff --git a/library/std/src/sys/thread_local/key/windows.rs b/library/std/src/sys/thread_local/key/windows.rs index c34c7bc204fd4..2ff0fd1196e12 100644 --- a/library/std/src/sys/thread_local/key/windows.rs +++ b/library/std/src/sys/thread_local/key/windows.rs @@ -81,15 +81,10 @@ impl LazyKey { } else { let key = unsafe { c::TlsAlloc() }; if key == c::TLS_OUT_OF_INDEXES { - // Wakeup the waiting threads before panicking to avoid deadlock. - unsafe { - c::InitOnceComplete( - self.once.get(), - c::INIT_ONCE_INIT_FAILED, - ptr::null_mut(), - ); - } - panic!("out of TLS indexes"); + // Since we abort the process, there is no need to wake up + // the waiting threads. If this were a panic, the wakeup + // would need to occur first in order to avoid deadlock. + rtabort!("out of TLS indexes"); } unsafe { @@ -112,7 +107,9 @@ impl LazyKey { // If there is no destructor to clean up, we can use racy initialization. let key = unsafe { c::TlsAlloc() }; - assert_ne!(key, c::TLS_OUT_OF_INDEXES, "out of TLS indexes"); + if key == c::TLS_OUT_OF_INDEXES { + rtabort!("out of TLS indexes"); + } match self.key.compare_exchange(0, key + 1, AcqRel, Acquire) { Ok(_) => key, diff --git a/src/tools/clippy/tests/ui/indexing_slicing_index.rs b/src/tools/clippy/tests/ui/indexing_slicing_index.rs index cfa1c2f7c75fa..ab6a823500831 100644 --- a/src/tools/clippy/tests/ui/indexing_slicing_index.rs +++ b/src/tools/clippy/tests/ui/indexing_slicing_index.rs @@ -68,7 +68,7 @@ fn main() { // This should be linted, since `suppress-restriction-lint-in-const` default is false. const { &ARR[idx4()] }; //~^ ERROR: indexing may panic - //~| ERROR: evaluation of `main + //~| ERROR: index out of bounds let y = &x; // Ok, referencing shouldn't affect this lint. See the issue 6021 diff --git a/src/tools/clippy/tests/ui/indexing_slicing_index.stderr b/src/tools/clippy/tests/ui/indexing_slicing_index.stderr index 50ee9b9edc75b..8e24b898ed5d5 100644 --- a/src/tools/clippy/tests/ui/indexing_slicing_index.stderr +++ b/src/tools/clippy/tests/ui/indexing_slicing_index.stderr @@ -9,11 +9,11 @@ LL | const REF: &i32 = &ARR[idx()]; // This should be linted, since `suppress-re = note: `-D clippy::indexing-slicing` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::indexing_slicing)]` -error[E0080]: evaluation of `main::{constant#3}` failed +error[E0080]: index out of bounds: the length is 2 but the index is 4 --> tests/ui/indexing_slicing_index.rs:69:14 | LL | const { &ARR[idx4()] }; - | ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4 + | ^^^^^^^^^^^ evaluation of `main::{constant#3}` failed here note: erroneous constant encountered --> tests/ui/indexing_slicing_index.rs:69:5 diff --git a/src/tools/miri/src/helpers.rs b/src/tools/miri/src/helpers.rs index dcc74b099d62f..20ea239b7e5e9 100644 --- a/src/tools/miri/src/helpers.rs +++ b/src/tools/miri/src/helpers.rs @@ -3,7 +3,7 @@ use std::time::Duration; use std::{cmp, iter}; use rand::RngCore; -use rustc_abi::{Align, ExternAbi, FieldIdx, FieldsShape, Size, Variants}; +use rustc_abi::{Align, CanonAbi, ExternAbi, FieldIdx, FieldsShape, Size, Variants}; use rustc_apfloat::Float; use rustc_apfloat::ieee::{Double, Half, Quad, Single}; use rustc_hir::Safety; @@ -18,7 +18,7 @@ use rustc_middle::ty::{self, Binder, FloatTy, FnSig, IntTy, Ty, TyCtxt, UintTy}; use rustc_session::config::CrateType; use rustc_span::{Span, Symbol}; use rustc_symbol_mangling::mangle_internal_symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use crate::*; @@ -936,11 +936,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { fn check_callconv<'a>( &self, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, - exp_abi: Conv, + exp_abi: CanonAbi, ) -> InterpResult<'a, ()> { if fn_abi.conv != exp_abi { throw_ub_format!( - "calling a function with calling convention {exp_abi} using caller calling convention {}", + r#"calling a function with calling convention "{exp_abi}" using caller calling convention "{}""#, fn_abi.conv ); } @@ -973,7 +973,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { fn check_abi_and_shim_symbol_clash( &mut self, abi: &FnAbi<'tcx, Ty<'tcx>>, - exp_abi: Conv, + exp_abi: CanonAbi, link_name: Symbol, ) -> InterpResult<'tcx, ()> { self.check_callconv(abi, exp_abi)?; @@ -998,7 +998,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { fn check_shim<'a, const N: usize>( &mut self, abi: &FnAbi<'tcx, Ty<'tcx>>, - exp_abi: Conv, + exp_abi: CanonAbi, link_name: Symbol, args: &'a [OpTy<'tcx>], ) -> InterpResult<'tcx, &'a [OpTy<'tcx>; N]> { @@ -1098,7 +1098,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { fn check_shim_variadic<'a, const N: usize>( &mut self, abi: &FnAbi<'tcx, Ty<'tcx>>, - exp_abi: Conv, + exp_abi: CanonAbi, link_name: Symbol, args: &'a [OpTy<'tcx>], ) -> InterpResult<'tcx, (&'a [OpTy<'tcx>; N], &'a [OpTy<'tcx>])> diff --git a/src/tools/miri/src/shims/aarch64.rs b/src/tools/miri/src/shims/aarch64.rs index 7cccc9e51d8ee..44ad5081ad571 100644 --- a/src/tools/miri/src/shims/aarch64.rs +++ b/src/tools/miri/src/shims/aarch64.rs @@ -1,7 +1,8 @@ +use rustc_abi::CanonAbi; use rustc_middle::mir::BinOp; use rustc_middle::ty::Ty; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use crate::*; @@ -19,7 +20,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { let unprefixed_name = link_name.as_str().strip_prefix("llvm.aarch64.").unwrap(); match unprefixed_name { "isb" => { - let [arg] = this.check_shim(abi, Conv::C, link_name, args)?; + let [arg] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let arg = this.read_scalar(arg)?.to_i32()?; match arg { // SY ("full system scope") @@ -37,7 +38,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // `left` input, the second half of the output from the `right` input. // https://developer.arm.com/architectures/instruction-sets/intrinsics/vpmaxq_u8 "neon.umaxp.v16i8" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (left, left_len) = this.project_to_simd(left)?; let (right, right_len) = this.project_to_simd(right)?; diff --git a/src/tools/miri/src/shims/backtrace.rs b/src/tools/miri/src/shims/backtrace.rs index 9f3bc06771f55..ab11553df6364 100644 --- a/src/tools/miri/src/shims/backtrace.rs +++ b/src/tools/miri/src/shims/backtrace.rs @@ -1,8 +1,8 @@ -use rustc_abi::Size; +use rustc_abi::{CanonAbi, Size}; use rustc_middle::ty::layout::LayoutOf as _; use rustc_middle::ty::{self, Instance, Ty}; use rustc_span::{BytePos, Loc, Symbol, hygiene}; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use crate::*; @@ -16,7 +16,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { dest: &MPlaceTy<'tcx>, ) -> InterpResult<'tcx> { let this = self.eval_context_mut(); - let [flags] = this.check_shim(abi, Conv::Rust, link_name, args)?; + let [flags] = this.check_shim(abi, CanonAbi::Rust, link_name, args)?; let flags = this.read_scalar(flags)?.to_u64()?; if flags != 0 { @@ -38,7 +38,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { let ptr_ty = this.machine.layouts.mut_raw_ptr.ty; let ptr_layout = this.layout_of(ptr_ty)?; - let [flags, buf] = this.check_shim(abi, Conv::Rust, link_name, args)?; + let [flags, buf] = this.check_shim(abi, CanonAbi::Rust, link_name, args)?; let flags = this.read_scalar(flags)?.to_u64()?; let buf_place = this.deref_pointer_as(buf, ptr_layout)?; @@ -118,7 +118,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { dest: &MPlaceTy<'tcx>, ) -> InterpResult<'tcx> { let this = self.eval_context_mut(); - let [ptr, flags] = this.check_shim(abi, Conv::Rust, link_name, args)?; + let [ptr, flags] = this.check_shim(abi, CanonAbi::Rust, link_name, args)?; let flags = this.read_scalar(flags)?.to_u64()?; @@ -190,7 +190,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { let this = self.eval_context_mut(); let [ptr, flags, name_ptr, filename_ptr] = - this.check_shim(abi, Conv::Rust, link_name, args)?; + this.check_shim(abi, CanonAbi::Rust, link_name, args)?; let flags = this.read_scalar(flags)?.to_u64()?; if flags != 0 { diff --git a/src/tools/miri/src/shims/foreign_items.rs b/src/tools/miri/src/shims/foreign_items.rs index b08b522d279a0..ae04ca018ab29 100644 --- a/src/tools/miri/src/shims/foreign_items.rs +++ b/src/tools/miri/src/shims/foreign_items.rs @@ -2,7 +2,7 @@ use std::collections::hash_map::Entry; use std::io::Write; use std::path::Path; -use rustc_abi::{Align, AlignFromBytesError, Size}; +use rustc_abi::{Align, AlignFromBytesError, CanonAbi, Size}; use rustc_apfloat::Float; use rustc_ast::expand::allocator::alloc_error_handler_name; use rustc_hir::def::DefKind; @@ -12,7 +12,7 @@ use rustc_middle::mir::interpret::AllocInit; use rustc_middle::ty::{Instance, Ty}; use rustc_middle::{mir, ty}; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use self::helpers::{ToHost, ToSoft}; use super::alloc::EvalContextExt as _; @@ -250,7 +250,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { // When adding a new shim, you should follow the following pattern: // ``` // "shim_name" => { - // let [arg1, arg2, arg3] = this.check_shim(abi, Conv::::C , link_name, args)?; + // let [arg1, arg2, arg3] = this.check_shim(abi, CanonAbi::C , link_name, args)?; // let result = this.shim_name(arg1, arg2, arg3)?; // this.write_scalar(result, dest)?; // } @@ -288,16 +288,16 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { match link_name.as_str() { // Miri-specific extern functions "miri_start_unwind" => { - let [payload] = this.check_shim(abi, Conv::Rust, link_name, args)?; + let [payload] = this.check_shim(abi, CanonAbi::Rust, link_name, args)?; this.handle_miri_start_unwind(payload)?; return interp_ok(EmulateItemResult::NeedsUnwind); } "miri_run_provenance_gc" => { - let [] = this.check_shim(abi, Conv::Rust, link_name, args)?; + let [] = this.check_shim(abi, CanonAbi::Rust, link_name, args)?; this.run_provenance_gc(); } "miri_get_alloc_id" => { - let [ptr] = this.check_shim(abi, Conv::Rust, link_name, args)?; + let [ptr] = this.check_shim(abi, CanonAbi::Rust, link_name, args)?; let ptr = this.read_pointer(ptr)?; let (alloc_id, _, _) = this.ptr_get_alloc_id(ptr, 0).map_err_kind(|_e| { err_machine_stop!(TerminationInfo::Abort(format!( @@ -307,7 +307,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { this.write_scalar(Scalar::from_u64(alloc_id.0.get()), dest)?; } "miri_print_borrow_state" => { - let [id, show_unnamed] = this.check_shim(abi, Conv::Rust, link_name, args)?; + let [id, show_unnamed] = this.check_shim(abi, CanonAbi::Rust, link_name, args)?; let id = this.read_scalar(id)?.to_u64()?; let show_unnamed = this.read_scalar(show_unnamed)?.to_bool()?; if let Some(id) = std::num::NonZero::new(id).map(AllocId) @@ -321,7 +321,8 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { "miri_pointer_name" => { // This associates a name to a tag. Very useful for debugging, and also makes // tests more strict. - let [ptr, nth_parent, name] = this.check_shim(abi, Conv::Rust, link_name, args)?; + let [ptr, nth_parent, name] = + this.check_shim(abi, CanonAbi::Rust, link_name, args)?; let ptr = this.read_pointer(ptr)?; let nth_parent = this.read_scalar(nth_parent)?.to_u8()?; let name = this.read_immediate(name)?; @@ -334,7 +335,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { this.give_pointer_debug_name(ptr, nth_parent, &name)?; } "miri_static_root" => { - let [ptr] = this.check_shim(abi, Conv::Rust, link_name, args)?; + let [ptr] = this.check_shim(abi, CanonAbi::Rust, link_name, args)?; let ptr = this.read_pointer(ptr)?; let (alloc_id, offset, _) = this.ptr_get_alloc_id(ptr, 0)?; if offset != Size::ZERO { @@ -345,7 +346,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { this.machine.static_roots.push(alloc_id); } "miri_host_to_target_path" => { - let [ptr, out, out_size] = this.check_shim(abi, Conv::Rust, link_name, args)?; + let [ptr, out, out_size] = this.check_shim(abi, CanonAbi::Rust, link_name, args)?; let ptr = this.read_pointer(ptr)?; let out = this.read_pointer(out)?; let out_size = this.read_scalar(out_size)?.to_target_usize(this)?; @@ -381,7 +382,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { // Writes some bytes to the interpreter's stdout/stderr. See the // README for details. "miri_write_to_stdout" | "miri_write_to_stderr" => { - let [msg] = this.check_shim(abi, Conv::Rust, link_name, args)?; + let [msg] = this.check_shim(abi, CanonAbi::Rust, link_name, args)?; let msg = this.read_immediate(msg)?; let msg = this.read_byte_slice(&msg)?; // Note: we're ignoring errors writing to host stdout/stderr. @@ -395,7 +396,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { "miri_promise_symbolic_alignment" => { use rustc_abi::AlignFromBytesError; - let [ptr, align] = this.check_shim(abi, Conv::Rust, link_name, args)?; + let [ptr, align] = this.check_shim(abi, CanonAbi::Rust, link_name, args)?; let ptr = this.read_pointer(ptr)?; let align = this.read_target_usize(align)?; if !align.is_power_of_two() { @@ -436,12 +437,12 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { // Aborting the process. "exit" => { - let [code] = this.check_shim(abi, Conv::C, link_name, args)?; + let [code] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let code = this.read_scalar(code)?.to_i32()?; throw_machine_stop!(TerminationInfo::Exit { code, leak_check: false }); } "abort" => { - let [] = this.check_shim(abi, Conv::C, link_name, args)?; + let [] = this.check_shim(abi, CanonAbi::C, link_name, args)?; throw_machine_stop!(TerminationInfo::Abort( "the program aborted execution".to_owned() )) @@ -449,7 +450,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { // Standard C allocation "malloc" => { - let [size] = this.check_shim(abi, Conv::C, link_name, args)?; + let [size] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let size = this.read_target_usize(size)?; if size <= this.max_size_of_val().bytes() { let res = this.malloc(size, AllocInit::Uninit)?; @@ -463,7 +464,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { } } "calloc" => { - let [items, elem_size] = this.check_shim(abi, Conv::C, link_name, args)?; + let [items, elem_size] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let items = this.read_target_usize(items)?; let elem_size = this.read_target_usize(elem_size)?; if let Some(size) = this.compute_size_in_bytes(Size::from_bytes(elem_size), items) { @@ -478,12 +479,12 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { } } "free" => { - let [ptr] = this.check_shim(abi, Conv::C, link_name, args)?; + let [ptr] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let ptr = this.read_pointer(ptr)?; this.free(ptr)?; } "realloc" => { - let [old_ptr, new_size] = this.check_shim(abi, Conv::C, link_name, args)?; + let [old_ptr, new_size] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let old_ptr = this.read_pointer(old_ptr)?; let new_size = this.read_target_usize(new_size)?; if new_size <= this.max_size_of_val().bytes() { @@ -503,7 +504,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { let default = |ecx: &mut MiriInterpCx<'tcx>| { // Only call `check_shim` when `#[global_allocator]` isn't used. When that // macro is used, we act like no shim exists, so that the exported function can run. - let [size, align] = ecx.check_shim(abi, Conv::Rust, link_name, args)?; + let [size, align] = ecx.check_shim(abi, CanonAbi::Rust, link_name, args)?; let size = ecx.read_target_usize(size)?; let align = ecx.read_target_usize(align)?; @@ -536,7 +537,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { return this.emulate_allocator(|this| { // See the comment for `__rust_alloc` why `check_shim` is only called in the // default case. - let [size, align] = this.check_shim(abi, Conv::Rust, link_name, args)?; + let [size, align] = this.check_shim(abi, CanonAbi::Rust, link_name, args)?; let size = this.read_target_usize(size)?; let align = this.read_target_usize(align)?; @@ -558,7 +559,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { // See the comment for `__rust_alloc` why `check_shim` is only called in the // default case. let [ptr, old_size, align] = - ecx.check_shim(abi, Conv::Rust, link_name, args)?; + ecx.check_shim(abi, CanonAbi::Rust, link_name, args)?; let ptr = ecx.read_pointer(ptr)?; let old_size = ecx.read_target_usize(old_size)?; let align = ecx.read_target_usize(align)?; @@ -589,7 +590,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { // See the comment for `__rust_alloc` why `check_shim` is only called in the // default case. let [ptr, old_size, align, new_size] = - this.check_shim(abi, Conv::Rust, link_name, args)?; + this.check_shim(abi, CanonAbi::Rust, link_name, args)?; let ptr = this.read_pointer(ptr)?; let old_size = this.read_target_usize(old_size)?; let align = this.read_target_usize(align)?; @@ -613,7 +614,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { // C memory handling functions "memcmp" => { - let [left, right, n] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right, n] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let left = this.read_pointer(left)?; let right = this.read_pointer(right)?; let n = Size::from_bytes(this.read_target_usize(n)?); @@ -637,7 +638,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { this.write_scalar(Scalar::from_i32(result), dest)?; } "memrchr" => { - let [ptr, val, num] = this.check_shim(abi, Conv::C, link_name, args)?; + let [ptr, val, num] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let ptr = this.read_pointer(ptr)?; let val = this.read_scalar(val)?.to_i32()?; let num = this.read_target_usize(num)?; @@ -663,7 +664,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { } } "memchr" => { - let [ptr, val, num] = this.check_shim(abi, Conv::C, link_name, args)?; + let [ptr, val, num] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let ptr = this.read_pointer(ptr)?; let val = this.read_scalar(val)?.to_i32()?; let num = this.read_target_usize(num)?; @@ -686,7 +687,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { } } "strlen" => { - let [ptr] = this.check_shim(abi, Conv::C, link_name, args)?; + let [ptr] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let ptr = this.read_pointer(ptr)?; // This reads at least 1 byte, so we are already enforcing that this is a valid pointer. let n = this.read_c_str(ptr)?.len(); @@ -696,7 +697,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { )?; } "wcslen" => { - let [ptr] = this.check_shim(abi, Conv::C, link_name, args)?; + let [ptr] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let ptr = this.read_pointer(ptr)?; // This reads at least 1 byte, so we are already enforcing that this is a valid pointer. let n = this.read_wchar_t_str(ptr)?.len(); @@ -706,7 +707,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { )?; } "memcpy" => { - let [ptr_dest, ptr_src, n] = this.check_shim(abi, Conv::C, link_name, args)?; + let [ptr_dest, ptr_src, n] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let ptr_dest = this.read_pointer(ptr_dest)?; let ptr_src = this.read_pointer(ptr_src)?; let n = this.read_target_usize(n)?; @@ -720,7 +721,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { this.write_pointer(ptr_dest, dest)?; } "strcpy" => { - let [ptr_dest, ptr_src] = this.check_shim(abi, Conv::C, link_name, args)?; + let [ptr_dest, ptr_src] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let ptr_dest = this.read_pointer(ptr_dest)?; let ptr_src = this.read_pointer(ptr_src)?; @@ -751,7 +752,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { | "erff" | "erfcf" => { - let [f] = this.check_shim(abi, Conv::C , link_name, args)?; + let [f] = this.check_shim(abi, CanonAbi::C , link_name, args)?; let f = this.read_scalar(f)?.to_f32()?; // Using host floats (but it's fine, these operations do not have guaranteed precision). let f_host = f.to_host(); @@ -789,7 +790,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { | "atan2f" | "fdimf" => { - let [f1, f2] = this.check_shim(abi, Conv::C , link_name, args)?; + let [f1, f2] = this.check_shim(abi, CanonAbi::C , link_name, args)?; let f1 = this.read_scalar(f1)?.to_f32()?; let f2 = this.read_scalar(f2)?.to_f32()?; // underscore case for windows, here and below @@ -828,7 +829,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { | "erf" | "erfc" => { - let [f] = this.check_shim(abi, Conv::C , link_name, args)?; + let [f] = this.check_shim(abi, CanonAbi::C , link_name, args)?; let f = this.read_scalar(f)?.to_f64()?; // Using host floats (but it's fine, these operations do not have guaranteed precision). let f_host = f.to_host(); @@ -866,7 +867,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { | "atan2" | "fdim" => { - let [f1, f2] = this.check_shim(abi, Conv::C , link_name, args)?; + let [f1, f2] = this.check_shim(abi, CanonAbi::C , link_name, args)?; let f1 = this.read_scalar(f1)?.to_f64()?; let f2 = this.read_scalar(f2)?.to_f64()?; // underscore case for windows, here and below @@ -895,7 +896,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { | "ldexp" | "scalbn" => { - let [x, exp] = this.check_shim(abi, Conv::C , link_name, args)?; + let [x, exp] = this.check_shim(abi, CanonAbi::C , link_name, args)?; // For radix-2 (binary) systems, `ldexp` and `scalbn` are the same. let x = this.read_scalar(x)?.to_f64()?; let exp = this.read_scalar(exp)?.to_i32()?; @@ -905,7 +906,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { this.write_scalar(res, dest)?; } "lgammaf_r" => { - let [x, signp] = this.check_shim(abi, Conv::C, link_name, args)?; + let [x, signp] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let x = this.read_scalar(x)?.to_f32()?; let signp = this.deref_pointer_as(signp, this.machine.layouts.i32)?; @@ -921,7 +922,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { this.write_scalar(res, dest)?; } "lgamma_r" => { - let [x, signp] = this.check_shim(abi, Conv::C, link_name, args)?; + let [x, signp] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let x = this.read_scalar(x)?.to_f64()?; let signp = this.deref_pointer_as(signp, this.machine.layouts.i32)?; @@ -939,7 +940,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { // LLVM intrinsics "llvm.prefetch" => { - let [p, rw, loc, ty] = this.check_shim(abi, Conv::C, link_name, args)?; + let [p, rw, loc, ty] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let _ = this.read_pointer(p)?; let rw = this.read_scalar(rw)?.to_i32()?; @@ -966,7 +967,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { // Used to implement the x86 `_mm{,256,512}_popcnt_epi{8,16,32,64}` and wasm // `{i,u}8x16_popcnt` functions. name if name.starts_with("llvm.ctpop.v") => { - let [op] = this.check_shim(abi, Conv::C, link_name, args)?; + let [op] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (op, op_len) = this.project_to_simd(op)?; let (dest, dest_len) = this.project_to_simd(dest)?; @@ -1002,7 +1003,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { } // FIXME: Move this to an `arm` submodule. "llvm.arm.hint" if this.tcx.sess.target.arch == "arm" => { - let [arg] = this.check_shim(abi, Conv::C, link_name, args)?; + let [arg] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let arg = this.read_scalar(arg)?.to_i32()?; // Note that different arguments might have different target feature requirements. match arg { diff --git a/src/tools/miri/src/shims/unix/android/foreign_items.rs b/src/tools/miri/src/shims/unix/android/foreign_items.rs index 0e7cf7153f5b3..690b5295681d9 100644 --- a/src/tools/miri/src/shims/unix/android/foreign_items.rs +++ b/src/tools/miri/src/shims/unix/android/foreign_items.rs @@ -1,6 +1,7 @@ +use rustc_abi::CanonAbi; use rustc_middle::ty::Ty; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use crate::shims::unix::android::thread::prctl; use crate::shims::unix::linux_like::epoll::EvalContextExt as _; @@ -25,29 +26,29 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { match link_name.as_str() { // epoll, eventfd "epoll_create1" => { - let [flag] = this.check_shim(abi, Conv::C, link_name, args)?; + let [flag] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.epoll_create1(flag)?; this.write_scalar(result, dest)?; } "epoll_ctl" => { - let [epfd, op, fd, event] = this.check_shim(abi, Conv::C, link_name, args)?; + let [epfd, op, fd, event] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.epoll_ctl(epfd, op, fd, event)?; this.write_scalar(result, dest)?; } "epoll_wait" => { let [epfd, events, maxevents, timeout] = - this.check_shim(abi, Conv::C, link_name, args)?; + this.check_shim(abi, CanonAbi::C, link_name, args)?; this.epoll_wait(epfd, events, maxevents, timeout, dest)?; } "eventfd" => { - let [val, flag] = this.check_shim(abi, Conv::C, link_name, args)?; + let [val, flag] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.eventfd(val, flag)?; this.write_scalar(result, dest)?; } // Miscellaneous "__errno" => { - let [] = this.check_shim(abi, Conv::C, link_name, args)?; + let [] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let errno_place = this.last_error_place()?; this.write_scalar(errno_place.to_ref(this).to_scalar(), dest)?; } diff --git a/src/tools/miri/src/shims/unix/android/thread.rs b/src/tools/miri/src/shims/unix/android/thread.rs index aa3a05ead85b4..5d17d6c8517b4 100644 --- a/src/tools/miri/src/shims/unix/android/thread.rs +++ b/src/tools/miri/src/shims/unix/android/thread.rs @@ -1,7 +1,7 @@ -use rustc_abi::Size; +use rustc_abi::{CanonAbi, Size}; use rustc_middle::ty::Ty; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use crate::helpers::check_min_vararg_count; use crate::shims::unix::thread::{EvalContextExt as _, ThreadNameResult}; @@ -16,7 +16,7 @@ pub fn prctl<'tcx>( args: &[OpTy<'tcx>], dest: &MPlaceTy<'tcx>, ) -> InterpResult<'tcx> { - let ([op], varargs) = ecx.check_shim_variadic(abi, Conv::C, link_name, args)?; + let ([op], varargs) = ecx.check_shim_variadic(abi, CanonAbi::C, link_name, args)?; // FIXME: Use constants once https://github.com/rust-lang/libc/pull/3941 backported to the 0.2 branch. let pr_set_name = 15; diff --git a/src/tools/miri/src/shims/unix/foreign_items.rs b/src/tools/miri/src/shims/unix/foreign_items.rs index 026aa1f950399..9106ef94c435b 100644 --- a/src/tools/miri/src/shims/unix/foreign_items.rs +++ b/src/tools/miri/src/shims/unix/foreign_items.rs @@ -1,11 +1,11 @@ use std::ffi::OsStr; use std::str; -use rustc_abi::{ExternAbi, Size}; +use rustc_abi::{CanonAbi, ExternAbi, Size}; use rustc_middle::ty::Ty; use rustc_middle::ty::layout::LayoutOf; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use self::shims::unix::android::foreign_items as android; use self::shims::unix::freebsd::foreign_items as freebsd; @@ -334,7 +334,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } "fcntl" => { let ([fd_num, cmd], varargs) = - this.check_shim_variadic(abi, Conv::C, link_name, args)?; + this.check_shim_variadic(abi, CanonAbi::C, link_name, args)?; let result = this.fcntl(fd_num, cmd, varargs)?; this.write_scalar(result, dest)?; } @@ -387,7 +387,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // `open` is variadic, the third argument is only present when the second argument // has O_CREAT (or on linux O_TMPFILE, but miri doesn't support that) set let ([path_raw, flag], varargs) = - this.check_shim_variadic(abi, Conv::C, link_name, args)?; + this.check_shim_variadic(abi, CanonAbi::C, link_name, args)?; let result = this.open(path_raw, flag, varargs)?; this.write_scalar(result, dest)?; } @@ -701,20 +701,20 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Allocation "posix_memalign" => { - let [memptr, align, size] = this.check_shim(abi, Conv::C, link_name, args)?; + let [memptr, align, size] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.posix_memalign(memptr, align, size)?; this.write_scalar(result, dest)?; } "mmap" => { let [addr, length, prot, flags, fd, offset] = - this.check_shim(abi, Conv::C, link_name, args)?; + this.check_shim(abi, CanonAbi::C, link_name, args)?; let offset = this.read_scalar(offset)?.to_int(this.libc_ty_layout("off_t").size)?; let ptr = this.mmap(addr, length, prot, flags, fd, offset)?; this.write_scalar(ptr, dest)?; } "munmap" => { - let [addr, length] = this.check_shim(abi, Conv::C, link_name, args)?; + let [addr, length] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.munmap(addr, length)?; this.write_scalar(result, dest)?; } @@ -722,7 +722,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { "reallocarray" => { // Currently this function does not exist on all Unixes, e.g. on macOS. this.check_target_os(&["linux", "freebsd", "android"], link_name)?; - let [ptr, nmemb, size] = this.check_shim(abi, Conv::C, link_name, args)?; + let [ptr, nmemb, size] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let ptr = this.read_pointer(ptr)?; let nmemb = this.read_target_usize(nmemb)?; let size = this.read_target_usize(size)?; @@ -745,14 +745,14 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { "aligned_alloc" => { // This is a C11 function, we assume all Unixes have it. // (MSVC explicitly does not support this.) - let [align, size] = this.check_shim(abi, Conv::C, link_name, args)?; + let [align, size] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let res = this.aligned_alloc(align, size)?; this.write_pointer(res, dest)?; } // Dynamic symbol loading "dlsym" => { - let [handle, symbol] = this.check_shim(abi, Conv::C, link_name, args)?; + let [handle, symbol] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.read_target_usize(handle)?; let symbol = this.read_pointer(symbol)?; let name = this.read_c_str(symbol)?; @@ -768,7 +768,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Thread-local storage "pthread_key_create" => { - let [key, dtor] = this.check_shim(abi, Conv::C, link_name, args)?; + let [key, dtor] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let key_place = this.deref_pointer_as(key, this.libc_ty_layout("pthread_key_t"))?; let dtor = this.read_pointer(dtor)?; @@ -796,21 +796,21 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { this.write_null(dest)?; } "pthread_key_delete" => { - let [key] = this.check_shim(abi, Conv::C, link_name, args)?; + let [key] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let key = this.read_scalar(key)?.to_bits(key.layout.size)?; this.machine.tls.delete_tls_key(key)?; // Return success (0) this.write_null(dest)?; } "pthread_getspecific" => { - let [key] = this.check_shim(abi, Conv::C, link_name, args)?; + let [key] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let key = this.read_scalar(key)?.to_bits(key.layout.size)?; let active_thread = this.active_thread(); let ptr = this.machine.tls.load_tls(key, active_thread, this)?; this.write_scalar(ptr, dest)?; } "pthread_setspecific" => { - let [key, new_ptr] = this.check_shim(abi, Conv::C, link_name, args)?; + let [key, new_ptr] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let key = this.read_scalar(key)?.to_bits(key.layout.size)?; let active_thread = this.active_thread(); let new_data = this.read_scalar(new_ptr)?; @@ -822,156 +822,157 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Synchronization primitives "pthread_mutexattr_init" => { - let [attr] = this.check_shim(abi, Conv::C, link_name, args)?; + let [attr] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.pthread_mutexattr_init(attr)?; this.write_null(dest)?; } "pthread_mutexattr_settype" => { - let [attr, kind] = this.check_shim(abi, Conv::C, link_name, args)?; + let [attr, kind] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.pthread_mutexattr_settype(attr, kind)?; this.write_scalar(result, dest)?; } "pthread_mutexattr_destroy" => { - let [attr] = this.check_shim(abi, Conv::C, link_name, args)?; + let [attr] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.pthread_mutexattr_destroy(attr)?; this.write_null(dest)?; } "pthread_mutex_init" => { - let [mutex, attr] = this.check_shim(abi, Conv::C, link_name, args)?; + let [mutex, attr] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.pthread_mutex_init(mutex, attr)?; this.write_null(dest)?; } "pthread_mutex_lock" => { - let [mutex] = this.check_shim(abi, Conv::C, link_name, args)?; + let [mutex] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.pthread_mutex_lock(mutex, dest)?; } "pthread_mutex_trylock" => { - let [mutex] = this.check_shim(abi, Conv::C, link_name, args)?; + let [mutex] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.pthread_mutex_trylock(mutex)?; this.write_scalar(result, dest)?; } "pthread_mutex_unlock" => { - let [mutex] = this.check_shim(abi, Conv::C, link_name, args)?; + let [mutex] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.pthread_mutex_unlock(mutex)?; this.write_scalar(result, dest)?; } "pthread_mutex_destroy" => { - let [mutex] = this.check_shim(abi, Conv::C, link_name, args)?; + let [mutex] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.pthread_mutex_destroy(mutex)?; this.write_int(0, dest)?; } "pthread_rwlock_rdlock" => { - let [rwlock] = this.check_shim(abi, Conv::C, link_name, args)?; + let [rwlock] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.pthread_rwlock_rdlock(rwlock, dest)?; } "pthread_rwlock_tryrdlock" => { - let [rwlock] = this.check_shim(abi, Conv::C, link_name, args)?; + let [rwlock] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.pthread_rwlock_tryrdlock(rwlock)?; this.write_scalar(result, dest)?; } "pthread_rwlock_wrlock" => { - let [rwlock] = this.check_shim(abi, Conv::C, link_name, args)?; + let [rwlock] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.pthread_rwlock_wrlock(rwlock, dest)?; } "pthread_rwlock_trywrlock" => { - let [rwlock] = this.check_shim(abi, Conv::C, link_name, args)?; + let [rwlock] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.pthread_rwlock_trywrlock(rwlock)?; this.write_scalar(result, dest)?; } "pthread_rwlock_unlock" => { - let [rwlock] = this.check_shim(abi, Conv::C, link_name, args)?; + let [rwlock] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.pthread_rwlock_unlock(rwlock)?; this.write_null(dest)?; } "pthread_rwlock_destroy" => { - let [rwlock] = this.check_shim(abi, Conv::C, link_name, args)?; + let [rwlock] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.pthread_rwlock_destroy(rwlock)?; this.write_null(dest)?; } "pthread_condattr_init" => { - let [attr] = this.check_shim(abi, Conv::C, link_name, args)?; + let [attr] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.pthread_condattr_init(attr)?; this.write_null(dest)?; } "pthread_condattr_setclock" => { - let [attr, clock_id] = this.check_shim(abi, Conv::C, link_name, args)?; + let [attr, clock_id] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.pthread_condattr_setclock(attr, clock_id)?; this.write_scalar(result, dest)?; } "pthread_condattr_getclock" => { - let [attr, clock_id] = this.check_shim(abi, Conv::C, link_name, args)?; + let [attr, clock_id] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.pthread_condattr_getclock(attr, clock_id)?; this.write_null(dest)?; } "pthread_condattr_destroy" => { - let [attr] = this.check_shim(abi, Conv::C, link_name, args)?; + let [attr] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.pthread_condattr_destroy(attr)?; this.write_null(dest)?; } "pthread_cond_init" => { - let [cond, attr] = this.check_shim(abi, Conv::C, link_name, args)?; + let [cond, attr] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.pthread_cond_init(cond, attr)?; this.write_null(dest)?; } "pthread_cond_signal" => { - let [cond] = this.check_shim(abi, Conv::C, link_name, args)?; + let [cond] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.pthread_cond_signal(cond)?; this.write_null(dest)?; } "pthread_cond_broadcast" => { - let [cond] = this.check_shim(abi, Conv::C, link_name, args)?; + let [cond] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.pthread_cond_broadcast(cond)?; this.write_null(dest)?; } "pthread_cond_wait" => { - let [cond, mutex] = this.check_shim(abi, Conv::C, link_name, args)?; + let [cond, mutex] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.pthread_cond_wait(cond, mutex, dest)?; } "pthread_cond_timedwait" => { - let [cond, mutex, abstime] = this.check_shim(abi, Conv::C, link_name, args)?; + let [cond, mutex, abstime] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.pthread_cond_timedwait(cond, mutex, abstime, dest)?; } "pthread_cond_destroy" => { - let [cond] = this.check_shim(abi, Conv::C, link_name, args)?; + let [cond] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.pthread_cond_destroy(cond)?; this.write_null(dest)?; } // Threading "pthread_create" => { - let [thread, attr, start, arg] = this.check_shim(abi, Conv::C, link_name, args)?; + let [thread, attr, start, arg] = + this.check_shim(abi, CanonAbi::C, link_name, args)?; this.pthread_create(thread, attr, start, arg)?; this.write_null(dest)?; } "pthread_join" => { - let [thread, retval] = this.check_shim(abi, Conv::C, link_name, args)?; + let [thread, retval] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let res = this.pthread_join(thread, retval)?; this.write_scalar(res, dest)?; } "pthread_detach" => { - let [thread] = this.check_shim(abi, Conv::C, link_name, args)?; + let [thread] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let res = this.pthread_detach(thread)?; this.write_scalar(res, dest)?; } "pthread_self" => { - let [] = this.check_shim(abi, Conv::C, link_name, args)?; + let [] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let res = this.pthread_self()?; this.write_scalar(res, dest)?; } "sched_yield" => { - let [] = this.check_shim(abi, Conv::C, link_name, args)?; + let [] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.sched_yield()?; this.write_null(dest)?; } "nanosleep" => { - let [req, rem] = this.check_shim(abi, Conv::C, link_name, args)?; + let [req, rem] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.nanosleep(req, rem)?; this.write_scalar(result, dest)?; } "sched_getaffinity" => { // Currently this function does not exist on all Unixes, e.g. on macOS. this.check_target_os(&["linux", "freebsd", "android"], link_name)?; - let [pid, cpusetsize, mask] = this.check_shim(abi, Conv::C, link_name, args)?; + let [pid, cpusetsize, mask] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let pid = this.read_scalar(pid)?.to_u32()?; let cpusetsize = this.read_target_usize(cpusetsize)?; let mask = this.read_pointer(mask)?; @@ -1008,7 +1009,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { "sched_setaffinity" => { // Currently this function does not exist on all Unixes, e.g. on macOS. this.check_target_os(&["linux", "freebsd", "android"], link_name)?; - let [pid, cpusetsize, mask] = this.check_shim(abi, Conv::C, link_name, args)?; + let [pid, cpusetsize, mask] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let pid = this.read_scalar(pid)?.to_u32()?; let cpusetsize = this.read_target_usize(cpusetsize)?; let mask = this.read_pointer(mask)?; @@ -1048,12 +1049,13 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Miscellaneous "isatty" => { - let [fd] = this.check_shim(abi, Conv::C, link_name, args)?; + let [fd] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.isatty(fd)?; this.write_scalar(result, dest)?; } "pthread_atfork" => { - let [prepare, parent, child] = this.check_shim(abi, Conv::C, link_name, args)?; + let [prepare, parent, child] = + this.check_shim(abi, CanonAbi::C, link_name, args)?; this.read_pointer(prepare)?; this.read_pointer(parent)?; this.read_pointer(child)?; @@ -1067,7 +1069,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { &["linux", "macos", "freebsd", "illumos", "solaris", "android"], link_name, )?; - let [buf, bufsize] = this.check_shim(abi, Conv::C, link_name, args)?; + let [buf, bufsize] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let buf = this.read_pointer(buf)?; let bufsize = this.read_target_usize(bufsize)?; @@ -1085,7 +1087,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } "strerror_r" => { - let [errnum, buf, buflen] = this.check_shim(abi, Conv::C, link_name, args)?; + let [errnum, buf, buflen] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.strerror_r(errnum, buf, buflen)?; this.write_scalar(result, dest)?; } @@ -1097,7 +1099,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { &["linux", "freebsd", "illumos", "solaris", "android"], link_name, )?; - let [ptr, len, flags] = this.check_shim(abi, Conv::C, link_name, args)?; + let [ptr, len, flags] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let ptr = this.read_pointer(ptr)?; let len = this.read_target_usize(len)?; let _flags = this.read_scalar(flags)?.to_i32()?; @@ -1109,7 +1111,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // This function is non-standard but exists with the same signature and // same behavior (eg never fails) on FreeBSD and Solaris/Illumos. this.check_target_os(&["freebsd", "illumos", "solaris"], link_name)?; - let [ptr, len] = this.check_shim(abi, Conv::C, link_name, args)?; + let [ptr, len] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let ptr = this.read_pointer(ptr)?; let len = this.read_target_usize(len)?; this.gen_random(ptr, len)?; @@ -1133,12 +1135,12 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { link_name, )?; // This function looks and behaves excatly like miri_start_unwind. - let [payload] = this.check_shim(abi, Conv::C, link_name, args)?; + let [payload] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.handle_miri_start_unwind(payload)?; return interp_ok(EmulateItemResult::NeedsUnwind); } "getuid" | "geteuid" => { - let [] = this.check_shim(abi, Conv::C, link_name, args)?; + let [] = this.check_shim(abi, CanonAbi::C, link_name, args)?; // For now, just pretend we always have this fixed UID. this.write_int(UID, dest)?; } @@ -1146,7 +1148,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Incomplete shims that we "stub out" just to get pre-main initialization code to work. // These shims are enabled only when the caller is in the standard library. "pthread_attr_getguardsize" if this.frame_in_std() => { - let [_attr, guard_size] = this.check_shim(abi, Conv::C, link_name, args)?; + let [_attr, guard_size] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let guard_size_layout = this.machine.layouts.usize; let guard_size = this.deref_pointer_as(guard_size, guard_size_layout)?; this.write_scalar( @@ -1159,11 +1161,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } "pthread_attr_init" | "pthread_attr_destroy" if this.frame_in_std() => { - let [_] = this.check_shim(abi, Conv::C, link_name, args)?; + let [_] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.write_null(dest)?; } "pthread_attr_setstacksize" if this.frame_in_std() => { - let [_, _] = this.check_shim(abi, Conv::C, link_name, args)?; + let [_, _] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.write_null(dest)?; } @@ -1171,7 +1173,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // We don't support "pthread_attr_setstack", so we just pretend all stacks have the same values here. // Hence we can mostly ignore the input `attr_place`. let [attr_place, addr_place, size_place] = - this.check_shim(abi, Conv::C, link_name, args)?; + this.check_shim(abi, CanonAbi::C, link_name, args)?; let _attr_place = this.deref_pointer_as(attr_place, this.libc_ty_layout("pthread_attr_t"))?; let addr_place = this.deref_pointer_as(addr_place, this.machine.layouts.usize)?; @@ -1191,18 +1193,18 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } "signal" | "sigaltstack" if this.frame_in_std() => { - let [_, _] = this.check_shim(abi, Conv::C, link_name, args)?; + let [_, _] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.write_null(dest)?; } "sigaction" | "mprotect" if this.frame_in_std() => { - let [_, _, _] = this.check_shim(abi, Conv::C, link_name, args)?; + let [_, _, _] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.write_null(dest)?; } "getpwuid_r" | "__posix_getpwuid_r" if this.frame_in_std() => { // getpwuid_r is the standard name, __posix_getpwuid_r is used on solarish let [uid, pwd, buf, buflen, result] = - this.check_shim(abi, Conv::C, link_name, args)?; + this.check_shim(abi, CanonAbi::C, link_name, args)?; this.check_no_isolation("`getpwuid_r`")?; let uid = this.read_scalar(uid)?.to_u32()?; diff --git a/src/tools/miri/src/shims/unix/freebsd/foreign_items.rs b/src/tools/miri/src/shims/unix/freebsd/foreign_items.rs index 533a741fea3f2..42502d5bf09af 100644 --- a/src/tools/miri/src/shims/unix/freebsd/foreign_items.rs +++ b/src/tools/miri/src/shims/unix/freebsd/foreign_items.rs @@ -1,6 +1,7 @@ +use rustc_abi::CanonAbi; use rustc_middle::ty::Ty; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use super::sync::EvalContextExt as _; use crate::shims::unix::*; @@ -23,7 +24,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { match link_name.as_str() { // Threading "pthread_setname_np" => { - let [thread, name] = this.check_shim(abi, Conv::C, link_name, args)?; + let [thread, name] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let max_len = u64::MAX; // FreeBSD does not seem to have a limit. let res = match this.pthread_setname_np( this.read_scalar(thread)?, @@ -38,7 +39,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { this.write_scalar(res, dest)?; } "pthread_getname_np" => { - let [thread, name, len] = this.check_shim(abi, Conv::C, link_name, args)?; + let [thread, name, len] = this.check_shim(abi, CanonAbi::C, link_name, args)?; // FreeBSD's pthread_getname_np uses strlcpy, which truncates the resulting value, // but always adds a null terminator (except for zero-sized buffers). // https://github.com/freebsd/freebsd-src/blob/c2d93a803acef634bd0eede6673aeea59e90c277/lib/libthr/thread/thr_info.c#L119-L144 @@ -59,7 +60,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { "cpuset_getaffinity" => { // The "same" kind of api as `sched_getaffinity` but more fine grained control for FreeBSD specifically. let [level, which, id, set_size, mask] = - this.check_shim(abi, Conv::C, link_name, args)?; + this.check_shim(abi, CanonAbi::C, link_name, args)?; let level = this.read_scalar(level)?.to_i32()?; let which = this.read_scalar(which)?.to_i32()?; @@ -123,7 +124,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Synchronization primitives "_umtx_op" => { let [obj, op, val, uaddr, uaddr2] = - this.check_shim(abi, Conv::C, link_name, args)?; + this.check_shim(abi, CanonAbi::C, link_name, args)?; this._umtx_op(obj, op, val, uaddr, uaddr2, dest)?; } @@ -131,29 +132,29 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // For those, we both intercept `func` and `call@FBSD_1.0` symbols cases // since freebsd 12 the former form can be expected. "stat" | "stat@FBSD_1.0" => { - let [path, buf] = this.check_shim(abi, Conv::C, link_name, args)?; + let [path, buf] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.macos_fbsd_solarish_stat(path, buf)?; this.write_scalar(result, dest)?; } "lstat" | "lstat@FBSD_1.0" => { - let [path, buf] = this.check_shim(abi, Conv::C, link_name, args)?; + let [path, buf] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.macos_fbsd_solarish_lstat(path, buf)?; this.write_scalar(result, dest)?; } "fstat" | "fstat@FBSD_1.0" => { - let [fd, buf] = this.check_shim(abi, Conv::C, link_name, args)?; + let [fd, buf] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.macos_fbsd_solarish_fstat(fd, buf)?; this.write_scalar(result, dest)?; } "readdir_r" | "readdir_r@FBSD_1.0" => { - let [dirp, entry, result] = this.check_shim(abi, Conv::C, link_name, args)?; + let [dirp, entry, result] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.macos_fbsd_readdir_r(dirp, entry, result)?; this.write_scalar(result, dest)?; } // Miscellaneous "__error" => { - let [] = this.check_shim(abi, Conv::C, link_name, args)?; + let [] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let errno_place = this.last_error_place()?; this.write_scalar(errno_place.to_ref(this).to_scalar(), dest)?; } @@ -161,7 +162,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Incomplete shims that we "stub out" just to get pre-main initialization code to work. // These shims are enabled only when the caller is in the standard library. "pthread_attr_get_np" if this.frame_in_std() => { - let [_thread, _attr] = this.check_shim(abi, Conv::C, link_name, args)?; + let [_thread, _attr] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.write_null(dest)?; } diff --git a/src/tools/miri/src/shims/unix/linux/foreign_items.rs b/src/tools/miri/src/shims/unix/linux/foreign_items.rs index 51c2434d68ac8..aeaff1cb13a53 100644 --- a/src/tools/miri/src/shims/unix/linux/foreign_items.rs +++ b/src/tools/miri/src/shims/unix/linux/foreign_items.rs @@ -1,6 +1,7 @@ +use rustc_abi::CanonAbi; use rustc_middle::ty::Ty; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use self::shims::unix::linux::mem::EvalContextExt as _; use self::shims::unix::linux_like::epoll::EvalContextExt as _; @@ -36,47 +37,48 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { match link_name.as_str() { // File related shims "readdir64" => { - let [dirp] = this.check_shim(abi, Conv::C, link_name, args)?; + let [dirp] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.linux_solarish_readdir64("dirent64", dirp)?; this.write_scalar(result, dest)?; } "sync_file_range" => { - let [fd, offset, nbytes, flags] = this.check_shim(abi, Conv::C, link_name, args)?; + let [fd, offset, nbytes, flags] = + this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.sync_file_range(fd, offset, nbytes, flags)?; this.write_scalar(result, dest)?; } "statx" => { let [dirfd, pathname, flags, mask, statxbuf] = - this.check_shim(abi, Conv::C, link_name, args)?; + this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.linux_statx(dirfd, pathname, flags, mask, statxbuf)?; this.write_scalar(result, dest)?; } // epoll, eventfd "epoll_create1" => { - let [flag] = this.check_shim(abi, Conv::C, link_name, args)?; + let [flag] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.epoll_create1(flag)?; this.write_scalar(result, dest)?; } "epoll_ctl" => { - let [epfd, op, fd, event] = this.check_shim(abi, Conv::C, link_name, args)?; + let [epfd, op, fd, event] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.epoll_ctl(epfd, op, fd, event)?; this.write_scalar(result, dest)?; } "epoll_wait" => { let [epfd, events, maxevents, timeout] = - this.check_shim(abi, Conv::C, link_name, args)?; + this.check_shim(abi, CanonAbi::C, link_name, args)?; this.epoll_wait(epfd, events, maxevents, timeout, dest)?; } "eventfd" => { - let [val, flag] = this.check_shim(abi, Conv::C, link_name, args)?; + let [val, flag] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.eventfd(val, flag)?; this.write_scalar(result, dest)?; } // Threading "pthread_setname_np" => { - let [thread, name] = this.check_shim(abi, Conv::C, link_name, args)?; + let [thread, name] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let res = match this.pthread_setname_np( this.read_scalar(thread)?, this.read_scalar(name)?, @@ -91,7 +93,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { this.write_scalar(res, dest)?; } "pthread_getname_np" => { - let [thread, name, len] = this.check_shim(abi, Conv::C, link_name, args)?; + let [thread, name, len] = this.check_shim(abi, CanonAbi::C, link_name, args)?; // The function's behavior isn't portable between platforms. // In case of glibc, the length of the output buffer must // be not shorter than TASK_COMM_LEN. @@ -114,7 +116,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { this.write_scalar(res, dest)?; } "gettid" => { - let [] = this.check_shim(abi, Conv::C, link_name, args)?; + let [] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.linux_gettid()?; this.write_scalar(result, dest)?; } @@ -127,34 +129,34 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Miscellaneous "mmap64" => { let [addr, length, prot, flags, fd, offset] = - this.check_shim(abi, Conv::C, link_name, args)?; + this.check_shim(abi, CanonAbi::C, link_name, args)?; let offset = this.read_scalar(offset)?.to_i64()?; let ptr = this.mmap(addr, length, prot, flags, fd, offset.into())?; this.write_scalar(ptr, dest)?; } "mremap" => { let ([old_address, old_size, new_size, flags], _) = - this.check_shim_variadic(abi, Conv::C, link_name, args)?; + this.check_shim_variadic(abi, CanonAbi::C, link_name, args)?; let ptr = this.mremap(old_address, old_size, new_size, flags)?; this.write_scalar(ptr, dest)?; } "__xpg_strerror_r" => { - let [errnum, buf, buflen] = this.check_shim(abi, Conv::C, link_name, args)?; + let [errnum, buf, buflen] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.strerror_r(errnum, buf, buflen)?; this.write_scalar(result, dest)?; } "__errno_location" => { - let [] = this.check_shim(abi, Conv::C, link_name, args)?; + let [] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let errno_place = this.last_error_place()?; this.write_scalar(errno_place.to_ref(this).to_scalar(), dest)?; } "__libc_current_sigrtmin" => { - let [] = this.check_shim(abi, Conv::C, link_name, args)?; + let [] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.write_int(SIGRTMIN, dest)?; } "__libc_current_sigrtmax" => { - let [] = this.check_shim(abi, Conv::C, link_name, args)?; + let [] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.write_int(SIGRTMAX, dest)?; } @@ -162,7 +164,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Incomplete shims that we "stub out" just to get pre-main initialization code to work. // These shims are enabled only when the caller is in the standard library. "pthread_getattr_np" if this.frame_in_std() => { - let [_thread, _attr] = this.check_shim(abi, Conv::C, link_name, args)?; + let [_thread, _attr] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.write_null(dest)?; } diff --git a/src/tools/miri/src/shims/unix/linux_like/syscall.rs b/src/tools/miri/src/shims/unix/linux_like/syscall.rs index 22c6dc975070b..d42d6b9073ecf 100644 --- a/src/tools/miri/src/shims/unix/linux_like/syscall.rs +++ b/src/tools/miri/src/shims/unix/linux_like/syscall.rs @@ -1,6 +1,7 @@ +use rustc_abi::CanonAbi; use rustc_middle::ty::Ty; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use crate::helpers::check_min_vararg_count; use crate::shims::unix::linux_like::eventfd::EvalContextExt as _; @@ -14,7 +15,7 @@ pub fn syscall<'tcx>( args: &[OpTy<'tcx>], dest: &MPlaceTy<'tcx>, ) -> InterpResult<'tcx> { - let ([op], varargs) = ecx.check_shim_variadic(abi, Conv::C, link_name, args)?; + let ([op], varargs) = ecx.check_shim_variadic(abi, CanonAbi::C, link_name, args)?; // The syscall variadic function is legal to call with more arguments than needed, // extra arguments are simply ignored. The important check is that when we use an // argument, we have to also check all arguments *before* it to ensure that they diff --git a/src/tools/miri/src/shims/unix/macos/foreign_items.rs b/src/tools/miri/src/shims/unix/macos/foreign_items.rs index 0281bb9f71dfc..ae921a013a40e 100644 --- a/src/tools/miri/src/shims/unix/macos/foreign_items.rs +++ b/src/tools/miri/src/shims/unix/macos/foreign_items.rs @@ -1,6 +1,7 @@ +use rustc_abi::CanonAbi; use rustc_middle::ty::Ty; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use super::sync::{EvalContextExt as _, MacOsFutexTimeout}; use crate::shims::unix::*; @@ -34,64 +35,64 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { match link_name.as_str() { // errno "__error" => { - let [] = this.check_shim(abi, Conv::C, link_name, args)?; + let [] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let errno_place = this.last_error_place()?; this.write_scalar(errno_place.to_ref(this).to_scalar(), dest)?; } // File related shims "close$NOCANCEL" => { - let [result] = this.check_shim(abi, Conv::C, link_name, args)?; + let [result] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.close(result)?; this.write_scalar(result, dest)?; } "stat" | "stat64" | "stat$INODE64" => { - let [path, buf] = this.check_shim(abi, Conv::C, link_name, args)?; + let [path, buf] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.macos_fbsd_solarish_stat(path, buf)?; this.write_scalar(result, dest)?; } "lstat" | "lstat64" | "lstat$INODE64" => { - let [path, buf] = this.check_shim(abi, Conv::C, link_name, args)?; + let [path, buf] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.macos_fbsd_solarish_lstat(path, buf)?; this.write_scalar(result, dest)?; } "fstat" | "fstat64" | "fstat$INODE64" => { - let [fd, buf] = this.check_shim(abi, Conv::C, link_name, args)?; + let [fd, buf] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.macos_fbsd_solarish_fstat(fd, buf)?; this.write_scalar(result, dest)?; } "opendir$INODE64" => { - let [name] = this.check_shim(abi, Conv::C, link_name, args)?; + let [name] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.opendir(name)?; this.write_scalar(result, dest)?; } "readdir_r" | "readdir_r$INODE64" => { - let [dirp, entry, result] = this.check_shim(abi, Conv::C, link_name, args)?; + let [dirp, entry, result] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.macos_fbsd_readdir_r(dirp, entry, result)?; this.write_scalar(result, dest)?; } "realpath$DARWIN_EXTSN" => { - let [path, resolved_path] = this.check_shim(abi, Conv::C, link_name, args)?; + let [path, resolved_path] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.realpath(path, resolved_path)?; this.write_scalar(result, dest)?; } "ioctl" => { let ([fd_num, cmd], varargs) = - this.check_shim_variadic(abi, Conv::C, link_name, args)?; + this.check_shim_variadic(abi, CanonAbi::C, link_name, args)?; let result = this.ioctl(fd_num, cmd, varargs)?; this.write_scalar(result, dest)?; } // Environment related shims "_NSGetEnviron" => { - let [] = this.check_shim(abi, Conv::C, link_name, args)?; + let [] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let environ = this.machine.env_vars.unix().environ(); this.write_pointer(environ, dest)?; } // Random data generation "CCRandomGenerateBytes" => { - let [bytes, count] = this.check_shim(abi, Conv::C, link_name, args)?; + let [bytes, count] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let bytes = this.read_pointer(bytes)?; let count = this.read_target_usize(count)?; let success = this.eval_libc_i32("kCCSuccess"); @@ -101,28 +102,28 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Time related shims "mach_absolute_time" => { - let [] = this.check_shim(abi, Conv::C, link_name, args)?; + let [] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.mach_absolute_time()?; this.write_scalar(result, dest)?; } "mach_timebase_info" => { - let [info] = this.check_shim(abi, Conv::C, link_name, args)?; + let [info] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.mach_timebase_info(info)?; this.write_scalar(result, dest)?; } // Access to command-line arguments "_NSGetArgc" => { - let [] = this.check_shim(abi, Conv::C, link_name, args)?; + let [] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.write_pointer(this.machine.argc.expect("machine must be initialized"), dest)?; } "_NSGetArgv" => { - let [] = this.check_shim(abi, Conv::C, link_name, args)?; + let [] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.write_pointer(this.machine.argv.expect("machine must be initialized"), dest)?; } "_NSGetExecutablePath" => { - let [buf, bufsize] = this.check_shim(abi, Conv::C, link_name, args)?; + let [buf, bufsize] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.check_no_isolation("`_NSGetExecutablePath`")?; let buf_ptr = this.read_pointer(buf)?; @@ -147,7 +148,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Thread-local storage "_tlv_atexit" => { - let [dtor, data] = this.check_shim(abi, Conv::C, link_name, args)?; + let [dtor, data] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let dtor = this.read_pointer(dtor)?; let dtor = this.get_ptr_fn(dtor)?.as_instance()?; let data = this.read_scalar(data)?; @@ -157,13 +158,13 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Querying system information "pthread_get_stackaddr_np" => { - let [thread] = this.check_shim(abi, Conv::C, link_name, args)?; + let [thread] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.read_target_usize(thread)?; let stack_addr = Scalar::from_uint(this.machine.stack_addr, this.pointer_size()); this.write_scalar(stack_addr, dest)?; } "pthread_get_stacksize_np" => { - let [thread] = this.check_shim(abi, Conv::C, link_name, args)?; + let [thread] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.read_target_usize(thread)?; let stack_size = Scalar::from_uint(this.machine.stack_size, this.pointer_size()); this.write_scalar(stack_size, dest)?; @@ -171,7 +172,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Threading "pthread_setname_np" => { - let [name] = this.check_shim(abi, Conv::C, link_name, args)?; + let [name] = this.check_shim(abi, CanonAbi::C, link_name, args)?; // The real implementation has logic in two places: // * in userland at https://github.com/apple-oss-distributions/libpthread/blob/c032e0b076700a0a47db75528a282b8d3a06531a/src/pthread.c#L1178-L1200, @@ -198,7 +199,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { this.write_scalar(res, dest)?; } "pthread_getname_np" => { - let [thread, name, len] = this.check_shim(abi, Conv::C, link_name, args)?; + let [thread, name, len] = this.check_shim(abi, CanonAbi::C, link_name, args)?; // The function's behavior isn't portable between platforms. // In case of macOS, a truncated name (due to a too small buffer) @@ -225,7 +226,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Synchronization primitives "os_sync_wait_on_address" => { let [addr_op, value_op, size_op, flags_op] = - this.check_shim(abi, Conv::C, link_name, args)?; + this.check_shim(abi, CanonAbi::C, link_name, args)?; this.os_sync_wait_on_address( addr_op, value_op, @@ -237,7 +238,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } "os_sync_wait_on_address_with_deadline" => { let [addr_op, value_op, size_op, flags_op, clock_op, timeout_op] = - this.check_shim(abi, Conv::C, link_name, args)?; + this.check_shim(abi, CanonAbi::C, link_name, args)?; this.os_sync_wait_on_address( addr_op, value_op, @@ -249,7 +250,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } "os_sync_wait_on_address_with_timeout" => { let [addr_op, value_op, size_op, flags_op, clock_op, timeout_op] = - this.check_shim(abi, Conv::C, link_name, args)?; + this.check_shim(abi, CanonAbi::C, link_name, args)?; this.os_sync_wait_on_address( addr_op, value_op, @@ -261,36 +262,36 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } "os_sync_wake_by_address_any" => { let [addr_op, size_op, flags_op] = - this.check_shim(abi, Conv::C, link_name, args)?; + this.check_shim(abi, CanonAbi::C, link_name, args)?; this.os_sync_wake_by_address( addr_op, size_op, flags_op, /* all */ false, dest, )?; } "os_sync_wake_by_address_all" => { let [addr_op, size_op, flags_op] = - this.check_shim(abi, Conv::C, link_name, args)?; + this.check_shim(abi, CanonAbi::C, link_name, args)?; this.os_sync_wake_by_address( addr_op, size_op, flags_op, /* all */ true, dest, )?; } "os_unfair_lock_lock" => { - let [lock_op] = this.check_shim(abi, Conv::C, link_name, args)?; + let [lock_op] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.os_unfair_lock_lock(lock_op)?; } "os_unfair_lock_trylock" => { - let [lock_op] = this.check_shim(abi, Conv::C, link_name, args)?; + let [lock_op] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.os_unfair_lock_trylock(lock_op, dest)?; } "os_unfair_lock_unlock" => { - let [lock_op] = this.check_shim(abi, Conv::C, link_name, args)?; + let [lock_op] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.os_unfair_lock_unlock(lock_op)?; } "os_unfair_lock_assert_owner" => { - let [lock_op] = this.check_shim(abi, Conv::C, link_name, args)?; + let [lock_op] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.os_unfair_lock_assert_owner(lock_op)?; } "os_unfair_lock_assert_not_owner" => { - let [lock_op] = this.check_shim(abi, Conv::C, link_name, args)?; + let [lock_op] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.os_unfair_lock_assert_not_owner(lock_op)?; } diff --git a/src/tools/miri/src/shims/unix/solarish/foreign_items.rs b/src/tools/miri/src/shims/unix/solarish/foreign_items.rs index 21d4f41f48529..e3d15b89be6d6 100644 --- a/src/tools/miri/src/shims/unix/solarish/foreign_items.rs +++ b/src/tools/miri/src/shims/unix/solarish/foreign_items.rs @@ -1,6 +1,7 @@ +use rustc_abi::CanonAbi; use rustc_middle::ty::Ty; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use crate::shims::unix::foreign_items::EvalContextExt as _; use crate::shims::unix::linux_like::epoll::EvalContextExt as _; @@ -26,32 +27,32 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // epoll, eventfd (NOT available on Solaris!) "epoll_create1" => { this.assert_target_os("illumos", "epoll_create1"); - let [flag] = this.check_shim(abi, Conv::C, link_name, args)?; + let [flag] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.epoll_create1(flag)?; this.write_scalar(result, dest)?; } "epoll_ctl" => { this.assert_target_os("illumos", "epoll_ctl"); - let [epfd, op, fd, event] = this.check_shim(abi, Conv::C, link_name, args)?; + let [epfd, op, fd, event] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.epoll_ctl(epfd, op, fd, event)?; this.write_scalar(result, dest)?; } "epoll_wait" => { this.assert_target_os("illumos", "epoll_wait"); let [epfd, events, maxevents, timeout] = - this.check_shim(abi, Conv::C, link_name, args)?; + this.check_shim(abi, CanonAbi::C, link_name, args)?; this.epoll_wait(epfd, events, maxevents, timeout, dest)?; } "eventfd" => { this.assert_target_os("illumos", "eventfd"); - let [val, flag] = this.check_shim(abi, Conv::C, link_name, args)?; + let [val, flag] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.eventfd(val, flag)?; this.write_scalar(result, dest)?; } // Threading "pthread_setname_np" => { - let [thread, name] = this.check_shim(abi, Conv::C, link_name, args)?; + let [thread, name] = this.check_shim(abi, CanonAbi::C, link_name, args)?; // THREAD_NAME_MAX allows a thread name of 31+1 length // https://github.com/illumos/illumos-gate/blob/7671517e13b8123748eda4ef1ee165c6d9dba7fe/usr/src/uts/common/sys/thread.h#L613 let max_len = 32; @@ -69,7 +70,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { this.write_scalar(res, dest)?; } "pthread_getname_np" => { - let [thread, name, len] = this.check_shim(abi, Conv::C, link_name, args)?; + let [thread, name, len] = this.check_shim(abi, CanonAbi::C, link_name, args)?; // See https://illumos.org/man/3C/pthread_getname_np for the error codes. let res = match this.pthread_getname_np( this.read_scalar(thread)?, @@ -86,22 +87,22 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // File related shims "stat" | "stat64" => { - let [path, buf] = this.check_shim(abi, Conv::C, link_name, args)?; + let [path, buf] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.macos_fbsd_solarish_stat(path, buf)?; this.write_scalar(result, dest)?; } "lstat" | "lstat64" => { - let [path, buf] = this.check_shim(abi, Conv::C, link_name, args)?; + let [path, buf] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.macos_fbsd_solarish_lstat(path, buf)?; this.write_scalar(result, dest)?; } "fstat" | "fstat64" => { - let [fd, buf] = this.check_shim(abi, Conv::C, link_name, args)?; + let [fd, buf] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.macos_fbsd_solarish_fstat(fd, buf)?; this.write_scalar(result, dest)?; } "readdir" => { - let [dirp] = this.check_shim(abi, Conv::C, link_name, args)?; + let [dirp] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.linux_solarish_readdir64("dirent", dirp)?; this.write_scalar(result, dest)?; } @@ -109,20 +110,20 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Sockets and pipes "__xnet_socketpair" => { let [domain, type_, protocol, sv] = - this.check_shim(abi, Conv::C, link_name, args)?; + this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.socketpair(domain, type_, protocol, sv)?; this.write_scalar(result, dest)?; } // Miscellaneous "___errno" => { - let [] = this.check_shim(abi, Conv::C, link_name, args)?; + let [] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let errno_place = this.last_error_place()?; this.write_scalar(errno_place.to_ref(this).to_scalar(), dest)?; } "stack_getbounds" => { - let [stack] = this.check_shim(abi, Conv::C, link_name, args)?; + let [stack] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let stack = this.deref_pointer_as(stack, this.libc_ty_layout("stack_t"))?; this.write_int_fields_named( @@ -140,7 +141,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } "pset_info" => { - let [pset, tpe, cpus, list] = this.check_shim(abi, Conv::C, link_name, args)?; + let [pset, tpe, cpus, list] = this.check_shim(abi, CanonAbi::C, link_name, args)?; // We do not need to handle the current process cpu mask, available_parallelism // implementation pass null anyway. We only care for the number of // cpus. @@ -169,7 +170,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } "__sysconf_xpg7" => { - let [val] = this.check_shim(abi, Conv::C, link_name, args)?; + let [val] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.sysconf(val)?; this.write_scalar(result, dest)?; } diff --git a/src/tools/miri/src/shims/wasi/foreign_items.rs b/src/tools/miri/src/shims/wasi/foreign_items.rs index 90de62b9e574a..8d92d0f3381f7 100644 --- a/src/tools/miri/src/shims/wasi/foreign_items.rs +++ b/src/tools/miri/src/shims/wasi/foreign_items.rs @@ -1,6 +1,7 @@ +use rustc_abi::CanonAbi; use rustc_middle::ty::Ty; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use crate::shims::alloc::EvalContextExt as _; use crate::*; @@ -22,12 +23,12 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { match link_name.as_str() { // Allocation "posix_memalign" => { - let [memptr, align, size] = this.check_shim(abi, Conv::C, link_name, args)?; + let [memptr, align, size] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let result = this.posix_memalign(memptr, align, size)?; this.write_scalar(result, dest)?; } "aligned_alloc" => { - let [align, size] = this.check_shim(abi, Conv::C, link_name, args)?; + let [align, size] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let res = this.aligned_alloc(align, size)?; this.write_pointer(res, dest)?; } diff --git a/src/tools/miri/src/shims/windows/foreign_items.rs b/src/tools/miri/src/shims/windows/foreign_items.rs index 98099e07b2eac..10f6df67ad47a 100644 --- a/src/tools/miri/src/shims/windows/foreign_items.rs +++ b/src/tools/miri/src/shims/windows/foreign_items.rs @@ -2,10 +2,10 @@ use std::ffi::OsStr; use std::path::{self, Path, PathBuf}; use std::{io, iter, str}; -use rustc_abi::{Align, Size}; +use rustc_abi::{Align, CanonAbi, Size, X86Call}; use rustc_middle::ty::Ty; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use self::shims::windows::handle::{Handle, PseudoHandle}; use crate::shims::os_str::bytes_to_os_str; @@ -140,7 +140,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // https://github.com/rust-lang/rust/blob/fb00adbdb69266f10df95a4527b767b0ad35ea48/compiler/rustc_target/src/spec/mod.rs#L2766-L2768, // x86-32 Windows uses a different calling convention than other Windows targets // for the "system" ABI. - let sys_conv = if this.tcx.sess.target.arch == "x86" { Conv::X86Stdcall } else { Conv::C }; + let sys_conv = if this.tcx.sess.target.arch == "x86" { + CanonAbi::X86(X86Call::Stdcall) + } else { + CanonAbi::C + }; // See `fn emulate_foreign_item_inner` in `shims/foreign_items.rs` for the general pattern. @@ -856,7 +860,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { ); } // This function looks and behaves excatly like miri_start_unwind. - let [payload] = this.check_shim(abi, Conv::C, link_name, args)?; + let [payload] = this.check_shim(abi, CanonAbi::C, link_name, args)?; this.handle_miri_start_unwind(payload)?; return interp_ok(EmulateItemResult::NeedsUnwind); } diff --git a/src/tools/miri/src/shims/x86/aesni.rs b/src/tools/miri/src/shims/x86/aesni.rs index c6784db67fb8e..7191284b5a3f4 100644 --- a/src/tools/miri/src/shims/x86/aesni.rs +++ b/src/tools/miri/src/shims/x86/aesni.rs @@ -1,7 +1,8 @@ +use rustc_abi::CanonAbi; use rustc_middle::ty::Ty; use rustc_middle::ty::layout::LayoutOf as _; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use crate::*; @@ -26,7 +27,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // `state` with the corresponding 128-bit key of `key`. // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_aesdec_si128 "aesdec" | "aesdec.256" | "aesdec.512" => { - let [state, key] = this.check_shim(abi, Conv::C, link_name, args)?; + let [state, key] = this.check_shim(abi, CanonAbi::C, link_name, args)?; aes_round(this, state, key, dest, |state, key| { let key = aes::Block::from(key.to_le_bytes()); let mut state = aes::Block::from(state.to_le_bytes()); @@ -42,7 +43,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // `state` with the corresponding 128-bit key of `key`. // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_aesdeclast_si128 "aesdeclast" | "aesdeclast.256" | "aesdeclast.512" => { - let [state, key] = this.check_shim(abi, Conv::C, link_name, args)?; + let [state, key] = this.check_shim(abi, CanonAbi::C, link_name, args)?; aes_round(this, state, key, dest, |state, key| { let mut state = aes::Block::from(state.to_le_bytes()); @@ -66,7 +67,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // `state` with the corresponding 128-bit key of `key`. // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_aesenc_si128 "aesenc" | "aesenc.256" | "aesenc.512" => { - let [state, key] = this.check_shim(abi, Conv::C, link_name, args)?; + let [state, key] = this.check_shim(abi, CanonAbi::C, link_name, args)?; aes_round(this, state, key, dest, |state, key| { let key = aes::Block::from(key.to_le_bytes()); let mut state = aes::Block::from(state.to_le_bytes()); @@ -82,7 +83,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // `state` with the corresponding 128-bit key of `key`. // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_aesenclast_si128 "aesenclast" | "aesenclast.256" | "aesenclast.512" => { - let [state, key] = this.check_shim(abi, Conv::C, link_name, args)?; + let [state, key] = this.check_shim(abi, CanonAbi::C, link_name, args)?; aes_round(this, state, key, dest, |state, key| { let mut state = aes::Block::from(state.to_le_bytes()); // `aes::hazmat::cipher_round` does the following operations: @@ -102,7 +103,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Used to implement the _mm_aesimc_si128 function. // Performs the AES InvMixColumns operation on `op` "aesimc" => { - let [op] = this.check_shim(abi, Conv::C, link_name, args)?; + let [op] = this.check_shim(abi, CanonAbi::C, link_name, args)?; // Transmute to `u128` let op = op.transmute(this.machine.layouts.u128, this)?; let dest = dest.transmute(this.machine.layouts.u128, this)?; diff --git a/src/tools/miri/src/shims/x86/avx.rs b/src/tools/miri/src/shims/x86/avx.rs index 3aeb2b429dad5..37539fec74858 100644 --- a/src/tools/miri/src/shims/x86/avx.rs +++ b/src/tools/miri/src/shims/x86/avx.rs @@ -1,9 +1,10 @@ +use rustc_abi::CanonAbi; use rustc_apfloat::ieee::{Double, Single}; use rustc_middle::mir; use rustc_middle::ty::Ty; use rustc_middle::ty::layout::LayoutOf as _; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use super::{ FloatBinOp, FloatUnaryOp, bin_op_simd_float_all, conditional_dot_product, convert_float_to_int, @@ -33,7 +34,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // matches the IEEE min/max operations, while x86 has different // semantics. "min.ps.256" | "max.ps.256" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let which = match unprefixed_name { "min.ps.256" => FloatBinOp::Min, @@ -45,7 +46,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } // Used to implement _mm256_min_pd and _mm256_max_pd functions. "min.pd.256" | "max.pd.256" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let which = match unprefixed_name { "min.pd.256" => FloatBinOp::Min, @@ -58,21 +59,21 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Used to implement the _mm256_round_ps function. // Rounds the elements of `op` according to `rounding`. "round.ps.256" => { - let [op, rounding] = this.check_shim(abi, Conv::C, link_name, args)?; + let [op, rounding] = this.check_shim(abi, CanonAbi::C, link_name, args)?; round_all::(this, op, rounding, dest)?; } // Used to implement the _mm256_round_pd function. // Rounds the elements of `op` according to `rounding`. "round.pd.256" => { - let [op, rounding] = this.check_shim(abi, Conv::C, link_name, args)?; + let [op, rounding] = this.check_shim(abi, CanonAbi::C, link_name, args)?; round_all::(this, op, rounding, dest)?; } // Used to implement _mm256_{rcp,rsqrt}_ps functions. // Performs the operations on all components of `op`. "rcp.ps.256" | "rsqrt.ps.256" => { - let [op] = this.check_shim(abi, Conv::C, link_name, args)?; + let [op] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let which = match unprefixed_name { "rcp.ps.256" => FloatUnaryOp::Rcp, @@ -84,7 +85,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } // Used to implement the _mm256_dp_ps function. "dp.ps.256" => { - let [left, right, imm] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right, imm] = this.check_shim(abi, CanonAbi::C, link_name, args)?; conditional_dot_product(this, left, right, imm, dest)?; } @@ -92,7 +93,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Horizontally add/subtract adjacent floating point values // in `left` and `right`. "hadd.ps.256" | "hadd.pd.256" | "hsub.ps.256" | "hsub.pd.256" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let which = match unprefixed_name { "hadd.ps.256" | "hadd.pd.256" => mir::BinOp::Add, @@ -107,7 +108,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // and `right`. For each component, returns 0 if false or u32::MAX // if true. "cmp.ps.256" => { - let [left, right, imm] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right, imm] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let which = FloatBinOp::cmp_from_imm(this, this.read_scalar(imm)?.to_i8()?, link_name)?; @@ -119,7 +120,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // and `right`. For each component, returns 0 if false or u64::MAX // if true. "cmp.pd.256" => { - let [left, right, imm] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right, imm] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let which = FloatBinOp::cmp_from_imm(this, this.read_scalar(imm)?.to_i8()?, link_name)?; @@ -130,7 +131,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // and _mm256_cvttpd_epi32 functions. // Converts packed f32/f64 to packed i32. "cvt.ps2dq.256" | "cvtt.ps2dq.256" | "cvt.pd2dq.256" | "cvtt.pd2dq.256" => { - let [op] = this.check_shim(abi, Conv::C, link_name, args)?; + let [op] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let rnd = match unprefixed_name { // "current SSE rounding mode", assume nearest @@ -148,7 +149,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // sequence of 4-element arrays, and we shuffle each of these arrays, where // `control` determines which element of the current `data` array is written. "vpermilvar.ps" | "vpermilvar.ps.256" => { - let [data, control] = this.check_shim(abi, Conv::C, link_name, args)?; + let [data, control] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (data, data_len) = this.project_to_simd(data)?; let (control, control_len) = this.project_to_simd(control)?; @@ -181,7 +182,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // where `right` determines which element of the current `left` array is // written. "vpermilvar.pd" | "vpermilvar.pd.256" => { - let [data, control] = this.check_shim(abi, Conv::C, link_name, args)?; + let [data, control] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (data, data_len) = this.project_to_simd(data)?; let (control, control_len) = this.project_to_simd(control)?; @@ -213,7 +214,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // For each 128-bit element of `dest`, copies one from `left`, `right` or // zero, according to `imm`. "vperm2f128.ps.256" | "vperm2f128.pd.256" | "vperm2f128.si.256" => { - let [left, right, imm] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right, imm] = this.check_shim(abi, CanonAbi::C, link_name, args)?; assert_eq!(dest.layout, left.layout); assert_eq!(dest.layout, right.layout); @@ -256,7 +257,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // is one, it is loaded from `ptr.wrapping_add(i)`, otherwise zero is // loaded. "maskload.ps" | "maskload.pd" | "maskload.ps.256" | "maskload.pd.256" => { - let [ptr, mask] = this.check_shim(abi, Conv::C, link_name, args)?; + let [ptr, mask] = this.check_shim(abi, CanonAbi::C, link_name, args)?; mask_load(this, ptr, mask, dest)?; } @@ -266,7 +267,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // is one, it is stored into `ptr.wapping_add(i)`. // Unlike SSE2's _mm_maskmoveu_si128, these are not non-temporal stores. "maskstore.ps" | "maskstore.pd" | "maskstore.ps.256" | "maskstore.pd.256" => { - let [ptr, mask, value] = this.check_shim(abi, Conv::C, link_name, args)?; + let [ptr, mask, value] = this.check_shim(abi, CanonAbi::C, link_name, args)?; mask_store(this, ptr, mask, value)?; } @@ -276,7 +277,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // the data crosses a cache line, but for Miri this is just a regular // unaligned read. "ldu.dq.256" => { - let [src_ptr] = this.check_shim(abi, Conv::C, link_name, args)?; + let [src_ptr] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let src_ptr = this.read_pointer(src_ptr)?; let dest = dest.force_mplace(this)?; @@ -288,7 +289,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Tests `op & mask == 0`, `op & mask == mask` or // `op & mask != 0 && op & mask != mask` "ptestz.256" | "ptestc.256" | "ptestnzc.256" => { - let [op, mask] = this.check_shim(abi, Conv::C, link_name, args)?; + let [op, mask] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (all_zero, masked_set) = test_bits_masked(this, op, mask)?; let res = match unprefixed_name { @@ -311,7 +312,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { "vtestz.pd.256" | "vtestc.pd.256" | "vtestnzc.pd.256" | "vtestz.pd" | "vtestc.pd" | "vtestnzc.pd" | "vtestz.ps.256" | "vtestc.ps.256" | "vtestnzc.ps.256" | "vtestz.ps" | "vtestc.ps" | "vtestnzc.ps" => { - let [op, mask] = this.check_shim(abi, Conv::C, link_name, args)?; + let [op, mask] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (direct, negated) = test_high_bits_masked(this, op, mask)?; let res = match unprefixed_name { @@ -333,7 +334,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // compiler, making these functions no-ops. // The only thing that needs to be ensured is the correct calling convention. - let [] = this.check_shim(abi, Conv::C, link_name, args)?; + let [] = this.check_shim(abi, CanonAbi::C, link_name, args)?; } _ => return interp_ok(EmulateItemResult::NotSupported), } diff --git a/src/tools/miri/src/shims/x86/avx2.rs b/src/tools/miri/src/shims/x86/avx2.rs index c79899285cd44..5dfe5cc2c5424 100644 --- a/src/tools/miri/src/shims/x86/avx2.rs +++ b/src/tools/miri/src/shims/x86/avx2.rs @@ -1,8 +1,9 @@ +use rustc_abi::CanonAbi; use rustc_middle::mir; use rustc_middle::ty::Ty; use rustc_middle::ty::layout::LayoutOf as _; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use super::{ ShiftOp, horizontal_bin_op, int_abs, mask_load, mask_store, mpsadbw, packssdw, packsswb, @@ -28,7 +29,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Used to implement the _mm256_abs_epi{8,16,32} functions. // Calculates the absolute value of packed 8/16/32-bit integers. "pabs.b" | "pabs.w" | "pabs.d" => { - let [op] = this.check_shim(abi, Conv::C, link_name, args)?; + let [op] = this.check_shim(abi, CanonAbi::C, link_name, args)?; int_abs(this, op, dest)?; } @@ -36,7 +37,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Horizontally add / add with saturation / subtract adjacent 16/32-bit // integer values in `left` and `right`. "phadd.w" | "phadd.sw" | "phadd.d" | "phsub.w" | "phsub.sw" | "phsub.d" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (which, saturating) = match unprefixed_name { "phadd.w" | "phadd.d" => (mir::BinOp::Add, false), @@ -57,7 +58,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { | "gather.d.pd.256" | "gather.q.pd" | "gather.q.pd.256" | "gather.d.ps" | "gather.d.ps.256" | "gather.q.ps" | "gather.q.ps.256" => { let [src, slice, offsets, mask, scale] = - this.check_shim(abi, Conv::C, link_name, args)?; + this.check_shim(abi, CanonAbi::C, link_name, args)?; assert_eq!(dest.layout, src.layout); @@ -114,7 +115,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // intermediate signed 32-bit integers. Horizontally add adjacent pairs of // intermediate 32-bit integers, and pack the results in `dest`. "pmadd.wd" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (left, left_len) = this.project_to_simd(left)?; let (right, right_len) = this.project_to_simd(right)?; @@ -150,7 +151,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // the saturating sum of the products with indices `2*i` and `2*i+1` // produces the output at index `i`. "pmadd.ub.sw" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (left, left_len) = this.project_to_simd(left)?; let (right, right_len) = this.project_to_simd(right)?; @@ -184,7 +185,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // is one, it is loaded from `ptr.wrapping_add(i)`, otherwise zero is // loaded. "maskload.d" | "maskload.q" | "maskload.d.256" | "maskload.q.256" => { - let [ptr, mask] = this.check_shim(abi, Conv::C, link_name, args)?; + let [ptr, mask] = this.check_shim(abi, CanonAbi::C, link_name, args)?; mask_load(this, ptr, mask, dest)?; } @@ -194,7 +195,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // is one, it is stored into `ptr.wapping_add(i)`. // Unlike SSE2's _mm_maskmoveu_si128, these are not non-temporal stores. "maskstore.d" | "maskstore.q" | "maskstore.d.256" | "maskstore.q.256" => { - let [ptr, mask, value] = this.check_shim(abi, Conv::C, link_name, args)?; + let [ptr, mask, value] = this.check_shim(abi, CanonAbi::C, link_name, args)?; mask_store(this, ptr, mask, value)?; } @@ -205,7 +206,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // offsets specified in `imm`. // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm256_mpsadbw_epu8 "mpsadbw" => { - let [left, right, imm] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right, imm] = this.check_shim(abi, CanonAbi::C, link_name, args)?; mpsadbw(this, left, right, imm, dest)?; } @@ -216,7 +217,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // 1 and then taking the bits `1..=16`. // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm256_mulhrs_epi16 "pmul.hr.sw" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; pmulhrsw(this, left, right, dest)?; } @@ -224,7 +225,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Converts two 16-bit integer vectors to a single 8-bit integer // vector with signed saturation. "packsswb" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; packsswb(this, left, right, dest)?; } @@ -232,7 +233,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Converts two 32-bit integer vectors to a single 16-bit integer // vector with signed saturation. "packssdw" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; packssdw(this, left, right, dest)?; } @@ -240,7 +241,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Converts two 16-bit signed integer vectors to a single 8-bit // unsigned integer vector with saturation. "packuswb" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; packuswb(this, left, right, dest)?; } @@ -248,7 +249,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Concatenates two 32-bit signed integer vectors and converts // the result to a 16-bit unsigned integer vector with saturation. "packusdw" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; packusdw(this, left, right, dest)?; } @@ -257,7 +258,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Shuffles `left` using the three low bits of each element of `right` // as indices. "permd" | "permps" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (left, left_len) = this.project_to_simd(left)?; let (right, right_len) = this.project_to_simd(right)?; @@ -277,7 +278,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Used to implement the _mm256_permute2x128_si256 function. // Shuffles 128-bit blocks of `a` and `b` using `imm` as pattern. "vperm2i128" => { - let [left, right, imm] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right, imm] = this.check_shim(abi, CanonAbi::C, link_name, args)?; assert_eq!(left.layout.size.bits(), 256); assert_eq!(right.layout.size.bits(), 256); @@ -314,7 +315,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // in `dest`. // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm256_sad_epu8 "psad.bw" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (left, left_len) = this.project_to_simd(left)?; let (right, right_len) = this.project_to_simd(right)?; @@ -346,7 +347,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Shuffles bytes from `left` using `right` as pattern. // Each 128-bit block is shuffled independently. "pshuf.b" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (left, left_len) = this.project_to_simd(left)?; let (right, right_len) = this.project_to_simd(right)?; @@ -377,7 +378,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // is writen to the corresponding output element. // Basically, we multiply `left` with `right.signum()`. "psign.b" | "psign.w" | "psign.d" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; psign(this, left, right, dest)?; } @@ -391,7 +392,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // is copied to remaining bits. "psll.w" | "psrl.w" | "psra.w" | "psll.d" | "psrl.d" | "psra.d" | "psll.q" | "psrl.q" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let which = match unprefixed_name { "psll.w" | "psll.d" | "psll.q" => ShiftOp::Left, @@ -406,7 +407,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // (except _mm{,256}_srav_epi64, which are not available in AVX2). "psllv.d" | "psllv.d.256" | "psllv.q" | "psllv.q.256" | "psrlv.d" | "psrlv.d.256" | "psrlv.q" | "psrlv.q.256" | "psrav.d" | "psrav.d.256" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let which = match unprefixed_name { "psllv.d" | "psllv.d.256" | "psllv.q" | "psllv.q.256" => ShiftOp::Left, diff --git a/src/tools/miri/src/shims/x86/bmi.rs b/src/tools/miri/src/shims/x86/bmi.rs index 8af59df0a68ba..80b1b2e16e609 100644 --- a/src/tools/miri/src/shims/x86/bmi.rs +++ b/src/tools/miri/src/shims/x86/bmi.rs @@ -1,6 +1,7 @@ +use rustc_abi::CanonAbi; use rustc_middle::ty::Ty; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use crate::*; @@ -34,7 +35,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { return interp_ok(EmulateItemResult::NotSupported); } - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let left = this.read_scalar(left)?; let right = this.read_scalar(right)?; diff --git a/src/tools/miri/src/shims/x86/gfni.rs b/src/tools/miri/src/shims/x86/gfni.rs index a91c74283fd85..f83ce560c84e9 100644 --- a/src/tools/miri/src/shims/x86/gfni.rs +++ b/src/tools/miri/src/shims/x86/gfni.rs @@ -1,6 +1,7 @@ +use rustc_abi::CanonAbi; use rustc_middle::ty::Ty; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use crate::*; @@ -30,14 +31,14 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // See `affine_transform` for details. // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=gf2p8affine_ "vgf2p8affineqb.128" | "vgf2p8affineqb.256" | "vgf2p8affineqb.512" => { - let [left, right, imm8] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right, imm8] = this.check_shim(abi, CanonAbi::C, link_name, args)?; affine_transform(this, left, right, imm8, dest, /* inverse */ false)?; } // Used to implement the `_mm{, 256, 512}_gf2p8affineinv_epi64_epi8` functions. // See `affine_transform` for details. // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=gf2p8affineinv "vgf2p8affineinvqb.128" | "vgf2p8affineinvqb.256" | "vgf2p8affineinvqb.512" => { - let [left, right, imm8] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right, imm8] = this.check_shim(abi, CanonAbi::C, link_name, args)?; affine_transform(this, left, right, imm8, dest, /* inverse */ true)?; } // Used to implement the `_mm{, 256, 512}_gf2p8mul_epi8` functions. @@ -46,7 +47,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // polynomial representation with the reduction polynomial x^8 + x^4 + x^3 + x + 1. // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=gf2p8mul "vgf2p8mulb.128" | "vgf2p8mulb.256" | "vgf2p8mulb.512" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (left, left_len) = this.project_to_simd(left)?; let (right, right_len) = this.project_to_simd(right)?; let (dest, dest_len) = this.project_to_simd(dest)?; diff --git a/src/tools/miri/src/shims/x86/mod.rs b/src/tools/miri/src/shims/x86/mod.rs index ac59cc2dfeb39..7dee8ddd23c1a 100644 --- a/src/tools/miri/src/shims/x86/mod.rs +++ b/src/tools/miri/src/shims/x86/mod.rs @@ -1,11 +1,11 @@ -use rustc_abi::Size; +use rustc_abi::{CanonAbi, Size}; use rustc_apfloat::Float; use rustc_apfloat::ieee::Single; use rustc_middle::ty::Ty; use rustc_middle::ty::layout::LayoutOf as _; use rustc_middle::{mir, ty}; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use self::helpers::bool_to_simd_element; use crate::*; @@ -46,7 +46,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { return interp_ok(EmulateItemResult::NotSupported); } - let [cb_in, a, b] = this.check_shim(abi, Conv::C, link_name, args)?; + let [cb_in, a, b] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let op = if unprefixed_name.starts_with("add") { mir::BinOp::AddWithOverflow } else { @@ -68,7 +68,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { if is_u64 && this.tcx.sess.target.arch != "x86_64" { return interp_ok(EmulateItemResult::NotSupported); } - let [c_in, a, b, out] = this.check_shim(abi, Conv::C, link_name, args)?; + let [c_in, a, b, out] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let out = this.deref_pointer_as( out, if is_u64 { this.machine.layouts.u64 } else { this.machine.layouts.u32 }, @@ -85,7 +85,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // the instruction behaves like a no-op, so it is always safe to call the // intrinsic. "sse2.pause" => { - let [] = this.check_shim(abi, Conv::C, link_name, args)?; + let [] = this.check_shim(abi, CanonAbi::C, link_name, args)?; // Only exhibit the spin-loop hint behavior when SSE2 is enabled. if this.tcx.sess.unstable_target_features.contains(&Symbol::intern("sse2")) { this.yield_active_thread(); @@ -104,7 +104,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { len = 8; } - let [left, right, imm] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right, imm] = this.check_shim(abi, CanonAbi::C, link_name, args)?; pclmulqdq(this, left, right, imm, dest, len)?; } diff --git a/src/tools/miri/src/shims/x86/sha.rs b/src/tools/miri/src/shims/x86/sha.rs index 23c83553f3b32..d37fad3e6c753 100644 --- a/src/tools/miri/src/shims/x86/sha.rs +++ b/src/tools/miri/src/shims/x86/sha.rs @@ -4,9 +4,10 @@ //! //! [RustCrypto's sha256 module]: https://github.com/RustCrypto/hashes/blob/6be8466247e936c415d8aafb848697f39894a386/sha2/src/sha256/soft.rs +use rustc_abi::CanonAbi; use rustc_middle::ty::Ty; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use crate::*; @@ -52,7 +53,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { match unprefixed_name { // Used to implement the _mm_sha256rnds2_epu32 function. "256rnds2" => { - let [a, b, k] = this.check_shim(abi, Conv::C, link_name, args)?; + let [a, b, k] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (a_reg, a_len) = this.project_to_simd(a)?; let (b_reg, b_len) = this.project_to_simd(b)?; @@ -73,7 +74,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } // Used to implement the _mm_sha256msg1_epu32 function. "256msg1" => { - let [a, b] = this.check_shim(abi, Conv::C, link_name, args)?; + let [a, b] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (a_reg, a_len) = this.project_to_simd(a)?; let (b_reg, b_len) = this.project_to_simd(b)?; @@ -91,7 +92,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } // Used to implement the _mm_sha256msg2_epu32 function. "256msg2" => { - let [a, b] = this.check_shim(abi, Conv::C, link_name, args)?; + let [a, b] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (a_reg, a_len) = this.project_to_simd(a)?; let (b_reg, b_len) = this.project_to_simd(b)?; diff --git a/src/tools/miri/src/shims/x86/sse.rs b/src/tools/miri/src/shims/x86/sse.rs index fd7aba2437a5a..1ec15d609c687 100644 --- a/src/tools/miri/src/shims/x86/sse.rs +++ b/src/tools/miri/src/shims/x86/sse.rs @@ -1,7 +1,8 @@ +use rustc_abi::CanonAbi; use rustc_apfloat::ieee::Single; use rustc_middle::ty::Ty; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use super::{ FloatBinOp, FloatUnaryOp, bin_op_simd_float_all, bin_op_simd_float_first, unary_op_ps, @@ -33,7 +34,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Performs the operations on the first component of `left` and // `right` and copies the remaining components from `left`. "min.ss" | "max.ss" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let which = match unprefixed_name { "min.ss" => FloatBinOp::Min, @@ -49,7 +50,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // matches the IEEE min/max operations, while x86 has different // semantics. "min.ps" | "max.ps" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let which = match unprefixed_name { "min.ps" => FloatBinOp::Min, @@ -63,7 +64,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Performs the operations on the first component of `op` and // copies the remaining components from `op`. "rcp.ss" | "rsqrt.ss" => { - let [op] = this.check_shim(abi, Conv::C, link_name, args)?; + let [op] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let which = match unprefixed_name { "rcp.ss" => FloatUnaryOp::Rcp, @@ -76,7 +77,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Used to implement _mm_{sqrt,rcp,rsqrt}_ps functions. // Performs the operations on all components of `op`. "rcp.ps" | "rsqrt.ps" => { - let [op] = this.check_shim(abi, Conv::C, link_name, args)?; + let [op] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let which = match unprefixed_name { "rcp.ps" => FloatUnaryOp::Rcp, @@ -95,7 +96,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // _mm_cmp{eq,lt,le,gt,ge,neq,nlt,nle,ngt,nge,ord,unord}_ss are SSE functions // with hard-coded operations. "cmp.ss" => { - let [left, right, imm] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right, imm] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let which = FloatBinOp::cmp_from_imm(this, this.read_scalar(imm)?.to_i8()?, link_name)?; @@ -111,7 +112,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // _mm_cmp{eq,lt,le,gt,ge,neq,nlt,nle,ngt,nge,ord,unord}_ps are SSE functions // with hard-coded operations. "cmp.ps" => { - let [left, right, imm] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right, imm] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let which = FloatBinOp::cmp_from_imm(this, this.read_scalar(imm)?.to_i8()?, link_name)?; @@ -124,7 +125,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { "comieq.ss" | "comilt.ss" | "comile.ss" | "comigt.ss" | "comige.ss" | "comineq.ss" | "ucomieq.ss" | "ucomilt.ss" | "ucomile.ss" | "ucomigt.ss" | "ucomige.ss" | "ucomineq.ss" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (left, left_len) = this.project_to_simd(left)?; let (right, right_len) = this.project_to_simd(right)?; @@ -152,7 +153,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // _mm_cvtss_si64 and _mm_cvttss_si64 functions. // Converts the first component of `op` from f32 to i32/i64. "cvtss2si" | "cvttss2si" | "cvtss2si64" | "cvttss2si64" => { - let [op] = this.check_shim(abi, Conv::C, link_name, args)?; + let [op] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (op, _) = this.project_to_simd(op)?; let op = this.read_immediate(&this.project_index(&op, 0)?)?; @@ -180,7 +181,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // are copied from `left`. // https://www.felixcloutier.com/x86/cvtsi2ss "cvtsi2ss" | "cvtsi642ss" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (left, left_len) = this.project_to_simd(left)?; let (dest, dest_len) = this.project_to_simd(dest)?; diff --git a/src/tools/miri/src/shims/x86/sse2.rs b/src/tools/miri/src/shims/x86/sse2.rs index e0695b7cb7b7a..d6052f8307716 100644 --- a/src/tools/miri/src/shims/x86/sse2.rs +++ b/src/tools/miri/src/shims/x86/sse2.rs @@ -1,7 +1,8 @@ +use rustc_abi::CanonAbi; use rustc_apfloat::ieee::Double; use rustc_middle::ty::Ty; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use super::{ FloatBinOp, ShiftOp, bin_op_simd_float_all, bin_op_simd_float_first, convert_float_to_int, @@ -40,7 +41,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // intermediate signed 32-bit integers. Horizontally add adjacent pairs of // intermediate 32-bit integers, and pack the results in `dest`. "pmadd.wd" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (left, left_len) = this.project_to_simd(left)?; let (right, right_len) = this.project_to_simd(right)?; @@ -78,7 +79,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_sad_epu8 "psad.bw" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (left, left_len) = this.project_to_simd(left)?; let (right, right_len) = this.project_to_simd(right)?; @@ -116,7 +117,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // is copied to remaining bits. "psll.w" | "psrl.w" | "psra.w" | "psll.d" | "psrl.d" | "psra.d" | "psll.q" | "psrl.q" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let which = match unprefixed_name { "psll.w" | "psll.d" | "psll.q" => ShiftOp::Left, @@ -131,7 +132,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // and _mm_cvttpd_epi32 functions. // Converts packed f32/f64 to packed i32. "cvtps2dq" | "cvttps2dq" | "cvtpd2dq" | "cvttpd2dq" => { - let [op] = this.check_shim(abi, Conv::C, link_name, args)?; + let [op] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (op_len, _) = op.layout.ty.simd_size_and_type(*this.tcx); let (dest_len, _) = dest.layout.ty.simd_size_and_type(*this.tcx); @@ -168,7 +169,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Converts two 16-bit integer vectors to a single 8-bit integer // vector with signed saturation. "packsswb.128" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; packsswb(this, left, right, dest)?; } @@ -176,7 +177,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Converts two 16-bit signed integer vectors to a single 8-bit // unsigned integer vector with saturation. "packuswb.128" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; packuswb(this, left, right, dest)?; } @@ -184,7 +185,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Converts two 32-bit integer vectors to a single 16-bit integer // vector with signed saturation. "packssdw.128" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; packssdw(this, left, right, dest)?; } @@ -194,7 +195,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // matches the IEEE min/max operations, while x86 has different // semantics. "min.sd" | "max.sd" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let which = match unprefixed_name { "min.sd" => FloatBinOp::Min, @@ -210,7 +211,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // matches the IEEE min/max operations, while x86 has different // semantics. "min.pd" | "max.pd" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let which = match unprefixed_name { "min.pd" => FloatBinOp::Min, @@ -229,7 +230,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // _mm_cmp{eq,lt,le,gt,ge,neq,nlt,nle,ngt,nge,ord,unord}_sd are SSE2 functions // with hard-coded operations. "cmp.sd" => { - let [left, right, imm] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right, imm] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let which = FloatBinOp::cmp_from_imm(this, this.read_scalar(imm)?.to_i8()?, link_name)?; @@ -245,7 +246,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // _mm_cmp{eq,lt,le,gt,ge,neq,nlt,nle,ngt,nge,ord,unord}_pd are SSE2 functions // with hard-coded operations. "cmp.pd" => { - let [left, right, imm] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right, imm] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let which = FloatBinOp::cmp_from_imm(this, this.read_scalar(imm)?.to_i8()?, link_name)?; @@ -258,7 +259,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { "comieq.sd" | "comilt.sd" | "comile.sd" | "comigt.sd" | "comige.sd" | "comineq.sd" | "ucomieq.sd" | "ucomilt.sd" | "ucomile.sd" | "ucomigt.sd" | "ucomige.sd" | "ucomineq.sd" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (left, left_len) = this.project_to_simd(left)?; let (right, right_len) = this.project_to_simd(right)?; @@ -286,7 +287,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // _mm_cvtsd_si64 and _mm_cvttsd_si64 functions. // Converts the first component of `op` from f64 to i32/i64. "cvtsd2si" | "cvttsd2si" | "cvtsd2si64" | "cvttsd2si64" => { - let [op] = this.check_shim(abi, Conv::C, link_name, args)?; + let [op] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (op, _) = this.project_to_simd(op)?; let op = this.read_immediate(&this.project_index(&op, 0)?)?; @@ -312,7 +313,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Converts the first f64/f32 from `right` to f32/f64 and copies // the remaining elements from `left` "cvtsd2ss" | "cvtss2sd" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (left, left_len) = this.project_to_simd(left)?; let (right, _) = this.project_to_simd(right)?; diff --git a/src/tools/miri/src/shims/x86/sse3.rs b/src/tools/miri/src/shims/x86/sse3.rs index 60b7764a01e9d..ebf3cb5c3ee0a 100644 --- a/src/tools/miri/src/shims/x86/sse3.rs +++ b/src/tools/miri/src/shims/x86/sse3.rs @@ -1,7 +1,8 @@ +use rustc_abi::CanonAbi; use rustc_middle::mir; use rustc_middle::ty::Ty; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use super::horizontal_bin_op; use crate::*; @@ -25,7 +26,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Horizontally add/subtract adjacent floating point values // in `left` and `right`. "hadd.ps" | "hadd.pd" | "hsub.ps" | "hsub.pd" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let which = match unprefixed_name { "hadd.ps" | "hadd.pd" => mir::BinOp::Add, @@ -41,7 +42,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // the data crosses a cache line, but for Miri this is just a regular // unaligned read. "ldu.dq" => { - let [src_ptr] = this.check_shim(abi, Conv::C, link_name, args)?; + let [src_ptr] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let src_ptr = this.read_pointer(src_ptr)?; let dest = dest.force_mplace(this)?; diff --git a/src/tools/miri/src/shims/x86/sse41.rs b/src/tools/miri/src/shims/x86/sse41.rs index 93d689a3044e3..6797039cf56f2 100644 --- a/src/tools/miri/src/shims/x86/sse41.rs +++ b/src/tools/miri/src/shims/x86/sse41.rs @@ -1,6 +1,7 @@ +use rustc_abi::CanonAbi; use rustc_middle::ty::Ty; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use super::{conditional_dot_product, mpsadbw, packusdw, round_all, round_first, test_bits_masked}; use crate::*; @@ -27,7 +28,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // bits `4..=5` if `imm`, and `i`th bit specifies whether element // `i` is zeroed. "insertps" => { - let [left, right, imm] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right, imm] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (left, left_len) = this.project_to_simd(left)?; let (right, right_len) = this.project_to_simd(right)?; @@ -62,7 +63,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Concatenates two 32-bit signed integer vectors and converts // the result to a 16-bit unsigned integer vector with saturation. "packusdw" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; packusdw(this, left, right, dest)?; } @@ -72,7 +73,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // products, and conditionally stores the sum in `dest` using the low // 4 bits of `imm`. "dpps" | "dppd" => { - let [left, right, imm] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right, imm] = this.check_shim(abi, CanonAbi::C, link_name, args)?; conditional_dot_product(this, left, right, imm, dest)?; } @@ -80,14 +81,14 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // functions. Rounds the first element of `right` according to `rounding` // and copies the remaining elements from `left`. "round.ss" => { - let [left, right, rounding] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right, rounding] = this.check_shim(abi, CanonAbi::C, link_name, args)?; round_first::(this, left, right, rounding, dest)?; } // Used to implement the _mm_floor_ps, _mm_ceil_ps and _mm_round_ps // functions. Rounds the elements of `op` according to `rounding`. "round.ps" => { - let [op, rounding] = this.check_shim(abi, Conv::C, link_name, args)?; + let [op, rounding] = this.check_shim(abi, CanonAbi::C, link_name, args)?; round_all::(this, op, rounding, dest)?; } @@ -95,14 +96,14 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // functions. Rounds the first element of `right` according to `rounding` // and copies the remaining elements from `left`. "round.sd" => { - let [left, right, rounding] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right, rounding] = this.check_shim(abi, CanonAbi::C, link_name, args)?; round_first::(this, left, right, rounding, dest)?; } // Used to implement the _mm_floor_pd, _mm_ceil_pd and _mm_round_pd // functions. Rounds the elements of `op` according to `rounding`. "round.pd" => { - let [op, rounding] = this.check_shim(abi, Conv::C, link_name, args)?; + let [op, rounding] = this.check_shim(abi, CanonAbi::C, link_name, args)?; round_all::(this, op, rounding, dest)?; } @@ -110,7 +111,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Find the minimum unsinged 16-bit integer in `op` and // returns its value and position. "phminposuw" => { - let [op] = this.check_shim(abi, Conv::C, link_name, args)?; + let [op] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (op, op_len) = this.project_to_simd(op)?; let (dest, dest_len) = this.project_to_simd(dest)?; @@ -144,7 +145,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // offsets specified in `imm`. // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_mpsadbw_epu8 "mpsadbw" => { - let [left, right, imm] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right, imm] = this.check_shim(abi, CanonAbi::C, link_name, args)?; mpsadbw(this, left, right, imm, dest)?; } @@ -153,7 +154,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Tests `(op & mask) == 0`, `(op & mask) == mask` or // `(op & mask) != 0 && (op & mask) != mask` "ptestz" | "ptestc" | "ptestnzc" => { - let [op, mask] = this.check_shim(abi, Conv::C, link_name, args)?; + let [op, mask] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (all_zero, masked_set) = test_bits_masked(this, op, mask)?; let res = match unprefixed_name { diff --git a/src/tools/miri/src/shims/x86/sse42.rs b/src/tools/miri/src/shims/x86/sse42.rs index 66bff328626a1..830513f02911f 100644 --- a/src/tools/miri/src/shims/x86/sse42.rs +++ b/src/tools/miri/src/shims/x86/sse42.rs @@ -1,9 +1,9 @@ -use rustc_abi::Size; +use rustc_abi::{CanonAbi, Size}; use rustc_middle::mir; use rustc_middle::ty::Ty; use rustc_middle::ty::layout::LayoutOf as _; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use crate::*; @@ -223,7 +223,7 @@ fn deconstruct_args<'tcx>( }; if is_explicit { - let [str1, len1, str2, len2, imm] = ecx.check_shim(abi, Conv::C, link_name, args)?; + let [str1, len1, str2, len2, imm] = ecx.check_shim(abi, CanonAbi::C, link_name, args)?; let imm = ecx.read_scalar(imm)?.to_u8()?; let default_len = default_len::(imm); @@ -236,7 +236,7 @@ fn deconstruct_args<'tcx>( interp_ok((str1, str2, Some((len1, len2)), imm)) } else { - let [str1, str2, imm] = ecx.check_shim(abi, Conv::C, link_name, args)?; + let [str1, str2, imm] = ecx.check_shim(abi, CanonAbi::C, link_name, args)?; let imm = ecx.read_scalar(imm)?.to_u8()?; let array_layout = array_layout_fn(ecx, imm)?; @@ -386,7 +386,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // search for a null terminator (see `deconstruct_args` for more details). // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#ig_expand=924,925 "pcmpistriz128" | "pcmpistris128" => { - let [str1, str2, imm] = this.check_shim(abi, Conv::C, link_name, args)?; + let [str1, str2, imm] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let imm = this.read_scalar(imm)?.to_u8()?; let str = if unprefixed_name == "pcmpistris128" { str1 } else { str2 }; @@ -406,7 +406,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // than 16 for byte-sized operands or 8 for word-sized operands. // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#ig_expand=1046,1047 "pcmpestriz128" | "pcmpestris128" => { - let [_, len1, _, len2, imm] = this.check_shim(abi, Conv::C, link_name, args)?; + let [_, len1, _, len2, imm] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let len = if unprefixed_name == "pcmpestris128" { len1 } else { len2 }; let len = this.read_scalar(len)?.to_i32()?; let imm = this.read_scalar(imm)?.to_u8()?; @@ -433,7 +433,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { return interp_ok(EmulateItemResult::NotSupported); } - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let left = this.read_scalar(left)?; let right = this.read_scalar(right)?; diff --git a/src/tools/miri/src/shims/x86/ssse3.rs b/src/tools/miri/src/shims/x86/ssse3.rs index f3e9ac0e5dc99..310d6b8f765ab 100644 --- a/src/tools/miri/src/shims/x86/ssse3.rs +++ b/src/tools/miri/src/shims/x86/ssse3.rs @@ -1,7 +1,8 @@ +use rustc_abi::CanonAbi; use rustc_middle::mir; use rustc_middle::ty::Ty; use rustc_span::Symbol; -use rustc_target::callconv::{Conv, FnAbi}; +use rustc_target::callconv::FnAbi; use super::{horizontal_bin_op, int_abs, pmulhrsw, psign}; use crate::*; @@ -24,7 +25,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Used to implement the _mm_abs_epi{8,16,32} functions. // Calculates the absolute value of packed 8/16/32-bit integers. "pabs.b.128" | "pabs.w.128" | "pabs.d.128" => { - let [op] = this.check_shim(abi, Conv::C, link_name, args)?; + let [op] = this.check_shim(abi, CanonAbi::C, link_name, args)?; int_abs(this, op, dest)?; } @@ -32,7 +33,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Shuffles bytes from `left` using `right` as pattern. // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_shuffle_epi8 "pshuf.b.128" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (left, left_len) = this.project_to_simd(left)?; let (right, right_len) = this.project_to_simd(right)?; @@ -61,7 +62,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // integer values in `left` and `right`. "phadd.w.128" | "phadd.sw.128" | "phadd.d.128" | "phsub.w.128" | "phsub.sw.128" | "phsub.d.128" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (which, saturating) = match unprefixed_name { "phadd.w.128" | "phadd.d.128" => (mir::BinOp::Add, false), @@ -80,7 +81,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // produces the output at index `i`. // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_maddubs_epi16 "pmadd.ub.sw.128" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; let (left, left_len) = this.project_to_simd(left)?; let (right, right_len) = this.project_to_simd(right)?; @@ -115,7 +116,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // 1 and then taking the bits `1..=16`. // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_mulhrs_epi16 "pmul.hr.sw.128" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; pmulhrsw(this, left, right, dest)?; } @@ -125,7 +126,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // is writen to the corresponding output element. // Basically, we multiply `left` with `right.signum()`. "psign.b.128" | "psign.w.128" | "psign.d.128" => { - let [left, right] = this.check_shim(abi, Conv::C, link_name, args)?; + let [left, right] = this.check_shim(abi, CanonAbi::C, link_name, args)?; psign(this, left, right, dest)?; } diff --git a/src/tools/miri/tests/fail/const-ub-checks.rs b/src/tools/miri/tests/fail/const-ub-checks.rs index 9cc8b91ff500c..004bbe9f5ea31 100644 --- a/src/tools/miri/tests/fail/const-ub-checks.rs +++ b/src/tools/miri/tests/fail/const-ub-checks.rs @@ -1,7 +1,7 @@ const UNALIGNED_READ: () = unsafe { let x = &[0u8; 4]; let ptr = x.as_ptr().cast::(); - ptr.read(); //~ERROR: evaluation of constant value failed + ptr.read(); //~ERROR: accessing memory based on pointer with alignment 1, but alignment 4 is required }; fn main() { diff --git a/src/tools/miri/tests/fail/const-ub-checks.stderr b/src/tools/miri/tests/fail/const-ub-checks.stderr index e6b302dd28cd6..9bac524bd452c 100644 --- a/src/tools/miri/tests/fail/const-ub-checks.stderr +++ b/src/tools/miri/tests/fail/const-ub-checks.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: accessing memory based on pointer with alignment ALIGN, but alignment ALIGN is required --> tests/fail/const-ub-checks.rs:LL:CC | LL | ptr.read(); - | ^^^^^^^^^^ accessing memory based on pointer with alignment ALIGN, but alignment ALIGN is required + | ^^^^^^^^^^ evaluation of constant value failed here note: erroneous constant encountered --> tests/fail/const-ub-checks.rs:LL:CC diff --git a/src/tools/miri/tests/fail/erroneous_const.rs b/src/tools/miri/tests/fail/erroneous_const.rs index 65f7aafc3cc85..6e126ed701f88 100644 --- a/src/tools/miri/tests/fail/erroneous_const.rs +++ b/src/tools/miri/tests/fail/erroneous_const.rs @@ -4,7 +4,7 @@ struct PrintName(T); impl PrintName { - const VOID: ! = panic!(); //~ERROR: evaluation of `PrintName::::VOID` failed + const VOID: ! = panic!(); //~ERROR: explicit panic } fn no_codegen() { diff --git a/src/tools/miri/tests/fail/erroneous_const.stderr b/src/tools/miri/tests/fail/erroneous_const.stderr index 6f1e3529ccc78..1aa87dd7188ce 100644 --- a/src/tools/miri/tests/fail/erroneous_const.stderr +++ b/src/tools/miri/tests/fail/erroneous_const.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `PrintName::::VOID` failed +error[E0080]: evaluation panicked: explicit panic --> tests/fail/erroneous_const.rs:LL:CC | LL | const VOID: ! = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `PrintName::::VOID` failed here note: erroneous constant encountered --> tests/fail/erroneous_const.rs:LL:CC diff --git a/src/tools/miri/tests/fail/erroneous_const2.rs b/src/tools/miri/tests/fail/erroneous_const2.rs index 9a1a970778fb4..ea98b64ad814e 100644 --- a/src/tools/miri/tests/fail/erroneous_const2.rs +++ b/src/tools/miri/tests/fail/erroneous_const2.rs @@ -1,7 +1,7 @@ const X: u32 = 5; const Y: u32 = 6; const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; -//~^ERROR: evaluation of constant value failed +//~^ERROR: overflow #[rustfmt::skip] // rustfmt bug: https://github.com/rust-lang/rustfmt/issues/5391 fn main() { diff --git a/src/tools/miri/tests/fail/erroneous_const2.stderr b/src/tools/miri/tests/fail/erroneous_const2.stderr index 76f8cbcd2893c..9d3f1b13beef8 100644 --- a/src/tools/miri/tests/fail/erroneous_const2.stderr +++ b/src/tools/miri/tests/fail/erroneous_const2.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `5_u32 - 6_u32`, which would overflow --> tests/fail/erroneous_const2.rs:LL:CC | LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; - | ^^^^^ attempt to compute `5_u32 - 6_u32`, which would overflow + | ^^^^^ evaluation of constant value failed here note: erroneous constant encountered --> tests/fail/erroneous_const2.rs:LL:CC diff --git a/src/tools/miri/tests/pass/iter_macro.rs b/src/tools/miri/tests/pass/iter_macro.rs new file mode 100644 index 0000000000000..367c13f996905 --- /dev/null +++ b/src/tools/miri/tests/pass/iter_macro.rs @@ -0,0 +1,22 @@ +#![feature(iter_macro, yield_expr)] + +use std::iter::iter; + +fn main() { + let i = iter! { || { + yield 0; + for x in 5..10 { + yield x * 2; + } + } }; + let mut i = i(); + assert_eq!(i.next(), Some(0)); + assert_eq!(i.next(), Some(10)); + assert_eq!(i.next(), Some(12)); + assert_eq!(i.next(), Some(14)); + assert_eq!(i.next(), Some(16)); + assert_eq!(i.next(), Some(18)); + assert_eq!(i.next(), None); + assert_eq!(i.next(), None); + assert_eq!(i.next(), None); +} diff --git a/tests/rustdoc-ui/const-evalutation-ice.rs b/tests/rustdoc-ui/const-evalutation-ice.rs index 0dd3bcaa2895d..72bcbeb4c5160 100644 --- a/tests/rustdoc-ui/const-evalutation-ice.rs +++ b/tests/rustdoc-ui/const-evalutation-ice.rs @@ -4,8 +4,8 @@ use std::cell::Cell; use std::mem; pub struct S { - s: Cell + s: Cell, } pub const N: usize = 0 - (mem::size_of::() != 400) as usize; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflow diff --git a/tests/rustdoc-ui/const-evalutation-ice.stderr b/tests/rustdoc-ui/const-evalutation-ice.stderr index e1cb3323856d1..2410782000d68 100644 --- a/tests/rustdoc-ui/const-evalutation-ice.stderr +++ b/tests/rustdoc-ui/const-evalutation-ice.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow --> $DIR/const-evalutation-ice.rs:10:22 | LL | pub const N: usize = 0 - (mem::size_of::() != 400) as usize; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/abi/sysv64-zst.stderr b/tests/ui/abi/sysv64-zst.stderr index 59d7b00441790..f91d1b5fa63c3 100644 --- a/tests/ui/abi/sysv64-zst.stderr +++ b/tests/ui/abi/sysv64-zst.stderr @@ -59,7 +59,9 @@ error: fn_abi_of(pass_zst) = FnAbi { }, c_variadic: false, fixed_count: 1, - conv: X86_64SysV, + conv: X86( + SysV64, + ), can_unwind: false, } --> $DIR/sysv64-zst.rs:8:1 diff --git a/tests/ui/array-slice-vec/array_const_index-0.rs b/tests/ui/array-slice-vec/array_const_index-0.rs index f4fe89a50c252..aef07d952faf0 100644 --- a/tests/ui/array-slice-vec/array_const_index-0.rs +++ b/tests/ui/array-slice-vec/array_const_index-0.rs @@ -1,7 +1,6 @@ const A: &'static [i32] = &[]; const B: i32 = (&A)[1]; -//~^ NOTE index out of bounds: the length is 0 but the index is 1 -//~| ERROR evaluation of constant value failed +//~^ ERROR index out of bounds: the length is 0 but the index is 1 fn main() { let _ = B; diff --git a/tests/ui/array-slice-vec/array_const_index-0.stderr b/tests/ui/array-slice-vec/array_const_index-0.stderr index d16e8d50dfdd5..1080705713b95 100644 --- a/tests/ui/array-slice-vec/array_const_index-0.stderr +++ b/tests/ui/array-slice-vec/array_const_index-0.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: index out of bounds: the length is 0 but the index is 1 --> $DIR/array_const_index-0.rs:2:16 | LL | const B: i32 = (&A)[1]; - | ^^^^^^^ index out of bounds: the length is 0 but the index is 1 + | ^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/array-slice-vec/array_const_index-1.rs b/tests/ui/array-slice-vec/array_const_index-1.rs index 0d4de137a6e0d..4adbd157ed0c6 100644 --- a/tests/ui/array-slice-vec/array_const_index-1.rs +++ b/tests/ui/array-slice-vec/array_const_index-1.rs @@ -1,7 +1,6 @@ const A: [i32; 0] = []; const B: i32 = A[1]; -//~^ NOTE index out of bounds: the length is 0 but the index is 1 -//~| ERROR evaluation of constant value failed +//~^ ERROR index out of bounds: the length is 0 but the index is 1 fn main() { let _ = B; diff --git a/tests/ui/array-slice-vec/array_const_index-1.stderr b/tests/ui/array-slice-vec/array_const_index-1.stderr index f9ba2f13911bd..56299848d9220 100644 --- a/tests/ui/array-slice-vec/array_const_index-1.stderr +++ b/tests/ui/array-slice-vec/array_const_index-1.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: index out of bounds: the length is 0 but the index is 1 --> $DIR/array_const_index-1.rs:2:16 | LL | const B: i32 = A[1]; - | ^^^^ index out of bounds: the length is 0 but the index is 1 + | ^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/asm/fail-const-eval-issue-121099.stderr b/tests/ui/asm/fail-const-eval-issue-121099.stderr index eb662dadffb1b..7e2718c9eac3e 100644 --- a/tests/ui/asm/fail-const-eval-issue-121099.stderr +++ b/tests/ui/asm/fail-const-eval-issue-121099.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of `{global_asm#0}::{constant#0}` failed +error[E0080]: attempt to shift left by `500_i32`, which would overflow --> $DIR/fail-const-eval-issue-121099.rs:8:31 | LL | global_asm!("/* {} */", const 1 << 500); - | ^^^^^^^^ attempt to shift left by `500_i32`, which would overflow + | ^^^^^^^^ evaluation of `{global_asm#0}::{constant#0}` failed here -error[E0080]: evaluation of `{global_asm#1}::{constant#0}` failed +error[E0080]: attempt to divide `1_i32` by zero --> $DIR/fail-const-eval-issue-121099.rs:10:31 | LL | global_asm!("/* {} */", const 1 / 0); - | ^^^^^ attempt to divide `1_i32` by zero + | ^^^^^ evaluation of `{global_asm#1}::{constant#0}` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/associated-consts/defaults-not-assumed-fail.rs b/tests/ui/associated-consts/defaults-not-assumed-fail.rs index 830fd4ab0e975..e63424e13e360 100644 --- a/tests/ui/associated-consts/defaults-not-assumed-fail.rs +++ b/tests/ui/associated-consts/defaults-not-assumed-fail.rs @@ -7,7 +7,7 @@ trait Tr { // This should not be a constant evaluation error (overflow). The value of // `Self::A` must not be assumed to hold inside the trait. const B: u8 = Self::A + 1; - //~^ ERROR evaluation of `<() as Tr>::B` failed + //~^ ERROR overflow } // An impl that doesn't override any constant will NOT cause a const eval error diff --git a/tests/ui/associated-consts/defaults-not-assumed-fail.stderr b/tests/ui/associated-consts/defaults-not-assumed-fail.stderr index 3386e81dc98f4..40f5f889f361d 100644 --- a/tests/ui/associated-consts/defaults-not-assumed-fail.stderr +++ b/tests/ui/associated-consts/defaults-not-assumed-fail.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `<() as Tr>::B` failed +error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow --> $DIR/defaults-not-assumed-fail.rs:9:19 | LL | const B: u8 = Self::A + 1; - | ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow + | ^^^^^^^^^^^ evaluation of `<() as Tr>::B` failed here note: erroneous constant encountered --> $DIR/defaults-not-assumed-fail.rs:34:16 diff --git a/tests/ui/borrowck/issue-81899.rs b/tests/ui/borrowck/issue-81899.rs index 11755620d864e..03d9b8cb6c6a1 100644 --- a/tests/ui/borrowck/issue-81899.rs +++ b/tests/ui/borrowck/issue-81899.rs @@ -3,7 +3,7 @@ //@ dont-require-annotations: NOTE -const _CONST: &[u8] = &f(&[], |_| {}); //~ ERROR evaluation of constant value failed +const _CONST: &[u8] = &f(&[], |_| {}); //~ ERROR explicit panic //~^ NOTE constant const fn f(_: &[u8], _: F) -> &[u8] diff --git a/tests/ui/borrowck/issue-81899.stderr b/tests/ui/borrowck/issue-81899.stderr index 97d463cb6a774..d236a17e0aa5a 100644 --- a/tests/ui/borrowck/issue-81899.stderr +++ b/tests/ui/borrowck/issue-81899.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/issue-81899.rs:6:24 | LL | const _CONST: &[u8] = &f(&[], |_| {}); - | ^^^^^^^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `f::<{closure@$DIR/issue-81899.rs:6:31: 6:34}>` --> $DIR/issue-81899.rs:13:5 diff --git a/tests/ui/borrowck/issue-88434-minimal-example.rs b/tests/ui/borrowck/issue-88434-minimal-example.rs index 7482b3fd612c1..901e0142c3626 100644 --- a/tests/ui/borrowck/issue-88434-minimal-example.rs +++ b/tests/ui/borrowck/issue-88434-minimal-example.rs @@ -2,7 +2,7 @@ //@ dont-require-annotations: NOTE -const _CONST: &() = &f(&|_| {}); //~ ERROR evaluation of constant value failed +const _CONST: &() = &f(&|_| {}); //~ ERROR explicit panic //~^ NOTE constant const fn f(_: &F) @@ -12,4 +12,4 @@ where panic!() //~ NOTE inside `f } -fn main() { } +fn main() {} diff --git a/tests/ui/borrowck/issue-88434-minimal-example.stderr b/tests/ui/borrowck/issue-88434-minimal-example.stderr index 4c525b9ea2c7a..3d9cc96604742 100644 --- a/tests/ui/borrowck/issue-88434-minimal-example.stderr +++ b/tests/ui/borrowck/issue-88434-minimal-example.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/issue-88434-minimal-example.rs:5:22 | LL | const _CONST: &() = &f(&|_| {}); - | ^^^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^^^ evaluation of constant value failed here | note: inside `f::<{closure@$DIR/issue-88434-minimal-example.rs:5:25: 5:28}>` --> $DIR/issue-88434-minimal-example.rs:12:5 diff --git a/tests/ui/borrowck/issue-88434-removal-index-should-be-less.rs b/tests/ui/borrowck/issue-88434-removal-index-should-be-less.rs index 09b1f59c449ca..cce59124adedb 100644 --- a/tests/ui/borrowck/issue-88434-removal-index-should-be-less.rs +++ b/tests/ui/borrowck/issue-88434-removal-index-should-be-less.rs @@ -2,7 +2,7 @@ //@ dont-require-annotations: NOTE -const _CONST: &[u8] = &f(&[], |_| {}); //~ ERROR evaluation of constant value failed +const _CONST: &[u8] = &f(&[], |_| {}); //~ ERROR explicit panic //~^ NOTE constant const fn f(_: &[u8], _: F) -> &[u8] @@ -12,4 +12,4 @@ where panic!() //~ NOTE inside `f } -fn main() { } +fn main() {} diff --git a/tests/ui/borrowck/issue-88434-removal-index-should-be-less.stderr b/tests/ui/borrowck/issue-88434-removal-index-should-be-less.stderr index a22621c9c1bb7..90d7f36938e57 100644 --- a/tests/ui/borrowck/issue-88434-removal-index-should-be-less.stderr +++ b/tests/ui/borrowck/issue-88434-removal-index-should-be-less.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/issue-88434-removal-index-should-be-less.rs:5:24 | LL | const _CONST: &[u8] = &f(&[], |_| {}); - | ^^^^^^^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `f::<{closure@$DIR/issue-88434-removal-index-should-be-less.rs:5:31: 5:34}>` --> $DIR/issue-88434-removal-index-should-be-less.rs:12:5 diff --git a/tests/ui/coherence/const-errs-dont-conflict-103369.stderr b/tests/ui/coherence/const-errs-dont-conflict-103369.stderr index b2104299f65e1..e577a36cc1013 100644 --- a/tests/ui/coherence/const-errs-dont-conflict-103369.stderr +++ b/tests/ui/coherence/const-errs-dont-conflict-103369.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: Some error occurred --> $DIR/const-errs-dont-conflict-103369.rs:5:25 | LL | impl ConstGenericTrait<{my_fn(1)}> for () {} - | ^^^^^^^^ evaluation panicked: Some error occurred + | ^^^^^^^^ evaluation of constant value failed here | note: inside `my_fn` --> $DIR/const-errs-dont-conflict-103369.rs:10:5 @@ -10,11 +10,11 @@ note: inside `my_fn` LL | panic!("Some error occurred"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: Some error occurred --> $DIR/const-errs-dont-conflict-103369.rs:7:25 | LL | impl ConstGenericTrait<{my_fn(2)}> for () {} - | ^^^^^^^^ evaluation panicked: Some error occurred + | ^^^^^^^^ evaluation of constant value failed here | note: inside `my_fn` --> $DIR/const-errs-dont-conflict-103369.rs:10:5 diff --git a/tests/ui/const-generics/defaults/default-param-wf-concrete.next.stderr b/tests/ui/const-generics/defaults/default-param-wf-concrete.next.stderr index 35aae46244379..3299c27a0e756 100644 --- a/tests/ui/const-generics/defaults/default-param-wf-concrete.next.stderr +++ b/tests/ui/const-generics/defaults/default-param-wf-concrete.next.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow --> $DIR/default-param-wf-concrete.rs:4:28 | LL | struct Foo; - | ^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow + | ^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/defaults/default-param-wf-concrete.old.stderr b/tests/ui/const-generics/defaults/default-param-wf-concrete.old.stderr index 35aae46244379..3299c27a0e756 100644 --- a/tests/ui/const-generics/defaults/default-param-wf-concrete.old.stderr +++ b/tests/ui/const-generics/defaults/default-param-wf-concrete.old.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow --> $DIR/default-param-wf-concrete.rs:4:28 | LL | struct Foo; - | ^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow + | ^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/defaults/default-param-wf-concrete.rs b/tests/ui/const-generics/defaults/default-param-wf-concrete.rs index f181f58233263..0385e55e3b29a 100644 --- a/tests/ui/const-generics/defaults/default-param-wf-concrete.rs +++ b/tests/ui/const-generics/defaults/default-param-wf-concrete.rs @@ -2,5 +2,5 @@ //@[next] compile-flags: -Znext-solver struct Foo; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflow fn main() {} diff --git a/tests/ui/const-generics/defaults/wfness.rs b/tests/ui/const-generics/defaults/wfness.rs index a93f670815a03..99e9452b46aa5 100644 --- a/tests/ui/const-generics/defaults/wfness.rs +++ b/tests/ui/const-generics/defaults/wfness.rs @@ -1,5 +1,5 @@ struct Ooopsies; -//~^ error: evaluation of constant value failed +//~^ error: overflow trait Trait {} impl Trait<3> for () {} diff --git a/tests/ui/const-generics/defaults/wfness.stderr b/tests/ui/const-generics/defaults/wfness.stderr index 290a80bd32fa0..ef5167cfc002d 100644 --- a/tests/ui/const-generics/defaults/wfness.stderr +++ b/tests/ui/const-generics/defaults/wfness.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow --> $DIR/wfness.rs:1:33 | LL | struct Ooopsies; - | ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow + | ^^^^^^^^^^^ evaluation of constant value failed here error[E0277]: the trait bound `(): Trait<2>` is not satisfied --> $DIR/wfness.rs:8:9 diff --git a/tests/ui/const-generics/generic_const_exprs/from-sig-fail.rs b/tests/ui/const-generics/generic_const_exprs/from-sig-fail.rs index b8f9827ec9187..1675374970294 100644 --- a/tests/ui/const-generics/generic_const_exprs/from-sig-fail.rs +++ b/tests/ui/const-generics/generic_const_exprs/from-sig-fail.rs @@ -2,7 +2,7 @@ #![allow(incomplete_features)] fn test() -> [u8; N - 1] { - //~^ ERROR evaluation of `test::<0>::{constant#0}` failed + //~^ ERROR overflow todo!() } diff --git a/tests/ui/const-generics/generic_const_exprs/from-sig-fail.stderr b/tests/ui/const-generics/generic_const_exprs/from-sig-fail.stderr index 080e920258dc7..72f2dac8fa21a 100644 --- a/tests/ui/const-generics/generic_const_exprs/from-sig-fail.stderr +++ b/tests/ui/const-generics/generic_const_exprs/from-sig-fail.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `test::<0>::{constant#0}` failed +error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow --> $DIR/from-sig-fail.rs:4:35 | LL | fn test() -> [u8; N - 1] { - | ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow + | ^^^^^ evaluation of `test::<0>::{constant#0}` failed here error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/generic_const_exprs/simple_fail.rs b/tests/ui/const-generics/generic_const_exprs/simple_fail.rs index cae54df4c1210..e89b5707fe2f0 100644 --- a/tests/ui/const-generics/generic_const_exprs/simple_fail.rs +++ b/tests/ui/const-generics/generic_const_exprs/simple_fail.rs @@ -2,12 +2,12 @@ #![allow(incomplete_features)] type Arr = [u8; N - 1]; -//~^ ERROR evaluation of `Arr::<0>::{constant#0}` failed +//~^ ERROR overflow fn test() -> Arr where [u8; N - 1]: Sized, - //~^ ERROR evaluation of `test::<0>::{constant#0}` failed + //~^ ERROR overflow { todo!() } 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 a25fa56b7d498..94a91159e956f 100644 --- a/tests/ui/const-generics/generic_const_exprs/simple_fail.stderr +++ b/tests/ui/const-generics/generic_const_exprs/simple_fail.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of `test::<0>::{constant#0}` failed +error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow --> $DIR/simple_fail.rs:9:10 | LL | [u8; N - 1]: Sized, - | ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow + | ^^^^^ evaluation of `test::<0>::{constant#0}` failed here -error[E0080]: evaluation of `Arr::<0>::{constant#0}` failed +error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow --> $DIR/simple_fail.rs:4:33 | LL | type Arr = [u8; N - 1]; - | ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow + | ^^^^^ evaluation of `Arr::<0>::{constant#0}` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/issues/issue-100313.rs b/tests/ui/const-generics/issues/issue-100313.rs index 7d43d7bee3470..1f61356162ca6 100644 --- a/tests/ui/const-generics/issues/issue-100313.rs +++ b/tests/ui/const-generics/issues/issue-100313.rs @@ -15,7 +15,7 @@ impl T { const _: () = { let x = T::<{ &true }>; - x.set_false(); //~ ERROR evaluation of constant value failed [E0080] + x.set_false(); //~ ERROR writing to ALLOC0 which is read-only }; fn main() {} diff --git a/tests/ui/const-generics/issues/issue-100313.stderr b/tests/ui/const-generics/issues/issue-100313.stderr index 98c3ec5379b5e..2ae4c30e15f40 100644 --- a/tests/ui/const-generics/issues/issue-100313.stderr +++ b/tests/ui/const-generics/issues/issue-100313.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: writing to ALLOC0 which is read-only --> $DIR/issue-100313.rs:18:5 | LL | x.set_false(); - | ^^^^^^^^^^^^^ writing to ALLOC0 which is read-only + | ^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `T::<&true>::set_false` --> $DIR/issue-100313.rs:11:13 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 d1f3b08dd36de..172fd37fa6941 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 @@ -1,36 +1,36 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/invalid-patterns.rs:40:32 | LL | get_flag::(); - | ^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: it is undefined behavior to use this value - --> $DIR/invalid-patterns.rs:43:14 +error[E0080]: constructing invalid value: encountered 0x42, but expected a boolean + --> $DIR/invalid-patterns.rs:42:14 | LL | get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x42, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 42 │ B } -error[E0080]: it is undefined behavior to use this value - --> $DIR/invalid-patterns.rs:45:14 +error[E0080]: constructing invalid value: encountered 0x42, but expected a boolean + --> $DIR/invalid-patterns.rs:44:14 | LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x42, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 42 │ B } -error[E0080]: evaluation of constant value failed - --> $DIR/invalid-patterns.rs:45:58 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/invalid-patterns.rs:44:58 | LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); - | ^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error[E0308]: mismatched types --> $DIR/invalid-patterns.rs:31:21 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 d1f3b08dd36de..172fd37fa6941 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 @@ -1,36 +1,36 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/invalid-patterns.rs:40:32 | LL | get_flag::(); - | ^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: it is undefined behavior to use this value - --> $DIR/invalid-patterns.rs:43:14 +error[E0080]: constructing invalid value: encountered 0x42, but expected a boolean + --> $DIR/invalid-patterns.rs:42:14 | LL | get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x42, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 42 │ B } -error[E0080]: it is undefined behavior to use this value - --> $DIR/invalid-patterns.rs:45:14 +error[E0080]: constructing invalid value: encountered 0x42, but expected a boolean + --> $DIR/invalid-patterns.rs:44:14 | LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x42, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 42 │ B } -error[E0080]: evaluation of constant value failed - --> $DIR/invalid-patterns.rs:45:58 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/invalid-patterns.rs:44:58 | LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); - | ^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error[E0308]: mismatched types --> $DIR/invalid-patterns.rs:31:21 diff --git a/tests/ui/const-generics/min_const_generics/invalid-patterns.rs b/tests/ui/const-generics/min_const_generics/invalid-patterns.rs index 10b0d742a0a97..85f019adf6649 100644 --- a/tests/ui/const-generics/min_const_generics/invalid-patterns.rs +++ b/tests/ui/const-generics/min_const_generics/invalid-patterns.rs @@ -38,12 +38,10 @@ fn main() { get_flag::(); - //~^ ERROR evaluation of constant value failed - //~| NOTE uninitialized + //~^ ERROR uninitialized get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>(); - //~^ ERROR it is undefined behavior + //~^ ERROR 0x42, but expected a boolean get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); - //~^ ERROR evaluation of constant value failed - //~| NOTE uninitialized - //~| ERROR it is undefined behavior + //~^ ERROR uninitialized + //~| ERROR 0x42, but expected a boolean } diff --git a/tests/ui/const-ptr/forbidden_slices.rs b/tests/ui/const-ptr/forbidden_slices.rs index 001cfd66ad145..fcb0dccf750e3 100644 --- a/tests/ui/const-ptr/forbidden_slices.rs +++ b/tests/ui/const-ptr/forbidden_slices.rs @@ -14,24 +14,24 @@ use std::{ // Null is never valid for references pub static S0: &[u32] = unsafe { from_raw_parts(ptr::null(), 0) }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: null reference pub static S1: &[()] = unsafe { from_raw_parts(ptr::null(), 0) }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: null reference // Out of bounds pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: dangling reference (going beyond the bounds of its allocation) // Reading uninitialized data -pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; //~ ERROR: it is undefined behavior to use this value +pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; //~ ERROR: uninitialized memory // Reinterpret pointers as integers (UB in CTFE.) -pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size_of::<&u32>()) }; //~ ERROR: it is undefined behavior to use this value +pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size_of::<&u32>()) }; //~ ERROR: pointer, but expected an integer // Layout mismatch -pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; //~ ERROR: it is undefined behavior to use this value +pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; //~ ERROR: 0x11, but expected a boolean // Reading padding is not ok pub static S7: &[u16] = unsafe { - //~^ ERROR: it is undefined behavior to use this value + //~^ ERROR: uninitialized memory let ptr = (&D2 as *const Struct as *const u16).add(1); from_raw_parts(ptr, 4) @@ -39,53 +39,53 @@ pub static S7: &[u16] = unsafe { // Unaligned read pub static S8: &[u64] = unsafe { - //~^ ERROR: it is undefined behavior to use this value + //~^ ERROR: dangling reference (going beyond the bounds of its allocation) let ptr = (&D4 as *const [u32; 2] as *const u32).byte_add(1).cast::(); from_raw_parts(ptr, 1) }; pub static R0: &[u32] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR encountered a null reference pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; // errors inside libcore -//~^ ERROR could not evaluate static initializer +//~^ ERROR 0 < pointee_size && pointee_size <= isize::MAX as usize pub static R2: &[u32] = unsafe { let ptr = &D0 as *const u32; from_ptr_range(ptr..ptr.add(2)) // errors inside libcore - //~^ ERROR could not evaluate static initializer + //~^ ERROR in-bounds pointer arithmetic failed }; pub static R4: &[u8] = unsafe { - //~^ ERROR: it is undefined behavior to use this value + //~^ ERROR: encountered uninitialized memory, but expected an integer let ptr = (&D1) as *const MaybeUninit<&u32> as *const u8; from_ptr_range(ptr..ptr.add(1)) }; pub static R5: &[u8] = unsafe { - //~^ ERROR: it is undefined behavior to use this value + //~^ ERROR: encountered a pointer, but expected an integer let ptr = &D3 as *const &u32; from_ptr_range(ptr.cast()..ptr.add(1).cast()) }; pub static R6: &[bool] = unsafe { - //~^ ERROR: it is undefined behavior to use this value + //~^ ERROR: 0x11, but expected a boolean let ptr = &D0 as *const u32 as *const bool; from_ptr_range(ptr..ptr.add(4)) }; pub static R7: &[u16] = unsafe { - //~^ ERROR: it is undefined behavior to use this value + //~^ ERROR: unaligned reference (required 2 byte alignment but found 1) let ptr = (&D2 as *const Struct as *const u16).byte_add(1); from_ptr_range(ptr..ptr.add(4)) }; pub static R8: &[u64] = unsafe { let ptr = (&D4 as *const [u32; 2] as *const u32).byte_add(1).cast::(); from_ptr_range(ptr..ptr.add(1)) - //~^ ERROR could not evaluate static initializer + //~^ ERROR in-bounds pointer arithmetic failed }; // This is sneaky: &D0 and &D0 point to different objects // (even if at runtime they have the same address) pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) }; -//~^ ERROR could not evaluate static initializer +//~^ ERROR not both derived from the same allocation pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) }; -//~^ ERROR could not evaluate static initializer +//~^ ERROR not both derived from the same allocation const D0: u32 = 0x11111111; // Constant chosen for endianness-independent behavior. const D1: MaybeUninit<&u32> = MaybeUninit::uninit(); diff --git a/tests/ui/const-ptr/forbidden_slices.stderr b/tests/ui/const-ptr/forbidden_slices.stderr index e618fbf7e0fe4..d4dcc6e66b1ef 100644 --- a/tests/ui/const-ptr/forbidden_slices.stderr +++ b/tests/ui/const-ptr/forbidden_slices.stderr @@ -1,179 +1,179 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered a null reference --> $DIR/forbidden_slices.rs:16:1 | LL | pub static S0: &[u32] = unsafe { from_raw_parts(ptr::null(), 0) }; - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered a null reference --> $DIR/forbidden_slices.rs:18:1 | LL | pub static S1: &[()] = unsafe { from_raw_parts(ptr::null(), 0) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) --> $DIR/forbidden_slices.rs:22:1 | LL | pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) }; - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .[0]: encountered uninitialized memory, but expected an integer --> $DIR/forbidden_slices.rs:26:1 | LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .[0]: encountered a pointer, but expected an integer --> $DIR/forbidden_slices.rs:28:1 | LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size_of::<&u32>()) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a pointer, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .[0]: encountered 0x11, but expected a boolean --> $DIR/forbidden_slices.rs:30:1 | LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered 0x11, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .[1]: encountered uninitialized memory, but expected an integer --> $DIR/forbidden_slices.rs:33:1 | LL | pub static S7: &[u16] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[1]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) --> $DIR/forbidden_slices.rs:41:1 | LL | pub static S8: &[u64] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered a null reference --> $DIR/forbidden_slices.rs:48:1 | LL | pub static R0: &[u32] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: could not evaluate static initializer +error[E0080]: evaluation panicked: assertion failed: 0 < pointee_size && pointee_size <= isize::MAX as usize --> $DIR/forbidden_slices.rs:50:33 | LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; // errors inside libcore - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: assertion failed: 0 < pointee_size && pointee_size <= isize::MAX as usize + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here -error[E0080]: could not evaluate static initializer +error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC10 which is only 4 bytes from the end of the allocation --> $DIR/forbidden_slices.rs:54:25 | LL | from_ptr_range(ptr..ptr.add(2)) // errors inside libcore - | ^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC10 which is only 4 bytes from the end of the allocation + | ^^^^^^^^^^ evaluation of static initializer failed here -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .[0]: encountered uninitialized memory, but expected an integer --> $DIR/forbidden_slices.rs:57:1 | LL | pub static R4: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .[0]: encountered a pointer, but expected an integer --> $DIR/forbidden_slices.rs:62:1 | LL | pub static R5: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a pointer, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .[0]: encountered 0x11, but expected a boolean --> $DIR/forbidden_slices.rs:67:1 | LL | pub static R6: &[bool] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered 0x11, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) --> $DIR/forbidden_slices.rs:72:1 | LL | pub static R7: &[u16] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: could not evaluate static initializer +error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC11+0x1 which is only 7 bytes from the end of the allocation --> $DIR/forbidden_slices.rs:79:25 | LL | from_ptr_range(ptr..ptr.add(1)) - | ^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC11+0x1 which is only 7 bytes from the end of the allocation + | ^^^^^^^^^^ evaluation of static initializer failed here -error[E0080]: could not evaluate static initializer +error[E0080]: `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation --> $DIR/forbidden_slices.rs:85:34 | LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here -error[E0080]: could not evaluate static initializer +error[E0080]: `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation --> $DIR/forbidden_slices.rs:87:35 | LL | pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation + | ^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here error: aborting due to 18 previous errors diff --git a/tests/ui/const-ptr/out_of_bounds_read.rs b/tests/ui/const-ptr/out_of_bounds_read.rs index ccf45bf324a0d..b09978badde5f 100644 --- a/tests/ui/const-ptr/out_of_bounds_read.rs +++ b/tests/ui/const-ptr/out_of_bounds_read.rs @@ -6,9 +6,9 @@ fn main() { const PAST_END_PTR: *const u32 = unsafe { DATA.as_ptr().add(1) }; const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR at or beyond the end of the allocation const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR at or beyond the end of the allocation const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR at or beyond the end of the allocation } diff --git a/tests/ui/const-ptr/out_of_bounds_read.stderr b/tests/ui/const-ptr/out_of_bounds_read.stderr index 8f93793802ba3..e921a5f49876e 100644 --- a/tests/ui/const-ptr/out_of_bounds_read.stderr +++ b/tests/ui/const-ptr/out_of_bounds_read.stderr @@ -1,20 +1,20 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes --> $DIR/out_of_bounds_read.rs:8:33 | LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes + | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes --> $DIR/out_of_bounds_read.rs:10:39 | LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; - | ^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes + | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes --> $DIR/out_of_bounds_read.rs:12:37 | LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 3 previous errors diff --git a/tests/ui/consts/assert-type-intrinsics.rs b/tests/ui/consts/assert-type-intrinsics.rs index 32b5f5c92c52d..91c8dd00e89f9 100644 --- a/tests/ui/consts/assert-type-intrinsics.rs +++ b/tests/ui/consts/assert-type-intrinsics.rs @@ -9,14 +9,14 @@ fn main() { const _BAD1: () = unsafe { MaybeUninit::::uninit().assume_init(); - //~^ERROR: evaluation of constant value failed + //~^ERROR: uninhabited }; const _BAD2: () = { intrinsics::assert_mem_uninitialized_valid::<&'static i32>(); - //~^ERROR: evaluation of constant value failed + //~^ERROR: uninitialized }; const _BAD3: () = { intrinsics::assert_zero_valid::<&'static i32>(); - //~^ERROR: evaluation of constant value failed + //~^ERROR: zero-initialize type `&i32` }; } diff --git a/tests/ui/consts/assert-type-intrinsics.stderr b/tests/ui/consts/assert-type-intrinsics.stderr index 92c0610a24807..90f003716d1a0 100644 --- a/tests/ui/consts/assert-type-intrinsics.stderr +++ b/tests/ui/consts/assert-type-intrinsics.stderr @@ -1,20 +1,20 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: aborted execution: attempted to instantiate uninhabited type `!` --> $DIR/assert-type-intrinsics.rs:11:9 | LL | MaybeUninit::::uninit().assume_init(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: aborted execution: attempted to instantiate uninhabited type `!` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: aborted execution: attempted to leave type `&i32` uninitialized, which is invalid --> $DIR/assert-type-intrinsics.rs:15:9 | LL | intrinsics::assert_mem_uninitialized_valid::<&'static i32>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: aborted execution: attempted to leave type `&i32` uninitialized, which is invalid + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: aborted execution: attempted to zero-initialize type `&i32`, which is invalid --> $DIR/assert-type-intrinsics.rs:19:9 | LL | intrinsics::assert_zero_valid::<&'static i32>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: aborted execution: attempted to zero-initialize type `&i32`, which is invalid + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 3 previous errors diff --git a/tests/ui/consts/assoc_const_generic_impl.rs b/tests/ui/consts/assoc_const_generic_impl.rs index 5820a724d073c..a4904795254ca 100644 --- a/tests/ui/consts/assoc_const_generic_impl.rs +++ b/tests/ui/consts/assoc_const_generic_impl.rs @@ -6,7 +6,7 @@ trait ZeroSized: Sized { } impl ZeroSized for T { - const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::()]; //~ ERROR evaluation of `::I_AM_ZERO_SIZED` failed + const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::()]; //~ ERROR index out of bounds: the length is 1 but the index is 4 fn requires_zero_size(self) { Self::I_AM_ZERO_SIZED; println!("requires_zero_size called"); diff --git a/tests/ui/consts/assoc_const_generic_impl.stderr b/tests/ui/consts/assoc_const_generic_impl.stderr index 4521950839670..fc8986a34c566 100644 --- a/tests/ui/consts/assoc_const_generic_impl.stderr +++ b/tests/ui/consts/assoc_const_generic_impl.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `::I_AM_ZERO_SIZED` failed - --> $DIR/assoc_const_generic_impl.rs:9:34 +error[E0080]: index out of bounds: the length is 1 but the index is 4 + --> $DIR/assoc_const_generic_impl.rs:9:33 | -LL | const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::()]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 4 +LL | const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::()]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `::I_AM_ZERO_SIZED` failed here note: erroneous constant encountered --> $DIR/assoc_const_generic_impl.rs:11:9 diff --git a/tests/ui/consts/const-array-oob.rs b/tests/ui/consts/const-array-oob.rs index 4b457d1c23c37..dc713b74d7f58 100644 --- a/tests/ui/consts/const-array-oob.rs +++ b/tests/ui/consts/const-array-oob.rs @@ -1,11 +1,9 @@ const FOO: [usize; 3] = [1, 2, 3]; const BAR: usize = FOO[5]; -//~^ ERROR: evaluation of constant value failed -//~| NOTE index out of bounds: the length is 3 but the index is 5 +//~^ ERROR: index out of bounds: the length is 3 but the index is 5 const BLUB: [u32; FOO[4]] = [5, 6]; -//~^ ERROR evaluation of constant value failed [E0080] -//~| NOTE index out of bounds: the length is 3 but the index is 4 +//~^ ERROR index out of bounds: the length is 3 but the index is 4 fn main() { let _ = BAR; diff --git a/tests/ui/consts/const-array-oob.stderr b/tests/ui/consts/const-array-oob.stderr index 89427c051e760..d4a0266449032 100644 --- a/tests/ui/consts/const-array-oob.stderr +++ b/tests/ui/consts/const-array-oob.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/const-array-oob.rs:6:19 +error[E0080]: index out of bounds: the length is 3 but the index is 4 + --> $DIR/const-array-oob.rs:5:19 | LL | const BLUB: [u32; FOO[4]] = [5, 6]; - | ^^^^^^ index out of bounds: the length is 3 but the index is 4 + | ^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: index out of bounds: the length is 3 but the index is 5 --> $DIR/const-array-oob.rs:2:20 | LL | const BAR: usize = FOO[5]; - | ^^^^^^ index out of bounds: the length is 3 but the index is 5 + | ^^^^^^ evaluation of constant value failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-assert-unchecked-ub.rs b/tests/ui/consts/const-assert-unchecked-ub.rs index ffc02eedcb7a7..a62abcf12d69a 100644 --- a/tests/ui/consts/const-assert-unchecked-ub.rs +++ b/tests/ui/consts/const-assert-unchecked-ub.rs @@ -1,6 +1,6 @@ const _: () = unsafe { let n = u32::MAX.count_ones(); - std::hint::assert_unchecked(n < 32); //~ ERROR evaluation of constant value failed + std::hint::assert_unchecked(n < 32); //~ ERROR `assume` called with `false` }; fn main() {} diff --git a/tests/ui/consts/const-assert-unchecked-ub.stderr b/tests/ui/consts/const-assert-unchecked-ub.stderr index 468f15f34728f..0a785942cf4af 100644 --- a/tests/ui/consts/const-assert-unchecked-ub.stderr +++ b/tests/ui/consts/const-assert-unchecked-ub.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: `assume` called with `false` --> $DIR/const-assert-unchecked-ub.rs:3:5 | LL | std::hint::assert_unchecked(n < 32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `assume` called with `false` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-compare-bytes-ub.rs b/tests/ui/consts/const-compare-bytes-ub.rs index 9dafae1efd1a6..0bc8585a4eed1 100644 --- a/tests/ui/consts/const-compare-bytes-ub.rs +++ b/tests/ui/consts/const-compare-bytes-ub.rs @@ -7,34 +7,34 @@ use std::mem::MaybeUninit; fn main() { const LHS_NULL: i32 = unsafe { compare_bytes(0 as *const u8, 2 as *const u8, 1) - //~^ ERROR evaluation of constant value failed + //~^ ERROR memory access failed }; const RHS_NULL: i32 = unsafe { compare_bytes(1 as *const u8, 0 as *const u8, 1) - //~^ ERROR evaluation of constant value failed + //~^ ERROR memory access failed }; const DANGLING_PTR_NON_ZERO_LENGTH: i32 = unsafe { compare_bytes(1 as *const u8, 2 as *const u8, 1) - //~^ ERROR evaluation of constant value failed + //~^ ERROR memory access failed }; const LHS_OUT_OF_BOUNDS: i32 = unsafe { compare_bytes([1, 2, 3].as_ptr(), [1, 2, 3, 4].as_ptr(), 4) - //~^ ERROR evaluation of constant value failed + //~^ ERROR memory access failed }; const RHS_OUT_OF_BOUNDS: i32 = unsafe { compare_bytes([1, 2, 3, 4].as_ptr(), [1, 2, 3].as_ptr(), 4) - //~^ ERROR evaluation of constant value failed + //~^ ERROR memory access failed }; const LHS_UNINIT: i32 = unsafe { compare_bytes(MaybeUninit::uninit().as_ptr(), [1].as_ptr(), 1) - //~^ ERROR evaluation of constant value failed + //~^ ERROR memory is uninitialized }; const RHS_UNINIT: i32 = unsafe { compare_bytes([1].as_ptr(), MaybeUninit::uninit().as_ptr(), 1) - //~^ ERROR evaluation of constant value failed + //~^ ERROR memory is uninitialized }; const WITH_PROVENANCE: i32 = unsafe { compare_bytes([&1].as_ptr().cast(), [&2].as_ptr().cast(), std::mem::size_of::()) - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer }; } diff --git a/tests/ui/consts/const-compare-bytes-ub.stderr b/tests/ui/consts/const-compare-bytes-ub.stderr index 0e77310c6bab9..1b3824f22d064 100644 --- a/tests/ui/consts/const-compare-bytes-ub.stderr +++ b/tests/ui/consts/const-compare-bytes-ub.stderr @@ -1,50 +1,50 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: attempting to access 1 byte, but got null pointer --> $DIR/const-compare-bytes-ub.rs:9:9 | LL | compare_bytes(0 as *const u8, 2 as *const u8, 1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 1 byte, but got null pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +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 | compare_bytes(1 as *const u8, 0 as *const u8, 1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +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 | compare_bytes(1 as *const u8, 2 as *const u8, 1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0 which is only 3 bytes from the end of the allocation --> $DIR/const-compare-bytes-ub.rs:21:9 | LL | compare_bytes([1, 2, 3].as_ptr(), [1, 2, 3, 4].as_ptr(), 4) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC0 which is only 3 bytes from the end of the allocation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC1 which is only 3 bytes from the end of the allocation --> $DIR/const-compare-bytes-ub.rs:25:9 | LL | compare_bytes([1, 2, 3, 4].as_ptr(), [1, 2, 3].as_ptr(), 4) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC1 which is only 3 bytes from the end of the allocation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: reading memory at ALLOC2[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory --> $DIR/const-compare-bytes-ub.rs:29:9 | LL | compare_bytes(MaybeUninit::uninit().as_ptr(), [1].as_ptr(), 1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at ALLOC2[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: reading memory at ALLOC3[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory --> $DIR/const-compare-bytes-ub.rs:33:9 | LL | compare_bytes([1].as_ptr(), MaybeUninit::uninit().as_ptr(), 1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at ALLOC3[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/const-compare-bytes-ub.rs:37:9 | LL | compare_bytes([&1].as_ptr().cast(), [&2].as_ptr().cast(), std::mem::size_of::()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/const-deref-ptr.rs b/tests/ui/consts/const-deref-ptr.rs index c80cb95ea936c..ae928f55ebd86 100644 --- a/tests/ui/consts/const-deref-ptr.rs +++ b/tests/ui/consts/const-deref-ptr.rs @@ -1,8 +1,7 @@ // Check that you can't dereference invalid raw pointers in constants. fn main() { - static C: u64 = unsafe {*(0xdeadbeef as *const u64)}; - //~^ ERROR could not evaluate static initializer - //~| NOTE dangling pointer + static C: u64 = unsafe { *(0xdeadbeef as *const u64) }; + //~^ ERROR dangling pointer println!("{}", C); } diff --git a/tests/ui/consts/const-deref-ptr.stderr b/tests/ui/consts/const-deref-ptr.stderr index 37502864947a4..f233b7d94bd9a 100644 --- a/tests/ui/consts/const-deref-ptr.stderr +++ b/tests/ui/consts/const-deref-ptr.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer - --> $DIR/const-deref-ptr.rs:4:29 +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 | static C: u64 = unsafe {*(0xdeadbeef as *const u64)}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 8 bytes, but got 0xdeadbeef[noalloc] which is a dangling pointer (it has no provenance) +LL | static C: u64 = unsafe { *(0xdeadbeef as *const u64) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-err-early.rs b/tests/ui/consts/const-err-early.rs index a3105b4fc4a37..998ac951ea919 100644 --- a/tests/ui/consts/const-err-early.rs +++ b/tests/ui/consts/const-err-early.rs @@ -1,8 +1,8 @@ -pub const A: i8 = -i8::MIN; //~ ERROR constant -pub const B: u8 = 200u8 + 200u8; //~ ERROR constant -pub const C: u8 = 200u8 * 4; //~ ERROR constant -pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR constant -pub const E: u8 = [5u8][1]; //~ ERROR constant +pub const A: i8 = -i8::MIN; //~ ERROR overflow +pub const B: u8 = 200u8 + 200u8; //~ ERROR overflow +pub const C: u8 = 200u8 * 4; //~ ERROR overflow +pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR overflow +pub const E: u8 = [5u8][1]; //~ ERROR index out of bounds fn main() { let _a = A; diff --git a/tests/ui/consts/const-err-early.stderr b/tests/ui/consts/const-err-early.stderr index 59bf637b7adbd..98f9b4fbd2a5b 100644 --- a/tests/ui/consts/const-err-early.stderr +++ b/tests/ui/consts/const-err-early.stderr @@ -1,32 +1,32 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to negate `i8::MIN`, which would overflow --> $DIR/const-err-early.rs:1:19 | LL | pub const A: i8 = -i8::MIN; - | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `200_u8 + 200_u8`, which would overflow --> $DIR/const-err-early.rs:2:19 | LL | pub const B: u8 = 200u8 + 200u8; - | ^^^^^^^^^^^^^ attempt to compute `200_u8 + 200_u8`, which would overflow + | ^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `200_u8 * 4_u8`, which would overflow --> $DIR/const-err-early.rs:3:19 | LL | pub const C: u8 = 200u8 * 4; - | ^^^^^^^^^ attempt to compute `200_u8 * 4_u8`, which would overflow + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `42_u8 - 43_u8`, which would overflow --> $DIR/const-err-early.rs:4:19 | LL | pub const D: u8 = 42u8 - (42u8 + 1); - | ^^^^^^^^^^^^^^^^^ attempt to compute `42_u8 - 43_u8`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: index out of bounds: the length is 1 but the index is 1 --> $DIR/const-err-early.rs:5:19 | LL | pub const E: u8 = [5u8][1]; - | ^^^^^^^^ index out of bounds: the length is 1 but the index is 1 + | ^^^^^^^^ evaluation of constant value failed here error: aborting due to 5 previous errors diff --git a/tests/ui/consts/const-err-enum-discriminant.rs b/tests/ui/consts/const-err-enum-discriminant.rs index 42165ff534653..190ef47f4362e 100644 --- a/tests/ui/consts/const-err-enum-discriminant.rs +++ b/tests/ui/consts/const-err-enum-discriminant.rs @@ -6,8 +6,7 @@ union Foo { enum Bar { Boo = [unsafe { Foo { b: () }.a }; 4][3], - //~^ ERROR evaluation of constant value failed - //~| NOTE uninitialized + //~^ ERROR uninitialized } fn main() { diff --git a/tests/ui/consts/const-err-enum-discriminant.stderr b/tests/ui/consts/const-err-enum-discriminant.stderr index 7cf34595dc972..702d85b2f9312 100644 --- a/tests/ui/consts/const-err-enum-discriminant.stderr +++ b/tests/ui/consts/const-err-enum-discriminant.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/const-err-enum-discriminant.rs:8:21 | LL | Boo = [unsafe { Foo { b: () }.a }; 4][3], - | ^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-err-late.rs b/tests/ui/consts/const-err-late.rs index f8bea388109d3..9cc2196a954ed 100644 --- a/tests/ui/consts/const-err-late.rs +++ b/tests/ui/consts/const-err-late.rs @@ -12,8 +12,8 @@ struct S(T); impl S { const FOO: u8 = [5u8][1]; - //~^ ERROR evaluation of `S::::FOO` failed - //~| ERROR evaluation of `S::::FOO` failed + //~^ ERROR index out of bounds: the length is 1 but the index is 1 + //~| ERROR index out of bounds: the length is 1 but the index is 1 } fn main() { diff --git a/tests/ui/consts/const-err-late.stderr b/tests/ui/consts/const-err-late.stderr index 0c021e8761ea1..02be7bbe10c47 100644 --- a/tests/ui/consts/const-err-late.stderr +++ b/tests/ui/consts/const-err-late.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `S::::FOO` failed +error[E0080]: index out of bounds: the length is 1 but the index is 1 --> $DIR/const-err-late.rs:14:21 | LL | const FOO: u8 = [5u8][1]; - | ^^^^^^^^ index out of bounds: the length is 1 but the index is 1 + | ^^^^^^^^ evaluation of `S::::FOO` failed here note: erroneous constant encountered --> $DIR/const-err-late.rs:20:16 @@ -10,11 +10,11 @@ note: erroneous constant encountered LL | black_box((S::::FOO, S::::FOO)); | ^^^^^^^^^^^^^ -error[E0080]: evaluation of `S::::FOO` failed +error[E0080]: index out of bounds: the length is 1 but the index is 1 --> $DIR/const-err-late.rs:14:21 | LL | const FOO: u8 = [5u8][1]; - | ^^^^^^^^ index out of bounds: the length is 1 but the index is 1 + | ^^^^^^^^ evaluation of `S::::FOO` failed here note: erroneous constant encountered --> $DIR/const-err-late.rs:20:31 diff --git a/tests/ui/consts/const-err-multi.rs b/tests/ui/consts/const-err-multi.rs index f21cc97345c79..2fb0d29124554 100644 --- a/tests/ui/consts/const-err-multi.rs +++ b/tests/ui/consts/const-err-multi.rs @@ -1,6 +1,6 @@ pub const A: i8 = -i8::MIN; -//~^ ERROR constant -//~| NOTE attempt to negate `i8::MIN`, which would overflow +//~^ NOTE constant +//~| ERROR attempt to negate `i8::MIN`, which would overflow pub const B: i8 = A; //~^ NOTE constant pub const C: u8 = A as u8; diff --git a/tests/ui/consts/const-err-multi.stderr b/tests/ui/consts/const-err-multi.stderr index c60be59b87d33..9e1554eb265a2 100644 --- a/tests/ui/consts/const-err-multi.stderr +++ b/tests/ui/consts/const-err-multi.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to negate `i8::MIN`, which would overflow --> $DIR/const-err-multi.rs:1:19 | LL | pub const A: i8 = -i8::MIN; - | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here note: erroneous constant encountered --> $DIR/const-err-multi.rs:4:19 diff --git a/tests/ui/consts/const-eval-fail-too-big.rs b/tests/ui/consts/const-eval-fail-too-big.rs index 4b5dbc1d7a4ef..b14505135fb52 100644 --- a/tests/ui/consts/const-eval-fail-too-big.rs +++ b/tests/ui/consts/const-eval-fail-too-big.rs @@ -2,7 +2,7 @@ struct B< A: Sized = [(); { let x = [0u8; !0usize]; - //~^ ERROR evaluation of constant value failed + //~^ ERROR too big for the target architecture 1 }], > { diff --git a/tests/ui/consts/const-eval-fail-too-big.stderr b/tests/ui/consts/const-eval-fail-too-big.stderr index ae6664832336e..3bc20ded5bfa0 100644 --- a/tests/ui/consts/const-eval-fail-too-big.stderr +++ b/tests/ui/consts/const-eval-fail-too-big.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +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 | let x = [0u8; !0usize]; - | ^^^^^^^^^^^^^^ values of the type `[u8; usize::MAX]` are too big for the target architecture + | ^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/assign-to-static-within-other-static.rs b/tests/ui/consts/const-eval/assign-to-static-within-other-static.rs index 30e40bd8be13e..7a7a256694011 100644 --- a/tests/ui/consts/const-eval/assign-to-static-within-other-static.rs +++ b/tests/ui/consts/const-eval/assign-to-static-within-other-static.rs @@ -6,7 +6,7 @@ use std::cell::UnsafeCell; static mut FOO: u32 = 42; static BOO: () = unsafe { FOO = 5; - //~^ ERROR could not evaluate static initializer [E0080] + //~^ ERROR modifying a static's initial value }; fn main() {} 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 5300111a6b6bd..b19d0eaa116ff 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,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: modifying a static's initial value from another static's initializer --> $DIR/assign-to-static-within-other-static.rs:8:5 | LL | FOO = 5; - | ^^^^^^^ modifying a static's initial value from another static's initializer + | ^^^^^^^ evaluation of static initializer failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/conditional_array_execution.rs b/tests/ui/consts/const-eval/conditional_array_execution.rs index 27d5383d6d47f..1473efa742852 100644 --- a/tests/ui/consts/const-eval/conditional_array_execution.rs +++ b/tests/ui/consts/const-eval/conditional_array_execution.rs @@ -1,7 +1,7 @@ const X: u32 = 5; const Y: u32 = 6; const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; -//~^ ERROR constant +//~^ ERROR overflow fn main() { println!("{}", FOO); diff --git a/tests/ui/consts/const-eval/conditional_array_execution.stderr b/tests/ui/consts/const-eval/conditional_array_execution.stderr index 3003437807970..65ae9a9fb8ade 100644 --- a/tests/ui/consts/const-eval/conditional_array_execution.stderr +++ b/tests/ui/consts/const-eval/conditional_array_execution.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `5_u32 - 6_u32`, which would overflow --> $DIR/conditional_array_execution.rs:3:19 | LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; - | ^^^^^ attempt to compute `5_u32 - 6_u32`, which would overflow + | ^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/const-eval-overflow-2.rs b/tests/ui/consts/const-eval/const-eval-overflow-2.rs index bae8a7ce243e9..71ac655435b33 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-2.rs +++ b/tests/ui/consts/const-eval/const-eval-overflow-2.rs @@ -8,7 +8,7 @@ use std::{i8, i16, i32, i64, isize}; use std::{u8, u16, u32, u64, usize}; const NEG_128: i8 = -128; -const NEG_NEG_128: i8 = -NEG_128; //~ ERROR constant +const NEG_NEG_128: i8 = -NEG_128; //~ ERROR overflow fn main() { match -128i8 { diff --git a/tests/ui/consts/const-eval/const-eval-overflow-2.stderr b/tests/ui/consts/const-eval/const-eval-overflow-2.stderr index 5599ff931e8e5..90b94600aed44 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-2.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-2.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to negate `i8::MIN`, which would overflow --> $DIR/const-eval-overflow-2.rs:11:25 | LL | const NEG_NEG_128: i8 = -NEG_128; - | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/const-eval-overflow-3.rs b/tests/ui/consts/const-eval/const-eval-overflow-3.rs index bcc966dc9621c..bf7e791483a58 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-3.rs +++ b/tests/ui/consts/const-eval/const-eval-overflow-3.rs @@ -16,7 +16,7 @@ use std::fmt; const A_I8_I : [u32; (i8::MAX as usize) + 1] = [0; (i8::MAX + 1) as usize]; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflow fn main() { foo(&A_I8_I[..]); 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 0437cd3adb41b..5ad7d08bdb3de 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-3.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-3.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i8::MAX + 1_i8`, which would overflow --> $DIR/const-eval-overflow-3.rs:18:11 | LL | = [0; (i8::MAX + 1) as usize]; - | ^^^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8`, which would overflow + | ^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/const-eval-overflow-4.rs b/tests/ui/consts/const-eval/const-eval-overflow-4.rs index 762c7a968a8ff..d42c29249af3a 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-4.rs +++ b/tests/ui/consts/const-eval/const-eval-overflow-4.rs @@ -9,7 +9,7 @@ use std::fmt; const A_I8_T : [u32; (i8::MAX as i8 + 1i8) as usize] - //~^ ERROR evaluation of constant value failed + //~^ ERROR overflow = [0; (i8::MAX as usize) + 1]; fn main() { 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 ce5e59901c133..c14a880849f22 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-4.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-4.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i8::MAX + 1_i8`, which would overflow --> $DIR/const-eval-overflow-4.rs:11:13 | LL | : [u32; (i8::MAX as i8 + 1i8) as usize] - | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/const-eval-overflow2.rs b/tests/ui/consts/const-eval/const-eval-overflow2.rs index 1676f7c2af65a..348c8e06f66b3 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2.rs +++ b/tests/ui/consts/const-eval/const-eval-overflow2.rs @@ -11,47 +11,47 @@ const VALS_I8: (i8,) = ( i8::MIN - 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I16: (i16,) = ( i16::MIN - 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I32: (i32,) = ( i32::MIN - 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I64: (i64,) = ( i64::MIN - 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U8: (u8,) = ( u8::MIN - 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U16: (u16,) = ( u16::MIN - 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U32: (u32,) = ( u32::MIN - 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U64: (u64,) = ( u64::MIN - 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow fn main() { foo(VALS_I8); diff --git a/tests/ui/consts/const-eval/const-eval-overflow2.stderr b/tests/ui/consts/const-eval/const-eval-overflow2.stderr index 341c15daf65b5..a705604e383f8 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow2.stderr @@ -1,50 +1,50 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i8::MIN - 1_i8`, which would overflow --> $DIR/const-eval-overflow2.rs:12:6 | LL | i8::MIN - 1, - | ^^^^^^^^^^^ attempt to compute `i8::MIN - 1_i8`, which would overflow + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i16::MIN - 1_i16`, which would overflow --> $DIR/const-eval-overflow2.rs:18:6 | LL | i16::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `i16::MIN - 1_i16`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i32::MIN - 1_i32`, which would overflow --> $DIR/const-eval-overflow2.rs:24:6 | LL | i32::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `i32::MIN - 1_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i64::MIN - 1_i64`, which would overflow --> $DIR/const-eval-overflow2.rs:30:6 | LL | i64::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `i64::MIN - 1_i64`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `0_u8 - 1_u8`, which would overflow --> $DIR/const-eval-overflow2.rs:36:6 | LL | u8::MIN - 1, - | ^^^^^^^^^^^ attempt to compute `0_u8 - 1_u8`, which would overflow + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `0_u16 - 1_u16`, which would overflow --> $DIR/const-eval-overflow2.rs:41:6 | LL | u16::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `0_u16 - 1_u16`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `0_u32 - 1_u32`, which would overflow --> $DIR/const-eval-overflow2.rs:46:6 | LL | u32::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `0_u64 - 1_u64`, which would overflow --> $DIR/const-eval-overflow2.rs:52:6 | LL | u64::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `0_u64 - 1_u64`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 8 previous errors diff --git a/tests/ui/consts/const-eval/const-eval-overflow2b.rs b/tests/ui/consts/const-eval/const-eval-overflow2b.rs index 59d1df5680deb..b05b0b11105cc 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2b.rs +++ b/tests/ui/consts/const-eval/const-eval-overflow2b.rs @@ -11,47 +11,47 @@ const VALS_I8: (i8,) = ( i8::MAX + 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I16: (i16,) = ( i16::MAX + 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I32: (i32,) = ( i32::MAX + 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I64: (i64,) = ( i64::MAX + 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U8: (u8,) = ( u8::MAX + 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U16: (u16,) = ( u16::MAX + 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U32: (u32,) = ( u32::MAX + 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U64: (u64,) = ( u64::MAX + 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow fn main() { foo(VALS_I8); diff --git a/tests/ui/consts/const-eval/const-eval-overflow2b.stderr b/tests/ui/consts/const-eval/const-eval-overflow2b.stderr index e661836b4b951..33de4b6ed32b4 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2b.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow2b.stderr @@ -1,50 +1,50 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i8::MAX + 1_i8`, which would overflow --> $DIR/const-eval-overflow2b.rs:12:6 | LL | i8::MAX + 1, - | ^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8`, which would overflow + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i16::MAX + 1_i16`, which would overflow --> $DIR/const-eval-overflow2b.rs:18:6 | LL | i16::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `i16::MAX + 1_i16`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i32::MAX + 1_i32`, which would overflow --> $DIR/const-eval-overflow2b.rs:24:6 | LL | i32::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `i32::MAX + 1_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i64::MAX + 1_i64`, which would overflow --> $DIR/const-eval-overflow2b.rs:30:6 | LL | i64::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `i64::MAX + 1_i64`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow --> $DIR/const-eval-overflow2b.rs:36:6 | LL | u8::MAX + 1, - | ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u16::MAX + 1_u16`, which would overflow --> $DIR/const-eval-overflow2b.rs:41:6 | LL | u16::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `u16::MAX + 1_u16`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u32::MAX + 1_u32`, which would overflow --> $DIR/const-eval-overflow2b.rs:46:6 | LL | u32::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `u32::MAX + 1_u32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u64::MAX + 1_u64`, which would overflow --> $DIR/const-eval-overflow2b.rs:52:6 | LL | u64::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `u64::MAX + 1_u64`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 8 previous errors diff --git a/tests/ui/consts/const-eval/const-eval-overflow2c.rs b/tests/ui/consts/const-eval/const-eval-overflow2c.rs index 33b892601153a..ec87f5e066c1d 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2c.rs +++ b/tests/ui/consts/const-eval/const-eval-overflow2c.rs @@ -11,47 +11,47 @@ const VALS_I8: (i8,) = ( i8::MIN * 2, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I16: (i16,) = ( i16::MIN * 2, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I32: (i32,) = ( i32::MIN * 2, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I64: (i64,) = ( i64::MIN * 2, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U8: (u8,) = ( u8::MAX * 2, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U16: (u16,) = ( u16::MAX * 2, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U32: (u32,) = ( u32::MAX * 2, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U64: (u64,) = ( u64::MAX * 2, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow fn main() { foo(VALS_I8); diff --git a/tests/ui/consts/const-eval/const-eval-overflow2c.stderr b/tests/ui/consts/const-eval/const-eval-overflow2c.stderr index 1fad15492fb82..69949b579044e 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2c.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow2c.stderr @@ -1,50 +1,50 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i8::MIN * 2_i8`, which would overflow --> $DIR/const-eval-overflow2c.rs:12:6 | LL | i8::MIN * 2, - | ^^^^^^^^^^^ attempt to compute `i8::MIN * 2_i8`, which would overflow + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i16::MIN * 2_i16`, which would overflow --> $DIR/const-eval-overflow2c.rs:18:6 | LL | i16::MIN * 2, - | ^^^^^^^^^^^^ attempt to compute `i16::MIN * 2_i16`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i32::MIN * 2_i32`, which would overflow --> $DIR/const-eval-overflow2c.rs:24:6 | LL | i32::MIN * 2, - | ^^^^^^^^^^^^ attempt to compute `i32::MIN * 2_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i64::MIN * 2_i64`, which would overflow --> $DIR/const-eval-overflow2c.rs:30:6 | LL | i64::MIN * 2, - | ^^^^^^^^^^^^ attempt to compute `i64::MIN * 2_i64`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u8::MAX * 2_u8`, which would overflow --> $DIR/const-eval-overflow2c.rs:36:6 | LL | u8::MAX * 2, - | ^^^^^^^^^^^ attempt to compute `u8::MAX * 2_u8`, which would overflow + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u16::MAX * 2_u16`, which would overflow --> $DIR/const-eval-overflow2c.rs:41:6 | LL | u16::MAX * 2, - | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 2_u16`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u32::MAX * 2_u32`, which would overflow --> $DIR/const-eval-overflow2c.rs:46:6 | LL | u32::MAX * 2, - | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 2_u32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u64::MAX * 2_u64`, which would overflow --> $DIR/const-eval-overflow2c.rs:52:6 | LL | u64::MAX * 2, - | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 2_u64`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 8 previous errors diff --git a/tests/ui/consts/const-eval/const-eval-query-stack.rs b/tests/ui/consts/const-eval/const-eval-query-stack.rs index 8de398787b41b..3728e2071d358 100644 --- a/tests/ui/consts/const-eval/const-eval-query-stack.rs +++ b/tests/ui/consts/const-eval/const-eval-query-stack.rs @@ -13,7 +13,7 @@ //@ normalize-stderr: ".*omitted \d{1,} frame.*\n" -> "" #![allow(unconditional_panic)] -const X: i32 = 1 / 0; //~ERROR constant +const X: i32 = 1 / 0; //~ERROR attempt to divide `1_i32` by zero fn main() { let x: &'static i32 = &X; diff --git a/tests/ui/consts/const-eval/const-eval-query-stack.stderr b/tests/ui/consts/const-eval/const-eval-query-stack.stderr index 5a71c770fdc7a..d5b7e67724dcc 100644 --- a/tests/ui/consts/const-eval/const-eval-query-stack.stderr +++ b/tests/ui/consts/const-eval/const-eval-query-stack.stderr @@ -1,8 +1,8 @@ -error: internal compiler error[E0080]: evaluation of constant value failed +error: internal compiler error[E0080]: attempt to divide `1_i32` by zero --> $DIR/const-eval-query-stack.rs:16:16 | LL | const X: i32 = 1 / 0; - | ^^^^^ attempt to divide `1_i32` by zero + | ^^^^^ evaluation of constant value failed here note: please make sure that you have updated to the latest nightly 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 3eccd596274a1..3a1e8c734d443 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,254 +1,254 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:27:49 | LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:30:43 | LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:33:45 | LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:36:45 | LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:39:45 | LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/const-pointer-values-in-various-types.rs:42:47 | LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:46:43 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:45:43 | LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:49:45 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:48:45 | LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:52:45 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:51:45 | LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:55:45 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:54:45 | LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:58:47 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/const-pointer-values-in-various-types.rs:57:47 | LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:62:45 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:60:45 | LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:65:45 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:63:45 | LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:68:47 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:66:47 | LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:71:47 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:69:47 | LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:74:39 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:72:39 | LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:77:41 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:75:41 | LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:80:41 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:78:41 | LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:83:41 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:81:41 | LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:86:43 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:84:43 | LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:89:39 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:87:39 | LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:92:41 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:90:41 | LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:95:41 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:93:41 | LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:98:41 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:96:41 | LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:101:43 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:99:43 | LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:104:41 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:102:41 | LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:107:41 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:105:41 | LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:110:43 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:108:43 | LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:113:43 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:111:43 | LL | const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/const-eval/const-pointer-values-in-various-types.rs b/tests/ui/consts/const-eval/const-pointer-values-in-various-types.rs index ce7380cd1553f..5720d6ea91ed5 100644 --- a/tests/ui/consts/const-eval/const-pointer-values-in-various-types.rs +++ b/tests/ui/consts/const-eval/const-pointer-values-in-various-types.rs @@ -25,91 +25,89 @@ union Nonsense { fn main() { const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 }; - //~^ ERROR evaluation of constant value failed - //~| NOTE uninitialized + //~^ ERROR uninitialized const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 }; - //~^ ERROR evaluation of constant value failed - //~| NOTE uninitialized + //~^ ERROR uninitialized const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer } diff --git a/tests/ui/consts/const-eval/const_fn_ptr_fail2.rs b/tests/ui/consts/const-eval/const_fn_ptr_fail2.rs index c6ae3af44270b..03976a05b75cf 100644 --- a/tests/ui/consts/const-eval/const_fn_ptr_fail2.rs +++ b/tests/ui/consts/const-eval/const_fn_ptr_fail2.rs @@ -14,11 +14,11 @@ const fn bar(x: fn(usize) -> usize, y: usize) -> usize { } const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday -//~^ ERROR evaluation of constant value failed -//~| NOTE calling non-const function `double` +//~^ NOTE evaluation of constant value failed +//~| ERROR calling non-const function `double` const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday -//~^ ERROR evaluation of constant value failed -//~| NOTE calling non-const function `double` +//~^ NOTE evaluation of constant value failed +//~| ERROR calling non-const function `double` fn main() { assert_eq!(Y, 4); diff --git a/tests/ui/consts/const-eval/const_fn_ptr_fail2.stderr b/tests/ui/consts/const-eval/const_fn_ptr_fail2.stderr index a4d2e26c3afbc..6eddb72bae803 100644 --- a/tests/ui/consts/const-eval/const_fn_ptr_fail2.stderr +++ b/tests/ui/consts/const-eval/const_fn_ptr_fail2.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: calling non-const function `double` --> $DIR/const_fn_ptr_fail2.rs:16:18 | LL | const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday - | ^^^^^^^^^ calling non-const function `double` + | ^^^^^^^^^ evaluation of constant value failed here | note: inside `bar` --> $DIR/const_fn_ptr_fail2.rs:9:5 @@ -10,11 +10,11 @@ note: inside `bar` LL | x(y) | ^^^^ the failure occurred here -error[E0080]: evaluation of constant value failed +error[E0080]: calling non-const function `double` --> $DIR/const_fn_ptr_fail2.rs:19:18 | LL | const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday - | ^^^^^^^^^^^^^^ calling non-const function `double` + | ^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `bar` --> $DIR/const_fn_ptr_fail2.rs:9:5 diff --git a/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.rs b/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.rs index 0bf2f0e6669d7..45298df024349 100644 --- a/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.rs +++ b/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.rs @@ -1,5 +1,5 @@ #![crate_type = "lib"] struct Bug([u8; panic!{"\t"}]); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked //~| NOTE: in this expansion of panic! diff --git a/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr b/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr index fae971c09f23f..6e5e0e727fb10 100644 --- a/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr +++ b/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: --> $DIR/const_panic-normalize-tabs-115498.rs:3:17 | LL | struct Bug([u8; panic!{"\t"}]); - | ^^^^^^^^^^^^ evaluation panicked: + | ^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/const_panic.rs b/tests/ui/consts/const-eval/const_panic.rs index 5b9a8f8e2a279..367396bab9462 100644 --- a/tests/ui/consts/const-eval/const_panic.rs +++ b/tests/ui/consts/const-eval/const_panic.rs @@ -4,37 +4,37 @@ const MSG: &str = "hello"; const Z: () = std::panic!("cheese"); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const Z2: () = std::panic!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const Y: () = std::unreachable!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const X: () = std::unimplemented!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const W: () = std::panic!(MSG); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const W2: () = std::panic!("{}", MSG); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const Z_CORE: () = core::panic!("cheese"); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const Z2_CORE: () = core::panic!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const Y_CORE: () = core::unreachable!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const X_CORE: () = core::unimplemented!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const W_CORE: () = core::panic!(MSG); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const W2_CORE: () = core::panic!("{}", MSG); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked diff --git a/tests/ui/consts/const-eval/const_panic.stderr b/tests/ui/consts/const-eval/const_panic.stderr index 0874224e5f277..1b5421276c326 100644 --- a/tests/ui/consts/const-eval/const_panic.stderr +++ b/tests/ui/consts/const-eval/const_panic.stderr @@ -1,78 +1,78 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: cheese --> $DIR/const_panic.rs:6:15 | LL | const Z: () = std::panic!("cheese"); - | ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: cheese + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/const_panic.rs:9:16 | LL | const Z2: () = std::panic!(); - | ^^^^^^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: internal error: entered unreachable code --> $DIR/const_panic.rs:12:15 | LL | const Y: () = std::unreachable!(); - | ^^^^^^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code + | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: not implemented --> $DIR/const_panic.rs:15:15 | LL | const X: () = std::unimplemented!(); - | ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: not implemented + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = note: this error originates in the macro `std::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: hello --> $DIR/const_panic.rs:18:15 | LL | const W: () = std::panic!(MSG); - | ^^^^^^^^^^^^^^^^ evaluation panicked: hello + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: hello --> $DIR/const_panic.rs:21:16 | LL | const W2: () = std::panic!("{}", MSG); - | ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: hello + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: cheese --> $DIR/const_panic.rs:24:20 | LL | const Z_CORE: () = core::panic!("cheese"); - | ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: cheese + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/const_panic.rs:27:21 | LL | const Z2_CORE: () = core::panic!(); - | ^^^^^^^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: internal error: entered unreachable code --> $DIR/const_panic.rs:30:20 | LL | const Y_CORE: () = core::unreachable!(); - | ^^^^^^^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code + | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: not implemented --> $DIR/const_panic.rs:33:20 | LL | const X_CORE: () = core::unimplemented!(); - | ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: not implemented + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = note: this error originates in the macro `core::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: hello --> $DIR/const_panic.rs:36:20 | LL | const W_CORE: () = core::panic!(MSG); - | ^^^^^^^^^^^^^^^^^ evaluation panicked: hello + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: hello --> $DIR/const_panic.rs:39:21 | LL | const W2_CORE: () = core::panic!("{}", MSG); - | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: hello + | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 12 previous errors diff --git a/tests/ui/consts/const-eval/const_panic_2021.rs b/tests/ui/consts/const-eval/const_panic_2021.rs index 31a80e71b7cb5..845f78beef994 100644 --- a/tests/ui/consts/const-eval/const_panic_2021.rs +++ b/tests/ui/consts/const-eval/const_panic_2021.rs @@ -4,31 +4,31 @@ const MSG: &str = "hello"; const A: () = std::panic!("blåhaj"); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const B: () = std::panic!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const C: () = std::unreachable!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const D: () = std::unimplemented!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const E: () = std::panic!("{}", MSG); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const A_CORE: () = core::panic!("shark"); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const B_CORE: () = core::panic!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const C_CORE: () = core::unreachable!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const D_CORE: () = core::unimplemented!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const E_CORE: () = core::panic!("{}", MSG); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked diff --git a/tests/ui/consts/const-eval/const_panic_2021.stderr b/tests/ui/consts/const-eval/const_panic_2021.stderr index 1496df4445a6d..15b173f94006b 100644 --- a/tests/ui/consts/const-eval/const_panic_2021.stderr +++ b/tests/ui/consts/const-eval/const_panic_2021.stderr @@ -1,66 +1,66 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: blåhaj --> $DIR/const_panic_2021.rs:6:15 | LL | const A: () = std::panic!("blåhaj"); - | ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: blåhaj + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/const_panic_2021.rs:9:15 | LL | const B: () = std::panic!(); - | ^^^^^^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: internal error: entered unreachable code --> $DIR/const_panic_2021.rs:12:15 | LL | const C: () = std::unreachable!(); - | ^^^^^^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code + | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: not implemented --> $DIR/const_panic_2021.rs:15:15 | LL | const D: () = std::unimplemented!(); - | ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: not implemented + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = note: this error originates in the macro `std::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: hello --> $DIR/const_panic_2021.rs:18:15 | LL | const E: () = std::panic!("{}", MSG); - | ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: hello + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: shark --> $DIR/const_panic_2021.rs:21:20 | LL | const A_CORE: () = core::panic!("shark"); - | ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: shark + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/const_panic_2021.rs:24:20 | LL | const B_CORE: () = core::panic!(); - | ^^^^^^^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: internal error: entered unreachable code --> $DIR/const_panic_2021.rs:27:20 | LL | const C_CORE: () = core::unreachable!(); - | ^^^^^^^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code + | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: not implemented --> $DIR/const_panic_2021.rs:30:20 | LL | const D_CORE: () = core::unimplemented!(); - | ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: not implemented + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = note: this error originates in the macro `core::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: hello --> $DIR/const_panic_2021.rs:33:20 | LL | const E_CORE: () = core::panic!("{}", MSG); - | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: hello + | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 10 previous errors diff --git a/tests/ui/consts/const-eval/const_panic_libcore_bin.rs b/tests/ui/consts/const-eval/const_panic_libcore_bin.rs index d4dc1a51d73aa..90ae5165d233b 100644 --- a/tests/ui/consts/const-eval/const_panic_libcore_bin.rs +++ b/tests/ui/consts/const-eval/const_panic_libcore_bin.rs @@ -6,13 +6,13 @@ use core::panic::PanicInfo; const Z: () = panic!("cheese"); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const Y: () = unreachable!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const X: () = unimplemented!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked #[lang = "eh_personality"] fn eh() {} diff --git a/tests/ui/consts/const-eval/const_panic_libcore_bin.stderr b/tests/ui/consts/const-eval/const_panic_libcore_bin.stderr index 2acab71129097..3c308e3885090 100644 --- a/tests/ui/consts/const-eval/const_panic_libcore_bin.stderr +++ b/tests/ui/consts/const-eval/const_panic_libcore_bin.stderr @@ -1,20 +1,20 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: cheese --> $DIR/const_panic_libcore_bin.rs:8:15 | LL | const Z: () = panic!("cheese"); - | ^^^^^^^^^^^^^^^^ evaluation panicked: cheese + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: internal error: entered unreachable code --> $DIR/const_panic_libcore_bin.rs:11:15 | LL | const Y: () = unreachable!(); - | ^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: not implemented --> $DIR/const_panic_libcore_bin.rs:14:15 | LL | const X: () = unimplemented!(); - | ^^^^^^^^^^^^^^^^ evaluation panicked: not implemented + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = note: this error originates in the macro `unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/const-eval/const_panic_track_caller.rs b/tests/ui/consts/const-eval/const_panic_track_caller.rs index 799a59d16ca2f..5f5d853eb97d3 100644 --- a/tests/ui/consts/const-eval/const_panic_track_caller.rs +++ b/tests/ui/consts/const-eval/const_panic_track_caller.rs @@ -17,5 +17,5 @@ const fn c() -> u32 { } const X: u32 = c(); -//~^ ERROR evaluation of constant value failed -//~| NOTE hey +//~^ NOTE evaluation of constant value failed +//~| ERROR hey diff --git a/tests/ui/consts/const-eval/const_panic_track_caller.stderr b/tests/ui/consts/const-eval/const_panic_track_caller.stderr index 8736a8c9409d6..b4017ccf8da6e 100644 --- a/tests/ui/consts/const-eval/const_panic_track_caller.stderr +++ b/tests/ui/consts/const-eval/const_panic_track_caller.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: hey --> $DIR/const_panic_track_caller.rs:19:16 | LL | const X: u32 = c(); - | ^^^ evaluation panicked: hey + | ^^^ evaluation of constant value failed here | note: inside `c` --> $DIR/const_panic_track_caller.rs:15:5 diff --git a/tests/ui/consts/const-eval/const_raw_ptr_ops2.rs b/tests/ui/consts/const-eval/const_raw_ptr_ops2.rs index 0e88aa80c7977..47998cf408c7c 100644 --- a/tests/ui/consts/const-eval/const_raw_ptr_ops2.rs +++ b/tests/ui/consts/const-eval/const_raw_ptr_ops2.rs @@ -4,7 +4,5 @@ fn main() {} const Z: i32 = unsafe { *(&1 as *const i32) }; // bad, will thus error in miri -const Z2: i32 = unsafe { *(42 as *const i32) }; //~ ERROR evaluation of constant value failed -//~| NOTE dangling pointer -const Z3: i32 = unsafe { *(44 as *const i32) }; //~ ERROR evaluation of constant value failed -//~| NOTE dangling pointer +const Z2: i32 = unsafe { *(42 as *const i32) }; //~ ERROR dangling pointer +const Z3: i32 = unsafe { *(44 as *const i32) }; //~ ERROR dangling pointer diff --git a/tests/ui/consts/const-eval/const_raw_ptr_ops2.stderr b/tests/ui/consts/const-eval/const_raw_ptr_ops2.stderr index a8a5560ccb9c2..6f096ee5ce7f7 100644 --- a/tests/ui/consts/const-eval/const_raw_ptr_ops2.stderr +++ b/tests/ui/consts/const-eval/const_raw_ptr_ops2.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: attempting to access 4 bytes, but got 0x2a[noalloc] which is a dangling pointer (it has no provenance) --> $DIR/const_raw_ptr_ops2.rs:7:26 | LL | const Z2: i32 = unsafe { *(42 as *const i32) }; - | ^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got 0x2a[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const_raw_ptr_ops2.rs:9:26 +error[E0080]: memory access failed: attempting to access 4 bytes, but got 0x2c[noalloc] which is a dangling pointer (it has no provenance) + --> $DIR/const_raw_ptr_ops2.rs:8:26 | LL | const Z3: i32 = unsafe { *(44 as *const i32) }; - | ^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got 0x2c[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs index b47e2b3c1ed01..d6e5a69671b69 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs @@ -4,7 +4,7 @@ #![feature(const_heap)] use std::intrinsics; -const FOO: i32 = foo(); //~ ERROR evaluation of constant value failed +const FOO: i32 = foo(); //~ ERROR 3 is not a power of 2 const fn foo() -> i32 { unsafe { let _ = intrinsics::const_allocate(4, 3) as *mut i32; //~ NOTE inside `foo` diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr index 9f7546df3a2b9..9132c7e9cd4bd 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: invalid align passed to `const_allocate`: 3 is not a power of 2 --> $DIR/alloc_intrinsic_errors.rs:7:18 | LL | const FOO: i32 = foo(); - | ^^^^^ invalid align passed to `const_allocate`: 3 is not a power of 2 + | ^^^^^ evaluation of constant value failed here | note: inside `foo` --> $DIR/alloc_intrinsic_errors.rs:10:17 diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr index 271c861109185..11ed0841a0039 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .: encountered uninitialized memory, but expected an integer --> $DIR/alloc_intrinsic_uninit.rs:7:1 | LL | const BAR: &i32 = unsafe { &*(intrinsics::const_allocate(4, 4) as *mut i32) }; - | ^^^^^^^^^^^^^^^ constructing invalid value at .: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr index ec7cc7d4140ac..691bde87d2f21 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .: encountered uninitialized memory, but expected an integer --> $DIR/alloc_intrinsic_uninit.rs:7:1 | LL | const BAR: &i32 = unsafe { &*(intrinsics::const_allocate(4, 4) as *mut i32) }; - | ^^^^^^^^^^^^^^^ constructing invalid value at .: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs index c283a5fae7de6..ffc35ca1ddceb 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs @@ -5,5 +5,5 @@ use std::intrinsics; const BAR: &i32 = unsafe { &*(intrinsics::const_allocate(4, 4) as *mut i32) }; -//~^ error: it is undefined behavior to use this value +//~^ ERROR: uninitialized memory fn main() {} diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs index 509c872f6095d..de9fc5d092137 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs @@ -9,7 +9,7 @@ use std::intrinsics; const _X: &'static u8 = unsafe { - //~^ error: it is undefined behavior to use this value + //~^ ERROR: dangling reference (use-after-free) let ptr = intrinsics::const_allocate(4, 4); intrinsics::const_deallocate(ptr, 4, 4); &*ptr @@ -20,7 +20,7 @@ const _Y: u8 = unsafe { let reference = &*ptr; intrinsics::const_deallocate(ptr, 4, 4); *reference - //~^ error: evaluation of constant value failed + //~^ ERROR: has been freed, so this pointer is dangling }; fn main() {} 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 0b0d2676dd3ef..cb419f2f739cf 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr @@ -1,19 +1,19 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered a dangling reference (use-after-free) --> $DIR/dealloc_intrinsic_dangling.rs:11:1 | LL | const _X: &'static u8 = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (use-after-free) + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: ALLOC1 has been freed, so this pointer is dangling --> $DIR/dealloc_intrinsic_dangling.rs:22:5 | LL | *reference - | ^^^^^^^^^^ memory access failed: ALLOC1 has been freed, so this pointer is dangling + | ^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.rs b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.rs index 4010b476990dc..5b7cd039b9baa 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.rs +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.rs @@ -7,7 +7,7 @@ const _X: () = unsafe { let ptr = intrinsics::const_allocate(4, 4); intrinsics::const_deallocate(ptr, 4, 4); intrinsics::const_deallocate(ptr, 4, 4); - //~^ error: evaluation of constant value failed + //~^ ERROR: dangling }; fn main() {} 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 d2d323e5a5156..3038d60f20209 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: ALLOC0 has been freed, so this pointer is dangling --> $DIR/dealloc_intrinsic_duplicate.rs:9:5 | LL | intrinsics::const_deallocate(ptr, 4, 4); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC0 has been freed, so this pointer is dangling + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.rs b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.rs index 031d70fdc8897..75c3601f2166e 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.rs +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.rs @@ -6,24 +6,24 @@ use std::intrinsics; const _X: () = unsafe { let ptr = intrinsics::const_allocate(4, 4); intrinsics::const_deallocate(ptr, 4, 2); - //~^ error: evaluation of constant value failed + //~^ error: incorrect layout on deallocation }; const _Y: () = unsafe { let ptr = intrinsics::const_allocate(4, 4); intrinsics::const_deallocate(ptr, 2, 4); - //~^ error: evaluation of constant value failed + //~^ error: incorrect layout on deallocation }; const _Z: () = unsafe { let ptr = intrinsics::const_allocate(4, 4); intrinsics::const_deallocate(ptr, 3, 4); - //~^ error: evaluation of constant value failed + //~^ error: incorrect layout on deallocation }; const _W: () = unsafe { let ptr = intrinsics::const_allocate(4, 4); intrinsics::const_deallocate(ptr, 4, 3); - //~^ error: evaluation of constant value failed + //~^ error: invalid align }; fn main() {} 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 4b1f0f686ca0b..dea55c6086e9c 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,26 +1,26 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: incorrect layout on deallocation: ALLOC0 has size 4 and alignment 4, but gave size 4 and alignment 2 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:8:5 | LL | intrinsics::const_deallocate(ptr, 4, 2); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC0 has size 4 and alignment 4, but gave size 4 and alignment 2 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: incorrect layout on deallocation: ALLOC1 has size 4 and alignment 4, but gave size 2 and alignment 4 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:13:5 | LL | intrinsics::const_deallocate(ptr, 2, 4); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC1 has size 4 and alignment 4, but gave size 2 and alignment 4 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: incorrect layout on deallocation: ALLOC2 has size 4 and alignment 4, but gave size 3 and alignment 4 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:19:5 | LL | intrinsics::const_deallocate(ptr, 3, 4); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC2 has size 4 and alignment 4, but gave size 3 and alignment 4 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: invalid align passed to `const_deallocate`: 3 is not a power of 2 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:25:5 | LL | intrinsics::const_deallocate(ptr, 4, 3); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid align passed to `const_deallocate`: 3 is not a power of 2 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 4 previous errors diff --git a/tests/ui/consts/const-eval/index-out-of-bounds-never-type.rs b/tests/ui/consts/const-eval/index-out-of-bounds-never-type.rs index 25ffc9cbdba4b..6777bee050a16 100644 --- a/tests/ui/consts/const-eval/index-out-of-bounds-never-type.rs +++ b/tests/ui/consts/const-eval/index-out-of-bounds-never-type.rs @@ -8,7 +8,7 @@ struct PrintName(T); impl PrintName { const VOID: ! = { let x = 0 * std::mem::size_of::(); [][x] }; - //~^ ERROR evaluation of `PrintName::<()>::VOID` failed + //~^ ERROR index out of bounds: the length is 0 but the index is 0 } 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 7facb2d1a5ca2..7e57e16aa4f03 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,8 +1,8 @@ -error[E0080]: evaluation of `PrintName::<()>::VOID` failed +error[E0080]: index out of bounds: the length is 0 but the index is 0 --> $DIR/index-out-of-bounds-never-type.rs:10:61 | LL | const VOID: ! = { let x = 0 * std::mem::size_of::(); [][x] }; - | ^^^^^ index out of bounds: the length is 0 but the index is 0 + | ^^^^^ evaluation of `PrintName::<()>::VOID` failed here note: erroneous constant encountered --> $DIR/index-out-of-bounds-never-type.rs:16:13 diff --git a/tests/ui/consts/const-eval/index_out_of_bounds.stderr b/tests/ui/consts/const-eval/index_out_of_bounds.stderr index d8df74fa01036..f4ec4c516fd0d 100644 --- a/tests/ui/consts/const-eval/index_out_of_bounds.stderr +++ b/tests/ui/consts/const-eval/index_out_of_bounds.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: index out of bounds: the length is 0 but the index is 0 --> $DIR/index_out_of_bounds.rs:1:19 | LL | static FOO: i32 = [][0]; - | ^^^^^ index out of bounds: the length is 0 but the index is 0 + | ^^^^^ evaluation of static initializer failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/issue-43197.rs b/tests/ui/consts/const-eval/issue-43197.rs index 145463f0ae298..778a66facb803 100644 --- a/tests/ui/consts/const-eval/issue-43197.rs +++ b/tests/ui/consts/const-eval/issue-43197.rs @@ -4,8 +4,8 @@ const fn foo(x: u32) -> u32 { fn main() { const X: u32 = 0 - 1; - //~^ ERROR constant + //~^ ERROR overflow const Y: u32 = foo(0 - 1); - //~^ ERROR constant + //~^ ERROR overflow println!("{} {}", X, Y); } diff --git a/tests/ui/consts/const-eval/issue-43197.stderr b/tests/ui/consts/const-eval/issue-43197.stderr index c59f13e488828..cad23becff7a6 100644 --- a/tests/ui/consts/const-eval/issue-43197.stderr +++ b/tests/ui/consts/const-eval/issue-43197.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `0_u32 - 1_u32`, which would overflow --> $DIR/issue-43197.rs:6:20 | LL | const X: u32 = 0 - 1; - | ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow + | ^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `0_u32 - 1_u32`, which would overflow --> $DIR/issue-43197.rs:8:24 | LL | const Y: u32 = foo(0 - 1); - | ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow + | ^^^^^ evaluation of constant value failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/issue-44578.rs b/tests/ui/consts/const-eval/issue-44578.rs index 565e1d3825b4d..ebd54f4079ccc 100644 --- a/tests/ui/consts/const-eval/issue-44578.rs +++ b/tests/ui/consts/const-eval/issue-44578.rs @@ -11,7 +11,7 @@ enum Bar { } impl Foo for Bar { - const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; //~ERROR evaluation of ` as Foo>::AMT` failed + const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; //~ERROR the length is 1 but the index is 1 } impl Foo for u8 { diff --git a/tests/ui/consts/const-eval/issue-44578.stderr b/tests/ui/consts/const-eval/issue-44578.stderr index 5093cec81c7ab..fd0b9ae1e17d4 100644 --- a/tests/ui/consts/const-eval/issue-44578.stderr +++ b/tests/ui/consts/const-eval/issue-44578.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of ` as Foo>::AMT` failed +error[E0080]: index out of bounds: the length is 1 but the index is 1 --> $DIR/issue-44578.rs:14:24 | LL | const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of ` as Foo>::AMT` failed here note: erroneous constant encountered --> $DIR/issue-44578.rs:26:20 diff --git a/tests/ui/consts/const-eval/issue-49296.rs b/tests/ui/consts/const-eval/issue-49296.rs index 917777a32fff3..a427b642899a5 100644 --- a/tests/ui/consts/const-eval/issue-49296.rs +++ b/tests/ui/consts/const-eval/issue-49296.rs @@ -7,7 +7,7 @@ const fn wat(x: u64) -> &'static u64 { } const X: u64 = *wat(42); -//~^ ERROR evaluation of constant value failed +//~^ ERROR dangling fn main() { println!("{}", X); diff --git a/tests/ui/consts/const-eval/issue-49296.stderr b/tests/ui/consts/const-eval/issue-49296.stderr index 485a11d1f3c6f..4a66ec6c9404d 100644 --- a/tests/ui/consts/const-eval/issue-49296.stderr +++ b/tests/ui/consts/const-eval/issue-49296.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: ALLOC0 has been freed, so this pointer is dangling --> $DIR/issue-49296.rs:9:16 | LL | const X: u64 = *wat(42); - | ^^^^^^^^ memory access failed: ALLOC0 has been freed, so this pointer is dangling + | ^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error 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 1f4f217b17560..6c0d6cf8b2153 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,8 +1,8 @@ -error[E0080]: evaluation of ` as Foo<()>>::BAR` failed +error[E0080]: index out of bounds: the length is 3 but the index is 42 --> $DIR/issue-50814-2.rs:17:24 | LL | const BAR: usize = [5, 6, 7][T::BOO]; - | ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42 + | ^^^^^^^^^^^^^^^^^ evaluation of ` as Foo<()>>::BAR` failed here note: erroneous constant encountered --> $DIR/issue-50814-2.rs:21:6 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 f790862aef158..749c9dde1ce19 100644 --- a/tests/ui/consts/const-eval/issue-50814-2.normal.stderr +++ b/tests/ui/consts/const-eval/issue-50814-2.normal.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of ` as Foo<()>>::BAR` failed +error[E0080]: index out of bounds: the length is 3 but the index is 42 --> $DIR/issue-50814-2.rs:17:24 | LL | const BAR: usize = [5, 6, 7][T::BOO]; - | ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42 + | ^^^^^^^^^^^^^^^^^ evaluation of ` as Foo<()>>::BAR` failed here note: erroneous constant encountered --> $DIR/issue-50814-2.rs:21:6 diff --git a/tests/ui/consts/const-eval/issue-50814-2.rs b/tests/ui/consts/const-eval/issue-50814-2.rs index 261dcd3aa4ca6..1b917a0916da3 100644 --- a/tests/ui/consts/const-eval/issue-50814-2.rs +++ b/tests/ui/consts/const-eval/issue-50814-2.rs @@ -14,7 +14,7 @@ trait Foo { struct A(T); impl Foo for A { - const BAR: usize = [5, 6, 7][T::BOO]; //~ ERROR evaluation of ` as Foo<()>>::BAR` failed + const BAR: usize = [5, 6, 7][T::BOO]; //~ ERROR index out of bounds: the length is 3 but the index is 42 } fn foo() -> &'static usize { diff --git a/tests/ui/consts/const-eval/issue-50814.rs b/tests/ui/consts/const-eval/issue-50814.rs index 5495fb43bba22..011f065ad814b 100644 --- a/tests/ui/consts/const-eval/issue-50814.rs +++ b/tests/ui/consts/const-eval/issue-50814.rs @@ -14,8 +14,8 @@ struct Sum(A, B); impl Unsigned for Sum { const MAX: u8 = A::MAX + B::MAX; - //~^ ERROR evaluation of ` as Unsigned>::MAX` failed - //~| ERROR evaluation of ` as Unsigned>::MAX` failed + //~^ ERROR attempt to compute `u8::MAX + u8::MAX`, which would overflow + //~| ERROR attempt to compute `u8::MAX + u8::MAX`, which would overflow } fn foo(_: T) -> &'static u8 { diff --git a/tests/ui/consts/const-eval/issue-50814.stderr b/tests/ui/consts/const-eval/issue-50814.stderr index 5b23c48e450de..1287c83ae0ff8 100644 --- a/tests/ui/consts/const-eval/issue-50814.stderr +++ b/tests/ui/consts/const-eval/issue-50814.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of ` as Unsigned>::MAX` failed +error[E0080]: attempt to compute `u8::MAX + u8::MAX`, which would overflow --> $DIR/issue-50814.rs:16:21 | LL | const MAX: u8 = A::MAX + B::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of ` as Unsigned>::MAX` failed here note: erroneous constant encountered --> $DIR/issue-50814.rs:22:6 @@ -10,11 +10,11 @@ note: erroneous constant encountered LL | &Sum::::MAX | ^^^^^^^^^^^^^^^^^^ -error[E0080]: evaluation of ` as Unsigned>::MAX` failed +error[E0080]: attempt to compute `u8::MAX + u8::MAX`, which would overflow --> $DIR/issue-50814.rs:16:21 | LL | const MAX: u8 = A::MAX + B::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of ` as Unsigned>::MAX` failed here | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/consts/const-eval/issue-85155.rs b/tests/ui/consts/const-eval/issue-85155.rs index cb5b3a08375d0..c47101d04c2c2 100644 --- a/tests/ui/consts/const-eval/issue-85155.rs +++ b/tests/ui/consts/const-eval/issue-85155.rs @@ -20,5 +20,5 @@ fn main() { //~^ NOTE the above error was encountered while instantiating } -//~? ERROR evaluation of `post_monomorphization_error::ValidateConstImm::<2, 0, 1>::VALID` failed +//~? ERROR attempt to divide `1_usize` by zero //~? NOTE erroneous constant encountered diff --git a/tests/ui/consts/const-eval/issue-85155.stderr b/tests/ui/consts/const-eval/issue-85155.stderr index 99836a3fac6d5..f7777bfac0206 100644 --- a/tests/ui/consts/const-eval/issue-85155.stderr +++ b/tests/ui/consts/const-eval/issue-85155.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `post_monomorphization_error::ValidateConstImm::<2, 0, 1>::VALID` failed +error[E0080]: attempt to divide `1_usize` by zero --> $DIR/auxiliary/post_monomorphization_error.rs:7:17 | LL | let _ = 1 / ((IMM >= MIN && IMM <= MAX) as usize); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to divide `1_usize` by zero + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `post_monomorphization_error::ValidateConstImm::<2, 0, 1>::VALID` failed here note: erroneous constant encountered --> $DIR/auxiliary/post_monomorphization_error.rs:19:5 diff --git a/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.rs b/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.rs index 3a932343ddda4..12effde1a9bba 100644 --- a/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.rs +++ b/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.rs @@ -36,8 +36,7 @@ const OFFSET: () = unsafe { // This needs to compute the field offset, but we don't know the type's alignment, so this // fails. let field = &x.a; - //~^ ERROR: evaluation of constant value failed - //~| NOTE does not have a known offset + //~^ ERROR: does not have a known offset }; fn main() {} 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 54d45ee8ffb24..ffff7594e3dd8 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,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: `extern type` field does not have a known offset --> $DIR/issue-91827-extern-types-field-offset.rs:38:17 | LL | let field = &x.a; - | ^^^^ `extern type` field does not have a known offset + | ^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/mod-static-with-const-fn.rs b/tests/ui/consts/const-eval/mod-static-with-const-fn.rs index 7de9d44305d60..ce2ecaa2638ad 100644 --- a/tests/ui/consts/const-eval/mod-static-with-const-fn.rs +++ b/tests/ui/consts/const-eval/mod-static-with-const-fn.rs @@ -12,7 +12,7 @@ static FOO: Foo = Foo(UnsafeCell::new(42)); static BAR: () = unsafe { *FOO.0.get() = 5; - //~^ ERROR could not evaluate static initializer + //~^ ERROR modifying a static's initial value }; fn main() { 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 47bfc235a1afe..f8cf609609598 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,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: modifying a static's initial value from another static's initializer --> $DIR/mod-static-with-const-fn.rs:14:5 | LL | *FOO.0.get() = 5; - | ^^^^^^^^^^^^^^^^ modifying a static's initial value from another static's initializer + | ^^^^^^^^^^^^^^^^ evaluation of static initializer failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/nonnull_as_ref_ub.rs b/tests/ui/consts/const-eval/nonnull_as_ref_ub.rs index 19ab5239986c7..908833e651429 100644 --- a/tests/ui/consts/const-eval/nonnull_as_ref_ub.rs +++ b/tests/ui/consts/const-eval/nonnull_as_ref_ub.rs @@ -1,6 +1,6 @@ use std::ptr::NonNull; const NON_NULL: NonNull = unsafe { NonNull::dangling() }; -const _: () = assert!(42 == *unsafe { NON_NULL.as_ref() }); //~ERROR: evaluation of constant value failed +const _: () = assert!(42 == *unsafe { NON_NULL.as_ref() }); //~ERROR: dangling pointer (it has no provenance) fn main() {} diff --git a/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr b/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr index 1996cd2721ecf..32ae94755602f 100644 --- a/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr +++ b/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) --> $DIR/nonnull_as_ref_ub.rs:4:29 | LL | const _: () = assert!(42 == *unsafe { NON_NULL.as_ref() }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/panic-assoc-never-type.rs b/tests/ui/consts/const-eval/panic-assoc-never-type.rs index 79b5dafaf15fa..a0a5ba36bfe4f 100644 --- a/tests/ui/consts/const-eval/panic-assoc-never-type.rs +++ b/tests/ui/consts/const-eval/panic-assoc-never-type.rs @@ -8,7 +8,7 @@ struct PrintName; impl PrintName { const VOID: ! = panic!(); - //~^ ERROR evaluation of constant value failed + //~^ ERROR explicit panic } fn main() { 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 03413f46b20ad..64c9f92d5ee37 100644 --- a/tests/ui/consts/const-eval/panic-assoc-never-type.stderr +++ b/tests/ui/consts/const-eval/panic-assoc-never-type.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/panic-assoc-never-type.rs:10:21 | LL | const VOID: ! = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of constant value failed here note: erroneous constant encountered --> $DIR/panic-assoc-never-type.rs:15:13 diff --git a/tests/ui/consts/const-eval/panic-never-type.rs b/tests/ui/consts/const-eval/panic-never-type.rs index a9e9026d9bc07..d9b46e70b357d 100644 --- a/tests/ui/consts/const-eval/panic-never-type.rs +++ b/tests/ui/consts/const-eval/panic-never-type.rs @@ -2,7 +2,7 @@ #![feature(never_type)] const VOID: ! = panic!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR explicit panic fn main() { let _ = VOID; diff --git a/tests/ui/consts/const-eval/panic-never-type.stderr b/tests/ui/consts/const-eval/panic-never-type.stderr index 1d9bba9aea2bf..cacce93babede 100644 --- a/tests/ui/consts/const-eval/panic-never-type.stderr +++ b/tests/ui/consts/const-eval/panic-never-type.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/panic-never-type.rs:4:17 | LL | const VOID: ! = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/parse_ints.rs b/tests/ui/consts/const-eval/parse_ints.rs index 309b7ee5d27ac..409fae9e51d92 100644 --- a/tests/ui/consts/const-eval/parse_ints.rs +++ b/tests/ui/consts/const-eval/parse_ints.rs @@ -2,7 +2,7 @@ const _OK: () = match i32::from_str_radix("-1234", 10) { Ok(x) => assert!(x == -1234), Err(_) => panic!(), }; -const _TOO_LOW: () = { u64::from_str_radix("12345ABCD", 1); }; //~ ERROR evaluation of constant value failed -const _TOO_HIGH: () = { u64::from_str_radix("12345ABCD", 37); }; //~ ERROR evaluation of constant value failed +const _TOO_LOW: () = { u64::from_str_radix("12345ABCD", 1); }; //~ ERROR radix must lie in the range `[2, 36]` +const _TOO_HIGH: () = { u64::from_str_radix("12345ABCD", 37); }; //~ ERROR radix must lie in the range `[2, 36]` fn main () {} diff --git a/tests/ui/consts/const-eval/parse_ints.stderr b/tests/ui/consts/const-eval/parse_ints.stderr index 7a855bb9e5cc7..99aad805a2dd4 100644 --- a/tests/ui/consts/const-eval/parse_ints.stderr +++ b/tests/ui/consts/const-eval/parse_ints.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: from_ascii_radix: radix must lie in the range `[2, 36]` --> $DIR/parse_ints.rs:5:24 | LL | const _TOO_LOW: () = { u64::from_str_radix("12345ABCD", 1); }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: from_ascii_radix: radix must lie in the range `[2, 36]` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `core::num::::from_str_radix` --> $SRC_DIR/core/src/num/mod.rs:LL:COL @@ -10,11 +10,11 @@ note: inside `core::num::::from_ascii_radix` --> $SRC_DIR/core/src/num/mod.rs:LL:COL = note: this error originates in the macro `from_str_int_impl` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: from_ascii_radix: radix must lie in the range `[2, 36]` --> $DIR/parse_ints.rs:6:25 | LL | const _TOO_HIGH: () = { u64::from_str_radix("12345ABCD", 37); }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: from_ascii_radix: radix must lie in the range `[2, 36]` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `core::num::::from_str_radix` --> $SRC_DIR/core/src/num/mod.rs:LL:COL diff --git a/tests/ui/consts/const-eval/partial_ptr_overwrite.rs b/tests/ui/consts/const-eval/partial_ptr_overwrite.rs index 9438de5e3fe78..bd97bec0f71a9 100644 --- a/tests/ui/consts/const-eval/partial_ptr_overwrite.rs +++ b/tests/ui/consts/const-eval/partial_ptr_overwrite.rs @@ -4,8 +4,7 @@ const PARTIAL_OVERWRITE: () = { let mut p = &42; unsafe { let ptr: *mut _ = &mut p; - *(ptr as *mut u8) = 123; //~ ERROR constant - //~| NOTE unable to overwrite parts of a pointer + *(ptr as *mut u8) = 123; //~ ERROR unable to overwrite parts of a pointer } let x = *p; }; diff --git a/tests/ui/consts/const-eval/partial_ptr_overwrite.stderr b/tests/ui/consts/const-eval/partial_ptr_overwrite.stderr index 1443d353848b0..4d514495e733e 100644 --- a/tests/ui/consts/const-eval/partial_ptr_overwrite.stderr +++ b/tests/ui/consts/const-eval/partial_ptr_overwrite.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: unable to overwrite parts of a pointer in memory at ALLOC0 --> $DIR/partial_ptr_overwrite.rs:7:9 | LL | *(ptr as *mut u8) = 123; - | ^^^^^^^^^^^^^^^^^^^^^^^ unable to overwrite parts of a pointer in memory at ALLOC0 + | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr index 120a08acc3346..36183e2892101 100644 --- a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr @@ -1,340 +1,340 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .: encountered 0x00000001, but expected a valid enum tag --> $DIR/raw-bytes.rs:23:1 | LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered 0x00000001, but expected a valid enum tag + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 01 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .: encountered 0x00000000, but expected a valid enum tag --> $DIR/raw-bytes.rs:31:1 | LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered 0x00000000, but expected a valid enum tag + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 00 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .: encountered an uninhabited enum variant --> $DIR/raw-bytes.rs:45:1 | LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 01 │ . } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .: encountered an uninhabited enum variant --> $DIR/raw-bytes.rs:47:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 03 │ . } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at ..0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) --> $DIR/raw-bytes.rs:53:1 | LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { 78 00 00 00 ff ff ff ff │ x....... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1 --> $DIR/raw-bytes.rs:58:1 | LL | const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 00 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 --> $DIR/raw-bytes.rs:61:1 | LL | const NULL_U8: NonZero = unsafe { mem::transmute(0u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 00 │ . } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 --> $DIR/raw-bytes.rs:63:1 | LL | const NULL_USIZE: NonZero = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 00 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 42, but expected something in the range 10..=30 --> $DIR/raw-bytes.rs:69:1 | LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 42, but expected something in the range 10..=30 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 2a 00 00 00 │ *... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30 --> $DIR/raw-bytes.rs:75:1 | LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 14 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1 --> $DIR/raw-bytes.rs:78:1 | LL | const NULL_FAT_PTR: NonNull = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { 00 00 00 00 ╾ALLOC_ID╼ │ ....╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:86:1 +error[E0080]: constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) + --> $DIR/raw-bytes.rs:85:1 | LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { ╾ALLOC_ID╼ │ ╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:90:1 +error[E0080]: constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) + --> $DIR/raw-bytes.rs:88:1 | LL | const UNALIGNED_BOX: Box = unsafe { mem::transmute(&[0u8; 4]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { ╾ALLOC_ID╼ │ ╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:94:1 +error[E0080]: constructing invalid value: encountered a null reference + --> $DIR/raw-bytes.rs:91:1 | LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference + | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 00 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:97:1 +error[E0080]: constructing invalid value: encountered a null box + --> $DIR/raw-bytes.rs:94:1 | LL | const NULL_BOX: Box = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box + | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 00 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:100:1 +error[E0080]: constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance) + --> $DIR/raw-bytes.rs:97:1 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 39 05 00 00 │ 9... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:103:1 +error[E0080]: constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance) + --> $DIR/raw-bytes.rs:100:1 | LL | const USIZE_AS_BOX: Box = unsafe { mem::transmute(1337usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 39 05 00 00 │ 9... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:106:1 +error[E0080]: constructing invalid value: encountered null pointer, but expected a function pointer + --> $DIR/raw-bytes.rs:103:1 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 00 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:108:1 +error[E0080]: constructing invalid value: encountered 0xd[noalloc], but expected a function pointer + --> $DIR/raw-bytes.rs:105:1 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 0d 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:110:1 +error[E0080]: constructing invalid value: encountered ALLOC3, but expected a function pointer + --> $DIR/raw-bytes.rs:107:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3, but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { ╾ALLOC_ID╼ │ ╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:116:1 +error[E0080]: constructing invalid value: encountered a reference pointing to uninhabited type Bar + --> $DIR/raw-bytes.rs:113:1 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 01 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:141:1 +error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + --> $DIR/raw-bytes.rs:137:1 | LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ e7 03 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:143:1 +error[E0080]: constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/raw-bytes.rs:139:1 | LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ ff ff ff ff │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:145:1 +error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/raw-bytes.rs:141:1 | LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ ff ff ff ff │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:148:1 +error[E0080]: constructing invalid value at .: encountered uninitialized memory, but expected a string + --> $DIR/raw-bytes.rs:144:1 | LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered uninitialized memory, but expected a string + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:150:1 +error[E0080]: constructing invalid value at ..0: encountered uninitialized memory, but expected a string + --> $DIR/raw-bytes.rs:146:1 | LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered uninitialized memory, but expected a string + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:152:1 +error[E0080]: constructing invalid value at ..0: encountered a pointer, but expected a string + --> $DIR/raw-bytes.rs:148:1 | LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered a pointer, but expected a string + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼.... } - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:156:1 +error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + --> $DIR/raw-bytes.rs:152:1 | LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ e7 03 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:158:1 +error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/raw-bytes.rs:154:1 | LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ ff ff ff 7f │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:161:1 +error[E0080]: constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation) + --> $DIR/raw-bytes.rs:157:1 | LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ e7 03 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:164:1 +error[E0080]: constructing invalid value at .[0]: encountered 0x03, but expected a boolean + --> $DIR/raw-bytes.rs:160:1 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { @@ -342,16 +342,16 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:164:40 + --> $DIR/raw-bytes.rs:160:40 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:170:1 +error[E0080]: constructing invalid value at ..0: encountered 0x03, but expected a boolean + --> $DIR/raw-bytes.rs:164:1 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { @@ -359,16 +359,16 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3 } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:170:42 + --> $DIR/raw-bytes.rs:164:42 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:174:1 +error[E0080]: constructing invalid value at ..1[0]: encountered 0x03, but expected a boolean + --> $DIR/raw-bytes.rs:167:1 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..1[0]: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { @@ -376,196 +376,196 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:174:42 + --> $DIR/raw-bytes.rs:167:42 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:179:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC17, but expected a vtable pointer + --> $DIR/raw-bytes.rs:171:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC17, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:183:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC19, but expected a vtable pointer + --> $DIR/raw-bytes.rs:174:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC19, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:187:1 +error[E0080]: constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer + --> $DIR/raw-bytes.rs:177:1 | LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:190:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC22, but expected a vtable pointer + --> $DIR/raw-bytes.rs:179:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC22, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:194:1 +error[E0080]: constructing invalid value at ..: encountered 0x03, but expected a boolean + --> $DIR/raw-bytes.rs:182:1 | LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:198:1 +error[E0080]: constructing invalid value: encountered null pointer, but expected a vtable pointer + --> $DIR/raw-bytes.rs:185:1 | LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 00 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:201:1 +error[E0080]: constructing invalid value: encountered ALLOC27, but expected a vtable pointer + --> $DIR/raw-bytes.rs:187:1 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC27, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:206:1 +error[E0080]: constructing invalid value: encountered a reference pointing to uninhabited type [!; 1] + --> $DIR/raw-bytes.rs:191:1 | LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; - | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type [!; 1] + | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 01 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:207:1 +error[E0080]: constructing invalid value at .[0]: encountered a value of the never type `!` + --> $DIR/raw-bytes.rs:192:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; - | ^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a value of the never type `!` + | ^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { 01 00 00 00 01 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:208:1 +error[E0080]: constructing invalid value at .[0]: encountered a value of the never type `!` + --> $DIR/raw-bytes.rs:193:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; - | ^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a value of the never type `!` + | ^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { 01 00 00 00 2a 00 00 00 │ ....*... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:212:1 +error[E0080]: constructing invalid value at .[0]: encountered uninitialized memory, but expected an integer + --> $DIR/raw-bytes.rs:196:1 | LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:215:1 +error[E0080]: constructing invalid value at .[0]: encountered a pointer, but expected an integer + --> $DIR/raw-bytes.rs:199:1 | LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a pointer, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼.... } - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:218:1 +error[E0080]: constructing invalid value at .[0]: encountered 0x11, but expected a boolean + --> $DIR/raw-bytes.rs:202:1 | LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered 0x11, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:222:1 +error[E0080]: constructing invalid value at .[1]: encountered uninitialized memory, but expected an integer + --> $DIR/raw-bytes.rs:206:1 | LL | pub static S7: &[u16] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[1]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID+0x2╼ 04 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:229:1 +error[E0080]: constructing invalid value at .[0]: encountered uninitialized memory, but expected an integer + --> $DIR/raw-bytes.rs:213:1 | LL | pub static R4: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:234:1 +error[E0080]: constructing invalid value at .[0]: encountered a pointer, but expected an integer + --> $DIR/raw-bytes.rs:218:1 | LL | pub static R5: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a pointer, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼.... } - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:239:1 +error[E0080]: constructing invalid value at .[0]: encountered 0x11, but expected a boolean + --> $DIR/raw-bytes.rs:223:1 | LL | pub static R6: &[bool] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered 0x11, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { diff --git a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr index d54ad7c8546c1..c53326534fdc5 100644 --- a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr @@ -1,340 +1,340 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .: encountered 0x0000000000000001, but expected a valid enum tag --> $DIR/raw-bytes.rs:23:1 | LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered 0x0000000000000001, but expected a valid enum tag + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 01 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .: encountered 0x0000000000000000, but expected a valid enum tag --> $DIR/raw-bytes.rs:31:1 | LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered 0x0000000000000000, but expected a valid enum tag + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 00 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .: encountered an uninhabited enum variant --> $DIR/raw-bytes.rs:45:1 | LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 01 │ . } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .: encountered an uninhabited enum variant --> $DIR/raw-bytes.rs:47:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 03 │ . } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at ..0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) --> $DIR/raw-bytes.rs:53:1 | LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { 78 00 00 00 ff ff ff ff │ x....... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1 --> $DIR/raw-bytes.rs:58:1 | LL | const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 00 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 --> $DIR/raw-bytes.rs:61:1 | LL | const NULL_U8: NonZero = unsafe { mem::transmute(0u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 00 │ . } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 --> $DIR/raw-bytes.rs:63:1 | LL | const NULL_USIZE: NonZero = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 00 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 42, but expected something in the range 10..=30 --> $DIR/raw-bytes.rs:69:1 | LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 42, but expected something in the range 10..=30 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 2a 00 00 00 │ *... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30 --> $DIR/raw-bytes.rs:75:1 | LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 14 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1 --> $DIR/raw-bytes.rs:78:1 | LL | const NULL_FAT_PTR: NonNull = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { 00 00 00 00 00 00 00 00 ╾ALLOC_ID╼ │ ........╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:86:1 +error[E0080]: constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) + --> $DIR/raw-bytes.rs:85:1 | LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { ╾ALLOC_ID╼ │ ╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:90:1 +error[E0080]: constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) + --> $DIR/raw-bytes.rs:88:1 | LL | const UNALIGNED_BOX: Box = unsafe { mem::transmute(&[0u8; 4]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { ╾ALLOC_ID╼ │ ╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:94:1 +error[E0080]: constructing invalid value: encountered a null reference + --> $DIR/raw-bytes.rs:91:1 | LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference + | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 00 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:97:1 +error[E0080]: constructing invalid value: encountered a null box + --> $DIR/raw-bytes.rs:94:1 | LL | const NULL_BOX: Box = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box + | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 00 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:100:1 +error[E0080]: constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance) + --> $DIR/raw-bytes.rs:97:1 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 39 05 00 00 00 00 00 00 │ 9....... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:103:1 +error[E0080]: constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance) + --> $DIR/raw-bytes.rs:100:1 | LL | const USIZE_AS_BOX: Box = unsafe { mem::transmute(1337usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 39 05 00 00 00 00 00 00 │ 9....... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:106:1 +error[E0080]: constructing invalid value: encountered null pointer, but expected a function pointer + --> $DIR/raw-bytes.rs:103:1 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 00 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:108:1 +error[E0080]: constructing invalid value: encountered 0xd[noalloc], but expected a function pointer + --> $DIR/raw-bytes.rs:105:1 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 0d 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:110:1 +error[E0080]: constructing invalid value: encountered ALLOC3, but expected a function pointer + --> $DIR/raw-bytes.rs:107:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3, but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { ╾ALLOC_ID╼ │ ╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:116:1 +error[E0080]: constructing invalid value: encountered a reference pointing to uninhabited type Bar + --> $DIR/raw-bytes.rs:113:1 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 01 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:141:1 +error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + --> $DIR/raw-bytes.rs:137:1 | LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:143:1 +error[E0080]: constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/raw-bytes.rs:139:1 | LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ ff ff ff ff ff ff ff ff │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:145:1 +error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/raw-bytes.rs:141:1 | LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ ff ff ff ff ff ff ff ff │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:148:1 +error[E0080]: constructing invalid value at .: encountered uninitialized memory, but expected a string + --> $DIR/raw-bytes.rs:144:1 | LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered uninitialized memory, but expected a string + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:150:1 +error[E0080]: constructing invalid value at ..0: encountered uninitialized memory, but expected a string + --> $DIR/raw-bytes.rs:146:1 | LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered uninitialized memory, but expected a string + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:152:1 +error[E0080]: constructing invalid value at ..0: encountered a pointer, but expected a string + --> $DIR/raw-bytes.rs:148:1 | LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered a pointer, but expected a string + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:156:1 +error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + --> $DIR/raw-bytes.rs:152:1 | LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:158:1 +error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/raw-bytes.rs:154:1 | LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ ff ff ff ff ff ff ff 7f │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:161:1 +error[E0080]: constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation) + --> $DIR/raw-bytes.rs:157:1 | LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:164:1 +error[E0080]: constructing invalid value at .[0]: encountered 0x03, but expected a boolean + --> $DIR/raw-bytes.rs:160:1 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { @@ -342,16 +342,16 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:164:40 + --> $DIR/raw-bytes.rs:160:40 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:170:1 +error[E0080]: constructing invalid value at ..0: encountered 0x03, but expected a boolean + --> $DIR/raw-bytes.rs:164:1 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { @@ -359,16 +359,16 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3 } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:170:42 + --> $DIR/raw-bytes.rs:164:42 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:174:1 +error[E0080]: constructing invalid value at ..1[0]: encountered 0x03, but expected a boolean + --> $DIR/raw-bytes.rs:167:1 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..1[0]: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { @@ -376,196 +376,196 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:174:42 + --> $DIR/raw-bytes.rs:167:42 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:179:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC17, but expected a vtable pointer + --> $DIR/raw-bytes.rs:171:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC17, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:183:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC19, but expected a vtable pointer + --> $DIR/raw-bytes.rs:174:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC19, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:187:1 +error[E0080]: constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer + --> $DIR/raw-bytes.rs:177:1 | LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:190:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC22, but expected a vtable pointer + --> $DIR/raw-bytes.rs:179:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC22, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:194:1 +error[E0080]: constructing invalid value at ..: encountered 0x03, but expected a boolean + --> $DIR/raw-bytes.rs:182:1 | LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:198:1 +error[E0080]: constructing invalid value: encountered null pointer, but expected a vtable pointer + --> $DIR/raw-bytes.rs:185:1 | LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 00 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:201:1 +error[E0080]: constructing invalid value: encountered ALLOC27, but expected a vtable pointer + --> $DIR/raw-bytes.rs:187:1 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC27, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:206:1 +error[E0080]: constructing invalid value: encountered a reference pointing to uninhabited type [!; 1] + --> $DIR/raw-bytes.rs:191:1 | LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; - | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type [!; 1] + | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 01 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:207:1 +error[E0080]: constructing invalid value at .[0]: encountered a value of the never type `!` + --> $DIR/raw-bytes.rs:192:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; - | ^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a value of the never type `!` + | ^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 │ ................ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:208:1 +error[E0080]: constructing invalid value at .[0]: encountered a value of the never type `!` + --> $DIR/raw-bytes.rs:193:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; - | ^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a value of the never type `!` + | ^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { 01 00 00 00 00 00 00 00 2a 00 00 00 00 00 00 00 │ ........*....... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:212:1 +error[E0080]: constructing invalid value at .[0]: encountered uninitialized memory, but expected an integer + --> $DIR/raw-bytes.rs:196:1 | LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:215:1 +error[E0080]: constructing invalid value at .[0]: encountered a pointer, but expected an integer + --> $DIR/raw-bytes.rs:199:1 | LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a pointer, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 08 00 00 00 00 00 00 00 │ ╾──────╼........ } - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:218:1 +error[E0080]: constructing invalid value at .[0]: encountered 0x11, but expected a boolean + --> $DIR/raw-bytes.rs:202:1 | LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered 0x11, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:222:1 +error[E0080]: constructing invalid value at .[1]: encountered uninitialized memory, but expected an integer + --> $DIR/raw-bytes.rs:206:1 | LL | pub static S7: &[u16] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[1]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID+0x2╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:229:1 +error[E0080]: constructing invalid value at .[0]: encountered uninitialized memory, but expected an integer + --> $DIR/raw-bytes.rs:213:1 | LL | pub static R4: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:234:1 +error[E0080]: constructing invalid value at .[0]: encountered a pointer, but expected an integer + --> $DIR/raw-bytes.rs:218:1 | LL | pub static R5: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a pointer, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 08 00 00 00 00 00 00 00 │ ╾──────╼........ } - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:239:1 +error[E0080]: constructing invalid value at .[0]: encountered 0x11, but expected a boolean + --> $DIR/raw-bytes.rs:223:1 | LL | pub static R6: &[bool] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered 0x11, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { diff --git a/tests/ui/consts/const-eval/raw-bytes.rs b/tests/ui/consts/const-eval/raw-bytes.rs index 1a585d55a5f02..58ae763e017f0 100644 --- a/tests/ui/consts/const-eval/raw-bytes.rs +++ b/tests/ui/consts/const-eval/raw-bytes.rs @@ -21,7 +21,7 @@ enum Enum { A = 0, } const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; -//~^ ERROR is undefined behavior +//~^ ERROR constructing invalid value #[repr(usize)] #[derive(Copy, Clone)] @@ -29,7 +29,7 @@ enum Enum2 { A = 2, } const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; -//~^ ERROR is undefined behavior +//~^ ERROR constructing invalid value #[derive(Copy, Clone)] enum Never {} @@ -43,79 +43,75 @@ enum UninhDiscriminant { D(Never), } const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; -//~^ ERROR is undefined behavior +//~^ ERROR constructing invalid value const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; -//~^ ERROR is undefined behavior +//~^ ERROR constructing invalid value // Invalid enum field content (mostly to test printing of paths for enum tuple // variants and tuples). // Need to create something which does not clash with enum layout optimizations. const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); -//~^ ERROR is undefined behavior +//~^ ERROR constructing invalid value // # Bad pointers and references const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const NULL_U8: NonZero = unsafe { mem::transmute(0u8) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const NULL_USIZE: NonZero = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value #[rustc_layout_scalar_valid_range_start(10)] #[rustc_layout_scalar_valid_range_end(30)] struct RestrictedRange1(u32); const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value #[rustc_layout_scalar_valid_range_start(30)] #[rustc_layout_scalar_valid_range_end(10)] struct RestrictedRange2(u32); const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const NULL_FAT_PTR: NonNull = unsafe { -//~^ ERROR it is undefined behavior to use this value + //~^ ERROR constructing invalid value let x: &dyn Send = &42; let meta = std::ptr::metadata(x); mem::transmute((0_usize, meta)) }; - const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) +//~^ ERROR constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) const UNALIGNED_BOX: Box = unsafe { mem::transmute(&[0u8; 4]) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) +//~^ ERROR constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) const NULL: &u16 = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const NULL_BOX: Box = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const USIZE_AS_BOX: Box = unsafe { mem::transmute(1337usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value #[derive(Copy, Clone)] enum Bar {} const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; -//~^ ERROR it is undefined behavior to use this value - +//~^ ERROR constructing invalid value /// A newtype wrapper to prevent MIR generation from inserting reborrows that would affect the error /// message. @@ -139,105 +135,93 @@ struct MySlice(bool, T); type MySliceBool = MySlice<[bool]>; const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: constructing invalid value // # slice const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value // bad slice box: length too big const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value // bad data *inside* the slice const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constant - +//~^ ERROR encountered 0x03, but expected a boolean // bad: sized field is not okay const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constant +//~^ ERROR encountered 0x03, but expected a boolean // bad: unsized part is not okay const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constant +//~^ ERROR encountered 0x03, but expected a boolean // bad trait object const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE expected a vtable +//~^ ERROR expected a vtable // bad trait object const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE expected a vtable +//~^ ERROR expected a vtable // bad trait object const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE expected a vtable +//~^ ERROR expected a vtable const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE expected a vtable +//~^ ERROR expected a vtable // bad data *inside* the trait object const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE expected a boolean +//~^ ERROR expected a boolean const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE null pointer +//~^ ERROR null pointer const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE vtable +//~^ ERROR vtable // Uninhabited types -const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR undefined behavior -const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR undefined behavior -const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; //~ ERROR undefined behavior - +const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR constructing invalid value +const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR constructing invalid value +const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; //~ ERROR constructing invalid value // Reading uninitialized data pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: constructing invalid value // Reinterpret pointers as integers (UB in CTFE.) pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: constructing invalid value // Layout mismatch pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: constructing invalid value // Reading padding is not ok pub static S7: &[u16] = unsafe { - //~^ ERROR: it is undefined behavior to use this value + //~^ ERROR: constructing invalid value let ptr = (&D2 as *const Struct as *const u16).add(1); from_raw_parts(ptr, 4) }; pub static R4: &[u8] = unsafe { - //~^ ERROR: it is undefined behavior to use this value + //~^ ERROR: constructing invalid value let ptr = (&D1) as *const mem::MaybeUninit<&u32> as *const u8; from_ptr_range(ptr..ptr.add(1)) }; pub static R5: &[u8] = unsafe { - //~^ ERROR: it is undefined behavior to use this value + //~^ ERROR: constructing invalid value let ptr = &D3 as *const &u32; from_ptr_range(ptr.cast()..ptr.add(1).cast()) }; pub static R6: &[bool] = unsafe { - //~^ ERROR: it is undefined behavior to use this value + //~^ ERROR: constructing invalid value let ptr = &D0 as *const u32 as *const bool; from_ptr_range(ptr..ptr.add(4)) }; diff --git a/tests/ui/consts/const-eval/raw-pointer-ub.rs b/tests/ui/consts/const-eval/raw-pointer-ub.rs index 1e76104d515e2..c8d1e36e88bf5 100644 --- a/tests/ui/consts/const-eval/raw-pointer-ub.rs +++ b/tests/ui/consts/const-eval/raw-pointer-ub.rs @@ -1,15 +1,15 @@ const MISALIGNED_LOAD: () = unsafe { let mem = [0u32; 8]; let ptr = mem.as_ptr().byte_add(1); - let _val = *ptr; //~ERROR: evaluation of constant value failed - //~^NOTE: based on pointer with alignment 1, but alignment 4 is required + let _val = *ptr; //~NOTE: evaluation of constant value failed + //~^ERROR: based on pointer with alignment 1, but alignment 4 is required }; const MISALIGNED_STORE: () = unsafe { let mut mem = [0u32; 8]; let ptr = mem.as_mut_ptr().byte_add(1); - *ptr = 0; //~ERROR: evaluation of constant value failed - //~^NOTE: based on pointer with alignment 1, but alignment 4 is required + *ptr = 0; //~NOTE: evaluation of constant value failed + //~^ERROR: based on pointer with alignment 1, but alignment 4 is required }; const MISALIGNED_COPY: () = unsafe { @@ -17,9 +17,9 @@ const MISALIGNED_COPY: () = unsafe { let y = x.as_ptr().cast::(); let mut z = 123; y.copy_to_nonoverlapping(&mut z, 1); - //~^ ERROR evaluation of constant value failed + //~^ NOTE evaluation of constant value failed //~| NOTE inside `std::ptr::copy_nonoverlapping::` - //~| NOTE accessing memory with alignment 1, but alignment 4 is required + //~| ERROR accessing memory with alignment 1, but alignment 4 is required // The actual error points into the implementation of `copy_to_nonoverlapping`. }; @@ -30,15 +30,15 @@ const MISALIGNED_FIELD: () = unsafe { let mem = [0f32; 8]; let ptr = mem.as_ptr().cast::(); // Accessing an f32 field but we still require the alignment of the pointer type. - let _val = (*ptr).0; //~ERROR: evaluation of constant value failed - //~^NOTE: based on pointer with alignment 4, but alignment 16 is required + let _val = (*ptr).0; //~NOTE: evaluation of constant value failed + //~^ERROR: based on pointer with alignment 4, but alignment 16 is required }; const OOB: () = unsafe { let mem = [0u32; 1]; let ptr = mem.as_ptr().cast::(); - let _val = *ptr; //~ERROR: evaluation of constant value failed - //~^NOTE: is only 4 bytes from the end of the allocation + let _val = *ptr; //~NOTE: evaluation of constant value failed + //~^ERROR: is only 4 bytes from the end of the allocation }; fn main() {} diff --git a/tests/ui/consts/const-eval/raw-pointer-ub.stderr b/tests/ui/consts/const-eval/raw-pointer-ub.stderr index 01a8decc93b01..e424924e14b00 100644 --- a/tests/ui/consts/const-eval/raw-pointer-ub.stderr +++ b/tests/ui/consts/const-eval/raw-pointer-ub.stderr @@ -1,35 +1,35 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: accessing memory based on pointer with alignment 1, but alignment 4 is required --> $DIR/raw-pointer-ub.rs:4:16 | LL | let _val = *ptr; - | ^^^^ accessing memory based on pointer with alignment 1, but alignment 4 is required + | ^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: accessing memory based on pointer with alignment 1, but alignment 4 is required --> $DIR/raw-pointer-ub.rs:11:5 | LL | *ptr = 0; - | ^^^^^^^^ accessing memory based on pointer with alignment 1, but alignment 4 is required + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: accessing memory with alignment 1, but alignment 4 is required --> $DIR/raw-pointer-ub.rs:19:5 | LL | y.copy_to_nonoverlapping(&mut z, 1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ accessing memory with alignment 1, but alignment 4 is required + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `std::ptr::copy_nonoverlapping::` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -error[E0080]: evaluation of constant value failed +error[E0080]: accessing memory based on pointer with alignment 4, but alignment 16 is required --> $DIR/raw-pointer-ub.rs:33:16 | LL | let _val = (*ptr).0; - | ^^^^^^^^ accessing memory based on pointer with alignment 4, but alignment 16 is required + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: attempting to access 8 bytes, but got ALLOC0 which is only 4 bytes from the end of the allocation --> $DIR/raw-pointer-ub.rs:40:16 | LL | let _val = *ptr; - | ^^^^ memory access failed: attempting to access 8 bytes, but got ALLOC0 which is only 4 bytes from the end of the allocation + | ^^^^ evaluation of constant value failed here error: aborting due to 5 previous errors diff --git a/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr b/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr index 18935626af1ca..be86541434be0 100644 --- a/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr +++ b/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/ref_to_int_match.rs:24:27 | LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; - | ^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr b/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr index 18935626af1ca..be86541434be0 100644 --- a/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr +++ b/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/ref_to_int_match.rs:24:27 | LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; - | ^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/const-eval/ref_to_int_match.rs b/tests/ui/consts/const-eval/ref_to_int_match.rs index be9420e0215d1..062df685f749d 100644 --- a/tests/ui/consts/const-eval/ref_to_int_match.rs +++ b/tests/ui/consts/const-eval/ref_to_int_match.rs @@ -3,9 +3,9 @@ fn main() { let n: Int = 40; match n { - 0..=10 => {}, - 10..=BAR => {}, // ok, `const` error already emitted - _ => {}, + 0..=10 => {} + 10..=BAR => {} // ok, `const` error already emitted + _ => {} } } @@ -15,11 +15,11 @@ union Foo { r: &'static u32, } -#[cfg(target_pointer_width="64")] +#[cfg(target_pointer_width = "64")] type Int = u64; -#[cfg(target_pointer_width="32")] +#[cfg(target_pointer_width = "32")] type Int = u32; const BAR: Int = unsafe { Foo { r: &42 }.f }; -//~^ ERROR constant +//~^ ERROR unable to turn pointer into integer diff --git a/tests/ui/consts/const-eval/shift_overflow.stderr b/tests/ui/consts/const-eval/shift_overflow.stderr index 901bfa10ee85c..e5703fb1d77fe 100644 --- a/tests/ui/consts/const-eval/shift_overflow.stderr +++ b/tests/ui/consts/const-eval/shift_overflow.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to shift left by `4294967296_u64`, which would overflow --> $DIR/shift_overflow.rs:3:9 | LL | X = 1 << ((u32::MAX as u64) + 1), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to shift left by `4294967296_u64`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/transmute-const.rs b/tests/ui/consts/const-eval/transmute-const.rs index fb6cb77675fa6..e67406a65630c 100644 --- a/tests/ui/consts/const-eval/transmute-const.rs +++ b/tests/ui/consts/const-eval/transmute-const.rs @@ -2,6 +2,6 @@ use std::mem; static FOO: bool = unsafe { mem::transmute(3u8) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR 0x03, but expected a bool fn main() {} diff --git a/tests/ui/consts/const-eval/transmute-const.stderr b/tests/ui/consts/const-eval/transmute-const.stderr index 35a5cabaa6710..ed3b3df70dd5d 100644 --- a/tests/ui/consts/const-eval/transmute-const.stderr +++ b/tests/ui/consts/const-eval/transmute-const.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0x03, but expected a boolean --> $DIR/transmute-const.rs:4:1 | LL | static FOO: bool = unsafe { mem::transmute(3u8) }; - | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { diff --git a/tests/ui/consts/const-eval/transmute-size-mismatch.rs b/tests/ui/consts/const-eval/transmute-size-mismatch.rs index 8a7fd8257b002..ea5cdceda8857 100644 --- a/tests/ui/consts/const-eval/transmute-size-mismatch.rs +++ b/tests/ui/consts/const-eval/transmute-size-mismatch.rs @@ -19,10 +19,10 @@ const unsafe fn mir_transmute(x: T) -> U { } } -const FROM_BIGGER: u16 = unsafe { mir_transmute(123_i32) }; //~ ERROR evaluation of constant value failed -//~^ NOTE transmuting from 4-byte type to 2-byte type: `i32` -> `u16` +const FROM_BIGGER: u16 = unsafe { mir_transmute(123_i32) }; //~ NOTE evaluation of constant value failed +//~^ ERROR transmuting from 4-byte type to 2-byte type: `i32` -> `u16` -const FROM_SMALLER: u32 = unsafe { mir_transmute(123_i16) }; //~ ERROR evaluation of constant value failed -//~^ NOTE transmuting from 2-byte type to 4-byte type: `i16` -> `u32` +const FROM_SMALLER: u32 = unsafe { mir_transmute(123_i16) }; //~ NOTE evaluation of constant value failed +//~^ ERROR transmuting from 2-byte type to 4-byte type: `i16` -> `u32` fn main() {} diff --git a/tests/ui/consts/const-eval/transmute-size-mismatch.stderr b/tests/ui/consts/const-eval/transmute-size-mismatch.stderr index 888df16ec4ee1..92088a4749a34 100644 --- a/tests/ui/consts/const-eval/transmute-size-mismatch.stderr +++ b/tests/ui/consts/const-eval/transmute-size-mismatch.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: transmuting from 4-byte type to 2-byte type: `i32` -> `u16` --> $DIR/transmute-size-mismatch.rs:22:35 | LL | const FROM_BIGGER: u16 = unsafe { mir_transmute(123_i32) }; - | ^^^^^^^^^^^^^^^^^^^^^^ transmuting from 4-byte type to 2-byte type: `i32` -> `u16` + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `mir_transmute::` --> $DIR/transmute-size-mismatch.rs:12:13 @@ -10,11 +10,11 @@ note: inside `mir_transmute::` LL | RET = CastTransmute(x); | ^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here -error[E0080]: evaluation of constant value failed +error[E0080]: transmuting from 2-byte type to 4-byte type: `i16` -> `u32` --> $DIR/transmute-size-mismatch.rs:25:36 | LL | const FROM_SMALLER: u32 = unsafe { mir_transmute(123_i16) }; - | ^^^^^^^^^^^^^^^^^^^^^^ transmuting from 2-byte type to 4-byte type: `i16` -> `u32` + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `mir_transmute::` --> $DIR/transmute-size-mismatch.rs:12:13 diff --git a/tests/ui/consts/const-eval/ub-enum-overwrite.rs b/tests/ui/consts/const-eval/ub-enum-overwrite.rs index e37c25718f8e8..005f3c78c1d7d 100644 --- a/tests/ui/consts/const-eval/ub-enum-overwrite.rs +++ b/tests/ui/consts/const-eval/ub-enum-overwrite.rs @@ -9,8 +9,7 @@ const _: u8 = { // Make sure overwriting `e` uninitializes other bytes e = E::B; unsafe { *p } - //~^ ERROR evaluation of constant value failed - //~| NOTE uninitialized + //~^ ERROR uninitialized }; fn main() {} diff --git a/tests/ui/consts/const-eval/ub-enum-overwrite.stderr b/tests/ui/consts/const-eval/ub-enum-overwrite.stderr index 315e865df93f3..0c1a606904c2f 100644 --- a/tests/ui/consts/const-eval/ub-enum-overwrite.stderr +++ b/tests/ui/consts/const-eval/ub-enum-overwrite.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/ub-enum-overwrite.rs:11:14 | LL | unsafe { *p } - | ^^ using uninitialized data, but this operation requires initialized memory + | ^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/ub-enum.rs b/tests/ui/consts/const-eval/ub-enum.rs index ac543430da9d3..52fc994506837 100644 --- a/tests/ui/consts/const-eval/ub-enum.rs +++ b/tests/ui/consts/const-eval/ub-enum.rs @@ -27,13 +27,13 @@ enum Enum { const GOOD_ENUM: Enum = unsafe { mem::transmute(0usize) }; const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; -//~^ ERROR is undefined behavior +//~^ ERROR expected a valid enum tag const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer const BAD_ENUM_WRAPPED: Wrap = unsafe { mem::transmute(&1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer // # simple enum with discriminant 2 @@ -45,12 +45,12 @@ enum Enum2 { } const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; -//~^ ERROR is undefined behavior +//~^ ERROR expected a valid enum tag const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer // something wrapping the enum so that we test layout first, not enum const BAD_ENUM2_WRAPPED: Wrap = unsafe { mem::transmute(&0) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer // Undef enum discriminant. #[repr(C)] @@ -58,13 +58,12 @@ union MaybeUninit { uninit: (), init: T, } -const BAD_ENUM2_UNDEF : Enum2 = unsafe { MaybeUninit { uninit: () }.init }; -//~^ ERROR evaluation of constant value failed -//~| NOTE uninitialized +const BAD_ENUM2_UNDEF: Enum2 = unsafe { MaybeUninit { uninit: () }.init }; +//~^ ERROR uninitialized // Pointer value in an enum with a niche that is not just 0. const BAD_ENUM2_OPTION_PTR: Option = unsafe { mem::transmute(&0) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer // # valid discriminant for uninhabited variant @@ -81,9 +80,9 @@ const GOOD_INHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(0u8) const GOOD_INHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(2u8) }; // variant C const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; -//~^ ERROR is undefined behavior +//~^ ERROR uninhabited enum variant const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; -//~^ ERROR is undefined behavior +//~^ ERROR uninhabited enum variant // # other @@ -91,20 +90,21 @@ const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) // variants and tuples). // Need to create something which does not clash with enum layout optimizations. const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); -//~^ ERROR is undefined behavior +//~^ ERROR expected a valid unicode scalar // All variants are uninhabited but also have data. // Use `0` as constant to make behavior endianness-independent. const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR uninhabited enum variant const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR uninhabited enum variant const TEST_ICE_89765: () = { // This is a regression test for https://github.com/rust-lang/rust/issues/89765. - unsafe { std::mem::discriminant(&*(&() as *const () as *const Never)); }; - //~^ ERROR evaluation of constant value failed + unsafe { + std::mem::discriminant(&*(&() as *const () as *const Never)); + //~^ ERROR uninhabited enum variant + }; }; -fn main() { -} +fn main() {} diff --git a/tests/ui/consts/const-eval/ub-enum.stderr b/tests/ui/consts/const-eval/ub-enum.stderr index faec412b004bc..7015102a50a4d 100644 --- a/tests/ui/consts/const-eval/ub-enum.stderr +++ b/tests/ui/consts/const-eval/ub-enum.stderr @@ -1,126 +1,126 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .: encountered 0x01, but expected a valid enum tag --> $DIR/ub-enum.rs:29:1 | LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered 0x01, but expected a valid enum tag + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/ub-enum.rs:32:1 | LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/ub-enum.rs:35:1 | LL | const BAD_ENUM_WRAPPED: Wrap = unsafe { mem::transmute(&1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .: encountered 0x0, but expected a valid enum tag --> $DIR/ub-enum.rs:47:1 | LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered 0x0, but expected a valid enum tag + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/ub-enum.rs:49:1 | LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/ub-enum.rs:52:1 | LL | const BAD_ENUM2_WRAPPED: Wrap = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:61:42 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/ub-enum.rs:61:41 | -LL | const BAD_ENUM2_UNDEF : Enum2 = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory +LL | const BAD_ENUM2_UNDEF: Enum2 = unsafe { MaybeUninit { uninit: () }.init }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:66:1 +error[E0080]: unable to turn pointer into integer + --> $DIR/ub-enum.rs:65:1 | LL | const BAD_ENUM2_OPTION_PTR: Option = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:83:1 +error[E0080]: constructing invalid value at .: encountered an uninhabited enum variant + --> $DIR/ub-enum.rs:82:1 | LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:85:1 +error[E0080]: constructing invalid value at .: encountered an uninhabited enum variant + --> $DIR/ub-enum.rs:84:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:93:1 +error[E0080]: constructing invalid value at ..0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) + --> $DIR/ub-enum.rs:92:1 | LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:98:77 +error[E0080]: constructing invalid value at .: encountered an uninhabited enum variant + --> $DIR/ub-enum.rs:97:77 | LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant + | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:100:77 +error[E0080]: constructing invalid value at .: encountered an uninhabited enum variant + --> $DIR/ub-enum.rs:99:77 | LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant + | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:105:14 +error[E0080]: read discriminant of an uninhabited enum variant + --> $DIR/ub-enum.rs:105:9 | -LL | unsafe { std::mem::discriminant(&*(&() as *const () as *const Never)); }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ read discriminant of an uninhabited enum variant +LL | std::mem::discriminant(&*(&() as *const () as *const Never)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `discriminant::` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL diff --git a/tests/ui/consts/const-eval/ub-incorrect-vtable.32bit.stderr b/tests/ui/consts/const-eval/ub-incorrect-vtable.32bit.stderr index 5c47cbfdf3b1e..86d6f8c52bc70 100644 --- a/tests/ui/consts/const-eval/ub-incorrect-vtable.32bit.stderr +++ b/tests/ui/consts/const-eval/ub-incorrect-vtable.32bit.stderr @@ -1,63 +1,63 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered ALLOC1, but expected a vtable pointer --> $DIR/ub-incorrect-vtable.rs:18:1 | LL | const INVALID_VTABLE_ALIGNMENT: &dyn Trait = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC1, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC0╼ ╾ALLOC1╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:23:1 +error[E0080]: constructing invalid value: encountered ALLOC3, but expected a vtable pointer + --> $DIR/ub-incorrect-vtable.rs:22:1 | LL | const INVALID_VTABLE_SIZE: &dyn Trait = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC2╼ ╾ALLOC3╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:33:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC5, but expected a vtable pointer + --> $DIR/ub-incorrect-vtable.rs:31:1 | LL | const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC5, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC4╼ ╾ALLOC5╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:38:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC7, but expected a vtable pointer + --> $DIR/ub-incorrect-vtable.rs:35:1 | LL | const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC7, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC6╼ ╾ALLOC7╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:44:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC9, but expected a vtable pointer + --> $DIR/ub-incorrect-vtable.rs:40:1 | LL | const INVALID_VTABLE_UB: W<&dyn Trait> = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC9, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC8╼ ╾ALLOC9╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:91:1 +error[E0080]: constructing invalid value at .1: encountered a dangling reference (going beyond the bounds of its allocation) + --> $DIR/ub-incorrect-vtable.rs:86:1 | LL | const G: Wide = unsafe { Transmute { t: FOO }.u }; - | ^^^^^^^^^^^^^ constructing invalid value at .1: encountered a dangling reference (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { diff --git a/tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr b/tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr index f400073aca215..a9518216dbdb7 100644 --- a/tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr +++ b/tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr @@ -1,63 +1,63 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered ALLOC1, but expected a vtable pointer --> $DIR/ub-incorrect-vtable.rs:18:1 | LL | const INVALID_VTABLE_ALIGNMENT: &dyn Trait = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC1, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC0╼ ╾ALLOC1╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:23:1 +error[E0080]: constructing invalid value: encountered ALLOC3, but expected a vtable pointer + --> $DIR/ub-incorrect-vtable.rs:22:1 | LL | const INVALID_VTABLE_SIZE: &dyn Trait = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC2╼ ╾ALLOC3╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:33:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC5, but expected a vtable pointer + --> $DIR/ub-incorrect-vtable.rs:31:1 | LL | const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC5, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC4╼ ╾ALLOC5╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:38:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC7, but expected a vtable pointer + --> $DIR/ub-incorrect-vtable.rs:35:1 | LL | const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC7, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC6╼ ╾ALLOC7╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:44:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC9, but expected a vtable pointer + --> $DIR/ub-incorrect-vtable.rs:40:1 | LL | const INVALID_VTABLE_UB: W<&dyn Trait> = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC9, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC8╼ ╾ALLOC9╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:91:1 +error[E0080]: constructing invalid value at .1: encountered a dangling reference (going beyond the bounds of its allocation) + --> $DIR/ub-incorrect-vtable.rs:86:1 | LL | const G: Wide = unsafe { Transmute { t: FOO }.u }; - | ^^^^^^^^^^^^^ constructing invalid value at .1: encountered a dangling reference (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { diff --git a/tests/ui/consts/const-eval/ub-incorrect-vtable.rs b/tests/ui/consts/const-eval/ub-incorrect-vtable.rs index 30c0ae3bb5af0..4185b0261b296 100644 --- a/tests/ui/consts/const-eval/ub-incorrect-vtable.rs +++ b/tests/ui/consts/const-eval/ub-incorrect-vtable.rs @@ -17,13 +17,11 @@ trait Trait {} const INVALID_VTABLE_ALIGNMENT: &dyn Trait = unsafe { std::mem::transmute((&92u8, &[0usize, 1usize, 1000usize])) }; -//~^^ ERROR it is undefined behavior to use this value -//~| NOTE vtable +//~^^ ERROR vtable const INVALID_VTABLE_SIZE: &dyn Trait = unsafe { std::mem::transmute((&92u8, &[1usize, usize::MAX, 1usize])) }; -//~^^ ERROR it is undefined behavior to use this value -//~| NOTE vtable +//~^^ ERROR vtable #[repr(transparent)] struct W(T); @@ -32,19 +30,16 @@ fn drop_me(_: *mut usize) {} const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> = unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), 1usize, 1000usize))) }; -//~^^ ERROR it is undefined behavior to use this value -//~| NOTE expected a vtable pointer +//~^^ ERROR expected a vtable pointer const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> = unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), usize::MAX, 1usize))) }; -//~^^ ERROR it is undefined behavior to use this value -//~| NOTE expected a vtable pointer +//~^^ ERROR expected a vtable pointer // Even if the vtable has a fn ptr and a reasonable size+align, it still does not work. const INVALID_VTABLE_UB: W<&dyn Trait> = unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), 1usize, 1usize))) }; -//~^^ ERROR it is undefined behavior to use this value -//~| NOTE expected a vtable pointer +//~^^ ERROR expected a vtable pointer // Trying to access the data in a vtable does not work, either. @@ -89,8 +84,7 @@ union Transmute { const FOO: &dyn Bar = &Foo { foo: 128, bar: false }; const G: Wide = unsafe { Transmute { t: FOO }.u }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE encountered a dangling reference +//~^ ERROR encountered a dangling reference // (it is dangling because vtables do not contain memory that can be dereferenced) fn main() {} diff --git a/tests/ui/consts/const-eval/ub-int-array.rs b/tests/ui/consts/const-eval/ub-int-array.rs index 169ac7f15194d..eebbccaa7c175 100644 --- a/tests/ui/consts/const-eval/ub-int-array.rs +++ b/tests/ui/consts/const-eval/ub-int-array.rs @@ -18,8 +18,7 @@ impl MaybeUninit { } const UNINIT_INT_0: [u32; 3] = unsafe { - //~^ ERROR it is undefined behavior to use this value - //~| NOTE invalid value at [0] + //~^ ERROR invalid value at [0] mem::transmute([ MaybeUninit { uninit: () }, // Constants chosen to achieve endianness-independent hex dump. @@ -28,8 +27,7 @@ const UNINIT_INT_0: [u32; 3] = unsafe { ]) }; const UNINIT_INT_1: [u32; 3] = unsafe { - //~^ ERROR it is undefined behavior to use this value - //~| NOTE invalid value at [1] + //~^ ERROR invalid value at [1] mem::transmute([ MaybeUninit::new(0u8), MaybeUninit::new(0u8), @@ -46,8 +44,7 @@ const UNINIT_INT_1: [u32; 3] = unsafe { ]) }; const UNINIT_INT_2: [u32; 3] = unsafe { - //~^ ERROR it is undefined behavior to use this value - //~| NOTE invalid value at [2] + //~^ ERROR invalid value at [2] mem::transmute([ MaybeUninit::new(0u8), MaybeUninit::new(0u8), diff --git a/tests/ui/consts/const-eval/ub-int-array.stderr b/tests/ui/consts/const-eval/ub-int-array.stderr index d6ef9bcfeba63..10eb7c46c928c 100644 --- a/tests/ui/consts/const-eval/ub-int-array.stderr +++ b/tests/ui/consts/const-eval/ub-int-array.stderr @@ -1,30 +1,30 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at [0]: encountered uninitialized memory, but expected an integer --> $DIR/ub-int-array.rs:20:1 | LL | const UNINIT_INT_0: [u32; 3] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 12, align: 4) { __ __ __ __ 11 11 11 11 22 22 22 22 │ ░░░░...."""" } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:30:1 +error[E0080]: constructing invalid value at [1]: encountered uninitialized memory, but expected an integer + --> $DIR/ub-int-array.rs:29:1 | LL | const UNINIT_INT_1: [u32; 3] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [1]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 12, align: 4) { 00 00 00 00 01 __ 01 01 02 02 __ 02 │ .....░....░. } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:48:1 +error[E0080]: constructing invalid value at [2]: encountered uninitialized memory, but expected an integer + --> $DIR/ub-int-array.rs:46:1 | LL | const UNINIT_INT_2: [u32; 3] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [2]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 12, align: 4) { diff --git a/tests/ui/consts/const-eval/ub-invalid-values.rs b/tests/ui/consts/const-eval/ub-invalid-values.rs index c0b68d7619a07..e5d387fa7cc78 100644 --- a/tests/ui/consts/const-eval/ub-invalid-values.rs +++ b/tests/ui/consts/const-eval/ub-invalid-values.rs @@ -5,8 +5,8 @@ const fn bool_cast(ptr: *const bool) { unsafe { const _: () = { let v = 3_u8; - bool_cast(&v as *const u8 as *const bool); //~ ERROR: evaluation of constant value failed - //~^ NOTE interpreting an invalid 8-bit value as a bool + bool_cast(&v as *const u8 as *const bool); //~ NOTE: evaluation of constant value failed + //~^ ERROR interpreting an invalid 8-bit value as a bool }; fn main() {} diff --git a/tests/ui/consts/const-eval/ub-invalid-values.stderr b/tests/ui/consts/const-eval/ub-invalid-values.stderr index 76952c1f1a32b..83879eeb716b4 100644 --- a/tests/ui/consts/const-eval/ub-invalid-values.stderr +++ b/tests/ui/consts/const-eval/ub-invalid-values.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: interpreting an invalid 8-bit value as a bool: 0x03 --> $DIR/ub-invalid-values.rs:8:5 | LL | bool_cast(&v as *const u8 as *const bool); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ interpreting an invalid 8-bit value as a bool: 0x03 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `bool_cast` --> $DIR/ub-invalid-values.rs:2:16 diff --git a/tests/ui/consts/const-eval/ub-nonnull.rs b/tests/ui/consts/const-eval/ub-nonnull.rs index 8ae913db1e4c4..9164684262480 100644 --- a/tests/ui/consts/const-eval/ub-nonnull.rs +++ b/tests/ui/consts/const-eval/ub-nonnull.rs @@ -14,19 +14,19 @@ const NON_NULL: NonNull = unsafe { mem::transmute(1usize) }; const NON_NULL_PTR: NonNull = unsafe { mem::transmute(&1) }; const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const OUT_OF_BOUNDS_PTR: NonNull = { unsafe { let ptr: &[u8; 256] = mem::transmute(&0u8); // &0 gets promoted so it does not dangle // Use address-of-element for pointer arithmetic. This could wrap around to null! - let out_of_bounds_ptr = &ptr[255]; //~ ERROR evaluation of constant value failed + let out_of_bounds_ptr = &ptr[255]; //~ ERROR in-bounds pointer arithmetic failed mem::transmute(out_of_bounds_ptr) } }; const NULL_U8: NonZero = unsafe { mem::transmute(0u8) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const NULL_USIZE: NonZero = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value #[repr(C)] union MaybeUninit { @@ -34,8 +34,7 @@ union MaybeUninit { init: T, } const UNINIT: NonZero = unsafe { MaybeUninit { uninit: () }.init }; -//~^ ERROR evaluation of constant value failed -//~| NOTE uninitialized +//~^ ERROR uninitialized // Also test other uses of rustc_layout_scalar_valid_range_start @@ -43,16 +42,16 @@ const UNINIT: NonZero = unsafe { MaybeUninit { uninit: () }.init }; #[rustc_layout_scalar_valid_range_end(30)] struct RestrictedRange1(u32); const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value #[rustc_layout_scalar_valid_range_start(30)] #[rustc_layout_scalar_valid_range_end(10)] struct RestrictedRange2(u32); const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const NULL_FAT_PTR: NonNull = unsafe { -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value let x: &dyn Send = &42; let meta = std::ptr::metadata(x); mem::transmute((0_usize, meta)) diff --git a/tests/ui/consts/const-eval/ub-nonnull.stderr b/tests/ui/consts/const-eval/ub-nonnull.stderr index 75dd0443ca4e4..0a02dbb16bff8 100644 --- a/tests/ui/consts/const-eval/ub-nonnull.stderr +++ b/tests/ui/consts/const-eval/ub-nonnull.stderr @@ -1,75 +1,75 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1 --> $DIR/ub-nonnull.rs:16:1 | LL | const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 255 bytes, but got ALLOC1 which is only 1 byte from the end of the allocation --> $DIR/ub-nonnull.rs:22:29 | LL | let out_of_bounds_ptr = &ptr[255]; - | ^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by 255 bytes, but got ALLOC1 which is only 1 byte from the end of the allocation + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 --> $DIR/ub-nonnull.rs:26:1 | LL | const NULL_U8: NonZero = unsafe { mem::transmute(0u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 --> $DIR/ub-nonnull.rs:28:1 | LL | const NULL_USIZE: NonZero = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/ub-nonnull.rs:36:38 | LL | const UNINIT: NonZero = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:45:1 +error[E0080]: constructing invalid value: encountered 42, but expected something in the range 10..=30 + --> $DIR/ub-nonnull.rs:44:1 | LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 42, but expected something in the range 10..=30 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:51:1 +error[E0080]: constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30 + --> $DIR/ub-nonnull.rs:50:1 | LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:54:1 +error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1 + --> $DIR/ub-nonnull.rs:53:1 | LL | const NULL_FAT_PTR: NonNull = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.rs b/tests/ui/consts/const-eval/ub-ref-ptr.rs index 988e6c62e3465..64b48939be6de 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.rs +++ b/tests/ui/consts/const-eval/ub-ref-ptr.rs @@ -15,57 +15,53 @@ union MaybeUninit { } const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) +//~^ ERROR constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) const UNALIGNED_BOX: Box = unsafe { mem::transmute(&[0u8; 4]) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) +//~^ ERROR constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) const NULL: &u16 = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const NULL_BOX: Box = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value // It is very important that we reject this: We do promote `&(4 * REF_AS_USIZE)`, // but that would fail to compile; so we ended up breaking user code that would // have worked fine had we not promoted. const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const USIZE_AS_BOX: Box = unsafe { mem::transmute(1337usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init }; -//~^ ERROR evaluation of constant value failed -//~| NOTE uninitialized +//~^ ERROR uninitialized const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init }; -//~^ ERROR evaluation of constant value failed -//~| NOTE uninitialized +//~^ ERROR uninitialized const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const UNALIGNED_READ: () = unsafe { let x = &[0u8; 4]; let ptr = x.as_ptr().cast::(); - ptr.read(); //~ ERROR evaluation of constant value failed + ptr.read(); //~ ERROR accessing memory }; diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.stderr b/tests/ui/consts/const-eval/ub-ref-ptr.stderr index cfec1a42f28aa..e10f21b02afe6 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-ref-ptr.stderr @@ -1,158 +1,158 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) --> $DIR/ub-ref-ptr.rs:17:1 | LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:21:1 +error[E0080]: constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) + --> $DIR/ub-ref-ptr.rs:20:1 | LL | const UNALIGNED_BOX: Box = unsafe { mem::transmute(&[0u8; 4]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:25:1 +error[E0080]: constructing invalid value: encountered a null reference + --> $DIR/ub-ref-ptr.rs:23:1 | LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference + | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:28:1 +error[E0080]: constructing invalid value: encountered a null box + --> $DIR/ub-ref-ptr.rs:26:1 | LL | const NULL_BOX: Box = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box + | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:35:1 +error[E0080]: unable to turn pointer into integer + --> $DIR/ub-ref-ptr.rs:33:1 | LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:38:39 +error[E0080]: unable to turn pointer into integer + --> $DIR/ub-ref-ptr.rs:36:39 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported note: erroneous constant encountered - --> $DIR/ub-ref-ptr.rs:38:38 + --> $DIR/ub-ref-ptr.rs:36:38 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:41:86 +error[E0080]: unable to turn pointer into integer + --> $DIR/ub-ref-ptr.rs:39:86 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; - | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported note: erroneous constant encountered - --> $DIR/ub-ref-ptr.rs:41:85 + --> $DIR/ub-ref-ptr.rs:39:85 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; | ^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:44:1 +error[E0080]: constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance) + --> $DIR/ub-ref-ptr.rs:42:1 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:47:1 +error[E0080]: constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance) + --> $DIR/ub-ref-ptr.rs:45:1 | LL | const USIZE_AS_BOX: Box = unsafe { mem::transmute(1337usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:50:41 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/ub-ref-ptr.rs:48:41 | LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:54:1 +error[E0080]: constructing invalid value: encountered null pointer, but expected a function pointer + --> $DIR/ub-ref-ptr.rs:51:1 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:56:38 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/ub-ref-ptr.rs:53:38 | LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:59:1 +error[E0080]: constructing invalid value: encountered 0xd[noalloc], but expected a function pointer + --> $DIR/ub-ref-ptr.rs:55:1 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:61:1 +error[E0080]: constructing invalid value: encountered ALLOC2, but expected a function pointer + --> $DIR/ub-ref-ptr.rs:57:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC2, but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:68:5 +error[E0080]: accessing memory based on pointer with alignment 1, but alignment 4 is required + --> $DIR/ub-ref-ptr.rs:64:5 | LL | ptr.read(); - | ^^^^^^^^^^ accessing memory based on pointer with alignment 1, but alignment 4 is required + | ^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 15 previous errors diff --git a/tests/ui/consts/const-eval/ub-uninhabit.rs b/tests/ui/consts/const-eval/ub-uninhabit.rs index 3a5e291d5df4a..188ad768a0e98 100644 --- a/tests/ui/consts/const-eval/ub-uninhabit.rs +++ b/tests/ui/consts/const-eval/ub-uninhabit.rs @@ -6,8 +6,7 @@ #![feature(core_intrinsics)] #![feature(never_type)] -use std::intrinsics; -use std::mem; +use std::{intrinsics, mem}; #[derive(Copy, Clone)] enum Bar {} @@ -19,25 +18,19 @@ union MaybeUninit { } const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init }; -//~^ ERROR evaluation of constant value failed -//~| NOTE constructing invalid value +//~^ ERROR constructing invalid value const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constructing invalid value +//~^ ERROR constructing invalid value const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init }; -//~^ ERROR evaluation of constant value failed -//~| NOTE constructing invalid value - +//~^ ERROR constructing invalid value const READ_NEVER: () = unsafe { let mem = [0u32; 8]; let ptr = mem.as_ptr().cast::(); let _val = intrinsics::read_via_copy(ptr); - //~^ ERROR evaluation of constant value failed - //~| NOTE constructing invalid value + //~^ ERROR constructing invalid value }; - fn main() {} diff --git a/tests/ui/consts/const-eval/ub-uninhabit.stderr b/tests/ui/consts/const-eval/ub-uninhabit.stderr index 9d3f93279e5ac..582a7a07be925 100644 --- a/tests/ui/consts/const-eval/ub-uninhabit.stderr +++ b/tests/ui/consts/const-eval/ub-uninhabit.stderr @@ -1,31 +1,31 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/ub-uninhabit.rs:21:35 +error[E0080]: constructing invalid value: encountered a value of uninhabited type `Bar` + --> $DIR/ub-uninhabit.rs:20:35 | LL | const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type `Bar` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-uninhabit.rs:25:1 +error[E0080]: constructing invalid value: encountered a reference pointing to uninhabited type Bar + --> $DIR/ub-uninhabit.rs:23:1 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-uninhabit.rs:29:42 +error[E0080]: constructing invalid value at [0]: encountered a value of uninhabited type `Bar` + --> $DIR/ub-uninhabit.rs:26:42 | LL | const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered a value of uninhabited type `Bar` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/ub-uninhabit.rs:37:16 +error[E0080]: constructing invalid value: encountered a value of the never type `!` + --> $DIR/ub-uninhabit.rs:32:16 | LL | let _val = intrinsics::read_via_copy(ptr); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of the never type `!` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 4 previous errors diff --git a/tests/ui/consts/const-eval/ub-upvars.32bit.stderr b/tests/ui/consts/const-eval/ub-upvars.32bit.stderr index 5342fea66bdb4..ecd1c768c287f 100644 --- a/tests/ui/consts/const-eval/ub-upvars.32bit.stderr +++ b/tests/ui/consts/const-eval/ub-upvars.32bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at ...: encountered a null reference --> $DIR/ub-upvars.rs:6:1 | LL | const BAD_UPVAR: &dyn FnOnce() = &{ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ...: encountered a null reference + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { diff --git a/tests/ui/consts/const-eval/ub-upvars.64bit.stderr b/tests/ui/consts/const-eval/ub-upvars.64bit.stderr index a2496dfc287bc..108dfe6b27be3 100644 --- a/tests/ui/consts/const-eval/ub-upvars.64bit.stderr +++ b/tests/ui/consts/const-eval/ub-upvars.64bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at ...: encountered a null reference --> $DIR/ub-upvars.rs:6:1 | LL | const BAD_UPVAR: &dyn FnOnce() = &{ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ...: encountered a null reference + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { diff --git a/tests/ui/consts/const-eval/ub-upvars.rs b/tests/ui/consts/const-eval/ub-upvars.rs index 817511180bea4..197222829842c 100644 --- a/tests/ui/consts/const-eval/ub-upvars.rs +++ b/tests/ui/consts/const-eval/ub-upvars.rs @@ -3,7 +3,7 @@ use std::mem; -const BAD_UPVAR: &dyn FnOnce() = &{ //~ ERROR it is undefined behavior to use this value +const BAD_UPVAR: &dyn FnOnce() = &{ //~ ERROR null reference let bad_ref: &'static u16 = unsafe { mem::transmute(0usize) }; let another_var = 13; move || { let _ = bad_ref; let _ = another_var; } diff --git a/tests/ui/consts/const-eval/ub-wide-ptr.rs b/tests/ui/consts/const-eval/ub-wide-ptr.rs index 4b9bbb8066ded..86235897e7e8d 100644 --- a/tests/ui/consts/const-eval/ub-wide-ptr.rs +++ b/tests/ui/consts/const-eval/ub-wide-ptr.rs @@ -37,74 +37,69 @@ type MySliceBool = MySlice<[bool]>; const STR_VALID: &str = unsafe { mem::transmute((&42u8, 1usize)) }; // bad str const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR encountered a dangling reference (going beyond the bounds of its allocation) const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR slice is bigger than largest supported object // bad str const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer // bad str in user-defined unsized type const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR slice is bigger than largest supported object // uninitialized byte const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR uninitialized memory, but expected a string // uninitialized byte in user-defined str-like const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR uninitialized memory, but expected a string // # slice // OK const SLICE_VALID: &[u8] = unsafe { mem::transmute((&42u8, 1usize)) }; // bad slice: length uninit const SLICE_LENGTH_UNINIT: &[u8] = unsafe { -//~^ ERROR evaluation of constant value failed -//~| NOTE uninitialized +//~^ ERROR uninitialized let uninit_len = MaybeUninit:: { uninit: () }; mem::transmute((42, uninit_len)) }; // bad slice: length too big const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR dangling reference (going beyond the bounds of its allocation) // bad slice: length computation overflows const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR slice is bigger than largest supported object // bad slice: length not an int const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer // bad slice box: length too big const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR dangling box (going beyond the bounds of its allocation) // bad slice box: length not an int const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer // bad data *inside* the slice const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constant +//~^ ERROR 0x03, but expected a boolean // good MySliceBool const MYSLICE_GOOD: &MySliceBool = &MySlice(true, [false]); // bad: sized field is not okay const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constant +//~^ ERROR 0x03, but expected a boolean // bad: unsized part is not okay const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constant +//~^ ERROR 0x03, but expected a boolean // # raw slice const RAW_SLICE_VALID: *const [u8] = unsafe { mem::transmute((&42u8, 1usize)) }; // ok const RAW_SLICE_TOO_LONG: *const [u8] = unsafe { mem::transmute((&42u8, 999usize)) }; // ok because raw const RAW_SLICE_MUCH_TOO_LONG: *const [u8] = unsafe { mem::transmute((&42u8, usize::MAX)) }; // ok because raw const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe { -//~^ ERROR evaluation of constant value failed -//~| NOTE uninitialized +//~^ ERROR uninitialized let uninit_len = MaybeUninit:: { uninit: () }; mem::transmute((42, uninit_len)) }; @@ -112,41 +107,31 @@ const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe { // # trait object // bad trait object const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE vtable +//~^ ERROR vtable // bad trait object const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE vtable +//~^ ERROR vtable // bad trait object const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE vtable +//~^ ERROR vtable const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE vtable +//~^ ERROR vtable const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE vtable +//~^ ERROR vtable const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE vtable +//~^ ERROR vtable const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE vtable +//~^ ERROR vtable // bad data *inside* the trait object const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE expected a boolean +//~^ ERROR expected a boolean // # raw trait object const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE null pointer +//~^ ERROR null pointer const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE vtable +//~^ ERROR vtable const RAW_TRAIT_OBJ_CONTENT_INVALID: *const dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) } as *const dyn Trait; // ok because raw // Officially blessed way to get the vtable const DYN_METADATA: ptr::DynMetadata = ptr::metadata::(ptr::null::()); @@ -154,13 +139,11 @@ const DYN_METADATA: ptr::DynMetadata = ptr::metadata::(ptr:: static mut RAW_TRAIT_OBJ_VTABLE_NULL_THROUGH_REF: *const dyn Trait = unsafe { mem::transmute::<_, &dyn Trait>((&92u8, 0usize)) - //~^^ ERROR it is undefined behavior to use this value - //~| NOTE null pointer + //~^^ ERROR null pointer }; static mut RAW_TRAIT_OBJ_VTABLE_INVALID_THROUGH_REF: *const dyn Trait = unsafe { mem::transmute::<_, &dyn Trait>((&92u8, &3u64)) - //~^^ ERROR it is undefined behavior to use this value - //~| NOTE vtable + //~^^ ERROR vtable }; fn main() {} diff --git a/tests/ui/consts/const-eval/ub-wide-ptr.stderr b/tests/ui/consts/const-eval/ub-wide-ptr.stderr index 92f0029a5b3eb..a586f154ca125 100644 --- a/tests/ui/consts/const-eval/ub-wide-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-wide-ptr.stderr @@ -1,138 +1,138 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) --> $DIR/ub-wide-ptr.rs:39:1 | LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object --> $DIR/ub-wide-ptr.rs:41:1 | LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/ub-wide-ptr.rs:44:1 | LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/ub-wide-ptr.rs:47:1 | LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object --> $DIR/ub-wide-ptr.rs:49:1 | LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .: encountered uninitialized memory, but expected a string --> $DIR/ub-wide-ptr.rs:53:1 | LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered uninitialized memory, but expected a string + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at ..0: encountered uninitialized memory, but expected a string --> $DIR/ub-wide-ptr.rs:56:1 | LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered uninitialized memory, but expected a string + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/ub-wide-ptr.rs:63:1 | LL | const SLICE_LENGTH_UNINIT: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:70:1 +error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + --> $DIR/ub-wide-ptr.rs:69:1 | LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:73:1 +error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/ub-wide-ptr.rs:72:1 | LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:76:1 +error[E0080]: unable to turn pointer into integer + --> $DIR/ub-wide-ptr.rs:75:1 | LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:79:1 +error[E0080]: constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation) + --> $DIR/ub-wide-ptr.rs:78:1 | LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:82:1 +error[E0080]: unable to turn pointer into integer + --> $DIR/ub-wide-ptr.rs:81:1 | LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:86:1 +error[E0080]: constructing invalid value at .[0]: encountered 0x03, but expected a boolean + --> $DIR/ub-wide-ptr.rs:85:1 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -140,16 +140,16 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; } note: erroneous constant encountered - --> $DIR/ub-wide-ptr.rs:86:40 + --> $DIR/ub-wide-ptr.rs:85:40 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:93:1 +error[E0080]: constructing invalid value at ..0: encountered 0x03, but expected a boolean + --> $DIR/ub-wide-ptr.rs:91:1 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -157,16 +157,16 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3 } note: erroneous constant encountered - --> $DIR/ub-wide-ptr.rs:93:42 + --> $DIR/ub-wide-ptr.rs:91:42 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:97:1 +error[E0080]: constructing invalid value at ..1[0]: encountered 0x03, but expected a boolean + --> $DIR/ub-wide-ptr.rs:94:1 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..1[0]: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -174,143 +174,143 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran } note: erroneous constant encountered - --> $DIR/ub-wide-ptr.rs:97:42 + --> $DIR/ub-wide-ptr.rs:94:42 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:105:1 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/ub-wide-ptr.rs:101:1 | LL | const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:114:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC12, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:109:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC12, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:118:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC14, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:112:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC14, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:122:1 +error[E0080]: constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:115:1 | LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:125:1 +error[E0080]: constructing invalid value: encountered ALLOC17, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:117:1 | LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC17, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:128:1 +error[E0080]: constructing invalid value: encountered ALLOC19, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:119:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC19, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:131:1 +error[E0080]: constructing invalid value: encountered ALLOC21, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:121:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC21, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:134:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC23, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:123:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC23, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:139:1 +error[E0080]: constructing invalid value at ..: encountered 0x03, but expected a boolean + --> $DIR/ub-wide-ptr.rs:127:1 | LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:144:1 +error[E0080]: constructing invalid value: encountered null pointer, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:131:1 | LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:147:1 +error[E0080]: constructing invalid value: encountered ALLOC28, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:133:1 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC28, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:155:1 +error[E0080]: constructing invalid value: encountered null pointer, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:140:1 | LL | static mut RAW_TRAIT_OBJ_VTABLE_NULL_THROUGH_REF: *const dyn Trait = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:160:1 +error[E0080]: constructing invalid value: encountered ALLOC31, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:144:1 | LL | static mut RAW_TRAIT_OBJ_VTABLE_INVALID_THROUGH_REF: *const dyn Trait = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC31, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { diff --git a/tests/ui/consts/const-eval/ub-write-through-immutable.rs b/tests/ui/consts/const-eval/ub-write-through-immutable.rs index 795ac602a1c65..28c7a617a4d58 100644 --- a/tests/ui/consts/const-eval/ub-write-through-immutable.rs +++ b/tests/ui/consts/const-eval/ub-write-through-immutable.rs @@ -1,21 +1,19 @@ //! Ensure we catch UB due to writing through a shared reference. #![allow(invalid_reference_casting)] -use std::mem; use std::cell::UnsafeCell; +use std::mem; const WRITE_AFTER_CAST: () = unsafe { let mut x = 0; let ptr = &x as *const i32 as *mut i32; - *ptr = 0; //~ERROR: evaluation of constant value failed - //~| NOTE immutable + *ptr = 0; //~ERROR: immutable }; const WRITE_AFTER_TRANSMUTE: () = unsafe { let mut x = 0; let ptr: *mut i32 = mem::transmute(&x); - *ptr = 0; //~ERROR: evaluation of constant value failed - //~| NOTE immutable + *ptr = 0; //~ERROR: immutable }; // it's okay when there is interior mutability; 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 d30df33bc55f9..dbcd07110cc20 100644 --- a/tests/ui/consts/const-eval/ub-write-through-immutable.stderr +++ b/tests/ui/consts/const-eval/ub-write-through-immutable.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: writing through a pointer that was derived from a shared (immutable) reference --> $DIR/ub-write-through-immutable.rs:10:5 | LL | *ptr = 0; - | ^^^^^^^^ writing through a pointer that was derived from a shared (immutable) reference + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/ub-write-through-immutable.rs:17:5 +error[E0080]: writing through a pointer that was derived from a shared (immutable) reference + --> $DIR/ub-write-through-immutable.rs:16:5 | LL | *ptr = 0; - | ^^^^^^^^ writing through a pointer that was derived from a shared (immutable) reference + | ^^^^^^^^ evaluation of constant value failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/union-const-eval-field.rs b/tests/ui/consts/const-eval/union-const-eval-field.rs index 55e9abe72e091..0ad94eee7f45a 100644 --- a/tests/ui/consts/const-eval/union-const-eval-field.rs +++ b/tests/ui/consts/const-eval/union-const-eval-field.rs @@ -26,8 +26,7 @@ const fn read_field2() -> Field2 { const fn read_field3() -> Field3 { const FIELD3: Field3 = unsafe { UNION.field3 }; - //~^ ERROR evaluation of constant value failed - //~| NOTE uninitialized + //~^ ERROR uninitialized FIELD3 } 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 4fd6b80381c32..eb3906a4eccad 100644 --- a/tests/ui/consts/const-eval/union-const-eval-field.stderr +++ b/tests/ui/consts/const-eval/union-const-eval-field.stderr @@ -1,17 +1,17 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/union-const-eval-field.rs:28:37 | LL | const FIELD3: Field3 = unsafe { UNION.field3 }; - | ^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^ evaluation of constant value failed here note: erroneous constant encountered - --> $DIR/union-const-eval-field.rs:31:5 + --> $DIR/union-const-eval-field.rs:30:5 | LL | FIELD3 | ^^^^^^ note: erroneous constant encountered - --> $DIR/union-const-eval-field.rs:31:5 + --> $DIR/union-const-eval-field.rs:30:5 | LL | FIELD3 | ^^^^^^ diff --git a/tests/ui/consts/const-eval/union-ice.rs b/tests/ui/consts/const-eval/union-ice.rs index 8ce5f6d89a8f3..7a4909e8ce281 100644 --- a/tests/ui/consts/const-eval/union-ice.rs +++ b/tests/ui/consts/const-eval/union-ice.rs @@ -12,14 +12,12 @@ union DummyUnion { const UNION: DummyUnion = DummyUnion { field1: 1065353216 }; const FIELD3: Field3 = unsafe { UNION.field3 }; -//~^ ERROR evaluation of constant value failed -//~| NOTE uninitialized +//~^ ERROR uninitialized const FIELD_PATH: Struct = Struct { a: 42, b: unsafe { UNION.field3 }, - //~^ ERROR evaluation of constant value failed - //~| NOTE uninitialized + //~^ ERROR uninitialized }; struct Struct { @@ -31,8 +29,7 @@ const FIELD_PATH2: Struct2 = Struct2 { b: [ 21, unsafe { UNION.field3 }, - //~^ ERROR evaluation of constant value failed - //~| NOTE uninitialized + //~^ ERROR uninitialized 23, 24, ], @@ -44,5 +41,4 @@ struct Struct2 { a: u8, } -fn main() { -} +fn main() {} diff --git a/tests/ui/consts/const-eval/union-ice.stderr b/tests/ui/consts/const-eval/union-ice.stderr index bd39a05510b9d..86c42713095bb 100644 --- a/tests/ui/consts/const-eval/union-ice.stderr +++ b/tests/ui/consts/const-eval/union-ice.stderr @@ -1,20 +1,20 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/union-ice.rs:14:33 | LL | const FIELD3: Field3 = unsafe { UNION.field3 }; - | ^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/union-ice.rs:20:17 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/union-ice.rs:19:17 | LL | b: unsafe { UNION.field3 }, - | ^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/union-ice.rs:33:18 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/union-ice.rs:31:18 | LL | unsafe { UNION.field3 }, - | ^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 3 previous errors diff --git a/tests/ui/consts/const-eval/union-ub.32bit.stderr b/tests/ui/consts/const-eval/union-ub.32bit.stderr index 38ded4d65cfb6..7b263c20d339d 100644 --- a/tests/ui/consts/const-eval/union-ub.32bit.stderr +++ b/tests/ui/consts/const-eval/union-ub.32bit.stderr @@ -1,19 +1,19 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0x2a, but expected a boolean --> $DIR/union-ub.rs:33:1 | -LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool}; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x2a, but expected a boolean +LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool }; + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 2a │ * } -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/union-ub.rs:35:36 | -LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory +LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/union-ub.64bit.stderr b/tests/ui/consts/const-eval/union-ub.64bit.stderr index 38ded4d65cfb6..7b263c20d339d 100644 --- a/tests/ui/consts/const-eval/union-ub.64bit.stderr +++ b/tests/ui/consts/const-eval/union-ub.64bit.stderr @@ -1,19 +1,19 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0x2a, but expected a boolean --> $DIR/union-ub.rs:33:1 | -LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool}; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x2a, but expected a boolean +LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool }; + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 2a │ * } -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/union-ub.rs:35:36 | -LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory +LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/union-ub.rs b/tests/ui/consts/const-eval/union-ub.rs index 7d8fd7446a0c5..0fa5d31285604 100644 --- a/tests/ui/consts/const-eval/union-ub.rs +++ b/tests/ui/consts/const-eval/union-ub.rs @@ -30,15 +30,13 @@ union Bar { } // the value is not valid for bools -const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool}; -//~^ ERROR it is undefined behavior to use this value -const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool}; -//~^ ERROR evaluation of constant value failed -//~| NOTE uninitialized +const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool }; +//~^ ERROR invalid value +const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool }; +//~^ ERROR uninitialized // The value is not valid for any union variant, but that's fine // unions are just a convenient way to transmute bits around const BAD_UNION: Foo = unsafe { Bar { u8: 42 }.foo }; - fn main() {} diff --git a/tests/ui/consts/const-eval/unused-broken-const.rs b/tests/ui/consts/const-eval/unused-broken-const.rs index f7e229aa9807b..602063626653f 100644 --- a/tests/ui/consts/const-eval/unused-broken-const.rs +++ b/tests/ui/consts/const-eval/unused-broken-const.rs @@ -3,6 +3,6 @@ //@ compile-flags: --emit=dep-info,metadata const FOO: i32 = [][0]; -//~^ ERROR evaluation of constant value failed +//~^ ERROR index out of bounds fn main() {} diff --git a/tests/ui/consts/const-eval/unused-broken-const.stderr b/tests/ui/consts/const-eval/unused-broken-const.stderr index fd0ee316fe248..5745539cb567e 100644 --- a/tests/ui/consts/const-eval/unused-broken-const.stderr +++ b/tests/ui/consts/const-eval/unused-broken-const.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: index out of bounds: the length is 0 but the index is 0 --> $DIR/unused-broken-const.rs:5:18 | LL | const FOO: i32 = [][0]; - | ^^^^^ index out of bounds: the length is 0 but the index is 0 + | ^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/unwind-abort.rs b/tests/ui/consts/const-eval/unwind-abort.rs index b239dba023973..688bb08535639 100644 --- a/tests/ui/consts/const-eval/unwind-abort.rs +++ b/tests/ui/consts/const-eval/unwind-abort.rs @@ -4,7 +4,7 @@ const extern "C" fn foo() { panic!() //~ NOTE inside `foo` } -const _: () = foo(); //~ ERROR evaluation of constant value failed +const _: () = foo(); //~ ERROR explicit panic // Ensure that the CTFE engine handles calls to `extern "C"` aborting gracefully fn main() { diff --git a/tests/ui/consts/const-eval/unwind-abort.stderr b/tests/ui/consts/const-eval/unwind-abort.stderr index 5ed7467e84b25..94cf3acec4543 100644 --- a/tests/ui/consts/const-eval/unwind-abort.stderr +++ b/tests/ui/consts/const-eval/unwind-abort.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/unwind-abort.rs:7:15 | LL | const _: () = foo(); - | ^^^^^ evaluation panicked: explicit panic + | ^^^^^ evaluation of constant value failed here | note: inside `foo` --> $DIR/unwind-abort.rs:4:5 diff --git a/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs b/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs index 5f1d27b0de001..dbb165c64d9ed 100644 --- a/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs +++ b/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs @@ -15,10 +15,10 @@ pub mod empty { } const FOO: [empty::Empty; 3] = [foo(); 3]; -//~^ ERROR evaluation of constant value failed +//~^ ERROR value of the never type const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; -//~^ ERROR evaluation of constant value failed +//~^ ERROR value of uninhabited type fn main() { FOO; diff --git a/tests/ui/consts/const-eval/validate_uninhabited_zsts.stderr b/tests/ui/consts/const-eval/validate_uninhabited_zsts.stderr index 0407ae5c323a5..4557b39290768 100644 --- a/tests/ui/consts/const-eval/validate_uninhabited_zsts.stderr +++ b/tests/ui/consts/const-eval/validate_uninhabited_zsts.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: constructing invalid value: encountered a value of the never type `!` --> $DIR/validate_uninhabited_zsts.rs:17:33 | LL | const FOO: [empty::Empty; 3] = [foo(); 3]; - | ^^^^^ constructing invalid value: encountered a value of the never type `!` + | ^^^^^ evaluation of constant value failed here | note: inside `foo` --> $DIR/validate_uninhabited_zsts.rs:4:14 @@ -10,11 +10,11 @@ note: inside `foo` LL | unsafe { std::mem::transmute(()) } | ^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here -error[E0080]: evaluation of constant value failed +error[E0080]: constructing invalid value at .0: encountered a value of uninhabited type `Void` --> $DIR/validate_uninhabited_zsts.rs:20:42 | LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered a value of uninhabited type `Void` + | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/validation-ice-extern-type-field.rs b/tests/ui/consts/const-eval/validation-ice-extern-type-field.rs index 8a32b170c40a4..3081689ee90cb 100644 --- a/tests/ui/consts/const-eval/validation-ice-extern-type-field.rs +++ b/tests/ui/consts/const-eval/validation-ice-extern-type-field.rs @@ -10,6 +10,6 @@ struct ThinDst { } const C1: &ThinDst = unsafe { std::mem::transmute(b"d".as_ptr()) }; -//~^ERROR: evaluation of constant value failed +//~^ERROR: `extern type` field does not have a known offset fn main() {} diff --git a/tests/ui/consts/const-eval/validation-ice-extern-type-field.stderr b/tests/ui/consts/const-eval/validation-ice-extern-type-field.stderr index 1ec36abc2eccf..08d791f49532e 100644 --- a/tests/ui/consts/const-eval/validation-ice-extern-type-field.stderr +++ b/tests/ui/consts/const-eval/validation-ice-extern-type-field.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: `extern type` field does not have a known offset --> $DIR/validation-ice-extern-type-field.rs:12:1 | LL | const C1: &ThinDst = unsafe { std::mem::transmute(b"d".as_ptr()) }; - | ^^^^^^^^^^^^^^^^^^ `extern type` field does not have a known offset + | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-external-macro-const-err.rs b/tests/ui/consts/const-external-macro-const-err.rs index 3cb83823f1ae6..60cbe36071dbd 100644 --- a/tests/ui/consts/const-external-macro-const-err.rs +++ b/tests/ui/consts/const-external-macro-const-err.rs @@ -9,5 +9,5 @@ extern crate external_macro; use external_macro::static_assert; fn main() { - static_assert!(2 + 2 == 5); //~ ERROR constant + static_assert!(2 + 2 == 5); //~ ERROR index out of bounds: the length is 1 but the index is 1 } diff --git a/tests/ui/consts/const-external-macro-const-err.stderr b/tests/ui/consts/const-external-macro-const-err.stderr index 63f81ea18bc04..7cd646b1c45db 100644 --- a/tests/ui/consts/const-external-macro-const-err.stderr +++ b/tests/ui/consts/const-external-macro-const-err.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: index out of bounds: the length is 1 but the index is 1 --> $DIR/const-external-macro-const-err.rs:12:5 | LL | static_assert!(2 + 2 == 5); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = note: this error originates in the macro `static_assert` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/const-int-unchecked.rs b/tests/ui/consts/const-int-unchecked.rs index 8de28aa2bb171..3fc58720cf122 100644 --- a/tests/ui/consts/const-int-unchecked.rs +++ b/tests/ui/consts/const-int-unchecked.rs @@ -1,6 +1,5 @@ #![feature(core_intrinsics)] - use std::intrinsics; // The documentation of `unchecked_shl` states that it: @@ -13,137 +12,137 @@ use std::intrinsics; // unsigned types: const SHL_U8: u8 = unsafe { intrinsics::unchecked_shl(5_u8, 8) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_U16: u16 = unsafe { intrinsics::unchecked_shl(5_u16, 16) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_U32: u32 = unsafe { intrinsics::unchecked_shl(5_u32, 32) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_U64: u64 = unsafe { intrinsics::unchecked_shl(5_u64, 64) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_U128: u128 = unsafe { intrinsics::unchecked_shl(5_u128, 128) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift // signed types: const SHL_I8: i8 = unsafe { intrinsics::unchecked_shl(5_i8, 8) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_I16: i16 = unsafe { intrinsics::unchecked_shl(5_i16, 16) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_I32: i32 = unsafe { intrinsics::unchecked_shl(5_i32, 32) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_I64: i64 = unsafe { intrinsics::unchecked_shl(5_i64, 64) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_I128: i128 = unsafe { intrinsics::unchecked_shl(5_i128, 128) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift // and make sure we capture y < 0: const SHL_I8_NEG: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_I16_NEG: i16 = unsafe { intrinsics::unchecked_shl(5_i16, -1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_I32_NEG: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_I64_NEG: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_I128_NEG: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift // and that there's no special relation to the value -1 by picking some // negative values at random: const SHL_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -6) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shl(5_i16, -13) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -25) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -30) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -93) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift // Repeat it all over for `unchecked_shr` // unsigned types: const SHR_U8: u8 = unsafe { intrinsics::unchecked_shr(5_u8, 8) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_U16: u16 = unsafe { intrinsics::unchecked_shr(5_u16, 16) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_U32: u32 = unsafe { intrinsics::unchecked_shr(5_u32, 32) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_U64: u64 = unsafe { intrinsics::unchecked_shr(5_u64, 64) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_U128: u128 = unsafe { intrinsics::unchecked_shr(5_u128, 128) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift // signed types: const SHR_I8: i8 = unsafe { intrinsics::unchecked_shr(5_i8, 8) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_I16: i16 = unsafe { intrinsics::unchecked_shr(5_i16, 16) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_I32: i32 = unsafe { intrinsics::unchecked_shr(5_i32, 32) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_I64: i64 = unsafe { intrinsics::unchecked_shr(5_i64, 64) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_I128: i128 = unsafe { intrinsics::unchecked_shr(5_i128, 128) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift // and make sure we capture y < 0: const SHR_I8_NEG: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_I16_NEG: i16 = unsafe { intrinsics::unchecked_shr(5_i16, -1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_I32_NEG: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_I64_NEG: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_I128_NEG: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift // and that there's no special relation to the value -1 by picking some // negative values at random: const SHR_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -6) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shr(5_i16, -13) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -25) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -30) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -93) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift // Other arithmetic functions: const _: u16 = unsafe { std::intrinsics::unchecked_add(40000u16, 30000) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR arithmetic overflow const _: u32 = unsafe { std::intrinsics::unchecked_sub(14u32, 22) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR arithmetic overflow const _: u16 = unsafe { std::intrinsics::unchecked_mul(300u16, 250u16) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR arithmetic overflow const _: i32 = unsafe { std::intrinsics::unchecked_div(1, 0) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR dividing by zero const _: i32 = unsafe { std::intrinsics::unchecked_div(i32::MIN, -1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflow in signed division (dividing MIN by -1) const _: i32 = unsafe { std::intrinsics::unchecked_rem(1, 0) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR calculating the remainder with a divisor of zero const _: i32 = unsafe { std::intrinsics::unchecked_rem(i32::MIN, -1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflow in signed remainder (dividing MIN by -1) // capture fault with zero value const _: u32 = unsafe { std::intrinsics::ctlz_nonzero(0) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR `ctlz_nonzero` called on 0 const _: u32 = unsafe { std::intrinsics::cttz_nonzero(0) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR `cttz_nonzero` called on 0 fn main() {} diff --git a/tests/ui/consts/const-int-unchecked.stderr b/tests/ui/consts/const-int-unchecked.stderr index 3130603231e1b..20c109b926501 100644 --- a/tests/ui/consts/const-int-unchecked.stderr +++ b/tests/ui/consts/const-int-unchecked.stderr @@ -1,296 +1,296 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:15:29 +error[E0080]: overflowing shift by 8 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:14:29 | LL | const SHL_U8: u8 = unsafe { intrinsics::unchecked_shl(5_u8, 8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 8 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:17:31 +error[E0080]: overflowing shift by 16 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:16:31 | LL | const SHL_U16: u16 = unsafe { intrinsics::unchecked_shl(5_u16, 16) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 16 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:19:31 +error[E0080]: overflowing shift by 32 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:18:31 | LL | const SHL_U32: u32 = unsafe { intrinsics::unchecked_shl(5_u32, 32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 32 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:21:31 +error[E0080]: overflowing shift by 64 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:20:31 | LL | const SHL_U64: u64 = unsafe { intrinsics::unchecked_shl(5_u64, 64) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 64 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:23:33 +error[E0080]: overflowing shift by 128 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:22:33 | LL | const SHL_U128: u128 = unsafe { intrinsics::unchecked_shl(5_u128, 128) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 128 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:28:29 +error[E0080]: overflowing shift by 8 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:27:29 | LL | const SHL_I8: i8 = unsafe { intrinsics::unchecked_shl(5_i8, 8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 8 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:30:31 +error[E0080]: overflowing shift by 16 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:29:31 | LL | const SHL_I16: i16 = unsafe { intrinsics::unchecked_shl(5_i16, 16) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 16 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:32:31 +error[E0080]: overflowing shift by 32 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:31:31 | LL | const SHL_I32: i32 = unsafe { intrinsics::unchecked_shl(5_i32, 32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 32 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:34:31 +error[E0080]: overflowing shift by 64 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:33:31 | LL | const SHL_I64: i64 = unsafe { intrinsics::unchecked_shl(5_i64, 64) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 64 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:36:33 +error[E0080]: overflowing shift by 128 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:35:33 | LL | const SHL_I128: i128 = unsafe { intrinsics::unchecked_shl(5_i128, 128) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 128 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:41:33 +error[E0080]: overflowing shift by -1 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:40:33 | LL | const SHL_I8_NEG: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -1 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:43:35 +error[E0080]: overflowing shift by -1 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:42:35 | LL | const SHL_I16_NEG: i16 = unsafe { intrinsics::unchecked_shl(5_i16, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -1 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:45:35 +error[E0080]: overflowing shift by -1 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:44:35 | LL | const SHL_I32_NEG: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -1 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:47:35 +error[E0080]: overflowing shift by -1 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:46:35 | LL | const SHL_I64_NEG: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -1 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:49:37 +error[E0080]: overflowing shift by -1 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:48:37 | LL | const SHL_I128_NEG: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -1 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:55:40 +error[E0080]: overflowing shift by -6 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:54:40 | LL | const SHL_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -6) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -6 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:57:42 +error[E0080]: overflowing shift by -13 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:56:42 | LL | const SHL_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shl(5_i16, -13) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -13 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:59:42 +error[E0080]: overflowing shift by -25 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:58:42 | LL | const SHL_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -25) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -25 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:61:42 +error[E0080]: overflowing shift by -30 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:60:42 | LL | const SHL_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -30) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -30 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:63:44 +error[E0080]: overflowing shift by -93 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:62:44 | LL | const SHL_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -93) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -93 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:70:29 +error[E0080]: overflowing shift by 8 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:69:29 | LL | const SHR_U8: u8 = unsafe { intrinsics::unchecked_shr(5_u8, 8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 8 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:72:31 +error[E0080]: overflowing shift by 16 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:71:31 | LL | const SHR_U16: u16 = unsafe { intrinsics::unchecked_shr(5_u16, 16) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 16 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:74:31 +error[E0080]: overflowing shift by 32 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:73:31 | LL | const SHR_U32: u32 = unsafe { intrinsics::unchecked_shr(5_u32, 32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 32 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:76:31 +error[E0080]: overflowing shift by 64 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:75:31 | LL | const SHR_U64: u64 = unsafe { intrinsics::unchecked_shr(5_u64, 64) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 64 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:78:33 +error[E0080]: overflowing shift by 128 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:77:33 | LL | const SHR_U128: u128 = unsafe { intrinsics::unchecked_shr(5_u128, 128) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 128 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:83:29 +error[E0080]: overflowing shift by 8 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:82:29 | LL | const SHR_I8: i8 = unsafe { intrinsics::unchecked_shr(5_i8, 8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 8 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:85:31 +error[E0080]: overflowing shift by 16 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:84:31 | LL | const SHR_I16: i16 = unsafe { intrinsics::unchecked_shr(5_i16, 16) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 16 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:87:31 +error[E0080]: overflowing shift by 32 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:86:31 | LL | const SHR_I32: i32 = unsafe { intrinsics::unchecked_shr(5_i32, 32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 32 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:89:31 +error[E0080]: overflowing shift by 64 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:88:31 | LL | const SHR_I64: i64 = unsafe { intrinsics::unchecked_shr(5_i64, 64) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 64 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:91:33 +error[E0080]: overflowing shift by 128 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:90:33 | LL | const SHR_I128: i128 = unsafe { intrinsics::unchecked_shr(5_i128, 128) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 128 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:96:33 +error[E0080]: overflowing shift by -1 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:95:33 | LL | const SHR_I8_NEG: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -1 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:98:35 +error[E0080]: overflowing shift by -1 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:97:35 | LL | const SHR_I16_NEG: i16 = unsafe { intrinsics::unchecked_shr(5_i16, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -1 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:100:35 +error[E0080]: overflowing shift by -1 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:99:35 | LL | const SHR_I32_NEG: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -1 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:102:35 +error[E0080]: overflowing shift by -1 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:101:35 | LL | const SHR_I64_NEG: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -1 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:104:37 +error[E0080]: overflowing shift by -1 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:103:37 | LL | const SHR_I128_NEG: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -1 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:110:40 +error[E0080]: overflowing shift by -6 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:109:40 | LL | const SHR_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -6) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -6 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:112:42 +error[E0080]: overflowing shift by -13 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:111:42 | LL | const SHR_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shr(5_i16, -13) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -13 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:114:42 +error[E0080]: overflowing shift by -25 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:113:42 | LL | const SHR_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -25) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -25 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:116:42 +error[E0080]: overflowing shift by -30 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:115:42 | LL | const SHR_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -30) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -30 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:118:44 +error[E0080]: overflowing shift by -93 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:117:44 | LL | const SHR_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -93) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -93 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:123:25 +error[E0080]: arithmetic overflow in `unchecked_add` + --> $DIR/const-int-unchecked.rs:122:25 | LL | const _: u16 = unsafe { std::intrinsics::unchecked_add(40000u16, 30000) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ arithmetic overflow in `unchecked_add` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:126:25 +error[E0080]: arithmetic overflow in `unchecked_sub` + --> $DIR/const-int-unchecked.rs:125:25 | LL | const _: u32 = unsafe { std::intrinsics::unchecked_sub(14u32, 22) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ arithmetic overflow in `unchecked_sub` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:129:25 +error[E0080]: arithmetic overflow in `unchecked_mul` + --> $DIR/const-int-unchecked.rs:128:25 | LL | const _: u16 = unsafe { std::intrinsics::unchecked_mul(300u16, 250u16) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ arithmetic overflow in `unchecked_mul` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:132:25 +error[E0080]: dividing by zero + --> $DIR/const-int-unchecked.rs:131:25 | LL | const _: i32 = unsafe { std::intrinsics::unchecked_div(1, 0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dividing by zero + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:134:25 +error[E0080]: overflow in signed division (dividing MIN by -1) + --> $DIR/const-int-unchecked.rs:133:25 | LL | const _: i32 = unsafe { std::intrinsics::unchecked_div(i32::MIN, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:137:25 +error[E0080]: calculating the remainder with a divisor of zero + --> $DIR/const-int-unchecked.rs:136:25 | LL | const _: i32 = unsafe { std::intrinsics::unchecked_rem(1, 0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calculating the remainder with a divisor of zero + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:139:25 +error[E0080]: overflow in signed remainder (dividing MIN by -1) + --> $DIR/const-int-unchecked.rs:138:25 | LL | const _: i32 = unsafe { std::intrinsics::unchecked_rem(i32::MIN, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:144:25 +error[E0080]: `ctlz_nonzero` called on 0 + --> $DIR/const-int-unchecked.rs:143:25 | LL | const _: u32 = unsafe { std::intrinsics::ctlz_nonzero(0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ctlz_nonzero` called on 0 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:146:25 +error[E0080]: `cttz_nonzero` called on 0 + --> $DIR/const-int-unchecked.rs:145:25 | LL | const _: u32 = unsafe { std::intrinsics::cttz_nonzero(0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `cttz_nonzero` called on 0 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 49 previous errors diff --git a/tests/ui/consts/const-len-underflow-separate-spans.next.stderr b/tests/ui/consts/const-len-underflow-separate-spans.next.stderr index aacd74635e9fa..510b9cdc4065e 100644 --- a/tests/ui/consts/const-len-underflow-separate-spans.next.stderr +++ b/tests/ui/consts/const-len-underflow-separate-spans.next.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `1_usize - 2_usize`, which would overflow --> $DIR/const-len-underflow-separate-spans.rs:10:20 | LL | const LEN: usize = ONE - TWO; - | ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow + | ^^^^^^^^^ evaluation of constant value failed here note: erroneous constant encountered --> $DIR/const-len-underflow-separate-spans.rs:15:17 diff --git a/tests/ui/consts/const-len-underflow-separate-spans.old.stderr b/tests/ui/consts/const-len-underflow-separate-spans.old.stderr index aacd74635e9fa..510b9cdc4065e 100644 --- a/tests/ui/consts/const-len-underflow-separate-spans.old.stderr +++ b/tests/ui/consts/const-len-underflow-separate-spans.old.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `1_usize - 2_usize`, which would overflow --> $DIR/const-len-underflow-separate-spans.rs:10:20 | LL | const LEN: usize = ONE - TWO; - | ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow + | ^^^^^^^^^ evaluation of constant value failed here note: erroneous constant encountered --> $DIR/const-len-underflow-separate-spans.rs:15:17 diff --git a/tests/ui/consts/const-len-underflow-separate-spans.rs b/tests/ui/consts/const-len-underflow-separate-spans.rs index 14eb88b142713..a815ecaef7099 100644 --- a/tests/ui/consts/const-len-underflow-separate-spans.rs +++ b/tests/ui/consts/const-len-underflow-separate-spans.rs @@ -8,10 +8,10 @@ const ONE: usize = 1; const TWO: usize = 2; const LEN: usize = ONE - TWO; -//~^ ERROR constant -//~| NOTE attempt to compute `1_usize - 2_usize`, which would overflow +//~^ NOTE constant +//~| ERROR attempt to compute `1_usize - 2_usize`, which would overflow fn main() { let a: [i8; LEN] = unimplemented!(); -//~^ NOTE constant + //~^ NOTE constant } diff --git a/tests/ui/consts/const-len-underflow-subspans.rs b/tests/ui/consts/const-len-underflow-subspans.rs index 5afb1bf89d091..1540bffa0ad29 100644 --- a/tests/ui/consts/const-len-underflow-subspans.rs +++ b/tests/ui/consts/const-len-underflow-subspans.rs @@ -6,6 +6,5 @@ const TWO: usize = 2; fn main() { let a: [i8; ONE - TWO] = unimplemented!(); - //~^ ERROR evaluation of constant value failed - //~| NOTE attempt to compute `1_usize - 2_usize`, which would overflow + //~^ ERROR attempt to compute `1_usize - 2_usize`, which would overflow } diff --git a/tests/ui/consts/const-len-underflow-subspans.stderr b/tests/ui/consts/const-len-underflow-subspans.stderr index bfec056cc8aae..42d744147d648 100644 --- a/tests/ui/consts/const-len-underflow-subspans.stderr +++ b/tests/ui/consts/const-len-underflow-subspans.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `1_usize - 2_usize`, which would overflow --> $DIR/const-len-underflow-subspans.rs:8:17 | LL | let a: [i8; ONE - TWO] = unimplemented!(); - | ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow + | ^^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final.rs b/tests/ui/consts/const-mut-refs/mut_ref_in_final.rs index bc534be6832e5..29474c7632038 100644 --- a/tests/ui/consts/const-mut-refs/mut_ref_in_final.rs +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final.rs @@ -25,8 +25,7 @@ const B4: Option<&mut i32> = helper(&mut 42); //~ ERROR temporary value dropped // Not ok, since it points to read-only memory. const IMMUT_MUT_REF: &mut u16 = unsafe { mem::transmute(&13) }; -//~^ ERROR undefined behavior to use this value -//~| NOTE pointing to read-only memory +//~^ ERROR pointing to read-only memory // Ok, because no references to mutable data exist here, since the `{}` moves // its value and then takes a reference to that. diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr b/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr index 1f49f08c40156..834ea3410f6fb 100644 --- a/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr @@ -24,11 +24,11 @@ LL | const B4: Option<&mut i32> = helper(&mut 42); | | creates a temporary value which is freed while still in use | using this value as a constant requires that borrow lasts for `'static` -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered mutable reference or box pointing to read-only memory --> $DIR/mut_ref_in_final.rs:27:1 | LL | const IMMUT_MUT_REF: &mut u16 = unsafe { mem::transmute(&13) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -36,7 +36,7 @@ LL | const IMMUT_MUT_REF: &mut u16 = unsafe { mem::transmute(&13) }; } error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:51:65 + --> $DIR/mut_ref_in_final.rs:50:65 | LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- @@ -46,7 +46,7 @@ LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | using this value as a constant requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:54:67 + --> $DIR/mut_ref_in_final.rs:53:67 | LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- @@ -56,7 +56,7 @@ LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | using this value as a static requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:57:71 + --> $DIR/mut_ref_in_final.rs:56:71 | LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- @@ -66,25 +66,25 @@ LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | using this value as a static requires that borrow lasts for `'static` error[E0764]: mutable references are not allowed in the final value of statics - --> $DIR/mut_ref_in_final.rs:70:53 + --> $DIR/mut_ref_in_final.rs:69:53 | LL | static RAW_MUT_CAST_S: SyncPtr = SyncPtr { x : &mut 42 as *mut _ as *const _ }; | ^^^^^^^ error[E0764]: mutable references are not allowed in the final value of statics - --> $DIR/mut_ref_in_final.rs:72:54 + --> $DIR/mut_ref_in_final.rs:71:54 | LL | static RAW_MUT_COERCE_S: SyncPtr = SyncPtr { x: &mut 0 }; | ^^^^^^ error[E0764]: mutable references are not allowed in the final value of constants - --> $DIR/mut_ref_in_final.rs:74:52 + --> $DIR/mut_ref_in_final.rs:73:52 | LL | const RAW_MUT_CAST_C: SyncPtr = SyncPtr { x : &mut 42 as *mut _ as *const _ }; | ^^^^^^^ error[E0764]: mutable references are not allowed in the final value of constants - --> $DIR/mut_ref_in_final.rs:76:53 + --> $DIR/mut_ref_in_final.rs:75:53 | LL | const RAW_MUT_COERCE_C: SyncPtr = SyncPtr { x: &mut 0 }; | ^^^^^^ diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs index a58c4437e1572..2707e8a14ec38 100644 --- a/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs @@ -16,24 +16,21 @@ static mut BUFFER: i32 = 42; const fn helper() -> Option<&'static mut i32> { unsafe { Some(&mut *std::ptr::addr_of_mut!(BUFFER)) } } -const MUT: Option<&mut i32> = helper(); //~ ERROR it is undefined behavior to use this value -//~^ NOTE encountered reference to mutable +const MUT: Option<&mut i32> = helper(); //~ ERROR encountered reference to mutable const fn helper_int2ptr() -> Option<&'static mut i32> { unsafe { // Undefined behaviour (integer as pointer), who doesn't love tests like this. Some(&mut *(42 as *mut i32)) } } -const INT2PTR: Option<&mut i32> = helper_int2ptr(); //~ ERROR it is undefined behavior to use this value -//~^ NOTE encountered a dangling reference -static INT2PTR_STATIC: Option<&mut i32> = helper_int2ptr(); //~ ERROR it is undefined behavior to use this value -//~^ NOTE encountered a dangling reference +const INT2PTR: Option<&mut i32> = helper_int2ptr(); //~ ERROR encountered a dangling reference +static INT2PTR_STATIC: Option<&mut i32> = helper_int2ptr(); //~ ERROR encountered a dangling reference const fn helper_dangling() -> Option<&'static mut i32> { unsafe { // Undefined behaviour (dangling pointer), who doesn't love tests like this. Some(&mut *(&mut 42 as *mut i32)) } } -const DANGLING: Option<&mut i32> = helper_dangling(); //~ ERROR it is undefined behavior to use this value -static DANGLING_STATIC: Option<&mut i32> = helper_dangling(); //~ ERROR it is undefined behavior to use this value +const DANGLING: Option<&mut i32> = helper_dangling(); //~ ERROR dangling reference +static DANGLING_STATIC: Option<&mut i32> = helper_dangling(); //~ ERROR dangling reference // These are fine! Just statics pointing to mutable statics, nothing fundamentally wrong with this. static MUT_STATIC: Option<&mut i32> = helper(); diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr index 4ea6fa62475e8..6456587b77a48 100644 --- a/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr @@ -1,52 +1,52 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at ..0: encountered reference to mutable memory in `const` --> $DIR/mut_ref_in_final_dynamic_check.rs:19:1 | LL | const MUT: Option<&mut i32> = helper(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered reference to mutable memory in `const` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/mut_ref_in_final_dynamic_check.rs:26:1 +error[E0080]: constructing invalid value at ..0: encountered a dangling reference (0x2a[noalloc] has no provenance) + --> $DIR/mut_ref_in_final_dynamic_check.rs:25:1 | LL | const INT2PTR: Option<&mut i32> = helper_int2ptr(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered a dangling reference (0x2a[noalloc] has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/mut_ref_in_final_dynamic_check.rs:28:1 +error[E0080]: constructing invalid value at ..0: encountered a dangling reference (0x2a[noalloc] has no provenance) + --> $DIR/mut_ref_in_final_dynamic_check.rs:26:1 | LL | static INT2PTR_STATIC: Option<&mut i32> = helper_int2ptr(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered a dangling reference (0x2a[noalloc] has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/mut_ref_in_final_dynamic_check.rs:35:1 +error[E0080]: constructing invalid value at ..0: encountered a dangling reference (use-after-free) + --> $DIR/mut_ref_in_final_dynamic_check.rs:32:1 | LL | const DANGLING: Option<&mut i32> = helper_dangling(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered a dangling reference (use-after-free) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/mut_ref_in_final_dynamic_check.rs:36:1 +error[E0080]: constructing invalid value at ..0: encountered a dangling reference (use-after-free) + --> $DIR/mut_ref_in_final_dynamic_check.rs:33:1 | LL | static DANGLING_STATIC: Option<&mut i32> = helper_dangling(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..0: encountered a dangling reference (use-after-free) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { diff --git a/tests/ui/consts/const-ptr-is-null.rs b/tests/ui/consts/const-ptr-is-null.rs index 319f6b1a62baa..7e7b74c3520fe 100644 --- a/tests/ui/consts/const-ptr-is-null.rs +++ b/tests/ui/consts/const-ptr-is-null.rs @@ -19,7 +19,7 @@ const MAYBE_NULL: () = { assert!(!ptr.wrapping_byte_sub(1).is_null()); // ... but once we shift outside the allocation, with an offset divisible by 4, // we might become null. - assert!(!ptr.wrapping_sub(512).is_null()); //~ ERROR evaluation of constant value failed + assert!(!ptr.wrapping_sub(512).is_null()); //~ ERROR null-ness of this pointer cannot be determined }; fn main() {} diff --git a/tests/ui/consts/const-ptr-is-null.stderr b/tests/ui/consts/const-ptr-is-null.stderr index 1a2be3b3cb185..9d83f8d51a796 100644 --- a/tests/ui/consts/const-ptr-is-null.stderr +++ b/tests/ui/consts/const-ptr-is-null.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: null-ness of this pointer cannot be determined in const context --> $DIR/const-ptr-is-null.rs:22:14 | LL | assert!(!ptr.wrapping_sub(512).is_null()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: null-ness of this pointer cannot be determined in const context + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `std::ptr::const_ptr::::is_null` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL diff --git a/tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs b/tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs index 598904d3c4453..14cdf6bb7c66e 100644 --- a/tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs +++ b/tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs @@ -7,7 +7,7 @@ extern "C" { type Opaque; } -const _SIZE: usize = unsafe { size_of_val(&4 as *const i32 as *const Opaque) }; //~ ERROR constant -const _ALIGN: usize = unsafe { min_align_of_val(&4 as *const i32 as *const Opaque) }; //~ ERROR constant +const _SIZE: usize = unsafe { size_of_val(&4 as *const i32 as *const Opaque) }; //~ ERROR layout +const _ALIGN: usize = unsafe { min_align_of_val(&4 as *const i32 as *const Opaque) }; //~ ERROR layout fn main() {} diff --git a/tests/ui/consts/const-size_of_val-align_of_val-extern-type.stderr b/tests/ui/consts/const-size_of_val-align_of_val-extern-type.stderr index 4c0252123a4d3..714d85bb39421 100644 --- a/tests/ui/consts/const-size_of_val-align_of_val-extern-type.stderr +++ b/tests/ui/consts/const-size_of_val-align_of_val-extern-type.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: `extern type` does not have known layout --> $DIR/const-size_of_val-align_of_val-extern-type.rs:10:31 | LL | const _SIZE: usize = unsafe { size_of_val(&4 as *const i32 as *const Opaque) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `extern type` does not have known layout + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: `extern type` does not have known layout --> $DIR/const-size_of_val-align_of_val-extern-type.rs:11:32 | LL | const _ALIGN: usize = unsafe { min_align_of_val(&4 as *const i32 as *const Opaque) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `extern type` does not have known layout + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-slice-oob.rs b/tests/ui/consts/const-slice-oob.rs index 09202df72c0f0..6682c234eaf59 100644 --- a/tests/ui/consts/const-slice-oob.rs +++ b/tests/ui/consts/const-slice-oob.rs @@ -1,7 +1,6 @@ -const FOO: &'static[u32] = &[1, 2, 3]; +const FOO: &'static [u32] = &[1, 2, 3]; const BAR: u32 = FOO[5]; -//~^ NOTE index out of bounds: the length is 3 but the index is 5 -//~| ERROR evaluation of constant value failed +//~^ ERROR index out of bounds: the length is 3 but the index is 5 fn main() { let _ = BAR; diff --git a/tests/ui/consts/const-slice-oob.stderr b/tests/ui/consts/const-slice-oob.stderr index 30ec340d2a237..d93c4783e27e4 100644 --- a/tests/ui/consts/const-slice-oob.stderr +++ b/tests/ui/consts/const-slice-oob.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: index out of bounds: the length is 3 but the index is 5 --> $DIR/const-slice-oob.rs:2:18 | LL | const BAR: u32 = FOO[5]; - | ^^^^^^ index out of bounds: the length is 3 but the index is 5 + | ^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-unwrap.rs b/tests/ui/consts/const-unwrap.rs index d48078a0834c5..38ebd5dd23080 100644 --- a/tests/ui/consts/const-unwrap.rs +++ b/tests/ui/consts/const-unwrap.rs @@ -4,12 +4,10 @@ const FOO: i32 = Some(42i32).unwrap(); const BAR: i32 = Option::::None.unwrap(); -//~^ ERROR: evaluation of constant value failed -//~| NOTE: called `Option::unwrap()` on a `None` value +//~^ ERROR: called `Option::unwrap()` on a `None` value const BAZ: i32 = Option::::None.expect("absolutely not!"); -//~^ ERROR: evaluation of constant value failed -//~| NOTE: absolutely not! +//~^ ERROR: absolutely not! fn main() { println!("{}", FOO); diff --git a/tests/ui/consts/const-unwrap.stderr b/tests/ui/consts/const-unwrap.stderr index 832c95992c871..88c9185eeb6d2 100644 --- a/tests/ui/consts/const-unwrap.stderr +++ b/tests/ui/consts/const-unwrap.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: called `Option::unwrap()` on a `None` value --> $DIR/const-unwrap.rs:6:18 | LL | const BAR: i32 = Option::::None.unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: called `Option::unwrap()` on a `None` value + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-unwrap.rs:10:18 +error[E0080]: evaluation panicked: absolutely not! + --> $DIR/const-unwrap.rs:9:18 | LL | const BAZ: i32 = Option::::None.expect("absolutely not!"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: absolutely not! + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const_refs_to_static_fail.rs b/tests/ui/consts/const_refs_to_static_fail.rs index e1f2262ba29af..b8bab91e005db 100644 --- a/tests/ui/consts/const_refs_to_static_fail.rs +++ b/tests/ui/consts/const_refs_to_static_fail.rs @@ -9,16 +9,13 @@ use std::cell::SyncUnsafeCell; static S: SyncUnsafeCell = SyncUnsafeCell::new(0); static mut S_MUT: i32 = 0; -const C1: &SyncUnsafeCell = &S; //~ERROR undefined behavior -//~| NOTE encountered reference to mutable memory +const C1: &SyncUnsafeCell = &S; //~ERROR encountered reference to mutable memory const C1_READ: () = unsafe { assert!(*C1.get() == 0); }; const C2: *const i32 = unsafe { std::ptr::addr_of!(S_MUT) }; const C2_READ: () = unsafe { - assert!(*C2 == 0); //~ERROR evaluation of constant value failed - //~^ NOTE constant accesses mutable global memory + assert!(*C2 == 0); //~ERROR constant accesses mutable global memory }; -fn main() { -} +fn main() {} diff --git a/tests/ui/consts/const_refs_to_static_fail.stderr b/tests/ui/consts/const_refs_to_static_fail.stderr index 245806da5c62b..96a6593279d79 100644 --- a/tests/ui/consts/const_refs_to_static_fail.stderr +++ b/tests/ui/consts/const_refs_to_static_fail.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` --> $DIR/const_refs_to_static_fail.rs:12:1 | LL | const C1: &SyncUnsafeCell = &S; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -10,16 +10,16 @@ LL | const C1: &SyncUnsafeCell = &S; } note: erroneous constant encountered - --> $DIR/const_refs_to_static_fail.rs:15:14 + --> $DIR/const_refs_to_static_fail.rs:14:14 | LL | assert!(*C1.get() == 0); | ^^ -error[E0080]: evaluation of constant value failed - --> $DIR/const_refs_to_static_fail.rs:19:13 +error[E0080]: constant accesses mutable global memory + --> $DIR/const_refs_to_static_fail.rs:18:13 | LL | assert!(*C2 == 0); - | ^^^ constant accesses mutable global memory + | ^^^ evaluation of constant value failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const_refs_to_static_fail_invalid.rs b/tests/ui/consts/const_refs_to_static_fail_invalid.rs index f6ccfbfc52fe9..34ed8540f3fdc 100644 --- a/tests/ui/consts/const_refs_to_static_fail_invalid.rs +++ b/tests/ui/consts/const_refs_to_static_fail_invalid.rs @@ -8,8 +8,7 @@ fn invalid() { static S: i8 = 10; const C: &bool = unsafe { std::mem::transmute(&S) }; - //~^ERROR: undefined behavior - //~| NOTE expected a boolean + //~^ERROR: expected a boolean // This must be rejected here (or earlier), since it's not a valid `&bool`. match &true { @@ -24,8 +23,7 @@ fn extern_() { } const C: &i8 = unsafe { &S }; - //~^ERROR: undefined behavior - //~| NOTE `extern` static + //~^ERROR: `extern` static // This must be rejected here (or earlier), since the pattern cannot be read. match &0 { @@ -38,8 +36,7 @@ fn mutable() { static mut S_MUT: i32 = 0; const C: &i32 = unsafe { &S_MUT }; - //~^ERROR: undefined behavior - //~| NOTE encountered reference to mutable memory + //~^ERROR: encountered reference to mutable memory // This *must not build*, the constant we are matching against // could change its value! diff --git a/tests/ui/consts/const_refs_to_static_fail_invalid.stderr b/tests/ui/consts/const_refs_to_static_fail_invalid.stderr index e0086e07af75d..8a034aa00bc56 100644 --- a/tests/ui/consts/const_refs_to_static_fail_invalid.stderr +++ b/tests/ui/consts/const_refs_to_static_fail_invalid.stderr @@ -1,30 +1,30 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .: encountered 0x0a, but expected a boolean --> $DIR/const_refs_to_static_fail_invalid.rs:10:5 | LL | const C: &bool = unsafe { std::mem::transmute(&S) }; - | ^^^^^^^^^^^^^^ constructing invalid value at .: encountered 0x0a, but expected a boolean + | ^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refs_to_static_fail_invalid.rs:26:5 +error[E0080]: constructing invalid value: encountered reference to `extern` static in `const` + --> $DIR/const_refs_to_static_fail_invalid.rs:25:5 | LL | const C: &i8 = unsafe { &S }; - | ^^^^^^^^^^^^ constructing invalid value: encountered reference to `extern` static in `const` + | ^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refs_to_static_fail_invalid.rs:40:5 +error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` + --> $DIR/const_refs_to_static_fail_invalid.rs:38:5 | LL | const C: &i32 = unsafe { &S_MUT }; - | ^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` + | ^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { diff --git a/tests/ui/consts/const_unsafe_unreachable_ub.rs b/tests/ui/consts/const_unsafe_unreachable_ub.rs index 76c6c56d7c50a..7c6c7a608b8fe 100644 --- a/tests/ui/consts/const_unsafe_unreachable_ub.rs +++ b/tests/ui/consts/const_unsafe_unreachable_ub.rs @@ -8,8 +8,8 @@ const unsafe fn foo(x: bool) -> bool { } const BAR: bool = unsafe { foo(false) }; -//~^ ERROR evaluation of constant value failed -//~| NOTE entering unreachable code +//~^ NOTE evaluation of constant value failed +//~| ERROR entering unreachable code fn main() { assert_eq!(BAR, true); diff --git a/tests/ui/consts/const_unsafe_unreachable_ub.stderr b/tests/ui/consts/const_unsafe_unreachable_ub.stderr index 42bf69aded022..6d9f8c1d73b63 100644 --- a/tests/ui/consts/const_unsafe_unreachable_ub.stderr +++ b/tests/ui/consts/const_unsafe_unreachable_ub.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: entering unreachable code --> $DIR/const_unsafe_unreachable_ub.rs:10:28 | LL | const BAR: bool = unsafe { foo(false) }; - | ^^^^^^^^^^ entering unreachable code + | ^^^^^^^^^^ evaluation of constant value failed here | note: inside `foo` --> $DIR/const_unsafe_unreachable_ub.rs:4:18 diff --git a/tests/ui/consts/control-flow/assert.rs b/tests/ui/consts/control-flow/assert.rs index 9d17f65b93cab..2c37207513743 100644 --- a/tests/ui/consts/control-flow/assert.rs +++ b/tests/ui/consts/control-flow/assert.rs @@ -3,6 +3,6 @@ const _: () = assert!(true); const _: () = assert!(false); -//~^ ERROR evaluation of constant value failed +//~^ ERROR assertion failed fn main() {} diff --git a/tests/ui/consts/control-flow/assert.stderr b/tests/ui/consts/control-flow/assert.stderr index 3fa98b74bf64c..6b68f706f909c 100644 --- a/tests/ui/consts/control-flow/assert.stderr +++ b/tests/ui/consts/control-flow/assert.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: assertion failed: false --> $DIR/assert.rs:5:15 | LL | const _: () = assert!(false); - | ^^^^^^^^^^^^^^ evaluation panicked: assertion failed: false + | ^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/copy-intrinsic.rs b/tests/ui/consts/copy-intrinsic.rs index d0242f285444a..480f1c5f460d0 100644 --- a/tests/ui/consts/copy-intrinsic.rs +++ b/tests/ui/consts/copy-intrinsic.rs @@ -1,8 +1,8 @@ // ignore-tidy-linelength #![feature(core_intrinsics)] -use std::mem; use std::intrinsics::{copy, copy_nonoverlapping}; +use std::mem; const COPY_ZERO: () = unsafe { // Since we are not copying anything, this should be allowed. @@ -17,8 +17,7 @@ const COPY_OOB_1: () = unsafe { // Zero-sized copy is fine. copy_nonoverlapping(0x100 as *const i32, dangle, 0); // Non-zero-sized copy is not. - copy_nonoverlapping(0x100 as *const i32, dangle, 1); //~ ERROR evaluation of constant value failed [E0080] - //~| NOTE which is a dangling pointer + copy_nonoverlapping(0x100 as *const i32, dangle, 1); //~ ERROR which is a dangling pointer }; const COPY_OOB_2: () = unsafe { let x = 0i32; @@ -26,22 +25,18 @@ const COPY_OOB_2: () = unsafe { // Zero-sized copy is fine. copy_nonoverlapping(dangle, 0x100 as *mut i32, 0); // Non-zero-sized copy is not. - copy_nonoverlapping(dangle, 0x100 as *mut i32, 1); //~ ERROR evaluation of constant value failed [E0080] - //~| NOTE is at or beyond the end of the allocation of size 4 bytes + copy_nonoverlapping(dangle, 0x100 as *mut i32, 1); //~ ERROR is at or beyond the end of the allocation of size 4 bytes }; const COPY_SIZE_OVERFLOW: () = unsafe { let x = 0; let mut y = 0; - copy(&x, &mut y, 1usize << (mem::size_of::() * 8 - 1)); //~ ERROR evaluation of constant value failed [E0080] - //~| NOTE overflow computing total size of `copy` + copy(&x, &mut y, 1usize << (mem::size_of::() * 8 - 1)); //~ ERROR overflow computing total size of `copy` }; const COPY_NONOVERLAPPING_SIZE_OVERFLOW: () = unsafe { let x = 0; let mut y = 0; - copy_nonoverlapping(&x, &mut y, 1usize << (mem::size_of::() * 8 - 1)); //~ ERROR evaluation of constant value failed [E0080] - //~| NOTE overflow computing total size of `copy_nonoverlapping` + copy_nonoverlapping(&x, &mut y, 1usize << (mem::size_of::() * 8 - 1)); //~ ERROR overflow computing total size of `copy_nonoverlapping` }; -fn main() { -} +fn main() {} diff --git a/tests/ui/consts/copy-intrinsic.stderr b/tests/ui/consts/copy-intrinsic.stderr index 8d586428e56f8..b9d89cf78ba35 100644 --- a/tests/ui/consts/copy-intrinsic.stderr +++ b/tests/ui/consts/copy-intrinsic.stderr @@ -1,26 +1,26 @@ -error[E0080]: evaluation of constant value failed +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 | copy_nonoverlapping(0x100 as *const i32, dangle, 1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got 0x100[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/copy-intrinsic.rs:29:5 +error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0+0x28 which is at or beyond the end of the allocation of size 4 bytes + --> $DIR/copy-intrinsic.rs:28:5 | LL | copy_nonoverlapping(dangle, 0x100 as *mut i32, 1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC0+0x28 which is at or beyond the end of the allocation of size 4 bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/copy-intrinsic.rs:36:5 +error[E0080]: overflow computing total size of `copy` + --> $DIR/copy-intrinsic.rs:34:5 | LL | copy(&x, &mut y, 1usize << (mem::size_of::() * 8 - 1)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `copy` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/copy-intrinsic.rs:42:5 +error[E0080]: overflow computing total size of `copy_nonoverlapping` + --> $DIR/copy-intrinsic.rs:39:5 | LL | copy_nonoverlapping(&x, &mut y, 1usize << (mem::size_of::() * 8 - 1)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `copy_nonoverlapping` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 4 previous errors diff --git a/tests/ui/consts/dangling-alloc-id-ice.rs b/tests/ui/consts/dangling-alloc-id-ice.rs index 8e9493c8d2851..b77c5971b2bc1 100644 --- a/tests/ui/consts/dangling-alloc-id-ice.rs +++ b/tests/ui/consts/dangling-alloc-id-ice.rs @@ -10,7 +10,7 @@ union Foo<'a> { } const FOO: &() = { - //~^ ERROR it is undefined behavior to use this value + //~^ ERROR dangling reference let y = (); unsafe { Foo { y: &y }.long_live_the_unit } }; diff --git a/tests/ui/consts/dangling-alloc-id-ice.stderr b/tests/ui/consts/dangling-alloc-id-ice.stderr index 881c0b162edca..65a46b62daed8 100644 --- a/tests/ui/consts/dangling-alloc-id-ice.stderr +++ b/tests/ui/consts/dangling-alloc-id-ice.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered a dangling reference (use-after-free) --> $DIR/dangling-alloc-id-ice.rs:12:1 | LL | const FOO: &() = { - | ^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (use-after-free) + | ^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { diff --git a/tests/ui/consts/dangling-zst-ice-issue-126393.rs b/tests/ui/consts/dangling-zst-ice-issue-126393.rs index 4beee913a978a..6b667fdfd35de 100644 --- a/tests/ui/consts/dangling-zst-ice-issue-126393.rs +++ b/tests/ui/consts/dangling-zst-ice-issue-126393.rs @@ -5,7 +5,7 @@ pub struct Wrapper; pub static MAGIC_FFI_REF: &'static Wrapper = unsafe { -//~^ERROR: it is undefined behavior to use this value + //~^ ERROR: dangling reference std::mem::transmute(&{ let y = 42; y diff --git a/tests/ui/consts/dangling-zst-ice-issue-126393.stderr b/tests/ui/consts/dangling-zst-ice-issue-126393.stderr index d32b427f14ef7..2f600e494c46c 100644 --- a/tests/ui/consts/dangling-zst-ice-issue-126393.stderr +++ b/tests/ui/consts/dangling-zst-ice-issue-126393.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered a dangling reference (use-after-free) --> $DIR/dangling-zst-ice-issue-126393.rs:7:1 | LL | pub static MAGIC_FFI_REF: &'static Wrapper = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (use-after-free) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { diff --git a/tests/ui/consts/eval-enum.rs b/tests/ui/consts/eval-enum.rs index fa9ad6736e297..ae0296bd4c092 100644 --- a/tests/ui/consts/eval-enum.rs +++ b/tests/ui/consts/eval-enum.rs @@ -1,10 +1,8 @@ enum Test { - DivZero = 1/0, - //~^ NOTE attempt to divide `1_isize` by zero - //~| ERROR evaluation of constant value failed - RemZero = 1%0, - //~^ NOTE attempt to calculate the remainder of `1_isize` with a divisor of zero - //~| ERROR evaluation of constant value failed + DivZero = 1 / 0, + //~^ ERROR attempt to divide `1_isize` by zero + RemZero = 1 % 0, + //~^ ERROR attempt to calculate the remainder of `1_isize` with a divisor of zero } fn main() {} diff --git a/tests/ui/consts/eval-enum.stderr b/tests/ui/consts/eval-enum.stderr index fb4d903489f7f..adfb7c79fea65 100644 --- a/tests/ui/consts/eval-enum.stderr +++ b/tests/ui/consts/eval-enum.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to divide `1_isize` by zero --> $DIR/eval-enum.rs:2:15 | -LL | DivZero = 1/0, - | ^^^ attempt to divide `1_isize` by zero +LL | DivZero = 1 / 0, + | ^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/eval-enum.rs:5:15 +error[E0080]: attempt to calculate the remainder of `1_isize` with a divisor of zero + --> $DIR/eval-enum.rs:4:15 | -LL | RemZero = 1%0, - | ^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero +LL | RemZero = 1 % 0, + | ^^^^^ evaluation of constant value failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/extra-const-ub/detect-extra-ub.rs b/tests/ui/consts/extra-const-ub/detect-extra-ub.rs index c3bd8301d5ce4..e17bac603b415 100644 --- a/tests/ui/consts/extra-const-ub/detect-extra-ub.rs +++ b/tests/ui/consts/extra-const-ub/detect-extra-ub.rs @@ -28,41 +28,35 @@ enum UninhDiscriminant { const INVALID_BOOL: () = unsafe { let _x: bool = transmute(3u8); - //[with_flag]~^ ERROR: evaluation of constant value failed - //[with_flag]~| NOTE invalid value + //[with_flag]~^ ERROR: invalid value }; const INVALID_PTR_IN_INT: () = unsafe { let _x: usize = transmute(&3u8); - //[with_flag]~^ ERROR: evaluation of constant value failed - //[with_flag]~| NOTE invalid value + //[with_flag]~^ ERROR: invalid value }; const INVALID_PTR_IN_ENUM: () = unsafe { let _x: PtrSizedEnum = transmute(&3u8); - //[with_flag]~^ ERROR: evaluation of constant value failed - //[with_flag]~| NOTE invalid value + //[with_flag]~^ ERROR: invalid value }; const INVALID_SLICE_TO_USIZE_TRANSMUTE: () = unsafe { let x: &[u8] = &[0; 32]; let _x: (usize, usize) = transmute(x); - //[with_flag]~^ ERROR: evaluation of constant value failed - //[with_flag]~| NOTE invalid value + //[with_flag]~^ ERROR: invalid value }; const UNALIGNED_PTR: () = unsafe { let _x: &u32 = transmute(&[0u8; 4]); - //[with_flag]~^ ERROR: evaluation of constant value failed - //[with_flag]~| NOTE invalid value + //[with_flag]~^ ERROR: invalid value }; const UNINHABITED_VARIANT: () = unsafe { let data = [1u8]; // Not using transmute, we want to hit the ImmTy code path. let v = *addr_of!(data).cast::(); - //[with_flag]~^ ERROR: evaluation of constant value failed - //[with_flag]~| NOTE invalid value + //[with_flag]~^ ERROR: invalid value }; const PARTIAL_POINTER: () = unsafe { @@ -81,8 +75,7 @@ const PARTIAL_POINTER: () = unsafe { let mem = Packed { pad1: 0, ptr: &0u8 as *const u8, pad2: [0; 7] }; let mem = Align { p: mem, align: 0 }; let _val = *(&mem as *const Align as *const [*const u8; 2]); - //[with_flag]~^ ERROR: evaluation of constant value failed - //[with_flag]~| NOTE invalid value + //[with_flag]~^ ERROR: invalid value }; // Regression tests for an ICE (related to ). @@ -96,8 +89,7 @@ const VALID_ARRAY: [Option; 0] = { let e = [None; 0]; e }; const OVERSIZED_REF: () = { unsafe { let slice: *const [u8] = transmute((1usize, usize::MAX)); let _val = &*slice; - //[with_flag]~^ ERROR: evaluation of constant value failed - //[with_flag]~| NOTE slice is bigger than largest supported object + //[with_flag]~^ ERROR: slice is bigger than largest supported object } }; fn main() {} 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 ea3b0e70b8285..0d8fd5aece9ea 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,62 +1,62 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: constructing invalid value: encountered 0x03, but expected a boolean --> $DIR/detect-extra-ub.rs:30:20 | LL | let _x: bool = transmute(3u8); - | ^^^^^^^^^^^^^^ constructing invalid value: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:36:21 +error[E0080]: constructing invalid value: encountered a pointer, but expected an integer + --> $DIR/detect-extra-ub.rs:35:21 | LL | let _x: usize = transmute(&3u8); - | ^^^^^^^^^^^^^^^ constructing invalid value: encountered a pointer, but expected an integer + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:42:28 +error[E0080]: constructing invalid value at .: encountered a pointer, but expected an integer + --> $DIR/detect-extra-ub.rs:40:28 | LL | let _x: PtrSizedEnum = transmute(&3u8); - | ^^^^^^^^^^^^^^^ constructing invalid value at .: encountered a pointer, but expected an integer + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:49:30 +error[E0080]: constructing invalid value at .0: encountered a pointer, but expected an integer + --> $DIR/detect-extra-ub.rs:46:30 | LL | let _x: (usize, usize) = transmute(x); - | ^^^^^^^^^^^^ constructing invalid value at .0: encountered a pointer, but expected an integer + | ^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:55:20 +error[E0080]: constructing invalid value: encountered an unaligned reference (required 4 byte alignment but found 1) + --> $DIR/detect-extra-ub.rs:51:20 | LL | let _x: &u32 = transmute(&[0u8; 4]); - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 4 byte alignment but found 1) + | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:63:13 +error[E0080]: constructing invalid value at .: encountered an uninhabited enum variant + --> $DIR/detect-extra-ub.rs:58:13 | LL | let v = *addr_of!(data).cast::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered an uninhabited enum variant + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:83:16 +error[E0080]: constructing invalid value at [0]: encountered a partial pointer or a mix of pointers + --> $DIR/detect-extra-ub.rs:77:16 | LL | let _val = *(&mem as *const Align as *const [*const u8; 2]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered a partial pointer or a mix of pointers + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:98:16 +error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/detect-extra-ub.rs:91:16 | LL | let _val = &*slice; - | ^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^ evaluation of constant value failed here error: aborting due to 8 previous errors diff --git a/tests/ui/consts/interior-mut-const-via-union.32bit.stderr b/tests/ui/consts/interior-mut-const-via-union.32bit.stderr index fb06643df8598..47bb2e5e879b2 100644 --- a/tests/ui/consts/interior-mut-const-via-union.32bit.stderr +++ b/tests/ui/consts/interior-mut-const-via-union.32bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at ..y..0: encountered `UnsafeCell` in read-only memory --> $DIR/interior-mut-const-via-union.rs:34:1 | LL | fn main() { - | ^^^^^^^^^ constructing invalid value at ..y..0: encountered `UnsafeCell` in read-only memory + | ^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { diff --git a/tests/ui/consts/interior-mut-const-via-union.64bit.stderr b/tests/ui/consts/interior-mut-const-via-union.64bit.stderr index f39ebe0afbd23..b4c9a4bd47e27 100644 --- a/tests/ui/consts/interior-mut-const-via-union.64bit.stderr +++ b/tests/ui/consts/interior-mut-const-via-union.64bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at ..y..0: encountered `UnsafeCell` in read-only memory --> $DIR/interior-mut-const-via-union.rs:34:1 | LL | fn main() { - | ^^^^^^^^^ constructing invalid value at ..y..0: encountered `UnsafeCell` in read-only memory + | ^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { diff --git a/tests/ui/consts/interior-mut-const-via-union.rs b/tests/ui/consts/interior-mut-const-via-union.rs index 6d40a9ba850eb..5e624671aee02 100644 --- a/tests/ui/consts/interior-mut-const-via-union.rs +++ b/tests/ui/consts/interior-mut-const-via-union.rs @@ -31,7 +31,7 @@ const C: S = { s }; -fn main() { //~ ERROR it is undefined behavior to use this value - // FIXME the span here is wrong, sould be pointing at the line below, not above. +fn main() { //~ ERROR encountered `UnsafeCell` in read-only memory + // FIXME the span here is wrong, should be pointing at the line below, not above. let _: &'static _ = &C; } diff --git a/tests/ui/consts/issue-17718-const-bad-values.rs b/tests/ui/consts/issue-17718-const-bad-values.rs index 286972365d5a1..40fc02cf64466 100644 --- a/tests/ui/consts/issue-17718-const-bad-values.rs +++ b/tests/ui/consts/issue-17718-const-bad-values.rs @@ -9,7 +9,6 @@ const C1: &'static mut [usize] = &mut []; static mut S: i32 = 3; const C2: &'static mut i32 = unsafe { &mut S }; -//~^ ERROR: it is undefined behavior to use this value -//~| NOTE reference to mutable memory +//~^ ERROR: reference to mutable memory fn main() {} diff --git a/tests/ui/consts/issue-17718-const-bad-values.stderr b/tests/ui/consts/issue-17718-const-bad-values.stderr index 102491e90bac1..effb614b15bce 100644 --- a/tests/ui/consts/issue-17718-const-bad-values.stderr +++ b/tests/ui/consts/issue-17718-const-bad-values.stderr @@ -4,11 +4,11 @@ error[E0764]: mutable references are not allowed in the final value of constants LL | const C1: &'static mut [usize] = &mut []; | ^^^^^^^ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` --> $DIR/issue-17718-const-bad-values.rs:11:1 | LL | const C2: &'static mut i32 = unsafe { &mut S }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $PTR, align: $PTR) { diff --git a/tests/ui/consts/issue-32829.rs b/tests/ui/consts/issue-32829.rs index 25f323b9803c8..e02db69c6861d 100644 --- a/tests/ui/consts/issue-32829.rs +++ b/tests/ui/consts/issue-32829.rs @@ -1,5 +1,5 @@ static S : u64 = { { panic!("foo"); 0 } }; -//~^ ERROR could not evaluate static initializer +//~^ ERROR evaluation panicked: foo fn main() { println!("{:?}", S); diff --git a/tests/ui/consts/issue-32829.stderr b/tests/ui/consts/issue-32829.stderr index 542dce1915189..0a04c66df96ab 100644 --- a/tests/ui/consts/issue-32829.stderr +++ b/tests/ui/consts/issue-32829.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: evaluation panicked: foo --> $DIR/issue-32829.rs:1:22 | LL | static S : u64 = { { panic!("foo"); 0 } }; - | ^^^^^^^^^^^^^ evaluation panicked: foo + | ^^^^^^^^^^^^^ evaluation of static initializer failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/issue-63952.32bit.stderr b/tests/ui/consts/issue-63952.32bit.stderr index f562f9104e3ed..e53407881671a 100644 --- a/tests/ui/consts/issue-63952.32bit.stderr +++ b/tests/ui/consts/issue-63952.32bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object --> $DIR/issue-63952.rs:17:1 | LL | const SLICE_WAY_TOO_LONG: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { diff --git a/tests/ui/consts/issue-63952.64bit.stderr b/tests/ui/consts/issue-63952.64bit.stderr index fe66bec13a1b0..27e74833fc569 100644 --- a/tests/ui/consts/issue-63952.64bit.stderr +++ b/tests/ui/consts/issue-63952.64bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object --> $DIR/issue-63952.rs:17:1 | LL | const SLICE_WAY_TOO_LONG: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { diff --git a/tests/ui/consts/issue-63952.rs b/tests/ui/consts/issue-63952.rs index aee06f8eb0428..fce6013b4d310 100644 --- a/tests/ui/consts/issue-63952.rs +++ b/tests/ui/consts/issue-63952.rs @@ -14,7 +14,7 @@ union SliceTransmute { } // bad slice: length too big to even exist anywhere -const SLICE_WAY_TOO_LONG: &[u8] = unsafe { //~ ERROR: it is undefined behavior to use this value +const SLICE_WAY_TOO_LONG: &[u8] = unsafe { //~ ERROR: slice is bigger than largest supported object SliceTransmute { repr: SliceRepr { ptr: &42, diff --git a/tests/ui/consts/issue-64506.rs b/tests/ui/consts/issue-64506.rs index 096d29cbe499c..8511c1edb302e 100644 --- a/tests/ui/consts/issue-64506.rs +++ b/tests/ui/consts/issue-64506.rs @@ -14,7 +14,7 @@ const FOO: () = { b: (), } let x = unsafe { Foo { b: () }.a }; - //~^ ERROR: evaluation of constant value failed + //~^ ERROR: value of uninhabited type let x = &x.inner; }; diff --git a/tests/ui/consts/issue-64506.stderr b/tests/ui/consts/issue-64506.stderr index 4cc2b71374100..dfb2c454031fd 100644 --- a/tests/ui/consts/issue-64506.stderr +++ b/tests/ui/consts/issue-64506.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: constructing invalid value at .inner: encountered a value of uninhabited type `AnonPipe` --> $DIR/issue-64506.rs:16:22 | LL | let x = unsafe { Foo { b: () }.a }; - | ^^^^^^^^^^^^^^^ constructing invalid value at .inner: encountered a value of uninhabited type `AnonPipe` + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/issue-66693-panic-in-array-len.rs b/tests/ui/consts/issue-66693-panic-in-array-len.rs index fc0dcd7a44daa..2256970e33746 100644 --- a/tests/ui/consts/issue-66693-panic-in-array-len.rs +++ b/tests/ui/consts/issue-66693-panic-in-array-len.rs @@ -8,7 +8,7 @@ fn main() { // ensure that conforming panics are handled correctly let _ = [false; panic!()]; - //~^ ERROR: evaluation of constant value failed + //~^ ERROR: explicit panic // typechecking halts before getting to this one let _ = ['a', panic!("panic in array len")]; diff --git a/tests/ui/consts/issue-66693-panic-in-array-len.stderr b/tests/ui/consts/issue-66693-panic-in-array-len.stderr index fdef515b6d41a..e0db2138d7417 100644 --- a/tests/ui/consts/issue-66693-panic-in-array-len.stderr +++ b/tests/ui/consts/issue-66693-panic-in-array-len.stderr @@ -4,11 +4,11 @@ error: argument to `panic!()` in a const context must have type `&str` LL | let _ = [0i32; panic!(2f32)]; | ^^^^^^^^^^^^ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/issue-66693-panic-in-array-len.rs:10:21 | LL | let _ = [false; panic!()]; - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of constant value failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/issue-66693.rs b/tests/ui/consts/issue-66693.rs index 416bd8ec72aef..9d82d5a42bdbf 100644 --- a/tests/ui/consts/issue-66693.rs +++ b/tests/ui/consts/issue-66693.rs @@ -14,9 +14,9 @@ const fn _foo() { // ensure that conforming panics don't cause an error beyond the failure to const eval const _: () = panic!(); -//~^ ERROR: evaluation of constant value failed +//~^ ERROR: explicit panic static _BAR: () = panic!("panic in static"); -//~^ ERROR could not evaluate static initializer +//~^ ERROR panic in static const fn _bar() { panic!("panic in const fn"); diff --git a/tests/ui/consts/issue-66693.stderr b/tests/ui/consts/issue-66693.stderr index ea657ec34bd6b..6d6edf8a5137f 100644 --- a/tests/ui/consts/issue-66693.stderr +++ b/tests/ui/consts/issue-66693.stderr @@ -10,17 +10,17 @@ error: argument to `panic!()` in a const context must have type `&str` LL | static _FOO: () = panic!(true); | ^^^^^^^^^^^^ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/issue-66693.rs:16:15 | LL | const _: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: could not evaluate static initializer +error[E0080]: evaluation panicked: panic in static --> $DIR/issue-66693.rs:18:19 | LL | static _BAR: () = panic!("panic in static"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: panic in static + | ^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here error: argument to `panic!()` in a const context must have type `&str` --> $DIR/issue-66693.rs:11:5 diff --git a/tests/ui/consts/issue-76064.rs b/tests/ui/consts/issue-76064.rs index 3c153ad726e28..b878629138c59 100644 --- a/tests/ui/consts/issue-76064.rs +++ b/tests/ui/consts/issue-76064.rs @@ -1,3 +1,3 @@ -struct Bug([u8; panic!("panic")]); //~ ERROR evaluation of constant value failed +struct Bug([u8; panic!("panic")]); //~ ERROR panic fn main() {} diff --git a/tests/ui/consts/issue-76064.stderr b/tests/ui/consts/issue-76064.stderr index 786d4213f1e56..97225178ee00c 100644 --- a/tests/ui/consts/issue-76064.stderr +++ b/tests/ui/consts/issue-76064.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: panic --> $DIR/issue-76064.rs:1:17 | LL | struct Bug([u8; panic!("panic")]); - | ^^^^^^^^^^^^^^^ evaluation panicked: panic + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/issue-79690.64bit.stderr b/tests/ui/consts/issue-79690.64bit.stderr index d603a1dc29127..7488f7b7752a6 100644 --- a/tests/ui/consts/issue-79690.64bit.stderr +++ b/tests/ui/consts/issue-79690.64bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .1: encountered a dangling reference (going beyond the bounds of its allocation) --> $DIR/issue-79690.rs:30:1 | LL | const G: Fat = unsafe { Transmute { t: FOO }.u }; - | ^^^^^^^^^^^^ constructing invalid value at .1: encountered a dangling reference (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { diff --git a/tests/ui/consts/issue-79690.rs b/tests/ui/consts/issue-79690.rs index 3da4cb73f1196..24e3220155d18 100644 --- a/tests/ui/consts/issue-79690.rs +++ b/tests/ui/consts/issue-79690.rs @@ -28,6 +28,6 @@ const FOO: &dyn Bar = &Foo { bar: false, }; const G: Fat = unsafe { Transmute { t: FOO }.u }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR dangling reference fn main() {} diff --git a/tests/ui/consts/issue-miri-1910.rs b/tests/ui/consts/issue-miri-1910.rs index d194dd3c78bbd..6eae885ea8aed 100644 --- a/tests/ui/consts/issue-miri-1910.rs +++ b/tests/ui/consts/issue-miri-1910.rs @@ -5,7 +5,7 @@ const C: () = unsafe { let foo = Some(&42 as *const i32); let one_and_a_half_pointers = std::mem::size_of::<*const i32>()/2*3; (&foo as *const _ as *const u8).add(one_and_a_half_pointers).read(); - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer }; fn main() { diff --git a/tests/ui/consts/issue-miri-1910.stderr b/tests/ui/consts/issue-miri-1910.stderr index 52edad0c389d8..8166b68d2e0c1 100644 --- a/tests/ui/consts/issue-miri-1910.stderr +++ b/tests/ui/consts/issue-miri-1910.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/issue-miri-1910.rs:7:5 | LL | (&foo as *const _ as *const u8).add(one_and_a_half_pointers).read(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/large_const_alloc.rs b/tests/ui/consts/large_const_alloc.rs index 3573a018630f6..c5b19dbc17f5d 100644 --- a/tests/ui/consts/large_const_alloc.rs +++ b/tests/ui/consts/large_const_alloc.rs @@ -9,12 +9,12 @@ const FOO: () = { // 128 TiB, unlikely anyone has that much RAM let x = [0_u8; (1 << 47) - 1]; - //~^ ERROR evaluation of constant value failed + //~^ ERROR tried to allocate more memory than available to compiler }; static FOO2: () = { let x = [0_u8; (1 << 47) - 1]; - //~^ ERROR could not evaluate static initializer + //~^ ERROR tried to allocate more memory than available to compiler }; fn main() { diff --git a/tests/ui/consts/large_const_alloc.stderr b/tests/ui/consts/large_const_alloc.stderr index f3f3de7af63ac..8f19def22e76e 100644 --- a/tests/ui/consts/large_const_alloc.stderr +++ b/tests/ui/consts/large_const_alloc.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: tried to allocate more memory than available to compiler --> $DIR/large_const_alloc.rs:11:13 | LL | let x = [0_u8; (1 << 47) - 1]; - | ^^^^^^^^^^^^^^^^^^^^^ tried to allocate more memory than available to compiler + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: could not evaluate static initializer +error[E0080]: tried to allocate more memory than available to compiler --> $DIR/large_const_alloc.rs:16:13 | LL | let x = [0_u8; (1 << 47) - 1]; - | ^^^^^^^^^^^^^^^^^^^^^ tried to allocate more memory than available to compiler + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/miri_unleashed/abi-mismatch.rs b/tests/ui/consts/miri_unleashed/abi-mismatch.rs index 6a46079b39b6a..91115f8511d15 100644 --- a/tests/ui/consts/miri_unleashed/abi-mismatch.rs +++ b/tests/ui/consts/miri_unleashed/abi-mismatch.rs @@ -9,8 +9,8 @@ const fn call_rust_fn(my_fn: extern "Rust" fn()) { } static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) }); -//~^ ERROR could not evaluate static initializer -//~| NOTE calling a function with calling convention "C" using calling convention "Rust" +//~^ NOTE evaluation of static initializer failed here +//~| ERROR calling a function with calling convention "C" using calling convention "Rust" fn main() {} diff --git a/tests/ui/consts/miri_unleashed/abi-mismatch.stderr b/tests/ui/consts/miri_unleashed/abi-mismatch.stderr index 7d1fdcce52614..6cd2a0b4bc54f 100644 --- a/tests/ui/consts/miri_unleashed/abi-mismatch.stderr +++ b/tests/ui/consts/miri_unleashed/abi-mismatch.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: calling a function with calling convention "C" using calling convention "Rust" --> $DIR/abi-mismatch.rs:11:18 | LL | static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calling a function with calling convention "C" using calling convention "Rust" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here | note: inside `call_rust_fn` --> $DIR/abi-mismatch.rs:7:5 diff --git a/tests/ui/consts/miri_unleashed/assoc_const.stderr b/tests/ui/consts/miri_unleashed/assoc_const.stderr index 758f1a2533990..b6dcb86f360fd 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const.stderr +++ b/tests/ui/consts/miri_unleashed/assoc_const.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `drop_in_place::> - shim(Some(Vec))` failed +error[E0080]: calling non-const function ` as Drop>::drop` --> $DIR/assoc_const.rs:12:31 | LL | const F: u32 = (U::X, 42).1; - | ^ calling non-const function ` as Drop>::drop` + | ^ evaluation of `drop_in_place::> - shim(Some(Vec))` failed here | note: inside `drop_in_place::<(Vec, u32)> - shim(Some((Vec, u32)))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL diff --git a/tests/ui/consts/miri_unleashed/assoc_const_2.rs b/tests/ui/consts/miri_unleashed/assoc_const_2.rs index 1d8ed2065a4fe..fa8ed682d980f 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const_2.rs +++ b/tests/ui/consts/miri_unleashed/assoc_const_2.rs @@ -8,7 +8,7 @@ trait Foo { } trait Bar { - const F: u32 = 100 / U::X; //~ ERROR evaluation of `>::F` failed + const F: u32 = 100 / U::X; //~ ERROR attempt to divide `100_u32` by zero } impl Foo for () { diff --git a/tests/ui/consts/miri_unleashed/assoc_const_2.stderr b/tests/ui/consts/miri_unleashed/assoc_const_2.stderr index 5503f8e56f09e..a38fe346da6d7 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const_2.stderr +++ b/tests/ui/consts/miri_unleashed/assoc_const_2.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `>::F` failed +error[E0080]: attempt to divide `100_u32` by zero --> $DIR/assoc_const_2.rs:11:20 | LL | const F: u32 = 100 / U::X; - | ^^^^^^^^^^ attempt to divide `100_u32` by zero + | ^^^^^^^^^^ evaluation of `>::F` failed here note: erroneous constant encountered --> $DIR/assoc_const_2.rs:28:13 diff --git a/tests/ui/consts/miri_unleashed/box.rs b/tests/ui/consts/miri_unleashed/box.rs index 1539083f09c24..d361870b58a6e 100644 --- a/tests/ui/consts/miri_unleashed/box.rs +++ b/tests/ui/consts/miri_unleashed/box.rs @@ -6,8 +6,7 @@ fn main() {} static TEST_BAD: &mut i32 = { &mut *(Box::new(0)) - //~^ ERROR could not evaluate static initializer - //~| NOTE calling non-const function `Box::::new` + //~^ ERROR calling non-const function `Box::::new` }; //~? WARN skipping const checks diff --git a/tests/ui/consts/miri_unleashed/box.stderr b/tests/ui/consts/miri_unleashed/box.stderr index 25cefa036ebb3..d6ceeebf87f02 100644 --- a/tests/ui/consts/miri_unleashed/box.stderr +++ b/tests/ui/consts/miri_unleashed/box.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: calling non-const function `Box::::new` --> $DIR/box.rs:8:11 | LL | &mut *(Box::new(0)) - | ^^^^^^^^^^^^^ calling non-const function `Box::::new` + | ^^^^^^^^^^^^^ evaluation of static initializer failed here warning: skipping const checks | diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static.rs b/tests/ui/consts/miri_unleashed/const_refers_to_static.rs index c66aaec8c56cf..6cc670943463b 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static.rs +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static.rs @@ -8,20 +8,19 @@ use std::sync::atomic::Ordering; const MUTATE_INTERIOR_MUT: usize = { static FOO: AtomicUsize = AtomicUsize::new(0); - FOO.fetch_add(1, Ordering::Relaxed) //~ERROR evaluation of constant value failed + FOO.fetch_add(1, Ordering::Relaxed) //~ERROR calling non-const function `AtomicUsize::fetch_add` }; const READ_INTERIOR_MUT: usize = { static FOO: AtomicUsize = AtomicUsize::new(0); - unsafe { *(&FOO as *const _ as *const usize) } //~ERROR evaluation of constant value failed + unsafe { *(&FOO as *const _ as *const usize) } //~ERROR constant accesses mutable global memory }; static mut MUTABLE: u32 = 0; -const READ_MUT: u32 = unsafe { MUTABLE }; //~ERROR evaluation of constant value failed +const READ_MUT: u32 = unsafe { MUTABLE }; //~ERROR constant accesses mutable global memory // Evaluating this does not read anything mutable, but validation does, so this should error. -const REF_INTERIOR_MUT: &usize = { //~ ERROR undefined behavior - //~| NOTE encountered reference to mutable memory +const REF_INTERIOR_MUT: &usize = { //~ ERROR encountered reference to mutable memory static FOO: AtomicUsize = AtomicUsize::new(0); unsafe { &*(&FOO as *const _ as *const usize) } }; diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr index f647107094d9d..f0161988b762d 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr @@ -1,26 +1,26 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: calling non-const function `AtomicUsize::fetch_add` --> $DIR/const_refers_to_static.rs:11:5 | LL | FOO.fetch_add(1, Ordering::Relaxed) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calling non-const function `AtomicUsize::fetch_add` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: constant accesses mutable global memory --> $DIR/const_refers_to_static.rs:16:14 | LL | unsafe { *(&FOO as *const _ as *const usize) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses mutable global memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: constant accesses mutable global memory --> $DIR/const_refers_to_static.rs:20:32 | LL | const READ_MUT: u32 = unsafe { MUTABLE }; - | ^^^^^^^ constant accesses mutable global memory + | ^^^^^^^ evaluation of constant value failed here -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` --> $DIR/const_refers_to_static.rs:23:1 | LL | const REF_INTERIOR_MUT: &usize = { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs index 86d23d44bffe7..6c7e78356616c 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs @@ -2,7 +2,6 @@ //@ aux-build:static_cross_crate.rs //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" //@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?()?─*╼ )+ *│.*" -> "HEX_DUMP" -//@ dont-require-annotations: NOTE #![feature(half_open_range_patterns_in_slices)] #![allow(static_mut_refs)] @@ -11,26 +10,25 @@ extern crate static_cross_crate; // Sneaky: reference to a mutable static. // Allowing this would be a disaster for pattern matching, we could violate exhaustiveness checking! -const SLICE_MUT: &[u8; 1] = { //~ ERROR undefined behavior - //~| NOTE encountered reference to mutable memory +const SLICE_MUT: &[u8; 1] = { + //~^ ERROR encountered reference to mutable memory unsafe { &static_cross_crate::ZERO } }; -const U8_MUT: &u8 = { //~ ERROR undefined behavior - //~| NOTE encountered reference to mutable memory +const U8_MUT: &u8 = { + //~^ ERROR encountered reference to mutable memory unsafe { &static_cross_crate::ZERO[0] } }; // Also test indirection that reads from other static. -const U8_MUT2: &u8 = { //~ ERROR undefined behavior - //~| NOTE encountered reference to mutable memory +const U8_MUT2: &u8 = { + //~^ ERROR encountered reference to mutable memory unsafe { &(*static_cross_crate::ZERO_REF)[0] } }; const U8_MUT3: &u8 = { unsafe { match static_cross_crate::OPT_ZERO { - //~^ ERROR evaluation of constant value failed - //~| NOTE constant accesses mutable global memory + //~^ ERROR constant accesses mutable global memory Some(ref u) => u, None => panic!(), } 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 4e5052ed4704d..8c176d562ee3d 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,41 +1,41 @@ -error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static_cross_crate.rs:14:1 +error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` + --> $DIR/const_refers_to_static_cross_crate.rs:13:1 | LL | const SLICE_MUT: &[u8; 1] = { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` + | ^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static_cross_crate.rs:19:1 +error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` + --> $DIR/const_refers_to_static_cross_crate.rs:18:1 | LL | const U8_MUT: &u8 = { - | ^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` + | ^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static_cross_crate.rs:25:1 +error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` + --> $DIR/const_refers_to_static_cross_crate.rs:24:1 | LL | const U8_MUT2: &u8 = { - | ^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` + | ^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/const_refers_to_static_cross_crate.rs:31:15 +error[E0080]: constant accesses mutable global memory + --> $DIR/const_refers_to_static_cross_crate.rs:30:15 | LL | match static_cross_crate::OPT_ZERO { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses mutable global memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 4 previous errors diff --git a/tests/ui/consts/miri_unleashed/drop.rs b/tests/ui/consts/miri_unleashed/drop.rs index ff9281358d4b3..6921ffa4f949e 100644 --- a/tests/ui/consts/miri_unleashed/drop.rs +++ b/tests/ui/consts/miri_unleashed/drop.rs @@ -13,8 +13,8 @@ static TEST_OK: () = { // The actual error is tested by the error-pattern above. static TEST_BAD: () = { let _v: Vec = Vec::new(); -}; //~ ERROR could not evaluate static initializer - //~| NOTE calling non-const function ` as Drop>::drop` +}; //~ NOTE evaluation of static initializer failed here + //~| ERROR calling non-const function ` as Drop>::drop` //~| NOTE inside `drop_in_place::> - shim(Some(Vec))` //~? WARN skipping const checks diff --git a/tests/ui/consts/miri_unleashed/drop.stderr b/tests/ui/consts/miri_unleashed/drop.stderr index 0286c43127945..f0a776d870246 100644 --- a/tests/ui/consts/miri_unleashed/drop.stderr +++ b/tests/ui/consts/miri_unleashed/drop.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: calling non-const function ` as Drop>::drop` --> $DIR/drop.rs:16:1 | LL | }; - | ^ calling non-const function ` as Drop>::drop` + | ^ evaluation of static initializer failed here | note: inside `drop_in_place::> - shim(Some(Vec))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL diff --git a/tests/ui/consts/miri_unleashed/extern-static.rs b/tests/ui/consts/miri_unleashed/extern-static.rs index c9d9397518ee2..e5d3b80648765 100644 --- a/tests/ui/consts/miri_unleashed/extern-static.rs +++ b/tests/ui/consts/miri_unleashed/extern-static.rs @@ -9,13 +9,11 @@ extern "C" { // Make sure we catch accessing extern static. static TEST_READ: () = { unsafe { let _val = DATA; } - //~^ ERROR could not evaluate static initializer - //~| NOTE cannot access extern static + //~^ ERROR cannot access extern static }; static TEST_WRITE: () = { unsafe { DATA = 0; } - //~^ ERROR could not evaluate static initializer - //~| NOTE cannot access extern static + //~^ ERROR cannot access extern static }; // Just creating a reference is fine, as long as we are not reading or writing. diff --git a/tests/ui/consts/miri_unleashed/extern-static.stderr b/tests/ui/consts/miri_unleashed/extern-static.stderr index 4dbabbe44a2bb..a1e4be5bd9c88 100644 --- a/tests/ui/consts/miri_unleashed/extern-static.stderr +++ b/tests/ui/consts/miri_unleashed/extern-static.stderr @@ -1,14 +1,14 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: cannot access extern static `DATA` --> $DIR/extern-static.rs:11:25 | LL | unsafe { let _val = DATA; } - | ^^^^ cannot access extern static `DATA` + | ^^^^ evaluation of static initializer failed here -error[E0080]: could not evaluate static initializer - --> $DIR/extern-static.rs:16:14 +error[E0080]: cannot access extern static `DATA` + --> $DIR/extern-static.rs:15:14 | LL | unsafe { DATA = 0; } - | ^^^^^^^^ cannot access extern static `DATA` + | ^^^^^^^^ evaluation of static initializer failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/miri_unleashed/inline_asm.rs b/tests/ui/consts/miri_unleashed/inline_asm.rs index f1ce613b16e85..51297aa636120 100644 --- a/tests/ui/consts/miri_unleashed/inline_asm.rs +++ b/tests/ui/consts/miri_unleashed/inline_asm.rs @@ -8,8 +8,7 @@ fn main() {} // Make sure we catch executing inline assembly. static TEST_BAD: () = { unsafe { asm!("nop"); } - //~^ ERROR could not evaluate static initializer - //~| NOTE inline assembly is not supported + //~^ ERROR inline assembly is not supported }; //~? WARN skipping const checks diff --git a/tests/ui/consts/miri_unleashed/inline_asm.stderr b/tests/ui/consts/miri_unleashed/inline_asm.stderr index e9643f02840c0..2f9d2dc214322 100644 --- a/tests/ui/consts/miri_unleashed/inline_asm.stderr +++ b/tests/ui/consts/miri_unleashed/inline_asm.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: inline assembly is not supported --> $DIR/inline_asm.rs:10:14 | LL | unsafe { asm!("nop"); } - | ^^^^^^^^^^^ inline assembly is not supported + | ^^^^^^^^^^^ evaluation of static initializer failed here warning: skipping const checks | diff --git a/tests/ui/consts/miri_unleashed/mutable_references.rs b/tests/ui/consts/miri_unleashed/mutable_references.rs index 02a35487e8a08..63d243f892cd0 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references.rs +++ b/tests/ui/consts/miri_unleashed/mutable_references.rs @@ -11,11 +11,9 @@ use std::sync::atomic::*; // This requires walking nested statics. static FOO: &&mut u32 = &&mut 42; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE pointing to read-only memory +//~^ ERROR pointing to read-only memory static OH_YES: &mut i32 = &mut 42; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE pointing to read-only memory +//~^ ERROR pointing to read-only memory static BAR: &mut () = &mut (); //~^ ERROR encountered mutable pointer in final value of static @@ -25,12 +23,10 @@ static BOO: &mut Foo<()> = &mut Foo(()); //~^ ERROR encountered mutable pointer in final value of static const BLUNT: &mut i32 = &mut 42; -//~^ ERROR: it is undefined behavior to use this value -//~| NOTE pointing to read-only memory +//~^ ERROR: pointing to read-only memory const SUBTLE: &mut i32 = unsafe { - //~^ ERROR: it is undefined behavior to use this value - //~| NOTE constructing invalid value: encountered reference to mutable memory in `const` + //~^ ERROR: constructing invalid value: encountered reference to mutable memory in `const` static mut STATIC: i32 = 0; &mut STATIC }; @@ -42,14 +38,12 @@ struct Meh { } unsafe impl Sync for Meh {} static MEH: Meh = Meh { x: &UnsafeCell::new(42) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE `UnsafeCell` in read-only memory +//~^ ERROR `UnsafeCell` in read-only memory // Same with a const: // the following will never be ok! no interior mut behind consts, because // all allocs interned here will be marked immutable. const MUH: Meh = Meh { - //~^ ERROR it is undefined behavior to use this value - //~| NOTE `UnsafeCell` in read-only memory + //~^ ERROR `UnsafeCell` in read-only memory x: &UnsafeCell::new(42), }; @@ -60,25 +54,21 @@ unsafe impl Sync for Synced {} // Make sure we also catch this behind a type-erased `dyn Trait` reference. const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; -//~^ ERROR: it is undefined behavior to use this value -//~| NOTE `UnsafeCell` in read-only memory +//~^ ERROR: `UnsafeCell` in read-only memory // # Check for mutable references to read-only memory static READONLY: i32 = 0; static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) }; -//~^ ERROR: it is undefined behavior to use this value -//~| NOTE pointing to read-only memory +//~^ ERROR: pointing to read-only memory // # Check for consts pointing to mutable memory static mut MUTABLE: i32 = 42; -const POINTS_TO_MUTABLE: &i32 = unsafe { &MUTABLE }; //~ ERROR undefined behavior -//~| NOTE encountered reference to mutable memory +const POINTS_TO_MUTABLE: &i32 = unsafe { &MUTABLE }; //~ ERROR encountered reference to mutable memory static mut MUTABLE_REF: &mut i32 = &mut 42; const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF }; -//~^ ERROR evaluation of constant value failed -//~| NOTE accesses mutable global memory +//~^ ERROR accesses mutable global memory const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _; //~^ ERROR mutable pointer in final value diff --git a/tests/ui/consts/miri_unleashed/mutable_references.stderr b/tests/ui/consts/miri_unleashed/mutable_references.stderr index 3049be80adc74..aaea7bda332ee 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references.stderr +++ b/tests/ui/consts/miri_unleashed/mutable_references.stderr @@ -1,19 +1,19 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .: encountered mutable reference or box pointing to read-only memory --> $DIR/mutable_references.rs:13:1 | LL | static FOO: &&mut u32 = &&mut 42; - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .: encountered mutable reference or box pointing to read-only memory + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:16:1 +error[E0080]: constructing invalid value: encountered mutable reference or box pointing to read-only memory + --> $DIR/mutable_references.rs:15:1 | LL | static OH_YES: &mut i32 = &mut 42; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -21,126 +21,126 @@ LL | static OH_YES: &mut i32 = &mut 42; } error: encountered mutable pointer in final value of static - --> $DIR/mutable_references.rs:19:1 + --> $DIR/mutable_references.rs:17:1 | LL | static BAR: &mut () = &mut (); | ^^^^^^^^^^^^^^^^^^^ error: encountered mutable pointer in final value of static - --> $DIR/mutable_references.rs:24:1 + --> $DIR/mutable_references.rs:22:1 | LL | static BOO: &mut Foo<()> = &mut Foo(()); | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:27:1 +error[E0080]: constructing invalid value: encountered mutable reference or box pointing to read-only memory + --> $DIR/mutable_references.rs:25:1 | LL | const BLUNT: &mut i32 = &mut 42; - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:31:1 +error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` + --> $DIR/mutable_references.rs:28:1 | LL | const SUBTLE: &mut i32 = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:44:1 +error[E0080]: constructing invalid value at .x.: encountered `UnsafeCell` in read-only memory + --> $DIR/mutable_references.rs:40:1 | LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) }; - | ^^^^^^^^^^^^^^^ constructing invalid value at .x.: encountered `UnsafeCell` in read-only memory + | ^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:50:1 +error[E0080]: constructing invalid value at .x.: encountered `UnsafeCell` in read-only memory + --> $DIR/mutable_references.rs:45:1 | LL | const MUH: Meh = Meh { - | ^^^^^^^^^^^^^^ constructing invalid value at .x.: encountered `UnsafeCell` in read-only memory + | ^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:62:1 +error[E0080]: constructing invalid value at ...x: encountered `UnsafeCell` in read-only memory + --> $DIR/mutable_references.rs:56:1 | LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ...x: encountered `UnsafeCell` in read-only memory + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:69:1 +error[E0080]: constructing invalid value: encountered mutable reference or box pointing to read-only memory + --> $DIR/mutable_references.rs:62:1 | LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:76:1 +error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` + --> $DIR/mutable_references.rs:68:1 | LL | const POINTS_TO_MUTABLE: &i32 = unsafe { &MUTABLE }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/mutable_references.rs:79:43 +error[E0080]: constant accesses mutable global memory + --> $DIR/mutable_references.rs:70:43 | LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF }; - | ^^^^^^^^^^^^^ constant accesses mutable global memory + | ^^^^^^^^^^^^^ evaluation of constant value failed here error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references.rs:83:1 + --> $DIR/mutable_references.rs:73:1 | LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references.rs:86:1 + --> $DIR/mutable_references.rs:76:1 | LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references.rs:106:1 + --> $DIR/mutable_references.rs:96:1 | LL | const RAW_MUT_CAST: SyncPtr = SyncPtr { x: &mut 42 as *mut _ as *const _ }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references.rs:109:1 + --> $DIR/mutable_references.rs:99:1 | LL | const RAW_MUT_COERCE: SyncPtr = SyncPtr { x: &mut 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0594]: cannot assign to `*OH_YES`, as `OH_YES` is an immutable static item - --> $DIR/mutable_references.rs:116:5 + --> $DIR/mutable_references.rs:106:5 | LL | *OH_YES = 99; | ^^^^^^^^^^^^ cannot assign @@ -153,67 +153,67 @@ help: skipping check that does not even have a feature gate LL | static FOO: &&mut u32 = &&mut 42; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:16:27 + --> $DIR/mutable_references.rs:15:27 | LL | static OH_YES: &mut i32 = &mut 42; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:19:23 + --> $DIR/mutable_references.rs:17:23 | LL | static BAR: &mut () = &mut (); | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:24:28 + --> $DIR/mutable_references.rs:22:28 | LL | static BOO: &mut Foo<()> = &mut Foo(()); | ^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:27:25 + --> $DIR/mutable_references.rs:25:25 | LL | const BLUNT: &mut i32 = &mut 42; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:44:28 + --> $DIR/mutable_references.rs:40:28 | LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) }; | ^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:53:8 + --> $DIR/mutable_references.rs:47:8 | LL | x: &UnsafeCell::new(42), | ^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:62:27 + --> $DIR/mutable_references.rs:56:27 | LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:83:45 + --> $DIR/mutable_references.rs:73:45 | LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:86:46 + --> $DIR/mutable_references.rs:76:46 | LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:91:47 + --> $DIR/mutable_references.rs:81:47 | LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; | ^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:103:51 + --> $DIR/mutable_references.rs:93:51 | LL | const RAW_SYNC: SyncPtr = SyncPtr { x: &AtomicI32::new(42) }; | ^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:106:49 + --> $DIR/mutable_references.rs:96:49 | LL | const RAW_MUT_CAST: SyncPtr = SyncPtr { x: &mut 42 as *mut _ as *const _ }; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:109:51 + --> $DIR/mutable_references.rs:99:51 | LL | const RAW_MUT_COERCE: SyncPtr = SyncPtr { x: &mut 0 }; | ^^^^^^ diff --git a/tests/ui/consts/miri_unleashed/mutating_global.rs b/tests/ui/consts/miri_unleashed/mutating_global.rs index 777813603742e..9a88f584a58ec 100644 --- a/tests/ui/consts/miri_unleashed/mutating_global.rs +++ b/tests/ui/consts/miri_unleashed/mutating_global.rs @@ -7,8 +7,7 @@ static mut GLOBAL: i32 = 0; static MUTATING_GLOBAL: () = { unsafe { GLOBAL = 99 - //~^ ERROR could not evaluate static initializer - //~| NOTE modifying a static's initial value + //~^ ERROR modifying a static's initial value } }; diff --git a/tests/ui/consts/miri_unleashed/mutating_global.stderr b/tests/ui/consts/miri_unleashed/mutating_global.stderr index c38e2d44d899e..706bc8e5d2320 100644 --- a/tests/ui/consts/miri_unleashed/mutating_global.stderr +++ b/tests/ui/consts/miri_unleashed/mutating_global.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: modifying a static's initial value from another static's initializer --> $DIR/mutating_global.rs:9:9 | LL | GLOBAL = 99 - | ^^^^^^^^^^^ modifying a static's initial value from another static's initializer + | ^^^^^^^^^^^ evaluation of static initializer failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/miri_unleashed/non_const_fn.rs b/tests/ui/consts/miri_unleashed/non_const_fn.rs index 201647ac8d880..18bee124db442 100644 --- a/tests/ui/consts/miri_unleashed/non_const_fn.rs +++ b/tests/ui/consts/miri_unleashed/non_const_fn.rs @@ -5,8 +5,7 @@ fn foo() {} static C: () = foo(); -//~^ ERROR could not evaluate static initializer -//~| NOTE calling non-const function `foo` +//~^ ERROR calling non-const function `foo` fn main() {} diff --git a/tests/ui/consts/miri_unleashed/non_const_fn.stderr b/tests/ui/consts/miri_unleashed/non_const_fn.stderr index cc893896ecf56..f490e51f5460e 100644 --- a/tests/ui/consts/miri_unleashed/non_const_fn.stderr +++ b/tests/ui/consts/miri_unleashed/non_const_fn.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: calling non-const function `foo` --> $DIR/non_const_fn.rs:7:16 | LL | static C: () = foo(); - | ^^^^^ calling non-const function `foo` + | ^^^^^ evaluation of static initializer failed here warning: skipping const checks | diff --git a/tests/ui/consts/miri_unleashed/ptr_arith.rs b/tests/ui/consts/miri_unleashed/ptr_arith.rs index 408aa5db24d19..3f34102833b0a 100644 --- a/tests/ui/consts/miri_unleashed/ptr_arith.rs +++ b/tests/ui/consts/miri_unleashed/ptr_arith.rs @@ -5,16 +5,14 @@ static PTR_INT_CAST: () = { let x = &0 as *const _ as usize; - //~^ ERROR could not evaluate static initializer - //~| NOTE exposing pointers + //~^ ERROR exposing pointers let _v = x == x; }; static PTR_INT_TRANSMUTE: () = unsafe { let x: usize = std::mem::transmute(&0); let _v = x + 0; - //~^ ERROR could not evaluate static initializer - //~| NOTE unable to turn pointer into integer + //~^ ERROR unable to turn pointer into integer }; // I'd love to test pointer comparison, but that is not possible since diff --git a/tests/ui/consts/miri_unleashed/ptr_arith.stderr b/tests/ui/consts/miri_unleashed/ptr_arith.stderr index 213966f90b840..280c76c42c13b 100644 --- a/tests/ui/consts/miri_unleashed/ptr_arith.stderr +++ b/tests/ui/consts/miri_unleashed/ptr_arith.stderr @@ -1,14 +1,14 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: exposing pointers is not possible at compile-time --> $DIR/ptr_arith.rs:7:13 | LL | let x = &0 as *const _ as usize; - | ^^^^^^^^^^^^^^^^^^^^^^^ exposing pointers is not possible at compile-time + | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here -error[E0080]: could not evaluate static initializer - --> $DIR/ptr_arith.rs:15:14 +error[E0080]: unable to turn pointer into integer + --> $DIR/ptr_arith.rs:14:14 | LL | let _v = x + 0; - | ^ unable to turn pointer into integer + | ^ evaluation of static initializer failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/miri_unleashed/static-no-inner-mut.32bit.stderr b/tests/ui/consts/miri_unleashed/static-no-inner-mut.32bit.stderr index 88a734bc241eb..1ef20689985c1 100644 --- a/tests/ui/consts/miri_unleashed/static-no-inner-mut.32bit.stderr +++ b/tests/ui/consts/miri_unleashed/static-no-inner-mut.32bit.stderr @@ -1,41 +1,41 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at ..v: encountered `UnsafeCell` in read-only memory --> $DIR/static-no-inner-mut.rs:8:1 | LL | static REF: &AtomicI32 = &AtomicI32::new(42); - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..v: encountered `UnsafeCell` in read-only memory + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { ╾ALLOC0╼ │ ╾──╼ } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered mutable reference or box pointing to read-only memory --> $DIR/static-no-inner-mut.rs:11:1 | LL | static REFMUT: &mut i32 = &mut 0; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { ╾ALLOC1╼ │ ╾──╼ } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at ..v: encountered `UnsafeCell` in read-only memory --> $DIR/static-no-inner-mut.rs:15:1 | LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}}; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..v: encountered `UnsafeCell` in read-only memory + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { ╾ALLOC2╼ │ ╾──╼ } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered mutable reference or box pointing to read-only memory --> $DIR/static-no-inner-mut.rs:17:1 | LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}}; - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory + | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { diff --git a/tests/ui/consts/miri_unleashed/static-no-inner-mut.64bit.stderr b/tests/ui/consts/miri_unleashed/static-no-inner-mut.64bit.stderr index c4f3903e14331..06f78e679b190 100644 --- a/tests/ui/consts/miri_unleashed/static-no-inner-mut.64bit.stderr +++ b/tests/ui/consts/miri_unleashed/static-no-inner-mut.64bit.stderr @@ -1,41 +1,41 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at ..v: encountered `UnsafeCell` in read-only memory --> $DIR/static-no-inner-mut.rs:8:1 | LL | static REF: &AtomicI32 = &AtomicI32::new(42); - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..v: encountered `UnsafeCell` in read-only memory + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { ╾ALLOC0╼ │ ╾──────╼ } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered mutable reference or box pointing to read-only memory --> $DIR/static-no-inner-mut.rs:11:1 | LL | static REFMUT: &mut i32 = &mut 0; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { ╾ALLOC1╼ │ ╾──────╼ } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at ..v: encountered `UnsafeCell` in read-only memory --> $DIR/static-no-inner-mut.rs:15:1 | LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}}; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at ..v: encountered `UnsafeCell` in read-only memory + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { ╾ALLOC2╼ │ ╾──────╼ } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered mutable reference or box pointing to read-only memory --> $DIR/static-no-inner-mut.rs:17:1 | LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}}; - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory + | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { diff --git a/tests/ui/consts/miri_unleashed/static-no-inner-mut.rs b/tests/ui/consts/miri_unleashed/static-no-inner-mut.rs index 7fa173d8d9d84..0e87442f6a698 100644 --- a/tests/ui/consts/miri_unleashed/static-no-inner-mut.rs +++ b/tests/ui/consts/miri_unleashed/static-no-inner-mut.rs @@ -6,16 +6,16 @@ use std::sync::atomic::*; static REF: &AtomicI32 = &AtomicI32::new(42); -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR `UnsafeCell` in read-only memory static REFMUT: &mut i32 = &mut 0; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR mutable reference or box pointing to read-only memory // Different way of writing this that avoids promotion. static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}}; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR `UnsafeCell` in read-only memory static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}}; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR mutable reference or box pointing to read-only memory // This one is obvious, since it is non-Sync. (It also suppresses the other errors, so it is // commented out.) diff --git a/tests/ui/consts/miri_unleashed/tls.rs b/tests/ui/consts/miri_unleashed/tls.rs index ab23a52499885..8f8a1bd96184e 100644 --- a/tests/ui/consts/miri_unleashed/tls.rs +++ b/tests/ui/consts/miri_unleashed/tls.rs @@ -9,8 +9,7 @@ static A: u8 = 0; // Make sure we catch accessing thread-local storage. static TEST_BAD: () = { unsafe { let _val = A; } - //~^ ERROR could not evaluate static initializer - //~| NOTE cannot access thread local static + //~^ ERROR cannot access thread local static }; // Make sure we catch taking a reference to thread-local storage. @@ -18,8 +17,7 @@ static TEST_BAD: () = { // sense at compile-time. static TEST_BAD_REF: () = { unsafe { let _val = &A; } - //~^ ERROR could not evaluate static initializer - //~| NOTE cannot access thread local static + //~^ ERROR cannot access thread local static }; fn main() {} diff --git a/tests/ui/consts/miri_unleashed/tls.stderr b/tests/ui/consts/miri_unleashed/tls.stderr index ef83654430318..cdfe8bfff4e5f 100644 --- a/tests/ui/consts/miri_unleashed/tls.stderr +++ b/tests/ui/consts/miri_unleashed/tls.stderr @@ -1,14 +1,14 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: cannot access thread local static `A` --> $DIR/tls.rs:11:25 | LL | unsafe { let _val = A; } - | ^ cannot access thread local static `A` + | ^ evaluation of static initializer failed here -error[E0080]: could not evaluate static initializer - --> $DIR/tls.rs:20:26 +error[E0080]: cannot access thread local static `A` + --> $DIR/tls.rs:19:26 | LL | unsafe { let _val = &A; } - | ^ cannot access thread local static `A` + | ^ evaluation of static initializer failed here warning: skipping const checks | @@ -18,7 +18,7 @@ help: skipping check that does not even have a feature gate LL | unsafe { let _val = A; } | ^ help: skipping check that does not even have a feature gate - --> $DIR/tls.rs:20:26 + --> $DIR/tls.rs:19:26 | LL | unsafe { let _val = &A; } | ^ diff --git a/tests/ui/consts/missing_span_in_backtrace.rs b/tests/ui/consts/missing_span_in_backtrace.rs index 490eb57c24d45..893dc321604fe 100644 --- a/tests/ui/consts/missing_span_in_backtrace.rs +++ b/tests/ui/consts/missing_span_in_backtrace.rs @@ -11,7 +11,7 @@ const X: () = { // Swap them, bytewise. unsafe { - ptr::swap_nonoverlapping( //~ ERROR evaluation of constant value failed + ptr::swap_nonoverlapping( //~ ERROR unable to copy parts of a pointer &mut ptr1 as *mut _ as *mut MaybeUninit, &mut ptr2 as *mut _ as *mut MaybeUninit, mem::size_of::<&i32>(), diff --git a/tests/ui/consts/missing_span_in_backtrace.stderr b/tests/ui/consts/missing_span_in_backtrace.stderr index f802138c61314..5ba5e34b4c1bd 100644 --- a/tests/ui/consts/missing_span_in_backtrace.stderr +++ b/tests/ui/consts/missing_span_in_backtrace.stderr @@ -1,4 +1,4 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: unable to copy parts of a pointer from memory at ALLOC0 --> $DIR/missing_span_in_backtrace.rs:14:9 | 14 | / ptr::swap_nonoverlapping( @@ -6,16 +6,16 @@ error[E0080]: evaluation of constant value failed 16 | | &mut ptr2 as *mut _ as *mut MaybeUninit, 17 | | mem::size_of::<&i32>(), 18 | | ); - | |_________^ unable to copy parts of a pointer from memory at ALLOC0 + | |_________^ evaluation of constant value failed here | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported note: inside `swap_nonoverlapping::compiletime::>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `std::ptr::swap_nonoverlapping_const::>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `std::ptr::copy_nonoverlapping::>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error: aborting due to 1 previous error diff --git a/tests/ui/consts/mono-reachable-invalid-const.rs b/tests/ui/consts/mono-reachable-invalid-const.rs index aabdb071bc9fb..aba41dabe71f9 100644 --- a/tests/ui/consts/mono-reachable-invalid-const.rs +++ b/tests/ui/consts/mono-reachable-invalid-const.rs @@ -5,7 +5,7 @@ struct Bar; impl Bar { const ASSERT: bool = { let b = std::convert::identity(1); - ["oops"][b]; //~ ERROR evaluation of `Bar::<0>::ASSERT` failed + ["oops"][b]; //~ ERROR index out of bounds: the length is 1 but the index is 1 true }; @@ -17,7 +17,6 @@ impl Bar { } } - fn main() { Bar::<0>::assert(); } diff --git a/tests/ui/consts/mono-reachable-invalid-const.stderr b/tests/ui/consts/mono-reachable-invalid-const.stderr index 6b7b25b59b821..e357fd096fdfa 100644 --- a/tests/ui/consts/mono-reachable-invalid-const.stderr +++ b/tests/ui/consts/mono-reachable-invalid-const.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Bar::<0>::ASSERT` failed +error[E0080]: index out of bounds: the length is 1 but the index is 1 --> $DIR/mono-reachable-invalid-const.rs:8:9 | LL | ["oops"][b]; - | ^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1 + | ^^^^^^^^^^^ evaluation of `Bar::<0>::ASSERT` failed here note: erroneous constant encountered --> $DIR/mono-reachable-invalid-const.rs:13:19 @@ -19,7 +19,7 @@ LL | let val = Self::ASSERT; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` note: the above error was encountered while instantiating `fn Bar::<0>::assert` - --> $DIR/mono-reachable-invalid-const.rs:22:5 + --> $DIR/mono-reachable-invalid-const.rs:21:5 | LL | Bar::<0>::assert(); | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/consts/no-ice-from-static-in-const-issue-52060.rs b/tests/ui/consts/no-ice-from-static-in-const-issue-52060.rs index e3cd8ec7d8a6a..2ad5d18d72dcb 100644 --- a/tests/ui/consts/no-ice-from-static-in-const-issue-52060.rs +++ b/tests/ui/consts/no-ice-from-static-in-const-issue-52060.rs @@ -3,7 +3,6 @@ static mut A: &'static [u32] = &[1]; static B: [u32; 1] = [0; unsafe { A.len() }]; -//~^ ERROR: evaluation of constant value failed -//~| NOTE mutable global memory +//~^ ERROR: mutable global memory fn main() {} diff --git a/tests/ui/consts/no-ice-from-static-in-const-issue-52060.stderr b/tests/ui/consts/no-ice-from-static-in-const-issue-52060.stderr index ca4d3224ec790..318082f545271 100644 --- a/tests/ui/consts/no-ice-from-static-in-const-issue-52060.stderr +++ b/tests/ui/consts/no-ice-from-static-in-const-issue-52060.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: constant accesses mutable global memory --> $DIR/no-ice-from-static-in-const-issue-52060.rs:5:35 | LL | static B: [u32; 1] = [0; unsafe { A.len() }]; - | ^ constant accesses mutable global memory + | ^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/offset_from_ub.rs b/tests/ui/consts/offset_from_ub.rs index 47511c0343d6c..ccbe591f97e81 100644 --- a/tests/ui/consts/offset_from_ub.rs +++ b/tests/ui/consts/offset_from_ub.rs @@ -17,28 +17,30 @@ pub const DIFFERENT_ALLOC: usize = { let base_ptr: *const Struct = &uninit as *const _ as *const Struct; let uninit2 = std::mem::MaybeUninit::::uninit(); let field_ptr: *const Struct = &uninit2 as *const _ as *const Struct; - let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) }; //~ERROR evaluation of constant value failed - //~| NOTE not both derived from the same allocation + let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) }; + //~^ ERROR not both derived from the same allocation offset as usize }; pub const NOT_PTR: usize = { - unsafe { (42 as *const u8).offset_from(&5u8) as usize } //~ ERROR evaluation of constant value failed + unsafe { (42 as *const u8).offset_from(&5u8) as usize } + //~^ ERROR not both derived from the same allocation }; pub const NOT_MULTIPLE_OF_SIZE: isize = { let data = [5u8, 6, 7]; let base_ptr = data.as_ptr(); let field_ptr = &data[1] as *const u8 as *const u16; - unsafe { ptr_offset_from(field_ptr, base_ptr as *const u16) } //~ERROR evaluation of constant value failed - //~| NOTE 1_isize cannot be divided by 2_isize without remainder + unsafe { ptr_offset_from(field_ptr, base_ptr as *const u16) } + //~^ ERROR 1_isize cannot be divided by 2_isize without remainder }; -pub const DIFFERENT_INT: isize = { // offset_from with two different integers: like DIFFERENT_ALLOC +pub const DIFFERENT_INT: isize = { + // offset_from with two different integers: like DIFFERENT_ALLOC let ptr1 = 8 as *const u8; let ptr2 = 16 as *const u8; - unsafe { ptr_offset_from(ptr2, ptr1) } //~ERROR evaluation of constant value failed - //~| NOTE not both derived from the same allocation + unsafe { ptr_offset_from(ptr2, ptr1) } + //~^ ERROR not both derived from the same allocation }; const OUT_OF_BOUNDS_1: isize = { @@ -46,8 +48,8 @@ const OUT_OF_BOUNDS_1: isize = { let length = 10; let end_ptr = (start_ptr).wrapping_add(length); // First ptr is out of bounds - unsafe { ptr_offset_from(end_ptr, start_ptr) } //~ERROR evaluation of constant value failed - //~| NOTE the memory range between them is not in-bounds of an allocation + unsafe { ptr_offset_from(end_ptr, start_ptr) } + //~^ ERROR the memory range between them is not in-bounds of an allocation }; const OUT_OF_BOUNDS_2: isize = { @@ -55,8 +57,8 @@ const OUT_OF_BOUNDS_2: isize = { let length = 10; let end_ptr = (start_ptr).wrapping_add(length); // Second ptr is out of bounds - unsafe { ptr_offset_from(start_ptr, end_ptr) } //~ERROR evaluation of constant value failed - //~| NOTE the memory range between them is not in-bounds of an allocation + unsafe { ptr_offset_from(start_ptr, end_ptr) } + //~^ ERROR the memory range between them is not in-bounds of an allocation }; pub const DIFFERENT_ALLOC_UNSIGNED: usize = { @@ -64,43 +66,42 @@ pub const DIFFERENT_ALLOC_UNSIGNED: usize = { let base_ptr: *const Struct = &uninit as *const _ as *const Struct; let uninit2 = std::mem::MaybeUninit::::uninit(); let field_ptr: *const Struct = &uninit2 as *const _ as *const Struct; - unsafe { ptr_offset_from_unsigned(field_ptr, base_ptr) } //~ERROR evaluation of constant value failed - //~| NOTE not both derived from the same allocation + unsafe { ptr_offset_from_unsigned(field_ptr, base_ptr) } + //~^ ERROR not both derived from the same allocation }; pub const TOO_FAR_APART1: isize = { let ptr1 = &0u8 as *const u8; let ptr2 = ptr1.wrapping_add(isize::MAX as usize + 42); - unsafe { ptr_offset_from(ptr2, ptr1) } //~ERROR evaluation of constant value failed - //~| NOTE too far ahead + unsafe { ptr_offset_from(ptr2, ptr1) } + //~^ ERROR too far ahead }; pub const TOO_FAR_APART2: isize = { let ptr1 = &0u8 as *const u8; let ptr2 = ptr1.wrapping_add(isize::MAX as usize + 42); - unsafe { ptr_offset_from(ptr1, ptr2) } //~ERROR evaluation of constant value failed - //~| NOTE too far before + unsafe { ptr_offset_from(ptr1, ptr2) } + //~^ ERROR too far before }; pub const TOO_FAR_APART3: isize = { let ptr1 = &0u8 as *const u8; let ptr2 = ptr1.wrapping_offset(isize::MIN); // The result of this would be `isize::MIN`, which *does* fit in an `isize`, but its // absolute value does not. (Also anyway there cannot be an allocation of that size.) - unsafe { ptr_offset_from(ptr1, ptr2) } //~ERROR evaluation of constant value failed - //~| NOTE too far before + unsafe { ptr_offset_from(ptr1, ptr2) } + //~^ ERROR too far before }; const WRONG_ORDER_UNSIGNED: usize = { let a = ['a', 'b', 'c']; let p = a.as_ptr(); - unsafe { ptr_offset_from_unsigned(p, p.add(2) ) } //~ERROR evaluation of constant value failed - //~| NOTE first pointer has smaller offset than second: 0 < 8 + unsafe { ptr_offset_from_unsigned(p, p.add(2)) } + //~^ ERROR first pointer has smaller offset than second: 0 < 8 }; pub const TOO_FAR_APART_UNSIGNED: usize = { let ptr1 = &0u8 as *const u8; let ptr2 = ptr1.wrapping_add(isize::MAX as usize + 42); // This would fit into a `usize` but we still don't allow it. - unsafe { ptr_offset_from_unsigned(ptr2, ptr1) } //~ERROR evaluation of constant value failed - //~| NOTE too far ahead + unsafe { ptr_offset_from_unsigned(ptr2, ptr1) } //~ERROR too far ahead }; // These do NOT complain that pointers are too far apart; they pass that check (to then fail the @@ -109,13 +110,13 @@ pub const OFFSET_VERY_FAR1: isize = { let ptr1 = ptr::null::(); let ptr2 = ptr1.wrapping_offset(isize::MAX); unsafe { ptr2.offset_from(ptr1) } - //~^ ERROR evaluation of constant value failed + //~^ ERROR called on two different pointers that are not both derived from the same allocation }; pub const OFFSET_VERY_FAR2: isize = { let ptr1 = ptr::null::(); let ptr2 = ptr1.wrapping_offset(isize::MAX); unsafe { ptr1.offset_from(ptr2.wrapping_offset(1)) } - //~^ ERROR evaluation of constant value failed + //~^ ERROR ptr_offset_from` called when first pointer is too far before second }; // If the pointers are the same, OOB/null/UAF is fine. diff --git a/tests/ui/consts/offset_from_ub.stderr b/tests/ui/consts/offset_from_ub.stderr index 5bfb9a1170cf3..842698e239d9e 100644 --- a/tests/ui/consts/offset_from_ub.stderr +++ b/tests/ui/consts/offset_from_ub.stderr @@ -1,92 +1,92 @@ -error[E0080]: evaluation of constant value failed +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 | let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers that are not both derived from the same allocation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +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 | unsafe { (42 as *const u8).offset_from(&5u8) as usize } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers that are not both derived from the same allocation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `std::ptr::const_ptr::::offset_from` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:33:14 +error[E0080]: exact_div: 1_isize cannot be divided by 2_isize without remainder + --> $DIR/offset_from_ub.rs:34:14 | LL | unsafe { ptr_offset_from(field_ptr, base_ptr as *const u16) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: 1_isize cannot be divided by 2_isize without remainder + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:40:14 +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 | unsafe { ptr_offset_from(ptr2, ptr1) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers that are not both derived from the same allocation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:49:14 +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 | unsafe { ptr_offset_from(end_ptr, start_ptr) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers where the memory range between them is not in-bounds of an allocation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:58:14 +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 | unsafe { ptr_offset_from(start_ptr, end_ptr) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers where the memory range between them is not in-bounds of an allocation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:67:14 +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 | unsafe { ptr_offset_from_unsigned(field_ptr, base_ptr) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:74:14 +error[E0080]: `ptr_offset_from` called when first pointer is too far ahead of second + --> $DIR/offset_from_ub.rs:76:14 | LL | unsafe { ptr_offset_from(ptr2, ptr1) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called when first pointer is too far ahead of second + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:80:14 +error[E0080]: `ptr_offset_from` called when first pointer is too far before second + --> $DIR/offset_from_ub.rs:82:14 | LL | unsafe { ptr_offset_from(ptr1, ptr2) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called when first pointer is too far before second + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:88:14 +error[E0080]: `ptr_offset_from` called when first pointer is too far before second + --> $DIR/offset_from_ub.rs:90:14 | LL | unsafe { ptr_offset_from(ptr1, ptr2) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called when first pointer is too far before second + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:95:14 +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 | unsafe { ptr_offset_from_unsigned(p, p.add(2) ) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called when first pointer has smaller offset than second: 0 < 8 +LL | unsafe { ptr_offset_from_unsigned(p, p.add(2)) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:102:14 +error[E0080]: `ptr_offset_from_unsigned` called when first pointer is too far ahead of second + --> $DIR/offset_from_ub.rs:104:14 | LL | unsafe { ptr_offset_from_unsigned(ptr2, ptr1) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called when first pointer is too far ahead of second + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:111:14 +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 | unsafe { ptr2.offset_from(ptr1) } - | ^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers that are not both derived from the same allocation + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `std::ptr::const_ptr::::offset_from` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:117:14 +error[E0080]: `ptr_offset_from` called when first pointer is too far before second + --> $DIR/offset_from_ub.rs:118:14 | LL | unsafe { ptr1.offset_from(ptr2.wrapping_offset(1)) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called when first pointer is too far before second + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `std::ptr::const_ptr::::offset_from` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL diff --git a/tests/ui/consts/offset_ub.stderr b/tests/ui/consts/offset_ub.stderr index 31a2a36a6690a..4135804da20fb 100644 --- a/tests/ui/consts/offset_ub.stderr +++ b/tests/ui/consts/offset_ub.stderr @@ -1,68 +1,68 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got ALLOC0 which is at the beginning of the allocation --> $DIR/offset_ub.rs:8:46 | LL | pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got ALLOC0 which is at the beginning of the allocation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got ALLOC1 which is only 1 byte from the end of the allocation --> $DIR/offset_ub.rs:9:43 | LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got ALLOC1 which is only 1 byte from the end of the allocation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got ALLOC2 which is only $BYTES bytes from the end of the allocation --> $DIR/offset_ub.rs:10:45 | LL | pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got ALLOC2 which is only $BYTES bytes from the end of the allocation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize` --> $DIR/offset_ub.rs:12:43 | LL | pub const OVERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MAX) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize` --> $DIR/offset_ub.rs:13:44 | LL | pub const UNDERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MIN) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got 0xf..f[noalloc] which is a dangling pointer (it has no provenance) --> $DIR/offset_ub.rs:14:56 | LL | pub const OVERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (usize::MAX as *const u8).offset(2) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got 0xf..f[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) --> $DIR/offset_ub.rs:15:57 | LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got ALLOC3-0x2 which is only $BYTES bytes from the beginning of the allocation --> $DIR/offset_ub.rs:16:49 | LL | pub const NEGATIVE_OFFSET: *const u8 = unsafe { [0u8; 1].as_ptr().wrapping_offset(-2).offset(-2) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got ALLOC3-0x2 which is only $BYTES bytes from the beginning of the allocation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 1 byte, but got ALLOC4 which is at or beyond the end of the allocation of size $BYTES bytes --> $DIR/offset_ub.rs:18:50 | LL | pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by 1 byte, but got ALLOC4 which is at or beyond the end of the allocation of size $BYTES bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) --> $DIR/offset_ub.rs:19:42 | LL | pub const DANGLING: *const u8 = unsafe { ptr::NonNull::::dangling().as_ptr().offset(4) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got 0xf..f[noalloc] which is a dangling pointer (it has no provenance) --> $DIR/offset_ub.rs:22:47 | LL | pub const UNDERFLOW_ABS: *const u8 = unsafe { (usize::MAX as *const u8).offset(isize::MIN) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got 0xf..f[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 11 previous errors diff --git a/tests/ui/consts/overflowing-consts.noopt.stderr b/tests/ui/consts/overflowing-consts.noopt.stderr index 81f22944adbe7..e317060a14148 100644 --- a/tests/ui/consts/overflowing-consts.noopt.stderr +++ b/tests/ui/consts/overflowing-consts.noopt.stderr @@ -1,1022 +1,1022 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:19:22 +error[E0080]: attempt to shift left by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:18:22 | LL | const _NI8_SHL: i8 = 1i8 << 8; - | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:20:26 +error[E0080]: attempt to shift left by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:19:26 | LL | const _NI8_SHL_P: &i8 = &(1i8 << 8); - | ^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:22:24 +error[E0080]: attempt to shift left by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:21:24 | LL | const _NI16_SHL: i16 = 1i16 << 16; - | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:23:28 +error[E0080]: attempt to shift left by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:22:28 | LL | const _NI16_SHL_P: &i16 = &(1i16 << 16); - | ^^^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:25:24 +error[E0080]: attempt to shift left by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:24:24 | LL | const _NI32_SHL: i32 = 1i32 << 32; - | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:26:28 +error[E0080]: attempt to shift left by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:25:28 | LL | const _NI32_SHL_P: &i32 = &(1i32 << 32); - | ^^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:28:24 +error[E0080]: attempt to shift left by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:27:24 | LL | const _NI64_SHL: i64 = 1i64 << 64; - | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:29:28 +error[E0080]: attempt to shift left by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:28:28 | LL | const _NI64_SHL_P: &i64 = &(1i64 << 64); - | ^^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:31:26 +error[E0080]: attempt to shift left by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:30:26 | LL | const _NI128_SHL: i128 = 1i128 << 128; - | ^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:32:30 +error[E0080]: attempt to shift left by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:31:30 | LL | const _NI128_SHL_P: &i128 = &(1i128 << 128); - | ^^^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:34:22 +error[E0080]: attempt to shift left by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:33:22 | LL | const _NU8_SHL: u8 = 1u8 << 8; - | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:35:26 +error[E0080]: attempt to shift left by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:34:26 | LL | const _NU8_SHL_P: &u8 = &(1u8 << 8); - | ^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:37:24 +error[E0080]: attempt to shift left by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:36:24 | LL | const _NU16_SHL: u16 = 1u16 << 16; - | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:38:28 +error[E0080]: attempt to shift left by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:37:28 | LL | const _NU16_SHL_P: &u16 = &(1u16 << 16); - | ^^^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:40:24 +error[E0080]: attempt to shift left by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:39:24 | LL | const _NU32_SHL: u32 = 1u32 << 32; - | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:41:28 +error[E0080]: attempt to shift left by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:40:28 | LL | const _NU32_SHL_P: &u32 = &(1u32 << 32); - | ^^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:43:24 +error[E0080]: attempt to shift left by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:42:24 | LL | const _NU64_SHL: u64 = 1u64 << 64; - | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:44:28 +error[E0080]: attempt to shift left by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:43:28 | LL | const _NU64_SHL_P: &u64 = &(1u64 << 64); - | ^^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:46:26 +error[E0080]: attempt to shift left by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:45:26 | LL | const _NU128_SHL: u128 = 1u128 << 128; - | ^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:47:30 +error[E0080]: attempt to shift left by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:46:30 | LL | const _NU128_SHL_P: &u128 = &(1u128 << 128); - | ^^^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:49:28 +error[E0080]: attempt to shift left by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:48:28 | LL | const _NISIZE_SHL: isize = 1isize << BITS; - | ^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:50:32 +error[E0080]: attempt to shift left by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:49:32 | LL | const _NISIZE_SHL_P: &isize = &(1isize << BITS); - | ^^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:52:28 +error[E0080]: attempt to shift left by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:51:28 | LL | const _NUSIZE_SHL: usize = 1usize << BITS; - | ^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:53:32 +error[E0080]: attempt to shift left by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:52:32 | LL | const _NUSIZE_SHL_P: &usize = &(1usize << BITS); - | ^^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:57:22 +error[E0080]: attempt to shift right by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:55:22 | LL | const _NI8_SHR: i8 = 1i8 >> 8; - | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:58:26 +error[E0080]: attempt to shift right by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:56:26 | LL | const _NI8_SHR_P: &i8 = &(1i8 >> 8); - | ^^^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:60:24 +error[E0080]: attempt to shift right by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:58:24 | LL | const _NI16_SHR: i16 = 1i16 >> 16; - | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:61:28 +error[E0080]: attempt to shift right by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:59:28 | LL | const _NI16_SHR_P: &i16 = &(1i16 >> 16); - | ^^^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:63:24 +error[E0080]: attempt to shift right by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:61:24 | LL | const _NI32_SHR: i32 = 1i32 >> 32; - | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:64:28 +error[E0080]: attempt to shift right by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:62:28 | LL | const _NI32_SHR_P: &i32 = &(1i32 >> 32); - | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:66:24 +error[E0080]: attempt to shift right by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:64:24 | LL | const _NI64_SHR: i64 = 1i64 >> 64; - | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:67:28 +error[E0080]: attempt to shift right by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:65:28 | LL | const _NI64_SHR_P: &i64 = &(1i64 >> 64); - | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:69:26 +error[E0080]: attempt to shift right by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:67:26 | LL | const _NI128_SHR: i128 = 1i128 >> 128; - | ^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:70:30 +error[E0080]: attempt to shift right by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:68:30 | LL | const _NI128_SHR_P: &i128 = &(1i128 >> 128); - | ^^^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:72:22 +error[E0080]: attempt to shift right by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:70:22 | LL | const _NU8_SHR: u8 = 1u8 >> 8; - | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:73:26 +error[E0080]: attempt to shift right by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:71:26 | LL | const _NU8_SHR_P: &u8 = &(1u8 >> 8); - | ^^^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:75:24 +error[E0080]: attempt to shift right by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:73:24 | LL | const _NU16_SHR: u16 = 1u16 >> 16; - | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:76:28 +error[E0080]: attempt to shift right by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:74:28 | LL | const _NU16_SHR_P: &u16 = &(1u16 >> 16); - | ^^^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:78:24 +error[E0080]: attempt to shift right by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:76:24 | LL | const _NU32_SHR: u32 = 1u32 >> 32; - | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:79:28 +error[E0080]: attempt to shift right by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:77:28 | LL | const _NU32_SHR_P: &u32 = &(1u32 >> 32); - | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:81:24 +error[E0080]: attempt to shift right by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:79:24 | LL | const _NU64_SHR: u64 = 1u64 >> 64; - | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:82:28 +error[E0080]: attempt to shift right by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:80:28 | LL | const _NU64_SHR_P: &u64 = &(1u64 >> 64); - | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:84:26 +error[E0080]: attempt to shift right by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:82:26 | LL | const _NU128_SHR: u128 = 1u128 >> 128; - | ^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:85:30 +error[E0080]: attempt to shift right by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:83:30 | LL | const _NU128_SHR_P: &u128 = &(1u128 >> 128); - | ^^^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:87:28 +error[E0080]: attempt to shift right by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:85:28 | LL | const _NISIZE_SHR: isize = 1isize >> BITS; - | ^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:88:32 +error[E0080]: attempt to shift right by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:86:32 | LL | const _NISIZE_SHR_P: &isize = &(1isize >> BITS); - | ^^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:90:28 +error[E0080]: attempt to shift right by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:88:28 | LL | const _NUSIZE_SHR: usize = 1usize >> BITS; - | ^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:91:32 +error[E0080]: attempt to shift right by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:89:32 | LL | const _NUSIZE_SHR_P: &usize = &(1usize >> BITS); - | ^^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:95:22 +error[E0080]: attempt to compute `1_i8 + i8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:92:22 | LL | const _NI8_ADD: i8 = 1i8 + i8::MAX; - | ^^^^^^^^^^^^^ attempt to compute `1_i8 + i8::MAX`, which would overflow + | ^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:96:26 +error[E0080]: attempt to compute `1_i8 + i8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:93:26 | LL | const _NI8_ADD_P: &i8 = &(1i8 + i8::MAX); - | ^^^^^^^^^^^^^^^ attempt to compute `1_i8 + i8::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:98:24 +error[E0080]: attempt to compute `1_i16 + i16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:95:24 | LL | const _NI16_ADD: i16 = 1i16 + i16::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_i16 + i16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:99:28 +error[E0080]: attempt to compute `1_i16 + i16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:96:28 | LL | const _NI16_ADD_P: &i16 = &(1i16 + i16::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i16 + i16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:101:24 +error[E0080]: attempt to compute `1_i32 + i32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:98:24 | LL | const _NI32_ADD: i32 = 1i32 + i32::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:102:28 +error[E0080]: attempt to compute `1_i32 + i32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:99:28 | LL | const _NI32_ADD_P: &i32 = &(1i32 + i32::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:104:24 +error[E0080]: attempt to compute `1_i64 + i64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:101:24 | LL | const _NI64_ADD: i64 = 1i64 + i64::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_i64 + i64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:105:28 +error[E0080]: attempt to compute `1_i64 + i64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:102:28 | LL | const _NI64_ADD_P: &i64 = &(1i64 + i64::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i64 + i64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:107:26 +error[E0080]: attempt to compute `1_i128 + i128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:104:26 | LL | const _NI128_ADD: i128 = 1i128 + i128::MAX; - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i128 + i128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:108:30 +error[E0080]: attempt to compute `1_i128 + i128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:105:30 | LL | const _NI128_ADD_P: &i128 = &(1i128 + i128::MAX); - | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_i128 + i128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:110:22 +error[E0080]: attempt to compute `1_u8 + u8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:107:22 | LL | const _NU8_ADD: u8 = 1u8 + u8::MAX; - | ^^^^^^^^^^^^^ attempt to compute `1_u8 + u8::MAX`, which would overflow + | ^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:111:26 +error[E0080]: attempt to compute `1_u8 + u8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:108:26 | LL | const _NU8_ADD_P: &u8 = &(1u8 + u8::MAX); - | ^^^^^^^^^^^^^^^ attempt to compute `1_u8 + u8::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:113:24 +error[E0080]: attempt to compute `1_u16 + u16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:110:24 | LL | const _NU16_ADD: u16 = 1u16 + u16::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_u16 + u16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:114:28 +error[E0080]: attempt to compute `1_u16 + u16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:111:28 | LL | const _NU16_ADD_P: &u16 = &(1u16 + u16::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u16 + u16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:116:24 +error[E0080]: attempt to compute `1_u32 + u32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:113:24 | LL | const _NU32_ADD: u32 = 1u32 + u32::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_u32 + u32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:117:28 +error[E0080]: attempt to compute `1_u32 + u32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:114:28 | LL | const _NU32_ADD_P: &u32 = &(1u32 + u32::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u32 + u32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:119:24 +error[E0080]: attempt to compute `1_u64 + u64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:116:24 | LL | const _NU64_ADD: u64 = 1u64 + u64::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_u64 + u64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:120:28 +error[E0080]: attempt to compute `1_u64 + u64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:117:28 | LL | const _NU64_ADD_P: &u64 = &(1u64 + u64::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u64 + u64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:122:26 +error[E0080]: attempt to compute `1_u128 + u128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:119:26 | LL | const _NU128_ADD: u128 = 1u128 + u128::MAX; - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u128 + u128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:123:30 +error[E0080]: attempt to compute `1_u128 + u128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:120:30 | LL | const _NU128_ADD_P: &u128 = &(1u128 + u128::MAX); - | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_u128 + u128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:125:28 +error[E0080]: attempt to compute `1_isize + isize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:122:28 | LL | const _NISIZE_ADD: isize = 1isize + isize::MAX; - | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_isize + isize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:126:32 +error[E0080]: attempt to compute `1_isize + isize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:123:32 | LL | const _NISIZE_ADD_P: &isize = &(1isize + isize::MAX); - | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_isize + isize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:128:28 +error[E0080]: attempt to compute `1_usize + usize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:125:28 | LL | const _NUSIZE_ADD: usize = 1usize + usize::MAX; - | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize + usize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:129:32 +error[E0080]: attempt to compute `1_usize + usize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:126:32 | LL | const _NUSIZE_ADD_P: &usize = &(1usize + usize::MAX); - | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize + usize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:133:22 +error[E0080]: attempt to compute `-5_i8 - i8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:129:22 | LL | const _NI8_SUB: i8 = -5i8 - i8::MAX; - | ^^^^^^^^^^^^^^ attempt to compute `-5_i8 - i8::MAX`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:134:26 +error[E0080]: attempt to compute `-5_i8 - i8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:130:26 | LL | const _NI8_SUB_P: &i8 = &(-5i8 - i8::MAX); - | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i8 - i8::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:136:24 +error[E0080]: attempt to compute `-5_i16 - i16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:132:24 | LL | const _NI16_SUB: i16 = -5i16 - i16::MAX; - | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i16 - i16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:137:28 +error[E0080]: attempt to compute `-5_i16 - i16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:133:28 | LL | const _NI16_SUB_P: &i16 = &(-5i16 - i16::MAX); - | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i16 - i16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:139:24 +error[E0080]: attempt to compute `-5_i32 - i32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:135:24 | LL | const _NI32_SUB: i32 = -5i32 - i32::MAX; - | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:140:28 +error[E0080]: attempt to compute `-5_i32 - i32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:136:28 | LL | const _NI32_SUB_P: &i32 = &(-5i32 - i32::MAX); - | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:142:24 +error[E0080]: attempt to compute `-5_i64 - i64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:138:24 | LL | const _NI64_SUB: i64 = -5i64 - i64::MAX; - | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i64 - i64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:143:28 +error[E0080]: attempt to compute `-5_i64 - i64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:139:28 | LL | const _NI64_SUB_P: &i64 = &(-5i64 - i64::MAX); - | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i64 - i64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:145:26 +error[E0080]: attempt to compute `-5_i128 - i128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:141:26 | LL | const _NI128_SUB: i128 = -5i128 - i128::MAX; - | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i128 - i128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:146:30 +error[E0080]: attempt to compute `-5_i128 - i128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:142:30 | LL | const _NI128_SUB_P: &i128 = &(-5i128 - i128::MAX); - | ^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i128 - i128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:148:22 +error[E0080]: attempt to compute `1_u8 - 5_u8`, which would overflow + --> $DIR/overflowing-consts.rs:144:22 | LL | const _NU8_SUB: u8 = 1u8 - 5; - | ^^^^^^^ attempt to compute `1_u8 - 5_u8`, which would overflow + | ^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:149:26 +error[E0080]: attempt to compute `1_u8 - 5_u8`, which would overflow + --> $DIR/overflowing-consts.rs:145:26 | LL | const _NU8_SUB_P: &u8 = &(1u8 - 5); - | ^^^^^^^^^ attempt to compute `1_u8 - 5_u8`, which would overflow + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:151:24 +error[E0080]: attempt to compute `1_u16 - 5_u16`, which would overflow + --> $DIR/overflowing-consts.rs:147:24 | LL | const _NU16_SUB: u16 = 1u16 - 5; - | ^^^^^^^^ attempt to compute `1_u16 - 5_u16`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:152:28 +error[E0080]: attempt to compute `1_u16 - 5_u16`, which would overflow + --> $DIR/overflowing-consts.rs:148:28 | LL | const _NU16_SUB_P: &u16 = &(1u16 - 5); - | ^^^^^^^^^^ attempt to compute `1_u16 - 5_u16`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:154:24 +error[E0080]: attempt to compute `1_u32 - 5_u32`, which would overflow + --> $DIR/overflowing-consts.rs:150:24 | LL | const _NU32_SUB: u32 = 1u32 - 5; - | ^^^^^^^^ attempt to compute `1_u32 - 5_u32`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:155:28 +error[E0080]: attempt to compute `1_u32 - 5_u32`, which would overflow + --> $DIR/overflowing-consts.rs:151:28 | LL | const _NU32_SUB_P: &u32 = &(1u32 - 5); - | ^^^^^^^^^^ attempt to compute `1_u32 - 5_u32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:157:24 +error[E0080]: attempt to compute `1_u64 - 5_u64`, which would overflow + --> $DIR/overflowing-consts.rs:153:24 | LL | const _NU64_SUB: u64 = 1u64 - 5; - | ^^^^^^^^ attempt to compute `1_u64 - 5_u64`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:158:28 +error[E0080]: attempt to compute `1_u64 - 5_u64`, which would overflow + --> $DIR/overflowing-consts.rs:154:28 | LL | const _NU64_SUB_P: &u64 = &(1u64 - 5); - | ^^^^^^^^^^ attempt to compute `1_u64 - 5_u64`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:160:26 +error[E0080]: attempt to compute `1_u128 - 5_u128`, which would overflow + --> $DIR/overflowing-consts.rs:156:26 | LL | const _NU128_SUB: u128 = 1u128 - 5; - | ^^^^^^^^^ attempt to compute `1_u128 - 5_u128`, which would overflow + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:161:30 +error[E0080]: attempt to compute `1_u128 - 5_u128`, which would overflow + --> $DIR/overflowing-consts.rs:157:30 | LL | const _NU128_SUB_P: &u128 = &(1u128 - 5); - | ^^^^^^^^^^^ attempt to compute `1_u128 - 5_u128`, which would overflow + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:163:28 +error[E0080]: attempt to compute `-5_isize - isize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:159:28 | LL | const _NISIZE_SUB: isize = -5isize - isize::MAX; - | ^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_isize - isize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:164:32 +error[E0080]: attempt to compute `-5_isize - isize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:160:32 | LL | const _NISIZE_SUB_P: &isize = &(-5isize - isize::MAX); - | ^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_isize - isize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:166:28 +error[E0080]: attempt to compute `1_usize - 5_usize`, which would overflow + --> $DIR/overflowing-consts.rs:162:28 | -LL | const _NUSIZE_SUB: usize = 1usize - 5 ; - | ^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow +LL | const _NUSIZE_SUB: usize = 1usize - 5; + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:167:32 +error[E0080]: attempt to compute `1_usize - 5_usize`, which would overflow + --> $DIR/overflowing-consts.rs:163:32 | -LL | const _NUSIZE_SUB_P: &usize = &(1usize - 5 ); - | ^^^^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow +LL | const _NUSIZE_SUB_P: &usize = &(1usize - 5); + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:171:22 +error[E0080]: attempt to compute `i8::MAX * 5_i8`, which would overflow + --> $DIR/overflowing-consts.rs:166:22 | LL | const _NI8_MUL: i8 = i8::MAX * 5; - | ^^^^^^^^^^^ attempt to compute `i8::MAX * 5_i8`, which would overflow + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:172:26 +error[E0080]: attempt to compute `i8::MAX * 5_i8`, which would overflow + --> $DIR/overflowing-consts.rs:167:26 | LL | const _NI8_MUL_P: &i8 = &(i8::MAX * 5); - | ^^^^^^^^^^^^^ attempt to compute `i8::MAX * 5_i8`, which would overflow + | ^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:174:24 +error[E0080]: attempt to compute `i16::MAX * 5_i16`, which would overflow + --> $DIR/overflowing-consts.rs:169:24 | LL | const _NI16_MUL: i16 = i16::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:175:28 +error[E0080]: attempt to compute `i16::MAX * 5_i16`, which would overflow + --> $DIR/overflowing-consts.rs:170:28 | LL | const _NI16_MUL_P: &i16 = &(i16::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:177:24 +error[E0080]: attempt to compute `i32::MAX * 5_i32`, which would overflow + --> $DIR/overflowing-consts.rs:172:24 | LL | const _NI32_MUL: i32 = i32::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:178:28 +error[E0080]: attempt to compute `i32::MAX * 5_i32`, which would overflow + --> $DIR/overflowing-consts.rs:173:28 | LL | const _NI32_MUL_P: &i32 = &(i32::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:180:24 +error[E0080]: attempt to compute `i64::MAX * 5_i64`, which would overflow + --> $DIR/overflowing-consts.rs:175:24 | LL | const _NI64_MUL: i64 = i64::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:181:28 +error[E0080]: attempt to compute `i64::MAX * 5_i64`, which would overflow + --> $DIR/overflowing-consts.rs:176:28 | LL | const _NI64_MUL_P: &i64 = &(i64::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:183:26 +error[E0080]: attempt to compute `i128::MAX * 5_i128`, which would overflow + --> $DIR/overflowing-consts.rs:178:26 | LL | const _NI128_MUL: i128 = i128::MAX * 5; - | ^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow + | ^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:184:30 +error[E0080]: attempt to compute `i128::MAX * 5_i128`, which would overflow + --> $DIR/overflowing-consts.rs:179:30 | LL | const _NI128_MUL_P: &i128 = &(i128::MAX * 5); - | ^^^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:186:22 +error[E0080]: attempt to compute `u8::MAX * 5_u8`, which would overflow + --> $DIR/overflowing-consts.rs:181:22 | LL | const _NU8_MUL: u8 = u8::MAX * 5; - | ^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:187:26 +error[E0080]: attempt to compute `u8::MAX * 5_u8`, which would overflow + --> $DIR/overflowing-consts.rs:182:26 | LL | const _NU8_MUL_P: &u8 = &(u8::MAX * 5); - | ^^^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow + | ^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:189:24 +error[E0080]: attempt to compute `u16::MAX * 5_u16`, which would overflow + --> $DIR/overflowing-consts.rs:184:24 | LL | const _NU16_MUL: u16 = u16::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:190:28 +error[E0080]: attempt to compute `u16::MAX * 5_u16`, which would overflow + --> $DIR/overflowing-consts.rs:185:28 | LL | const _NU16_MUL_P: &u16 = &(u16::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:192:24 +error[E0080]: attempt to compute `u32::MAX * 5_u32`, which would overflow + --> $DIR/overflowing-consts.rs:187:24 | LL | const _NU32_MUL: u32 = u32::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:193:28 +error[E0080]: attempt to compute `u32::MAX * 5_u32`, which would overflow + --> $DIR/overflowing-consts.rs:188:28 | LL | const _NU32_MUL_P: &u32 = &(u32::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:195:24 +error[E0080]: attempt to compute `u64::MAX * 5_u64`, which would overflow + --> $DIR/overflowing-consts.rs:190:24 | LL | const _NU64_MUL: u64 = u64::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:196:28 +error[E0080]: attempt to compute `u64::MAX * 5_u64`, which would overflow + --> $DIR/overflowing-consts.rs:191:28 | LL | const _NU64_MUL_P: &u64 = &(u64::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:198:26 +error[E0080]: attempt to compute `u128::MAX * 5_u128`, which would overflow + --> $DIR/overflowing-consts.rs:193:26 | LL | const _NU128_MUL: u128 = u128::MAX * 5; - | ^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow + | ^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:199:30 +error[E0080]: attempt to compute `u128::MAX * 5_u128`, which would overflow + --> $DIR/overflowing-consts.rs:194:30 | LL | const _NU128_MUL_P: &u128 = &(u128::MAX * 5); - | ^^^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:201:28 +error[E0080]: attempt to compute `isize::MAX * 5_isize`, which would overflow + --> $DIR/overflowing-consts.rs:196:28 | LL | const _NISIZE_MUL: isize = isize::MAX * 5; - | ^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:202:32 +error[E0080]: attempt to compute `isize::MAX * 5_isize`, which would overflow + --> $DIR/overflowing-consts.rs:197:32 | LL | const _NISIZE_MUL_P: &isize = &(isize::MAX * 5); - | ^^^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:204:28 +error[E0080]: attempt to compute `usize::MAX * 5_usize`, which would overflow + --> $DIR/overflowing-consts.rs:199:28 | LL | const _NUSIZE_MUL: usize = usize::MAX * 5; - | ^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:205:32 +error[E0080]: attempt to compute `usize::MAX * 5_usize`, which would overflow + --> $DIR/overflowing-consts.rs:200:32 | LL | const _NUSIZE_MUL_P: &usize = &(usize::MAX * 5); - | ^^^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:209:22 +error[E0080]: attempt to divide `1_i8` by zero + --> $DIR/overflowing-consts.rs:203:22 | LL | const _NI8_DIV: i8 = 1i8 / 0; - | ^^^^^^^ attempt to divide `1_i8` by zero + | ^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:210:26 +error[E0080]: attempt to divide `1_i8` by zero + --> $DIR/overflowing-consts.rs:204:26 | LL | const _NI8_DIV_P: &i8 = &(1i8 / 0); - | ^^^^^^^^^ attempt to divide `1_i8` by zero + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:212:24 +error[E0080]: attempt to divide `1_i16` by zero + --> $DIR/overflowing-consts.rs:206:24 | LL | const _NI16_DIV: i16 = 1i16 / 0; - | ^^^^^^^^ attempt to divide `1_i16` by zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:213:28 +error[E0080]: attempt to divide `1_i16` by zero + --> $DIR/overflowing-consts.rs:207:28 | LL | const _NI16_DIV_P: &i16 = &(1i16 / 0); - | ^^^^^^^^^^ attempt to divide `1_i16` by zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:215:24 +error[E0080]: attempt to divide `1_i32` by zero + --> $DIR/overflowing-consts.rs:209:24 | LL | const _NI32_DIV: i32 = 1i32 / 0; - | ^^^^^^^^ attempt to divide `1_i32` by zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:216:28 +error[E0080]: attempt to divide `1_i32` by zero + --> $DIR/overflowing-consts.rs:210:28 | LL | const _NI32_DIV_P: &i32 = &(1i32 / 0); - | ^^^^^^^^^^ attempt to divide `1_i32` by zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:218:24 +error[E0080]: attempt to divide `1_i64` by zero + --> $DIR/overflowing-consts.rs:212:24 | LL | const _NI64_DIV: i64 = 1i64 / 0; - | ^^^^^^^^ attempt to divide `1_i64` by zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:219:28 +error[E0080]: attempt to divide `1_i64` by zero + --> $DIR/overflowing-consts.rs:213:28 | LL | const _NI64_DIV_P: &i64 = &(1i64 / 0); - | ^^^^^^^^^^ attempt to divide `1_i64` by zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:221:26 +error[E0080]: attempt to divide `1_i128` by zero + --> $DIR/overflowing-consts.rs:215:26 | LL | const _NI128_DIV: i128 = 1i128 / 0; - | ^^^^^^^^^ attempt to divide `1_i128` by zero + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:222:30 +error[E0080]: attempt to divide `1_i128` by zero + --> $DIR/overflowing-consts.rs:216:30 | LL | const _NI128_DIV_P: &i128 = &(1i128 / 0); - | ^^^^^^^^^^^ attempt to divide `1_i128` by zero + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:224:22 +error[E0080]: attempt to divide `1_u8` by zero + --> $DIR/overflowing-consts.rs:218:22 | LL | const _NU8_DIV: u8 = 1u8 / 0; - | ^^^^^^^ attempt to divide `1_u8` by zero + | ^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:225:26 +error[E0080]: attempt to divide `1_u8` by zero + --> $DIR/overflowing-consts.rs:219:26 | LL | const _NU8_DIV_P: &u8 = &(1u8 / 0); - | ^^^^^^^^^ attempt to divide `1_u8` by zero + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:227:24 +error[E0080]: attempt to divide `1_u16` by zero + --> $DIR/overflowing-consts.rs:221:24 | LL | const _NU16_DIV: u16 = 1u16 / 0; - | ^^^^^^^^ attempt to divide `1_u16` by zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:228:28 +error[E0080]: attempt to divide `1_u16` by zero + --> $DIR/overflowing-consts.rs:222:28 | LL | const _NU16_DIV_P: &u16 = &(1u16 / 0); - | ^^^^^^^^^^ attempt to divide `1_u16` by zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:230:24 +error[E0080]: attempt to divide `1_u32` by zero + --> $DIR/overflowing-consts.rs:224:24 | LL | const _NU32_DIV: u32 = 1u32 / 0; - | ^^^^^^^^ attempt to divide `1_u32` by zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:231:28 +error[E0080]: attempt to divide `1_u32` by zero + --> $DIR/overflowing-consts.rs:225:28 | LL | const _NU32_DIV_P: &u32 = &(1u32 / 0); - | ^^^^^^^^^^ attempt to divide `1_u32` by zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:233:24 +error[E0080]: attempt to divide `1_u64` by zero + --> $DIR/overflowing-consts.rs:227:24 | LL | const _NU64_DIV: u64 = 1u64 / 0; - | ^^^^^^^^ attempt to divide `1_u64` by zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:234:28 +error[E0080]: attempt to divide `1_u64` by zero + --> $DIR/overflowing-consts.rs:228:28 | LL | const _NU64_DIV_P: &u64 = &(1u64 / 0); - | ^^^^^^^^^^ attempt to divide `1_u64` by zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:236:26 +error[E0080]: attempt to divide `1_u128` by zero + --> $DIR/overflowing-consts.rs:230:26 | LL | const _NU128_DIV: u128 = 1u128 / 0; - | ^^^^^^^^^ attempt to divide `1_u128` by zero + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:237:30 +error[E0080]: attempt to divide `1_u128` by zero + --> $DIR/overflowing-consts.rs:231:30 | LL | const _NU128_DIV_P: &u128 = &(1u128 / 0); - | ^^^^^^^^^^^ attempt to divide `1_u128` by zero + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:239:28 +error[E0080]: attempt to divide `1_isize` by zero + --> $DIR/overflowing-consts.rs:233:28 | LL | const _NISIZE_DIV: isize = 1isize / 0; - | ^^^^^^^^^^ attempt to divide `1_isize` by zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:240:32 +error[E0080]: attempt to divide `1_isize` by zero + --> $DIR/overflowing-consts.rs:234:32 | LL | const _NISIZE_DIV_P: &isize = &(1isize / 0); - | ^^^^^^^^^^^^ attempt to divide `1_isize` by zero + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:242:28 +error[E0080]: attempt to divide `1_usize` by zero + --> $DIR/overflowing-consts.rs:236:28 | LL | const _NUSIZE_DIV: usize = 1usize / 0; - | ^^^^^^^^^^ attempt to divide `1_usize` by zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:243:32 +error[E0080]: attempt to divide `1_usize` by zero + --> $DIR/overflowing-consts.rs:237:32 | LL | const _NUSIZE_DIV_P: &usize = &(1usize / 0); - | ^^^^^^^^^^^^ attempt to divide `1_usize` by zero + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:246:22 +error[E0080]: attempt to calculate the remainder of `1_i8` with a divisor of zero + --> $DIR/overflowing-consts.rs:240:22 | LL | const _NI8_MOD: i8 = 1i8 % 0; - | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero + | ^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:247:26 +error[E0080]: attempt to calculate the remainder of `1_i8` with a divisor of zero + --> $DIR/overflowing-consts.rs:241:26 | LL | const _NI8_MOD_P: &i8 = &(1i8 % 0); - | ^^^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:249:24 +error[E0080]: attempt to calculate the remainder of `1_i16` with a divisor of zero + --> $DIR/overflowing-consts.rs:243:24 | LL | const _NI16_MOD: i16 = 1i16 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:250:28 +error[E0080]: attempt to calculate the remainder of `1_i16` with a divisor of zero + --> $DIR/overflowing-consts.rs:244:28 | LL | const _NI16_MOD_P: &i16 = &(1i16 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:252:24 +error[E0080]: attempt to calculate the remainder of `1_i32` with a divisor of zero + --> $DIR/overflowing-consts.rs:246:24 | LL | const _NI32_MOD: i32 = 1i32 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:253:28 +error[E0080]: attempt to calculate the remainder of `1_i32` with a divisor of zero + --> $DIR/overflowing-consts.rs:247:28 | LL | const _NI32_MOD_P: &i32 = &(1i32 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:255:24 +error[E0080]: attempt to calculate the remainder of `1_i64` with a divisor of zero + --> $DIR/overflowing-consts.rs:249:24 | LL | const _NI64_MOD: i64 = 1i64 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:256:28 +error[E0080]: attempt to calculate the remainder of `1_i64` with a divisor of zero + --> $DIR/overflowing-consts.rs:250:28 | LL | const _NI64_MOD_P: &i64 = &(1i64 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:258:26 +error[E0080]: attempt to calculate the remainder of `1_i128` with a divisor of zero + --> $DIR/overflowing-consts.rs:252:26 | LL | const _NI128_MOD: i128 = 1i128 % 0; - | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:259:30 +error[E0080]: attempt to calculate the remainder of `1_i128` with a divisor of zero + --> $DIR/overflowing-consts.rs:253:30 | LL | const _NI128_MOD_P: &i128 = &(1i128 % 0); - | ^^^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:261:22 +error[E0080]: attempt to calculate the remainder of `1_u8` with a divisor of zero + --> $DIR/overflowing-consts.rs:255:22 | LL | const _NU8_MOD: u8 = 1u8 % 0; - | ^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero + | ^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:262:26 +error[E0080]: attempt to calculate the remainder of `1_u8` with a divisor of zero + --> $DIR/overflowing-consts.rs:256:26 | LL | const _NU8_MOD_P: &u8 = &(1u8 % 0); - | ^^^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:264:24 +error[E0080]: attempt to calculate the remainder of `1_u16` with a divisor of zero + --> $DIR/overflowing-consts.rs:258:24 | LL | const _NU16_MOD: u16 = 1u16 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:265:28 +error[E0080]: attempt to calculate the remainder of `1_u16` with a divisor of zero + --> $DIR/overflowing-consts.rs:259:28 | LL | const _NU16_MOD_P: &u16 = &(1u16 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:267:24 +error[E0080]: attempt to calculate the remainder of `1_u32` with a divisor of zero + --> $DIR/overflowing-consts.rs:261:24 | LL | const _NU32_MOD: u32 = 1u32 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:268:28 +error[E0080]: attempt to calculate the remainder of `1_u32` with a divisor of zero + --> $DIR/overflowing-consts.rs:262:28 | LL | const _NU32_MOD_P: &u32 = &(1u32 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:270:24 +error[E0080]: attempt to calculate the remainder of `1_u64` with a divisor of zero + --> $DIR/overflowing-consts.rs:264:24 | LL | const _NU64_MOD: u64 = 1u64 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:271:28 +error[E0080]: attempt to calculate the remainder of `1_u64` with a divisor of zero + --> $DIR/overflowing-consts.rs:265:28 | LL | const _NU64_MOD_P: &u64 = &(1u64 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:273:26 +error[E0080]: attempt to calculate the remainder of `1_u128` with a divisor of zero + --> $DIR/overflowing-consts.rs:267:26 | LL | const _NU128_MOD: u128 = 1u128 % 0; - | ^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:274:30 +error[E0080]: attempt to calculate the remainder of `1_u128` with a divisor of zero + --> $DIR/overflowing-consts.rs:268:30 | LL | const _NU128_MOD_P: &u128 = &(1u128 % 0); - | ^^^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:276:28 +error[E0080]: attempt to calculate the remainder of `1_isize` with a divisor of zero + --> $DIR/overflowing-consts.rs:270:28 | LL | const _NISIZE_MOD: isize = 1isize % 0; - | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:277:32 +error[E0080]: attempt to calculate the remainder of `1_isize` with a divisor of zero + --> $DIR/overflowing-consts.rs:271:32 | LL | const _NISIZE_MOD_P: &isize = &(1isize % 0); - | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:279:28 +error[E0080]: attempt to calculate the remainder of `1_usize` with a divisor of zero + --> $DIR/overflowing-consts.rs:273:28 | LL | const _NUSIZE_MOD: usize = 1usize % 0; - | ^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:280:32 +error[E0080]: attempt to calculate the remainder of `1_usize` with a divisor of zero + --> $DIR/overflowing-consts.rs:274:32 | LL | const _NUSIZE_MOD_P: &usize = &(1usize % 0); - | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:284:24 +error[E0080]: index out of bounds: the length is 3 but the index is 4 + --> $DIR/overflowing-consts.rs:277:24 | LL | const _NI32_OOB: i32 = [1, 2, 3][4]; - | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:285:28 +error[E0080]: index out of bounds: the length is 3 but the index is 4 + --> $DIR/overflowing-consts.rs:278:28 | LL | const _NI32_OOB_P: &i32 = &([1, 2, 3][4]); - | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + | ^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 170 previous errors diff --git a/tests/ui/consts/overflowing-consts.opt.stderr b/tests/ui/consts/overflowing-consts.opt.stderr index 81f22944adbe7..e317060a14148 100644 --- a/tests/ui/consts/overflowing-consts.opt.stderr +++ b/tests/ui/consts/overflowing-consts.opt.stderr @@ -1,1022 +1,1022 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:19:22 +error[E0080]: attempt to shift left by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:18:22 | LL | const _NI8_SHL: i8 = 1i8 << 8; - | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:20:26 +error[E0080]: attempt to shift left by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:19:26 | LL | const _NI8_SHL_P: &i8 = &(1i8 << 8); - | ^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:22:24 +error[E0080]: attempt to shift left by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:21:24 | LL | const _NI16_SHL: i16 = 1i16 << 16; - | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:23:28 +error[E0080]: attempt to shift left by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:22:28 | LL | const _NI16_SHL_P: &i16 = &(1i16 << 16); - | ^^^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:25:24 +error[E0080]: attempt to shift left by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:24:24 | LL | const _NI32_SHL: i32 = 1i32 << 32; - | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:26:28 +error[E0080]: attempt to shift left by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:25:28 | LL | const _NI32_SHL_P: &i32 = &(1i32 << 32); - | ^^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:28:24 +error[E0080]: attempt to shift left by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:27:24 | LL | const _NI64_SHL: i64 = 1i64 << 64; - | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:29:28 +error[E0080]: attempt to shift left by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:28:28 | LL | const _NI64_SHL_P: &i64 = &(1i64 << 64); - | ^^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:31:26 +error[E0080]: attempt to shift left by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:30:26 | LL | const _NI128_SHL: i128 = 1i128 << 128; - | ^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:32:30 +error[E0080]: attempt to shift left by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:31:30 | LL | const _NI128_SHL_P: &i128 = &(1i128 << 128); - | ^^^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:34:22 +error[E0080]: attempt to shift left by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:33:22 | LL | const _NU8_SHL: u8 = 1u8 << 8; - | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:35:26 +error[E0080]: attempt to shift left by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:34:26 | LL | const _NU8_SHL_P: &u8 = &(1u8 << 8); - | ^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:37:24 +error[E0080]: attempt to shift left by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:36:24 | LL | const _NU16_SHL: u16 = 1u16 << 16; - | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:38:28 +error[E0080]: attempt to shift left by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:37:28 | LL | const _NU16_SHL_P: &u16 = &(1u16 << 16); - | ^^^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:40:24 +error[E0080]: attempt to shift left by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:39:24 | LL | const _NU32_SHL: u32 = 1u32 << 32; - | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:41:28 +error[E0080]: attempt to shift left by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:40:28 | LL | const _NU32_SHL_P: &u32 = &(1u32 << 32); - | ^^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:43:24 +error[E0080]: attempt to shift left by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:42:24 | LL | const _NU64_SHL: u64 = 1u64 << 64; - | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:44:28 +error[E0080]: attempt to shift left by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:43:28 | LL | const _NU64_SHL_P: &u64 = &(1u64 << 64); - | ^^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:46:26 +error[E0080]: attempt to shift left by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:45:26 | LL | const _NU128_SHL: u128 = 1u128 << 128; - | ^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:47:30 +error[E0080]: attempt to shift left by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:46:30 | LL | const _NU128_SHL_P: &u128 = &(1u128 << 128); - | ^^^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:49:28 +error[E0080]: attempt to shift left by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:48:28 | LL | const _NISIZE_SHL: isize = 1isize << BITS; - | ^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:50:32 +error[E0080]: attempt to shift left by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:49:32 | LL | const _NISIZE_SHL_P: &isize = &(1isize << BITS); - | ^^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:52:28 +error[E0080]: attempt to shift left by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:51:28 | LL | const _NUSIZE_SHL: usize = 1usize << BITS; - | ^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:53:32 +error[E0080]: attempt to shift left by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:52:32 | LL | const _NUSIZE_SHL_P: &usize = &(1usize << BITS); - | ^^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:57:22 +error[E0080]: attempt to shift right by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:55:22 | LL | const _NI8_SHR: i8 = 1i8 >> 8; - | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:58:26 +error[E0080]: attempt to shift right by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:56:26 | LL | const _NI8_SHR_P: &i8 = &(1i8 >> 8); - | ^^^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:60:24 +error[E0080]: attempt to shift right by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:58:24 | LL | const _NI16_SHR: i16 = 1i16 >> 16; - | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:61:28 +error[E0080]: attempt to shift right by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:59:28 | LL | const _NI16_SHR_P: &i16 = &(1i16 >> 16); - | ^^^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:63:24 +error[E0080]: attempt to shift right by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:61:24 | LL | const _NI32_SHR: i32 = 1i32 >> 32; - | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:64:28 +error[E0080]: attempt to shift right by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:62:28 | LL | const _NI32_SHR_P: &i32 = &(1i32 >> 32); - | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:66:24 +error[E0080]: attempt to shift right by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:64:24 | LL | const _NI64_SHR: i64 = 1i64 >> 64; - | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:67:28 +error[E0080]: attempt to shift right by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:65:28 | LL | const _NI64_SHR_P: &i64 = &(1i64 >> 64); - | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:69:26 +error[E0080]: attempt to shift right by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:67:26 | LL | const _NI128_SHR: i128 = 1i128 >> 128; - | ^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:70:30 +error[E0080]: attempt to shift right by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:68:30 | LL | const _NI128_SHR_P: &i128 = &(1i128 >> 128); - | ^^^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:72:22 +error[E0080]: attempt to shift right by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:70:22 | LL | const _NU8_SHR: u8 = 1u8 >> 8; - | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:73:26 +error[E0080]: attempt to shift right by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:71:26 | LL | const _NU8_SHR_P: &u8 = &(1u8 >> 8); - | ^^^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:75:24 +error[E0080]: attempt to shift right by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:73:24 | LL | const _NU16_SHR: u16 = 1u16 >> 16; - | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:76:28 +error[E0080]: attempt to shift right by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:74:28 | LL | const _NU16_SHR_P: &u16 = &(1u16 >> 16); - | ^^^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:78:24 +error[E0080]: attempt to shift right by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:76:24 | LL | const _NU32_SHR: u32 = 1u32 >> 32; - | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:79:28 +error[E0080]: attempt to shift right by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:77:28 | LL | const _NU32_SHR_P: &u32 = &(1u32 >> 32); - | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:81:24 +error[E0080]: attempt to shift right by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:79:24 | LL | const _NU64_SHR: u64 = 1u64 >> 64; - | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:82:28 +error[E0080]: attempt to shift right by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:80:28 | LL | const _NU64_SHR_P: &u64 = &(1u64 >> 64); - | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:84:26 +error[E0080]: attempt to shift right by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:82:26 | LL | const _NU128_SHR: u128 = 1u128 >> 128; - | ^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:85:30 +error[E0080]: attempt to shift right by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:83:30 | LL | const _NU128_SHR_P: &u128 = &(1u128 >> 128); - | ^^^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:87:28 +error[E0080]: attempt to shift right by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:85:28 | LL | const _NISIZE_SHR: isize = 1isize >> BITS; - | ^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:88:32 +error[E0080]: attempt to shift right by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:86:32 | LL | const _NISIZE_SHR_P: &isize = &(1isize >> BITS); - | ^^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:90:28 +error[E0080]: attempt to shift right by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:88:28 | LL | const _NUSIZE_SHR: usize = 1usize >> BITS; - | ^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:91:32 +error[E0080]: attempt to shift right by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:89:32 | LL | const _NUSIZE_SHR_P: &usize = &(1usize >> BITS); - | ^^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:95:22 +error[E0080]: attempt to compute `1_i8 + i8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:92:22 | LL | const _NI8_ADD: i8 = 1i8 + i8::MAX; - | ^^^^^^^^^^^^^ attempt to compute `1_i8 + i8::MAX`, which would overflow + | ^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:96:26 +error[E0080]: attempt to compute `1_i8 + i8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:93:26 | LL | const _NI8_ADD_P: &i8 = &(1i8 + i8::MAX); - | ^^^^^^^^^^^^^^^ attempt to compute `1_i8 + i8::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:98:24 +error[E0080]: attempt to compute `1_i16 + i16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:95:24 | LL | const _NI16_ADD: i16 = 1i16 + i16::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_i16 + i16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:99:28 +error[E0080]: attempt to compute `1_i16 + i16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:96:28 | LL | const _NI16_ADD_P: &i16 = &(1i16 + i16::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i16 + i16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:101:24 +error[E0080]: attempt to compute `1_i32 + i32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:98:24 | LL | const _NI32_ADD: i32 = 1i32 + i32::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:102:28 +error[E0080]: attempt to compute `1_i32 + i32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:99:28 | LL | const _NI32_ADD_P: &i32 = &(1i32 + i32::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:104:24 +error[E0080]: attempt to compute `1_i64 + i64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:101:24 | LL | const _NI64_ADD: i64 = 1i64 + i64::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_i64 + i64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:105:28 +error[E0080]: attempt to compute `1_i64 + i64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:102:28 | LL | const _NI64_ADD_P: &i64 = &(1i64 + i64::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i64 + i64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:107:26 +error[E0080]: attempt to compute `1_i128 + i128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:104:26 | LL | const _NI128_ADD: i128 = 1i128 + i128::MAX; - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i128 + i128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:108:30 +error[E0080]: attempt to compute `1_i128 + i128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:105:30 | LL | const _NI128_ADD_P: &i128 = &(1i128 + i128::MAX); - | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_i128 + i128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:110:22 +error[E0080]: attempt to compute `1_u8 + u8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:107:22 | LL | const _NU8_ADD: u8 = 1u8 + u8::MAX; - | ^^^^^^^^^^^^^ attempt to compute `1_u8 + u8::MAX`, which would overflow + | ^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:111:26 +error[E0080]: attempt to compute `1_u8 + u8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:108:26 | LL | const _NU8_ADD_P: &u8 = &(1u8 + u8::MAX); - | ^^^^^^^^^^^^^^^ attempt to compute `1_u8 + u8::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:113:24 +error[E0080]: attempt to compute `1_u16 + u16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:110:24 | LL | const _NU16_ADD: u16 = 1u16 + u16::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_u16 + u16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:114:28 +error[E0080]: attempt to compute `1_u16 + u16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:111:28 | LL | const _NU16_ADD_P: &u16 = &(1u16 + u16::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u16 + u16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:116:24 +error[E0080]: attempt to compute `1_u32 + u32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:113:24 | LL | const _NU32_ADD: u32 = 1u32 + u32::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_u32 + u32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:117:28 +error[E0080]: attempt to compute `1_u32 + u32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:114:28 | LL | const _NU32_ADD_P: &u32 = &(1u32 + u32::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u32 + u32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:119:24 +error[E0080]: attempt to compute `1_u64 + u64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:116:24 | LL | const _NU64_ADD: u64 = 1u64 + u64::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_u64 + u64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:120:28 +error[E0080]: attempt to compute `1_u64 + u64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:117:28 | LL | const _NU64_ADD_P: &u64 = &(1u64 + u64::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u64 + u64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:122:26 +error[E0080]: attempt to compute `1_u128 + u128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:119:26 | LL | const _NU128_ADD: u128 = 1u128 + u128::MAX; - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u128 + u128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:123:30 +error[E0080]: attempt to compute `1_u128 + u128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:120:30 | LL | const _NU128_ADD_P: &u128 = &(1u128 + u128::MAX); - | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_u128 + u128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:125:28 +error[E0080]: attempt to compute `1_isize + isize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:122:28 | LL | const _NISIZE_ADD: isize = 1isize + isize::MAX; - | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_isize + isize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:126:32 +error[E0080]: attempt to compute `1_isize + isize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:123:32 | LL | const _NISIZE_ADD_P: &isize = &(1isize + isize::MAX); - | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_isize + isize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:128:28 +error[E0080]: attempt to compute `1_usize + usize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:125:28 | LL | const _NUSIZE_ADD: usize = 1usize + usize::MAX; - | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize + usize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:129:32 +error[E0080]: attempt to compute `1_usize + usize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:126:32 | LL | const _NUSIZE_ADD_P: &usize = &(1usize + usize::MAX); - | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize + usize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:133:22 +error[E0080]: attempt to compute `-5_i8 - i8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:129:22 | LL | const _NI8_SUB: i8 = -5i8 - i8::MAX; - | ^^^^^^^^^^^^^^ attempt to compute `-5_i8 - i8::MAX`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:134:26 +error[E0080]: attempt to compute `-5_i8 - i8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:130:26 | LL | const _NI8_SUB_P: &i8 = &(-5i8 - i8::MAX); - | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i8 - i8::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:136:24 +error[E0080]: attempt to compute `-5_i16 - i16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:132:24 | LL | const _NI16_SUB: i16 = -5i16 - i16::MAX; - | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i16 - i16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:137:28 +error[E0080]: attempt to compute `-5_i16 - i16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:133:28 | LL | const _NI16_SUB_P: &i16 = &(-5i16 - i16::MAX); - | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i16 - i16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:139:24 +error[E0080]: attempt to compute `-5_i32 - i32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:135:24 | LL | const _NI32_SUB: i32 = -5i32 - i32::MAX; - | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:140:28 +error[E0080]: attempt to compute `-5_i32 - i32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:136:28 | LL | const _NI32_SUB_P: &i32 = &(-5i32 - i32::MAX); - | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:142:24 +error[E0080]: attempt to compute `-5_i64 - i64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:138:24 | LL | const _NI64_SUB: i64 = -5i64 - i64::MAX; - | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i64 - i64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:143:28 +error[E0080]: attempt to compute `-5_i64 - i64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:139:28 | LL | const _NI64_SUB_P: &i64 = &(-5i64 - i64::MAX); - | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i64 - i64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:145:26 +error[E0080]: attempt to compute `-5_i128 - i128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:141:26 | LL | const _NI128_SUB: i128 = -5i128 - i128::MAX; - | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i128 - i128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:146:30 +error[E0080]: attempt to compute `-5_i128 - i128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:142:30 | LL | const _NI128_SUB_P: &i128 = &(-5i128 - i128::MAX); - | ^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i128 - i128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:148:22 +error[E0080]: attempt to compute `1_u8 - 5_u8`, which would overflow + --> $DIR/overflowing-consts.rs:144:22 | LL | const _NU8_SUB: u8 = 1u8 - 5; - | ^^^^^^^ attempt to compute `1_u8 - 5_u8`, which would overflow + | ^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:149:26 +error[E0080]: attempt to compute `1_u8 - 5_u8`, which would overflow + --> $DIR/overflowing-consts.rs:145:26 | LL | const _NU8_SUB_P: &u8 = &(1u8 - 5); - | ^^^^^^^^^ attempt to compute `1_u8 - 5_u8`, which would overflow + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:151:24 +error[E0080]: attempt to compute `1_u16 - 5_u16`, which would overflow + --> $DIR/overflowing-consts.rs:147:24 | LL | const _NU16_SUB: u16 = 1u16 - 5; - | ^^^^^^^^ attempt to compute `1_u16 - 5_u16`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:152:28 +error[E0080]: attempt to compute `1_u16 - 5_u16`, which would overflow + --> $DIR/overflowing-consts.rs:148:28 | LL | const _NU16_SUB_P: &u16 = &(1u16 - 5); - | ^^^^^^^^^^ attempt to compute `1_u16 - 5_u16`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:154:24 +error[E0080]: attempt to compute `1_u32 - 5_u32`, which would overflow + --> $DIR/overflowing-consts.rs:150:24 | LL | const _NU32_SUB: u32 = 1u32 - 5; - | ^^^^^^^^ attempt to compute `1_u32 - 5_u32`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:155:28 +error[E0080]: attempt to compute `1_u32 - 5_u32`, which would overflow + --> $DIR/overflowing-consts.rs:151:28 | LL | const _NU32_SUB_P: &u32 = &(1u32 - 5); - | ^^^^^^^^^^ attempt to compute `1_u32 - 5_u32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:157:24 +error[E0080]: attempt to compute `1_u64 - 5_u64`, which would overflow + --> $DIR/overflowing-consts.rs:153:24 | LL | const _NU64_SUB: u64 = 1u64 - 5; - | ^^^^^^^^ attempt to compute `1_u64 - 5_u64`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:158:28 +error[E0080]: attempt to compute `1_u64 - 5_u64`, which would overflow + --> $DIR/overflowing-consts.rs:154:28 | LL | const _NU64_SUB_P: &u64 = &(1u64 - 5); - | ^^^^^^^^^^ attempt to compute `1_u64 - 5_u64`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:160:26 +error[E0080]: attempt to compute `1_u128 - 5_u128`, which would overflow + --> $DIR/overflowing-consts.rs:156:26 | LL | const _NU128_SUB: u128 = 1u128 - 5; - | ^^^^^^^^^ attempt to compute `1_u128 - 5_u128`, which would overflow + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:161:30 +error[E0080]: attempt to compute `1_u128 - 5_u128`, which would overflow + --> $DIR/overflowing-consts.rs:157:30 | LL | const _NU128_SUB_P: &u128 = &(1u128 - 5); - | ^^^^^^^^^^^ attempt to compute `1_u128 - 5_u128`, which would overflow + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:163:28 +error[E0080]: attempt to compute `-5_isize - isize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:159:28 | LL | const _NISIZE_SUB: isize = -5isize - isize::MAX; - | ^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_isize - isize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:164:32 +error[E0080]: attempt to compute `-5_isize - isize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:160:32 | LL | const _NISIZE_SUB_P: &isize = &(-5isize - isize::MAX); - | ^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_isize - isize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:166:28 +error[E0080]: attempt to compute `1_usize - 5_usize`, which would overflow + --> $DIR/overflowing-consts.rs:162:28 | -LL | const _NUSIZE_SUB: usize = 1usize - 5 ; - | ^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow +LL | const _NUSIZE_SUB: usize = 1usize - 5; + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:167:32 +error[E0080]: attempt to compute `1_usize - 5_usize`, which would overflow + --> $DIR/overflowing-consts.rs:163:32 | -LL | const _NUSIZE_SUB_P: &usize = &(1usize - 5 ); - | ^^^^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow +LL | const _NUSIZE_SUB_P: &usize = &(1usize - 5); + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:171:22 +error[E0080]: attempt to compute `i8::MAX * 5_i8`, which would overflow + --> $DIR/overflowing-consts.rs:166:22 | LL | const _NI8_MUL: i8 = i8::MAX * 5; - | ^^^^^^^^^^^ attempt to compute `i8::MAX * 5_i8`, which would overflow + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:172:26 +error[E0080]: attempt to compute `i8::MAX * 5_i8`, which would overflow + --> $DIR/overflowing-consts.rs:167:26 | LL | const _NI8_MUL_P: &i8 = &(i8::MAX * 5); - | ^^^^^^^^^^^^^ attempt to compute `i8::MAX * 5_i8`, which would overflow + | ^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:174:24 +error[E0080]: attempt to compute `i16::MAX * 5_i16`, which would overflow + --> $DIR/overflowing-consts.rs:169:24 | LL | const _NI16_MUL: i16 = i16::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:175:28 +error[E0080]: attempt to compute `i16::MAX * 5_i16`, which would overflow + --> $DIR/overflowing-consts.rs:170:28 | LL | const _NI16_MUL_P: &i16 = &(i16::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:177:24 +error[E0080]: attempt to compute `i32::MAX * 5_i32`, which would overflow + --> $DIR/overflowing-consts.rs:172:24 | LL | const _NI32_MUL: i32 = i32::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:178:28 +error[E0080]: attempt to compute `i32::MAX * 5_i32`, which would overflow + --> $DIR/overflowing-consts.rs:173:28 | LL | const _NI32_MUL_P: &i32 = &(i32::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:180:24 +error[E0080]: attempt to compute `i64::MAX * 5_i64`, which would overflow + --> $DIR/overflowing-consts.rs:175:24 | LL | const _NI64_MUL: i64 = i64::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:181:28 +error[E0080]: attempt to compute `i64::MAX * 5_i64`, which would overflow + --> $DIR/overflowing-consts.rs:176:28 | LL | const _NI64_MUL_P: &i64 = &(i64::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:183:26 +error[E0080]: attempt to compute `i128::MAX * 5_i128`, which would overflow + --> $DIR/overflowing-consts.rs:178:26 | LL | const _NI128_MUL: i128 = i128::MAX * 5; - | ^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow + | ^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:184:30 +error[E0080]: attempt to compute `i128::MAX * 5_i128`, which would overflow + --> $DIR/overflowing-consts.rs:179:30 | LL | const _NI128_MUL_P: &i128 = &(i128::MAX * 5); - | ^^^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:186:22 +error[E0080]: attempt to compute `u8::MAX * 5_u8`, which would overflow + --> $DIR/overflowing-consts.rs:181:22 | LL | const _NU8_MUL: u8 = u8::MAX * 5; - | ^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:187:26 +error[E0080]: attempt to compute `u8::MAX * 5_u8`, which would overflow + --> $DIR/overflowing-consts.rs:182:26 | LL | const _NU8_MUL_P: &u8 = &(u8::MAX * 5); - | ^^^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow + | ^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:189:24 +error[E0080]: attempt to compute `u16::MAX * 5_u16`, which would overflow + --> $DIR/overflowing-consts.rs:184:24 | LL | const _NU16_MUL: u16 = u16::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:190:28 +error[E0080]: attempt to compute `u16::MAX * 5_u16`, which would overflow + --> $DIR/overflowing-consts.rs:185:28 | LL | const _NU16_MUL_P: &u16 = &(u16::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:192:24 +error[E0080]: attempt to compute `u32::MAX * 5_u32`, which would overflow + --> $DIR/overflowing-consts.rs:187:24 | LL | const _NU32_MUL: u32 = u32::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:193:28 +error[E0080]: attempt to compute `u32::MAX * 5_u32`, which would overflow + --> $DIR/overflowing-consts.rs:188:28 | LL | const _NU32_MUL_P: &u32 = &(u32::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:195:24 +error[E0080]: attempt to compute `u64::MAX * 5_u64`, which would overflow + --> $DIR/overflowing-consts.rs:190:24 | LL | const _NU64_MUL: u64 = u64::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:196:28 +error[E0080]: attempt to compute `u64::MAX * 5_u64`, which would overflow + --> $DIR/overflowing-consts.rs:191:28 | LL | const _NU64_MUL_P: &u64 = &(u64::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:198:26 +error[E0080]: attempt to compute `u128::MAX * 5_u128`, which would overflow + --> $DIR/overflowing-consts.rs:193:26 | LL | const _NU128_MUL: u128 = u128::MAX * 5; - | ^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow + | ^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:199:30 +error[E0080]: attempt to compute `u128::MAX * 5_u128`, which would overflow + --> $DIR/overflowing-consts.rs:194:30 | LL | const _NU128_MUL_P: &u128 = &(u128::MAX * 5); - | ^^^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:201:28 +error[E0080]: attempt to compute `isize::MAX * 5_isize`, which would overflow + --> $DIR/overflowing-consts.rs:196:28 | LL | const _NISIZE_MUL: isize = isize::MAX * 5; - | ^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:202:32 +error[E0080]: attempt to compute `isize::MAX * 5_isize`, which would overflow + --> $DIR/overflowing-consts.rs:197:32 | LL | const _NISIZE_MUL_P: &isize = &(isize::MAX * 5); - | ^^^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:204:28 +error[E0080]: attempt to compute `usize::MAX * 5_usize`, which would overflow + --> $DIR/overflowing-consts.rs:199:28 | LL | const _NUSIZE_MUL: usize = usize::MAX * 5; - | ^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:205:32 +error[E0080]: attempt to compute `usize::MAX * 5_usize`, which would overflow + --> $DIR/overflowing-consts.rs:200:32 | LL | const _NUSIZE_MUL_P: &usize = &(usize::MAX * 5); - | ^^^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:209:22 +error[E0080]: attempt to divide `1_i8` by zero + --> $DIR/overflowing-consts.rs:203:22 | LL | const _NI8_DIV: i8 = 1i8 / 0; - | ^^^^^^^ attempt to divide `1_i8` by zero + | ^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:210:26 +error[E0080]: attempt to divide `1_i8` by zero + --> $DIR/overflowing-consts.rs:204:26 | LL | const _NI8_DIV_P: &i8 = &(1i8 / 0); - | ^^^^^^^^^ attempt to divide `1_i8` by zero + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:212:24 +error[E0080]: attempt to divide `1_i16` by zero + --> $DIR/overflowing-consts.rs:206:24 | LL | const _NI16_DIV: i16 = 1i16 / 0; - | ^^^^^^^^ attempt to divide `1_i16` by zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:213:28 +error[E0080]: attempt to divide `1_i16` by zero + --> $DIR/overflowing-consts.rs:207:28 | LL | const _NI16_DIV_P: &i16 = &(1i16 / 0); - | ^^^^^^^^^^ attempt to divide `1_i16` by zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:215:24 +error[E0080]: attempt to divide `1_i32` by zero + --> $DIR/overflowing-consts.rs:209:24 | LL | const _NI32_DIV: i32 = 1i32 / 0; - | ^^^^^^^^ attempt to divide `1_i32` by zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:216:28 +error[E0080]: attempt to divide `1_i32` by zero + --> $DIR/overflowing-consts.rs:210:28 | LL | const _NI32_DIV_P: &i32 = &(1i32 / 0); - | ^^^^^^^^^^ attempt to divide `1_i32` by zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:218:24 +error[E0080]: attempt to divide `1_i64` by zero + --> $DIR/overflowing-consts.rs:212:24 | LL | const _NI64_DIV: i64 = 1i64 / 0; - | ^^^^^^^^ attempt to divide `1_i64` by zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:219:28 +error[E0080]: attempt to divide `1_i64` by zero + --> $DIR/overflowing-consts.rs:213:28 | LL | const _NI64_DIV_P: &i64 = &(1i64 / 0); - | ^^^^^^^^^^ attempt to divide `1_i64` by zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:221:26 +error[E0080]: attempt to divide `1_i128` by zero + --> $DIR/overflowing-consts.rs:215:26 | LL | const _NI128_DIV: i128 = 1i128 / 0; - | ^^^^^^^^^ attempt to divide `1_i128` by zero + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:222:30 +error[E0080]: attempt to divide `1_i128` by zero + --> $DIR/overflowing-consts.rs:216:30 | LL | const _NI128_DIV_P: &i128 = &(1i128 / 0); - | ^^^^^^^^^^^ attempt to divide `1_i128` by zero + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:224:22 +error[E0080]: attempt to divide `1_u8` by zero + --> $DIR/overflowing-consts.rs:218:22 | LL | const _NU8_DIV: u8 = 1u8 / 0; - | ^^^^^^^ attempt to divide `1_u8` by zero + | ^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:225:26 +error[E0080]: attempt to divide `1_u8` by zero + --> $DIR/overflowing-consts.rs:219:26 | LL | const _NU8_DIV_P: &u8 = &(1u8 / 0); - | ^^^^^^^^^ attempt to divide `1_u8` by zero + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:227:24 +error[E0080]: attempt to divide `1_u16` by zero + --> $DIR/overflowing-consts.rs:221:24 | LL | const _NU16_DIV: u16 = 1u16 / 0; - | ^^^^^^^^ attempt to divide `1_u16` by zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:228:28 +error[E0080]: attempt to divide `1_u16` by zero + --> $DIR/overflowing-consts.rs:222:28 | LL | const _NU16_DIV_P: &u16 = &(1u16 / 0); - | ^^^^^^^^^^ attempt to divide `1_u16` by zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:230:24 +error[E0080]: attempt to divide `1_u32` by zero + --> $DIR/overflowing-consts.rs:224:24 | LL | const _NU32_DIV: u32 = 1u32 / 0; - | ^^^^^^^^ attempt to divide `1_u32` by zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:231:28 +error[E0080]: attempt to divide `1_u32` by zero + --> $DIR/overflowing-consts.rs:225:28 | LL | const _NU32_DIV_P: &u32 = &(1u32 / 0); - | ^^^^^^^^^^ attempt to divide `1_u32` by zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:233:24 +error[E0080]: attempt to divide `1_u64` by zero + --> $DIR/overflowing-consts.rs:227:24 | LL | const _NU64_DIV: u64 = 1u64 / 0; - | ^^^^^^^^ attempt to divide `1_u64` by zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:234:28 +error[E0080]: attempt to divide `1_u64` by zero + --> $DIR/overflowing-consts.rs:228:28 | LL | const _NU64_DIV_P: &u64 = &(1u64 / 0); - | ^^^^^^^^^^ attempt to divide `1_u64` by zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:236:26 +error[E0080]: attempt to divide `1_u128` by zero + --> $DIR/overflowing-consts.rs:230:26 | LL | const _NU128_DIV: u128 = 1u128 / 0; - | ^^^^^^^^^ attempt to divide `1_u128` by zero + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:237:30 +error[E0080]: attempt to divide `1_u128` by zero + --> $DIR/overflowing-consts.rs:231:30 | LL | const _NU128_DIV_P: &u128 = &(1u128 / 0); - | ^^^^^^^^^^^ attempt to divide `1_u128` by zero + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:239:28 +error[E0080]: attempt to divide `1_isize` by zero + --> $DIR/overflowing-consts.rs:233:28 | LL | const _NISIZE_DIV: isize = 1isize / 0; - | ^^^^^^^^^^ attempt to divide `1_isize` by zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:240:32 +error[E0080]: attempt to divide `1_isize` by zero + --> $DIR/overflowing-consts.rs:234:32 | LL | const _NISIZE_DIV_P: &isize = &(1isize / 0); - | ^^^^^^^^^^^^ attempt to divide `1_isize` by zero + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:242:28 +error[E0080]: attempt to divide `1_usize` by zero + --> $DIR/overflowing-consts.rs:236:28 | LL | const _NUSIZE_DIV: usize = 1usize / 0; - | ^^^^^^^^^^ attempt to divide `1_usize` by zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:243:32 +error[E0080]: attempt to divide `1_usize` by zero + --> $DIR/overflowing-consts.rs:237:32 | LL | const _NUSIZE_DIV_P: &usize = &(1usize / 0); - | ^^^^^^^^^^^^ attempt to divide `1_usize` by zero + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:246:22 +error[E0080]: attempt to calculate the remainder of `1_i8` with a divisor of zero + --> $DIR/overflowing-consts.rs:240:22 | LL | const _NI8_MOD: i8 = 1i8 % 0; - | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero + | ^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:247:26 +error[E0080]: attempt to calculate the remainder of `1_i8` with a divisor of zero + --> $DIR/overflowing-consts.rs:241:26 | LL | const _NI8_MOD_P: &i8 = &(1i8 % 0); - | ^^^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:249:24 +error[E0080]: attempt to calculate the remainder of `1_i16` with a divisor of zero + --> $DIR/overflowing-consts.rs:243:24 | LL | const _NI16_MOD: i16 = 1i16 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:250:28 +error[E0080]: attempt to calculate the remainder of `1_i16` with a divisor of zero + --> $DIR/overflowing-consts.rs:244:28 | LL | const _NI16_MOD_P: &i16 = &(1i16 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:252:24 +error[E0080]: attempt to calculate the remainder of `1_i32` with a divisor of zero + --> $DIR/overflowing-consts.rs:246:24 | LL | const _NI32_MOD: i32 = 1i32 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:253:28 +error[E0080]: attempt to calculate the remainder of `1_i32` with a divisor of zero + --> $DIR/overflowing-consts.rs:247:28 | LL | const _NI32_MOD_P: &i32 = &(1i32 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:255:24 +error[E0080]: attempt to calculate the remainder of `1_i64` with a divisor of zero + --> $DIR/overflowing-consts.rs:249:24 | LL | const _NI64_MOD: i64 = 1i64 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:256:28 +error[E0080]: attempt to calculate the remainder of `1_i64` with a divisor of zero + --> $DIR/overflowing-consts.rs:250:28 | LL | const _NI64_MOD_P: &i64 = &(1i64 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:258:26 +error[E0080]: attempt to calculate the remainder of `1_i128` with a divisor of zero + --> $DIR/overflowing-consts.rs:252:26 | LL | const _NI128_MOD: i128 = 1i128 % 0; - | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:259:30 +error[E0080]: attempt to calculate the remainder of `1_i128` with a divisor of zero + --> $DIR/overflowing-consts.rs:253:30 | LL | const _NI128_MOD_P: &i128 = &(1i128 % 0); - | ^^^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:261:22 +error[E0080]: attempt to calculate the remainder of `1_u8` with a divisor of zero + --> $DIR/overflowing-consts.rs:255:22 | LL | const _NU8_MOD: u8 = 1u8 % 0; - | ^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero + | ^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:262:26 +error[E0080]: attempt to calculate the remainder of `1_u8` with a divisor of zero + --> $DIR/overflowing-consts.rs:256:26 | LL | const _NU8_MOD_P: &u8 = &(1u8 % 0); - | ^^^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:264:24 +error[E0080]: attempt to calculate the remainder of `1_u16` with a divisor of zero + --> $DIR/overflowing-consts.rs:258:24 | LL | const _NU16_MOD: u16 = 1u16 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:265:28 +error[E0080]: attempt to calculate the remainder of `1_u16` with a divisor of zero + --> $DIR/overflowing-consts.rs:259:28 | LL | const _NU16_MOD_P: &u16 = &(1u16 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:267:24 +error[E0080]: attempt to calculate the remainder of `1_u32` with a divisor of zero + --> $DIR/overflowing-consts.rs:261:24 | LL | const _NU32_MOD: u32 = 1u32 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:268:28 +error[E0080]: attempt to calculate the remainder of `1_u32` with a divisor of zero + --> $DIR/overflowing-consts.rs:262:28 | LL | const _NU32_MOD_P: &u32 = &(1u32 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:270:24 +error[E0080]: attempt to calculate the remainder of `1_u64` with a divisor of zero + --> $DIR/overflowing-consts.rs:264:24 | LL | const _NU64_MOD: u64 = 1u64 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:271:28 +error[E0080]: attempt to calculate the remainder of `1_u64` with a divisor of zero + --> $DIR/overflowing-consts.rs:265:28 | LL | const _NU64_MOD_P: &u64 = &(1u64 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:273:26 +error[E0080]: attempt to calculate the remainder of `1_u128` with a divisor of zero + --> $DIR/overflowing-consts.rs:267:26 | LL | const _NU128_MOD: u128 = 1u128 % 0; - | ^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:274:30 +error[E0080]: attempt to calculate the remainder of `1_u128` with a divisor of zero + --> $DIR/overflowing-consts.rs:268:30 | LL | const _NU128_MOD_P: &u128 = &(1u128 % 0); - | ^^^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:276:28 +error[E0080]: attempt to calculate the remainder of `1_isize` with a divisor of zero + --> $DIR/overflowing-consts.rs:270:28 | LL | const _NISIZE_MOD: isize = 1isize % 0; - | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:277:32 +error[E0080]: attempt to calculate the remainder of `1_isize` with a divisor of zero + --> $DIR/overflowing-consts.rs:271:32 | LL | const _NISIZE_MOD_P: &isize = &(1isize % 0); - | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:279:28 +error[E0080]: attempt to calculate the remainder of `1_usize` with a divisor of zero + --> $DIR/overflowing-consts.rs:273:28 | LL | const _NUSIZE_MOD: usize = 1usize % 0; - | ^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:280:32 +error[E0080]: attempt to calculate the remainder of `1_usize` with a divisor of zero + --> $DIR/overflowing-consts.rs:274:32 | LL | const _NUSIZE_MOD_P: &usize = &(1usize % 0); - | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:284:24 +error[E0080]: index out of bounds: the length is 3 but the index is 4 + --> $DIR/overflowing-consts.rs:277:24 | LL | const _NI32_OOB: i32 = [1, 2, 3][4]; - | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:285:28 +error[E0080]: index out of bounds: the length is 3 but the index is 4 + --> $DIR/overflowing-consts.rs:278:28 | LL | const _NI32_OOB_P: &i32 = &([1, 2, 3][4]); - | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + | ^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 170 previous errors diff --git a/tests/ui/consts/overflowing-consts.opt_with_overflow_checks.stderr b/tests/ui/consts/overflowing-consts.opt_with_overflow_checks.stderr index 81f22944adbe7..e317060a14148 100644 --- a/tests/ui/consts/overflowing-consts.opt_with_overflow_checks.stderr +++ b/tests/ui/consts/overflowing-consts.opt_with_overflow_checks.stderr @@ -1,1022 +1,1022 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:19:22 +error[E0080]: attempt to shift left by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:18:22 | LL | const _NI8_SHL: i8 = 1i8 << 8; - | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:20:26 +error[E0080]: attempt to shift left by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:19:26 | LL | const _NI8_SHL_P: &i8 = &(1i8 << 8); - | ^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:22:24 +error[E0080]: attempt to shift left by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:21:24 | LL | const _NI16_SHL: i16 = 1i16 << 16; - | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:23:28 +error[E0080]: attempt to shift left by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:22:28 | LL | const _NI16_SHL_P: &i16 = &(1i16 << 16); - | ^^^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:25:24 +error[E0080]: attempt to shift left by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:24:24 | LL | const _NI32_SHL: i32 = 1i32 << 32; - | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:26:28 +error[E0080]: attempt to shift left by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:25:28 | LL | const _NI32_SHL_P: &i32 = &(1i32 << 32); - | ^^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:28:24 +error[E0080]: attempt to shift left by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:27:24 | LL | const _NI64_SHL: i64 = 1i64 << 64; - | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:29:28 +error[E0080]: attempt to shift left by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:28:28 | LL | const _NI64_SHL_P: &i64 = &(1i64 << 64); - | ^^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:31:26 +error[E0080]: attempt to shift left by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:30:26 | LL | const _NI128_SHL: i128 = 1i128 << 128; - | ^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:32:30 +error[E0080]: attempt to shift left by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:31:30 | LL | const _NI128_SHL_P: &i128 = &(1i128 << 128); - | ^^^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:34:22 +error[E0080]: attempt to shift left by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:33:22 | LL | const _NU8_SHL: u8 = 1u8 << 8; - | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:35:26 +error[E0080]: attempt to shift left by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:34:26 | LL | const _NU8_SHL_P: &u8 = &(1u8 << 8); - | ^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:37:24 +error[E0080]: attempt to shift left by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:36:24 | LL | const _NU16_SHL: u16 = 1u16 << 16; - | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:38:28 +error[E0080]: attempt to shift left by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:37:28 | LL | const _NU16_SHL_P: &u16 = &(1u16 << 16); - | ^^^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:40:24 +error[E0080]: attempt to shift left by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:39:24 | LL | const _NU32_SHL: u32 = 1u32 << 32; - | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:41:28 +error[E0080]: attempt to shift left by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:40:28 | LL | const _NU32_SHL_P: &u32 = &(1u32 << 32); - | ^^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:43:24 +error[E0080]: attempt to shift left by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:42:24 | LL | const _NU64_SHL: u64 = 1u64 << 64; - | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:44:28 +error[E0080]: attempt to shift left by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:43:28 | LL | const _NU64_SHL_P: &u64 = &(1u64 << 64); - | ^^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:46:26 +error[E0080]: attempt to shift left by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:45:26 | LL | const _NU128_SHL: u128 = 1u128 << 128; - | ^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:47:30 +error[E0080]: attempt to shift left by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:46:30 | LL | const _NU128_SHL_P: &u128 = &(1u128 << 128); - | ^^^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:49:28 +error[E0080]: attempt to shift left by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:48:28 | LL | const _NISIZE_SHL: isize = 1isize << BITS; - | ^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:50:32 +error[E0080]: attempt to shift left by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:49:32 | LL | const _NISIZE_SHL_P: &isize = &(1isize << BITS); - | ^^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:52:28 +error[E0080]: attempt to shift left by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:51:28 | LL | const _NUSIZE_SHL: usize = 1usize << BITS; - | ^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:53:32 +error[E0080]: attempt to shift left by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:52:32 | LL | const _NUSIZE_SHL_P: &usize = &(1usize << BITS); - | ^^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:57:22 +error[E0080]: attempt to shift right by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:55:22 | LL | const _NI8_SHR: i8 = 1i8 >> 8; - | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:58:26 +error[E0080]: attempt to shift right by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:56:26 | LL | const _NI8_SHR_P: &i8 = &(1i8 >> 8); - | ^^^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:60:24 +error[E0080]: attempt to shift right by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:58:24 | LL | const _NI16_SHR: i16 = 1i16 >> 16; - | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:61:28 +error[E0080]: attempt to shift right by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:59:28 | LL | const _NI16_SHR_P: &i16 = &(1i16 >> 16); - | ^^^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:63:24 +error[E0080]: attempt to shift right by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:61:24 | LL | const _NI32_SHR: i32 = 1i32 >> 32; - | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:64:28 +error[E0080]: attempt to shift right by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:62:28 | LL | const _NI32_SHR_P: &i32 = &(1i32 >> 32); - | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:66:24 +error[E0080]: attempt to shift right by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:64:24 | LL | const _NI64_SHR: i64 = 1i64 >> 64; - | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:67:28 +error[E0080]: attempt to shift right by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:65:28 | LL | const _NI64_SHR_P: &i64 = &(1i64 >> 64); - | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:69:26 +error[E0080]: attempt to shift right by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:67:26 | LL | const _NI128_SHR: i128 = 1i128 >> 128; - | ^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:70:30 +error[E0080]: attempt to shift right by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:68:30 | LL | const _NI128_SHR_P: &i128 = &(1i128 >> 128); - | ^^^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:72:22 +error[E0080]: attempt to shift right by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:70:22 | LL | const _NU8_SHR: u8 = 1u8 >> 8; - | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:73:26 +error[E0080]: attempt to shift right by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:71:26 | LL | const _NU8_SHR_P: &u8 = &(1u8 >> 8); - | ^^^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:75:24 +error[E0080]: attempt to shift right by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:73:24 | LL | const _NU16_SHR: u16 = 1u16 >> 16; - | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:76:28 +error[E0080]: attempt to shift right by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:74:28 | LL | const _NU16_SHR_P: &u16 = &(1u16 >> 16); - | ^^^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:78:24 +error[E0080]: attempt to shift right by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:76:24 | LL | const _NU32_SHR: u32 = 1u32 >> 32; - | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:79:28 +error[E0080]: attempt to shift right by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:77:28 | LL | const _NU32_SHR_P: &u32 = &(1u32 >> 32); - | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:81:24 +error[E0080]: attempt to shift right by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:79:24 | LL | const _NU64_SHR: u64 = 1u64 >> 64; - | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:82:28 +error[E0080]: attempt to shift right by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:80:28 | LL | const _NU64_SHR_P: &u64 = &(1u64 >> 64); - | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:84:26 +error[E0080]: attempt to shift right by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:82:26 | LL | const _NU128_SHR: u128 = 1u128 >> 128; - | ^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:85:30 +error[E0080]: attempt to shift right by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:83:30 | LL | const _NU128_SHR_P: &u128 = &(1u128 >> 128); - | ^^^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:87:28 +error[E0080]: attempt to shift right by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:85:28 | LL | const _NISIZE_SHR: isize = 1isize >> BITS; - | ^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:88:32 +error[E0080]: attempt to shift right by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:86:32 | LL | const _NISIZE_SHR_P: &isize = &(1isize >> BITS); - | ^^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:90:28 +error[E0080]: attempt to shift right by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:88:28 | LL | const _NUSIZE_SHR: usize = 1usize >> BITS; - | ^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:91:32 +error[E0080]: attempt to shift right by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:89:32 | LL | const _NUSIZE_SHR_P: &usize = &(1usize >> BITS); - | ^^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:95:22 +error[E0080]: attempt to compute `1_i8 + i8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:92:22 | LL | const _NI8_ADD: i8 = 1i8 + i8::MAX; - | ^^^^^^^^^^^^^ attempt to compute `1_i8 + i8::MAX`, which would overflow + | ^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:96:26 +error[E0080]: attempt to compute `1_i8 + i8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:93:26 | LL | const _NI8_ADD_P: &i8 = &(1i8 + i8::MAX); - | ^^^^^^^^^^^^^^^ attempt to compute `1_i8 + i8::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:98:24 +error[E0080]: attempt to compute `1_i16 + i16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:95:24 | LL | const _NI16_ADD: i16 = 1i16 + i16::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_i16 + i16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:99:28 +error[E0080]: attempt to compute `1_i16 + i16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:96:28 | LL | const _NI16_ADD_P: &i16 = &(1i16 + i16::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i16 + i16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:101:24 +error[E0080]: attempt to compute `1_i32 + i32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:98:24 | LL | const _NI32_ADD: i32 = 1i32 + i32::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:102:28 +error[E0080]: attempt to compute `1_i32 + i32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:99:28 | LL | const _NI32_ADD_P: &i32 = &(1i32 + i32::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:104:24 +error[E0080]: attempt to compute `1_i64 + i64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:101:24 | LL | const _NI64_ADD: i64 = 1i64 + i64::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_i64 + i64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:105:28 +error[E0080]: attempt to compute `1_i64 + i64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:102:28 | LL | const _NI64_ADD_P: &i64 = &(1i64 + i64::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i64 + i64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:107:26 +error[E0080]: attempt to compute `1_i128 + i128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:104:26 | LL | const _NI128_ADD: i128 = 1i128 + i128::MAX; - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i128 + i128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:108:30 +error[E0080]: attempt to compute `1_i128 + i128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:105:30 | LL | const _NI128_ADD_P: &i128 = &(1i128 + i128::MAX); - | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_i128 + i128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:110:22 +error[E0080]: attempt to compute `1_u8 + u8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:107:22 | LL | const _NU8_ADD: u8 = 1u8 + u8::MAX; - | ^^^^^^^^^^^^^ attempt to compute `1_u8 + u8::MAX`, which would overflow + | ^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:111:26 +error[E0080]: attempt to compute `1_u8 + u8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:108:26 | LL | const _NU8_ADD_P: &u8 = &(1u8 + u8::MAX); - | ^^^^^^^^^^^^^^^ attempt to compute `1_u8 + u8::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:113:24 +error[E0080]: attempt to compute `1_u16 + u16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:110:24 | LL | const _NU16_ADD: u16 = 1u16 + u16::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_u16 + u16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:114:28 +error[E0080]: attempt to compute `1_u16 + u16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:111:28 | LL | const _NU16_ADD_P: &u16 = &(1u16 + u16::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u16 + u16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:116:24 +error[E0080]: attempt to compute `1_u32 + u32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:113:24 | LL | const _NU32_ADD: u32 = 1u32 + u32::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_u32 + u32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:117:28 +error[E0080]: attempt to compute `1_u32 + u32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:114:28 | LL | const _NU32_ADD_P: &u32 = &(1u32 + u32::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u32 + u32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:119:24 +error[E0080]: attempt to compute `1_u64 + u64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:116:24 | LL | const _NU64_ADD: u64 = 1u64 + u64::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_u64 + u64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:120:28 +error[E0080]: attempt to compute `1_u64 + u64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:117:28 | LL | const _NU64_ADD_P: &u64 = &(1u64 + u64::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u64 + u64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:122:26 +error[E0080]: attempt to compute `1_u128 + u128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:119:26 | LL | const _NU128_ADD: u128 = 1u128 + u128::MAX; - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u128 + u128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:123:30 +error[E0080]: attempt to compute `1_u128 + u128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:120:30 | LL | const _NU128_ADD_P: &u128 = &(1u128 + u128::MAX); - | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_u128 + u128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:125:28 +error[E0080]: attempt to compute `1_isize + isize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:122:28 | LL | const _NISIZE_ADD: isize = 1isize + isize::MAX; - | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_isize + isize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:126:32 +error[E0080]: attempt to compute `1_isize + isize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:123:32 | LL | const _NISIZE_ADD_P: &isize = &(1isize + isize::MAX); - | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_isize + isize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:128:28 +error[E0080]: attempt to compute `1_usize + usize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:125:28 | LL | const _NUSIZE_ADD: usize = 1usize + usize::MAX; - | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize + usize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:129:32 +error[E0080]: attempt to compute `1_usize + usize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:126:32 | LL | const _NUSIZE_ADD_P: &usize = &(1usize + usize::MAX); - | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize + usize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:133:22 +error[E0080]: attempt to compute `-5_i8 - i8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:129:22 | LL | const _NI8_SUB: i8 = -5i8 - i8::MAX; - | ^^^^^^^^^^^^^^ attempt to compute `-5_i8 - i8::MAX`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:134:26 +error[E0080]: attempt to compute `-5_i8 - i8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:130:26 | LL | const _NI8_SUB_P: &i8 = &(-5i8 - i8::MAX); - | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i8 - i8::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:136:24 +error[E0080]: attempt to compute `-5_i16 - i16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:132:24 | LL | const _NI16_SUB: i16 = -5i16 - i16::MAX; - | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i16 - i16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:137:28 +error[E0080]: attempt to compute `-5_i16 - i16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:133:28 | LL | const _NI16_SUB_P: &i16 = &(-5i16 - i16::MAX); - | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i16 - i16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:139:24 +error[E0080]: attempt to compute `-5_i32 - i32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:135:24 | LL | const _NI32_SUB: i32 = -5i32 - i32::MAX; - | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:140:28 +error[E0080]: attempt to compute `-5_i32 - i32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:136:28 | LL | const _NI32_SUB_P: &i32 = &(-5i32 - i32::MAX); - | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:142:24 +error[E0080]: attempt to compute `-5_i64 - i64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:138:24 | LL | const _NI64_SUB: i64 = -5i64 - i64::MAX; - | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i64 - i64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:143:28 +error[E0080]: attempt to compute `-5_i64 - i64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:139:28 | LL | const _NI64_SUB_P: &i64 = &(-5i64 - i64::MAX); - | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i64 - i64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:145:26 +error[E0080]: attempt to compute `-5_i128 - i128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:141:26 | LL | const _NI128_SUB: i128 = -5i128 - i128::MAX; - | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i128 - i128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:146:30 +error[E0080]: attempt to compute `-5_i128 - i128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:142:30 | LL | const _NI128_SUB_P: &i128 = &(-5i128 - i128::MAX); - | ^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i128 - i128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:148:22 +error[E0080]: attempt to compute `1_u8 - 5_u8`, which would overflow + --> $DIR/overflowing-consts.rs:144:22 | LL | const _NU8_SUB: u8 = 1u8 - 5; - | ^^^^^^^ attempt to compute `1_u8 - 5_u8`, which would overflow + | ^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:149:26 +error[E0080]: attempt to compute `1_u8 - 5_u8`, which would overflow + --> $DIR/overflowing-consts.rs:145:26 | LL | const _NU8_SUB_P: &u8 = &(1u8 - 5); - | ^^^^^^^^^ attempt to compute `1_u8 - 5_u8`, which would overflow + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:151:24 +error[E0080]: attempt to compute `1_u16 - 5_u16`, which would overflow + --> $DIR/overflowing-consts.rs:147:24 | LL | const _NU16_SUB: u16 = 1u16 - 5; - | ^^^^^^^^ attempt to compute `1_u16 - 5_u16`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:152:28 +error[E0080]: attempt to compute `1_u16 - 5_u16`, which would overflow + --> $DIR/overflowing-consts.rs:148:28 | LL | const _NU16_SUB_P: &u16 = &(1u16 - 5); - | ^^^^^^^^^^ attempt to compute `1_u16 - 5_u16`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:154:24 +error[E0080]: attempt to compute `1_u32 - 5_u32`, which would overflow + --> $DIR/overflowing-consts.rs:150:24 | LL | const _NU32_SUB: u32 = 1u32 - 5; - | ^^^^^^^^ attempt to compute `1_u32 - 5_u32`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:155:28 +error[E0080]: attempt to compute `1_u32 - 5_u32`, which would overflow + --> $DIR/overflowing-consts.rs:151:28 | LL | const _NU32_SUB_P: &u32 = &(1u32 - 5); - | ^^^^^^^^^^ attempt to compute `1_u32 - 5_u32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:157:24 +error[E0080]: attempt to compute `1_u64 - 5_u64`, which would overflow + --> $DIR/overflowing-consts.rs:153:24 | LL | const _NU64_SUB: u64 = 1u64 - 5; - | ^^^^^^^^ attempt to compute `1_u64 - 5_u64`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:158:28 +error[E0080]: attempt to compute `1_u64 - 5_u64`, which would overflow + --> $DIR/overflowing-consts.rs:154:28 | LL | const _NU64_SUB_P: &u64 = &(1u64 - 5); - | ^^^^^^^^^^ attempt to compute `1_u64 - 5_u64`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:160:26 +error[E0080]: attempt to compute `1_u128 - 5_u128`, which would overflow + --> $DIR/overflowing-consts.rs:156:26 | LL | const _NU128_SUB: u128 = 1u128 - 5; - | ^^^^^^^^^ attempt to compute `1_u128 - 5_u128`, which would overflow + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:161:30 +error[E0080]: attempt to compute `1_u128 - 5_u128`, which would overflow + --> $DIR/overflowing-consts.rs:157:30 | LL | const _NU128_SUB_P: &u128 = &(1u128 - 5); - | ^^^^^^^^^^^ attempt to compute `1_u128 - 5_u128`, which would overflow + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:163:28 +error[E0080]: attempt to compute `-5_isize - isize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:159:28 | LL | const _NISIZE_SUB: isize = -5isize - isize::MAX; - | ^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_isize - isize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:164:32 +error[E0080]: attempt to compute `-5_isize - isize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:160:32 | LL | const _NISIZE_SUB_P: &isize = &(-5isize - isize::MAX); - | ^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_isize - isize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:166:28 +error[E0080]: attempt to compute `1_usize - 5_usize`, which would overflow + --> $DIR/overflowing-consts.rs:162:28 | -LL | const _NUSIZE_SUB: usize = 1usize - 5 ; - | ^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow +LL | const _NUSIZE_SUB: usize = 1usize - 5; + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:167:32 +error[E0080]: attempt to compute `1_usize - 5_usize`, which would overflow + --> $DIR/overflowing-consts.rs:163:32 | -LL | const _NUSIZE_SUB_P: &usize = &(1usize - 5 ); - | ^^^^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow +LL | const _NUSIZE_SUB_P: &usize = &(1usize - 5); + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:171:22 +error[E0080]: attempt to compute `i8::MAX * 5_i8`, which would overflow + --> $DIR/overflowing-consts.rs:166:22 | LL | const _NI8_MUL: i8 = i8::MAX * 5; - | ^^^^^^^^^^^ attempt to compute `i8::MAX * 5_i8`, which would overflow + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:172:26 +error[E0080]: attempt to compute `i8::MAX * 5_i8`, which would overflow + --> $DIR/overflowing-consts.rs:167:26 | LL | const _NI8_MUL_P: &i8 = &(i8::MAX * 5); - | ^^^^^^^^^^^^^ attempt to compute `i8::MAX * 5_i8`, which would overflow + | ^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:174:24 +error[E0080]: attempt to compute `i16::MAX * 5_i16`, which would overflow + --> $DIR/overflowing-consts.rs:169:24 | LL | const _NI16_MUL: i16 = i16::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:175:28 +error[E0080]: attempt to compute `i16::MAX * 5_i16`, which would overflow + --> $DIR/overflowing-consts.rs:170:28 | LL | const _NI16_MUL_P: &i16 = &(i16::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:177:24 +error[E0080]: attempt to compute `i32::MAX * 5_i32`, which would overflow + --> $DIR/overflowing-consts.rs:172:24 | LL | const _NI32_MUL: i32 = i32::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:178:28 +error[E0080]: attempt to compute `i32::MAX * 5_i32`, which would overflow + --> $DIR/overflowing-consts.rs:173:28 | LL | const _NI32_MUL_P: &i32 = &(i32::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:180:24 +error[E0080]: attempt to compute `i64::MAX * 5_i64`, which would overflow + --> $DIR/overflowing-consts.rs:175:24 | LL | const _NI64_MUL: i64 = i64::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:181:28 +error[E0080]: attempt to compute `i64::MAX * 5_i64`, which would overflow + --> $DIR/overflowing-consts.rs:176:28 | LL | const _NI64_MUL_P: &i64 = &(i64::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:183:26 +error[E0080]: attempt to compute `i128::MAX * 5_i128`, which would overflow + --> $DIR/overflowing-consts.rs:178:26 | LL | const _NI128_MUL: i128 = i128::MAX * 5; - | ^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow + | ^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:184:30 +error[E0080]: attempt to compute `i128::MAX * 5_i128`, which would overflow + --> $DIR/overflowing-consts.rs:179:30 | LL | const _NI128_MUL_P: &i128 = &(i128::MAX * 5); - | ^^^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:186:22 +error[E0080]: attempt to compute `u8::MAX * 5_u8`, which would overflow + --> $DIR/overflowing-consts.rs:181:22 | LL | const _NU8_MUL: u8 = u8::MAX * 5; - | ^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:187:26 +error[E0080]: attempt to compute `u8::MAX * 5_u8`, which would overflow + --> $DIR/overflowing-consts.rs:182:26 | LL | const _NU8_MUL_P: &u8 = &(u8::MAX * 5); - | ^^^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow + | ^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:189:24 +error[E0080]: attempt to compute `u16::MAX * 5_u16`, which would overflow + --> $DIR/overflowing-consts.rs:184:24 | LL | const _NU16_MUL: u16 = u16::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:190:28 +error[E0080]: attempt to compute `u16::MAX * 5_u16`, which would overflow + --> $DIR/overflowing-consts.rs:185:28 | LL | const _NU16_MUL_P: &u16 = &(u16::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:192:24 +error[E0080]: attempt to compute `u32::MAX * 5_u32`, which would overflow + --> $DIR/overflowing-consts.rs:187:24 | LL | const _NU32_MUL: u32 = u32::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:193:28 +error[E0080]: attempt to compute `u32::MAX * 5_u32`, which would overflow + --> $DIR/overflowing-consts.rs:188:28 | LL | const _NU32_MUL_P: &u32 = &(u32::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:195:24 +error[E0080]: attempt to compute `u64::MAX * 5_u64`, which would overflow + --> $DIR/overflowing-consts.rs:190:24 | LL | const _NU64_MUL: u64 = u64::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:196:28 +error[E0080]: attempt to compute `u64::MAX * 5_u64`, which would overflow + --> $DIR/overflowing-consts.rs:191:28 | LL | const _NU64_MUL_P: &u64 = &(u64::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:198:26 +error[E0080]: attempt to compute `u128::MAX * 5_u128`, which would overflow + --> $DIR/overflowing-consts.rs:193:26 | LL | const _NU128_MUL: u128 = u128::MAX * 5; - | ^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow + | ^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:199:30 +error[E0080]: attempt to compute `u128::MAX * 5_u128`, which would overflow + --> $DIR/overflowing-consts.rs:194:30 | LL | const _NU128_MUL_P: &u128 = &(u128::MAX * 5); - | ^^^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:201:28 +error[E0080]: attempt to compute `isize::MAX * 5_isize`, which would overflow + --> $DIR/overflowing-consts.rs:196:28 | LL | const _NISIZE_MUL: isize = isize::MAX * 5; - | ^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:202:32 +error[E0080]: attempt to compute `isize::MAX * 5_isize`, which would overflow + --> $DIR/overflowing-consts.rs:197:32 | LL | const _NISIZE_MUL_P: &isize = &(isize::MAX * 5); - | ^^^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:204:28 +error[E0080]: attempt to compute `usize::MAX * 5_usize`, which would overflow + --> $DIR/overflowing-consts.rs:199:28 | LL | const _NUSIZE_MUL: usize = usize::MAX * 5; - | ^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:205:32 +error[E0080]: attempt to compute `usize::MAX * 5_usize`, which would overflow + --> $DIR/overflowing-consts.rs:200:32 | LL | const _NUSIZE_MUL_P: &usize = &(usize::MAX * 5); - | ^^^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:209:22 +error[E0080]: attempt to divide `1_i8` by zero + --> $DIR/overflowing-consts.rs:203:22 | LL | const _NI8_DIV: i8 = 1i8 / 0; - | ^^^^^^^ attempt to divide `1_i8` by zero + | ^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:210:26 +error[E0080]: attempt to divide `1_i8` by zero + --> $DIR/overflowing-consts.rs:204:26 | LL | const _NI8_DIV_P: &i8 = &(1i8 / 0); - | ^^^^^^^^^ attempt to divide `1_i8` by zero + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:212:24 +error[E0080]: attempt to divide `1_i16` by zero + --> $DIR/overflowing-consts.rs:206:24 | LL | const _NI16_DIV: i16 = 1i16 / 0; - | ^^^^^^^^ attempt to divide `1_i16` by zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:213:28 +error[E0080]: attempt to divide `1_i16` by zero + --> $DIR/overflowing-consts.rs:207:28 | LL | const _NI16_DIV_P: &i16 = &(1i16 / 0); - | ^^^^^^^^^^ attempt to divide `1_i16` by zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:215:24 +error[E0080]: attempt to divide `1_i32` by zero + --> $DIR/overflowing-consts.rs:209:24 | LL | const _NI32_DIV: i32 = 1i32 / 0; - | ^^^^^^^^ attempt to divide `1_i32` by zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:216:28 +error[E0080]: attempt to divide `1_i32` by zero + --> $DIR/overflowing-consts.rs:210:28 | LL | const _NI32_DIV_P: &i32 = &(1i32 / 0); - | ^^^^^^^^^^ attempt to divide `1_i32` by zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:218:24 +error[E0080]: attempt to divide `1_i64` by zero + --> $DIR/overflowing-consts.rs:212:24 | LL | const _NI64_DIV: i64 = 1i64 / 0; - | ^^^^^^^^ attempt to divide `1_i64` by zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:219:28 +error[E0080]: attempt to divide `1_i64` by zero + --> $DIR/overflowing-consts.rs:213:28 | LL | const _NI64_DIV_P: &i64 = &(1i64 / 0); - | ^^^^^^^^^^ attempt to divide `1_i64` by zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:221:26 +error[E0080]: attempt to divide `1_i128` by zero + --> $DIR/overflowing-consts.rs:215:26 | LL | const _NI128_DIV: i128 = 1i128 / 0; - | ^^^^^^^^^ attempt to divide `1_i128` by zero + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:222:30 +error[E0080]: attempt to divide `1_i128` by zero + --> $DIR/overflowing-consts.rs:216:30 | LL | const _NI128_DIV_P: &i128 = &(1i128 / 0); - | ^^^^^^^^^^^ attempt to divide `1_i128` by zero + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:224:22 +error[E0080]: attempt to divide `1_u8` by zero + --> $DIR/overflowing-consts.rs:218:22 | LL | const _NU8_DIV: u8 = 1u8 / 0; - | ^^^^^^^ attempt to divide `1_u8` by zero + | ^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:225:26 +error[E0080]: attempt to divide `1_u8` by zero + --> $DIR/overflowing-consts.rs:219:26 | LL | const _NU8_DIV_P: &u8 = &(1u8 / 0); - | ^^^^^^^^^ attempt to divide `1_u8` by zero + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:227:24 +error[E0080]: attempt to divide `1_u16` by zero + --> $DIR/overflowing-consts.rs:221:24 | LL | const _NU16_DIV: u16 = 1u16 / 0; - | ^^^^^^^^ attempt to divide `1_u16` by zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:228:28 +error[E0080]: attempt to divide `1_u16` by zero + --> $DIR/overflowing-consts.rs:222:28 | LL | const _NU16_DIV_P: &u16 = &(1u16 / 0); - | ^^^^^^^^^^ attempt to divide `1_u16` by zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:230:24 +error[E0080]: attempt to divide `1_u32` by zero + --> $DIR/overflowing-consts.rs:224:24 | LL | const _NU32_DIV: u32 = 1u32 / 0; - | ^^^^^^^^ attempt to divide `1_u32` by zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:231:28 +error[E0080]: attempt to divide `1_u32` by zero + --> $DIR/overflowing-consts.rs:225:28 | LL | const _NU32_DIV_P: &u32 = &(1u32 / 0); - | ^^^^^^^^^^ attempt to divide `1_u32` by zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:233:24 +error[E0080]: attempt to divide `1_u64` by zero + --> $DIR/overflowing-consts.rs:227:24 | LL | const _NU64_DIV: u64 = 1u64 / 0; - | ^^^^^^^^ attempt to divide `1_u64` by zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:234:28 +error[E0080]: attempt to divide `1_u64` by zero + --> $DIR/overflowing-consts.rs:228:28 | LL | const _NU64_DIV_P: &u64 = &(1u64 / 0); - | ^^^^^^^^^^ attempt to divide `1_u64` by zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:236:26 +error[E0080]: attempt to divide `1_u128` by zero + --> $DIR/overflowing-consts.rs:230:26 | LL | const _NU128_DIV: u128 = 1u128 / 0; - | ^^^^^^^^^ attempt to divide `1_u128` by zero + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:237:30 +error[E0080]: attempt to divide `1_u128` by zero + --> $DIR/overflowing-consts.rs:231:30 | LL | const _NU128_DIV_P: &u128 = &(1u128 / 0); - | ^^^^^^^^^^^ attempt to divide `1_u128` by zero + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:239:28 +error[E0080]: attempt to divide `1_isize` by zero + --> $DIR/overflowing-consts.rs:233:28 | LL | const _NISIZE_DIV: isize = 1isize / 0; - | ^^^^^^^^^^ attempt to divide `1_isize` by zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:240:32 +error[E0080]: attempt to divide `1_isize` by zero + --> $DIR/overflowing-consts.rs:234:32 | LL | const _NISIZE_DIV_P: &isize = &(1isize / 0); - | ^^^^^^^^^^^^ attempt to divide `1_isize` by zero + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:242:28 +error[E0080]: attempt to divide `1_usize` by zero + --> $DIR/overflowing-consts.rs:236:28 | LL | const _NUSIZE_DIV: usize = 1usize / 0; - | ^^^^^^^^^^ attempt to divide `1_usize` by zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:243:32 +error[E0080]: attempt to divide `1_usize` by zero + --> $DIR/overflowing-consts.rs:237:32 | LL | const _NUSIZE_DIV_P: &usize = &(1usize / 0); - | ^^^^^^^^^^^^ attempt to divide `1_usize` by zero + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:246:22 +error[E0080]: attempt to calculate the remainder of `1_i8` with a divisor of zero + --> $DIR/overflowing-consts.rs:240:22 | LL | const _NI8_MOD: i8 = 1i8 % 0; - | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero + | ^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:247:26 +error[E0080]: attempt to calculate the remainder of `1_i8` with a divisor of zero + --> $DIR/overflowing-consts.rs:241:26 | LL | const _NI8_MOD_P: &i8 = &(1i8 % 0); - | ^^^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:249:24 +error[E0080]: attempt to calculate the remainder of `1_i16` with a divisor of zero + --> $DIR/overflowing-consts.rs:243:24 | LL | const _NI16_MOD: i16 = 1i16 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:250:28 +error[E0080]: attempt to calculate the remainder of `1_i16` with a divisor of zero + --> $DIR/overflowing-consts.rs:244:28 | LL | const _NI16_MOD_P: &i16 = &(1i16 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:252:24 +error[E0080]: attempt to calculate the remainder of `1_i32` with a divisor of zero + --> $DIR/overflowing-consts.rs:246:24 | LL | const _NI32_MOD: i32 = 1i32 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:253:28 +error[E0080]: attempt to calculate the remainder of `1_i32` with a divisor of zero + --> $DIR/overflowing-consts.rs:247:28 | LL | const _NI32_MOD_P: &i32 = &(1i32 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:255:24 +error[E0080]: attempt to calculate the remainder of `1_i64` with a divisor of zero + --> $DIR/overflowing-consts.rs:249:24 | LL | const _NI64_MOD: i64 = 1i64 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:256:28 +error[E0080]: attempt to calculate the remainder of `1_i64` with a divisor of zero + --> $DIR/overflowing-consts.rs:250:28 | LL | const _NI64_MOD_P: &i64 = &(1i64 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:258:26 +error[E0080]: attempt to calculate the remainder of `1_i128` with a divisor of zero + --> $DIR/overflowing-consts.rs:252:26 | LL | const _NI128_MOD: i128 = 1i128 % 0; - | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:259:30 +error[E0080]: attempt to calculate the remainder of `1_i128` with a divisor of zero + --> $DIR/overflowing-consts.rs:253:30 | LL | const _NI128_MOD_P: &i128 = &(1i128 % 0); - | ^^^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:261:22 +error[E0080]: attempt to calculate the remainder of `1_u8` with a divisor of zero + --> $DIR/overflowing-consts.rs:255:22 | LL | const _NU8_MOD: u8 = 1u8 % 0; - | ^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero + | ^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:262:26 +error[E0080]: attempt to calculate the remainder of `1_u8` with a divisor of zero + --> $DIR/overflowing-consts.rs:256:26 | LL | const _NU8_MOD_P: &u8 = &(1u8 % 0); - | ^^^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:264:24 +error[E0080]: attempt to calculate the remainder of `1_u16` with a divisor of zero + --> $DIR/overflowing-consts.rs:258:24 | LL | const _NU16_MOD: u16 = 1u16 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:265:28 +error[E0080]: attempt to calculate the remainder of `1_u16` with a divisor of zero + --> $DIR/overflowing-consts.rs:259:28 | LL | const _NU16_MOD_P: &u16 = &(1u16 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:267:24 +error[E0080]: attempt to calculate the remainder of `1_u32` with a divisor of zero + --> $DIR/overflowing-consts.rs:261:24 | LL | const _NU32_MOD: u32 = 1u32 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:268:28 +error[E0080]: attempt to calculate the remainder of `1_u32` with a divisor of zero + --> $DIR/overflowing-consts.rs:262:28 | LL | const _NU32_MOD_P: &u32 = &(1u32 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:270:24 +error[E0080]: attempt to calculate the remainder of `1_u64` with a divisor of zero + --> $DIR/overflowing-consts.rs:264:24 | LL | const _NU64_MOD: u64 = 1u64 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:271:28 +error[E0080]: attempt to calculate the remainder of `1_u64` with a divisor of zero + --> $DIR/overflowing-consts.rs:265:28 | LL | const _NU64_MOD_P: &u64 = &(1u64 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:273:26 +error[E0080]: attempt to calculate the remainder of `1_u128` with a divisor of zero + --> $DIR/overflowing-consts.rs:267:26 | LL | const _NU128_MOD: u128 = 1u128 % 0; - | ^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:274:30 +error[E0080]: attempt to calculate the remainder of `1_u128` with a divisor of zero + --> $DIR/overflowing-consts.rs:268:30 | LL | const _NU128_MOD_P: &u128 = &(1u128 % 0); - | ^^^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:276:28 +error[E0080]: attempt to calculate the remainder of `1_isize` with a divisor of zero + --> $DIR/overflowing-consts.rs:270:28 | LL | const _NISIZE_MOD: isize = 1isize % 0; - | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:277:32 +error[E0080]: attempt to calculate the remainder of `1_isize` with a divisor of zero + --> $DIR/overflowing-consts.rs:271:32 | LL | const _NISIZE_MOD_P: &isize = &(1isize % 0); - | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:279:28 +error[E0080]: attempt to calculate the remainder of `1_usize` with a divisor of zero + --> $DIR/overflowing-consts.rs:273:28 | LL | const _NUSIZE_MOD: usize = 1usize % 0; - | ^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:280:32 +error[E0080]: attempt to calculate the remainder of `1_usize` with a divisor of zero + --> $DIR/overflowing-consts.rs:274:32 | LL | const _NUSIZE_MOD_P: &usize = &(1usize % 0); - | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:284:24 +error[E0080]: index out of bounds: the length is 3 but the index is 4 + --> $DIR/overflowing-consts.rs:277:24 | LL | const _NI32_OOB: i32 = [1, 2, 3][4]; - | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:285:28 +error[E0080]: index out of bounds: the length is 3 but the index is 4 + --> $DIR/overflowing-consts.rs:278:28 | LL | const _NI32_OOB_P: &i32 = &([1, 2, 3][4]); - | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + | ^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 170 previous errors diff --git a/tests/ui/consts/overflowing-consts.rs b/tests/ui/consts/overflowing-consts.rs index 5ff205ce58e66..7c008573b87ac 100644 --- a/tests/ui/consts/overflowing-consts.rs +++ b/tests/ui/consts/overflowing-consts.rs @@ -9,280 +9,272 @@ //@ normalize-stderr: "shift left by `(64|32)_usize`, which" -> "shift left by `%BITS%`, which" //@ normalize-stderr: "shift right by `(64|32)_usize`, which" -> "shift right by `%BITS%`, which" - #[cfg(target_pointer_width = "32")] const BITS: usize = 32; #[cfg(target_pointer_width = "64")] const BITS: usize = 64; // Shift left -const _NI8_SHL: i8 = 1i8 << 8; //~ ERROR: evaluation of constant value failed -const _NI8_SHL_P: &i8 = &(1i8 << 8); //~ ERROR: evaluation of constant value failed - -const _NI16_SHL: i16 = 1i16 << 16; //~ ERROR: evaluation of constant value failed -const _NI16_SHL_P: &i16 = &(1i16 << 16); //~ ERROR: evaluation of constant value failed +const _NI8_SHL: i8 = 1i8 << 8; //~ ERROR: overflow +const _NI8_SHL_P: &i8 = &(1i8 << 8); //~ ERROR: overflow -const _NI32_SHL: i32 = 1i32 << 32; //~ ERROR: evaluation of constant value failed -const _NI32_SHL_P: &i32 = &(1i32 << 32); //~ ERROR: evaluation of constant value failed +const _NI16_SHL: i16 = 1i16 << 16; //~ ERROR: overflow +const _NI16_SHL_P: &i16 = &(1i16 << 16); //~ ERROR: overflow -const _NI64_SHL: i64 = 1i64 << 64; //~ ERROR: evaluation of constant value failed -const _NI64_SHL_P: &i64 = &(1i64 << 64); //~ ERROR: evaluation of constant value failed +const _NI32_SHL: i32 = 1i32 << 32; //~ ERROR: overflow +const _NI32_SHL_P: &i32 = &(1i32 << 32); //~ ERROR: overflow -const _NI128_SHL: i128 = 1i128 << 128; //~ ERROR: evaluation of constant value failed -const _NI128_SHL_P: &i128 = &(1i128 << 128); //~ ERROR: evaluation of constant value failed +const _NI64_SHL: i64 = 1i64 << 64; //~ ERROR: overflow +const _NI64_SHL_P: &i64 = &(1i64 << 64); //~ ERROR: overflow -const _NU8_SHL: u8 = 1u8 << 8; //~ ERROR: evaluation of constant value failed -const _NU8_SHL_P: &u8 = &(1u8 << 8); //~ ERROR: evaluation of constant value failed +const _NI128_SHL: i128 = 1i128 << 128; //~ ERROR: overflow +const _NI128_SHL_P: &i128 = &(1i128 << 128); //~ ERROR: overflow -const _NU16_SHL: u16 = 1u16 << 16; //~ ERROR: evaluation of constant value failed -const _NU16_SHL_P: &u16 = &(1u16 << 16); //~ ERROR: evaluation of constant value failed +const _NU8_SHL: u8 = 1u8 << 8; //~ ERROR: overflow +const _NU8_SHL_P: &u8 = &(1u8 << 8); //~ ERROR: overflow -const _NU32_SHL: u32 = 1u32 << 32; //~ ERROR: evaluation of constant value failed -const _NU32_SHL_P: &u32 = &(1u32 << 32); //~ ERROR: evaluation of constant value failed +const _NU16_SHL: u16 = 1u16 << 16; //~ ERROR: overflow +const _NU16_SHL_P: &u16 = &(1u16 << 16); //~ ERROR: overflow -const _NU64_SHL: u64 = 1u64 << 64; //~ ERROR: evaluation of constant value failed -const _NU64_SHL_P: &u64 = &(1u64 << 64); //~ ERROR: evaluation of constant value failed +const _NU32_SHL: u32 = 1u32 << 32; //~ ERROR: overflow +const _NU32_SHL_P: &u32 = &(1u32 << 32); //~ ERROR: overflow -const _NU128_SHL: u128 = 1u128 << 128; //~ ERROR: evaluation of constant value failed -const _NU128_SHL_P: &u128 = &(1u128 << 128); //~ ERROR: evaluation of constant value failed +const _NU64_SHL: u64 = 1u64 << 64; //~ ERROR: overflow +const _NU64_SHL_P: &u64 = &(1u64 << 64); //~ ERROR: overflow -const _NISIZE_SHL: isize = 1isize << BITS; //~ ERROR: evaluation of constant value failed -const _NISIZE_SHL_P: &isize = &(1isize << BITS); //~ ERROR: evaluation of constant value failed +const _NU128_SHL: u128 = 1u128 << 128; //~ ERROR: overflow +const _NU128_SHL_P: &u128 = &(1u128 << 128); //~ ERROR: overflow -const _NUSIZE_SHL: usize = 1usize << BITS; //~ ERROR: evaluation of constant value failed -const _NUSIZE_SHL_P: &usize = &(1usize << BITS); //~ ERROR: evaluation of constant value failed +const _NISIZE_SHL: isize = 1isize << BITS; //~ ERROR: overflow +const _NISIZE_SHL_P: &isize = &(1isize << BITS); //~ ERROR: overflow +const _NUSIZE_SHL: usize = 1usize << BITS; //~ ERROR: overflow +const _NUSIZE_SHL_P: &usize = &(1usize << BITS); //~ ERROR: overflow // Shift right -const _NI8_SHR: i8 = 1i8 >> 8; //~ ERROR: evaluation of constant value failed -const _NI8_SHR_P: &i8 = &(1i8 >> 8); //~ ERROR: evaluation of constant value failed +const _NI8_SHR: i8 = 1i8 >> 8; //~ ERROR: overflow +const _NI8_SHR_P: &i8 = &(1i8 >> 8); //~ ERROR: overflow -const _NI16_SHR: i16 = 1i16 >> 16; //~ ERROR: evaluation of constant value failed -const _NI16_SHR_P: &i16 = &(1i16 >> 16); //~ ERROR: evaluation of constant value failed +const _NI16_SHR: i16 = 1i16 >> 16; //~ ERROR: overflow +const _NI16_SHR_P: &i16 = &(1i16 >> 16); //~ ERROR: overflow -const _NI32_SHR: i32 = 1i32 >> 32; //~ ERROR: evaluation of constant value failed -const _NI32_SHR_P: &i32 = &(1i32 >> 32); //~ ERROR: evaluation of constant value failed +const _NI32_SHR: i32 = 1i32 >> 32; //~ ERROR: overflow +const _NI32_SHR_P: &i32 = &(1i32 >> 32); //~ ERROR: overflow -const _NI64_SHR: i64 = 1i64 >> 64; //~ ERROR: evaluation of constant value failed -const _NI64_SHR_P: &i64 = &(1i64 >> 64); //~ ERROR: evaluation of constant value failed +const _NI64_SHR: i64 = 1i64 >> 64; //~ ERROR: overflow +const _NI64_SHR_P: &i64 = &(1i64 >> 64); //~ ERROR: overflow -const _NI128_SHR: i128 = 1i128 >> 128; //~ ERROR: evaluation of constant value failed -const _NI128_SHR_P: &i128 = &(1i128 >> 128); //~ ERROR: evaluation of constant value failed +const _NI128_SHR: i128 = 1i128 >> 128; //~ ERROR: overflow +const _NI128_SHR_P: &i128 = &(1i128 >> 128); //~ ERROR: overflow -const _NU8_SHR: u8 = 1u8 >> 8; //~ ERROR: evaluation of constant value failed -const _NU8_SHR_P: &u8 = &(1u8 >> 8); //~ ERROR: evaluation of constant value failed +const _NU8_SHR: u8 = 1u8 >> 8; //~ ERROR: overflow +const _NU8_SHR_P: &u8 = &(1u8 >> 8); //~ ERROR: overflow -const _NU16_SHR: u16 = 1u16 >> 16; //~ ERROR: evaluation of constant value failed -const _NU16_SHR_P: &u16 = &(1u16 >> 16); //~ ERROR: evaluation of constant value failed +const _NU16_SHR: u16 = 1u16 >> 16; //~ ERROR: overflow +const _NU16_SHR_P: &u16 = &(1u16 >> 16); //~ ERROR: overflow -const _NU32_SHR: u32 = 1u32 >> 32; //~ ERROR: evaluation of constant value failed -const _NU32_SHR_P: &u32 = &(1u32 >> 32); //~ ERROR: evaluation of constant value failed +const _NU32_SHR: u32 = 1u32 >> 32; //~ ERROR: overflow +const _NU32_SHR_P: &u32 = &(1u32 >> 32); //~ ERROR: overflow -const _NU64_SHR: u64 = 1u64 >> 64; //~ ERROR: evaluation of constant value failed -const _NU64_SHR_P: &u64 = &(1u64 >> 64); //~ ERROR: evaluation of constant value failed +const _NU64_SHR: u64 = 1u64 >> 64; //~ ERROR: overflow +const _NU64_SHR_P: &u64 = &(1u64 >> 64); //~ ERROR: overflow -const _NU128_SHR: u128 = 1u128 >> 128; //~ ERROR: evaluation of constant value failed -const _NU128_SHR_P: &u128 = &(1u128 >> 128); //~ ERROR: evaluation of constant value failed +const _NU128_SHR: u128 = 1u128 >> 128; //~ ERROR: overflow +const _NU128_SHR_P: &u128 = &(1u128 >> 128); //~ ERROR: overflow -const _NISIZE_SHR: isize = 1isize >> BITS; //~ ERROR: evaluation of constant value failed -const _NISIZE_SHR_P: &isize = &(1isize >> BITS); //~ ERROR: evaluation of constant value failed - -const _NUSIZE_SHR: usize = 1usize >> BITS; //~ ERROR: evaluation of constant value failed -const _NUSIZE_SHR_P: &usize = &(1usize >> BITS); //~ ERROR: evaluation of constant value failed +const _NISIZE_SHR: isize = 1isize >> BITS; //~ ERROR: overflow +const _NISIZE_SHR_P: &isize = &(1isize >> BITS); //~ ERROR: overflow +const _NUSIZE_SHR: usize = 1usize >> BITS; //~ ERROR: overflow +const _NUSIZE_SHR_P: &usize = &(1usize >> BITS); //~ ERROR: overflow // Addition -const _NI8_ADD: i8 = 1i8 + i8::MAX; //~ ERROR: evaluation of constant value failed -const _NI8_ADD_P: &i8 = &(1i8 + i8::MAX); //~ ERROR: evaluation of constant value failed - -const _NI16_ADD: i16 = 1i16 + i16::MAX; //~ ERROR: evaluation of constant value failed -const _NI16_ADD_P: &i16 = &(1i16 + i16::MAX); //~ ERROR: evaluation of constant value failed +const _NI8_ADD: i8 = 1i8 + i8::MAX; //~ ERROR: overflow +const _NI8_ADD_P: &i8 = &(1i8 + i8::MAX); //~ ERROR: overflow -const _NI32_ADD: i32 = 1i32 + i32::MAX; //~ ERROR: evaluation of constant value failed -const _NI32_ADD_P: &i32 = &(1i32 + i32::MAX); //~ ERROR: evaluation of constant value failed +const _NI16_ADD: i16 = 1i16 + i16::MAX; //~ ERROR: overflow +const _NI16_ADD_P: &i16 = &(1i16 + i16::MAX); //~ ERROR: overflow -const _NI64_ADD: i64 = 1i64 + i64::MAX; //~ ERROR: evaluation of constant value failed -const _NI64_ADD_P: &i64 = &(1i64 + i64::MAX); //~ ERROR: evaluation of constant value failed +const _NI32_ADD: i32 = 1i32 + i32::MAX; //~ ERROR: overflow +const _NI32_ADD_P: &i32 = &(1i32 + i32::MAX); //~ ERROR: overflow -const _NI128_ADD: i128 = 1i128 + i128::MAX; //~ ERROR: evaluation of constant value failed -const _NI128_ADD_P: &i128 = &(1i128 + i128::MAX); //~ ERROR: evaluation of constant value failed +const _NI64_ADD: i64 = 1i64 + i64::MAX; //~ ERROR: overflow +const _NI64_ADD_P: &i64 = &(1i64 + i64::MAX); //~ ERROR: overflow -const _NU8_ADD: u8 = 1u8 + u8::MAX; //~ ERROR: evaluation of constant value failed -const _NU8_ADD_P: &u8 = &(1u8 + u8::MAX); //~ ERROR: evaluation of constant value failed +const _NI128_ADD: i128 = 1i128 + i128::MAX; //~ ERROR: overflow +const _NI128_ADD_P: &i128 = &(1i128 + i128::MAX); //~ ERROR: overflow -const _NU16_ADD: u16 = 1u16 + u16::MAX; //~ ERROR: evaluation of constant value failed -const _NU16_ADD_P: &u16 = &(1u16 + u16::MAX); //~ ERROR: evaluation of constant value failed +const _NU8_ADD: u8 = 1u8 + u8::MAX; //~ ERROR: overflow +const _NU8_ADD_P: &u8 = &(1u8 + u8::MAX); //~ ERROR: overflow -const _NU32_ADD: u32 = 1u32 + u32::MAX; //~ ERROR: evaluation of constant value failed -const _NU32_ADD_P: &u32 = &(1u32 + u32::MAX); //~ ERROR: evaluation of constant value failed +const _NU16_ADD: u16 = 1u16 + u16::MAX; //~ ERROR: overflow +const _NU16_ADD_P: &u16 = &(1u16 + u16::MAX); //~ ERROR: overflow -const _NU64_ADD: u64 = 1u64 + u64::MAX; //~ ERROR: evaluation of constant value failed -const _NU64_ADD_P: &u64 = &(1u64 + u64::MAX); //~ ERROR: evaluation of constant value failed +const _NU32_ADD: u32 = 1u32 + u32::MAX; //~ ERROR: overflow +const _NU32_ADD_P: &u32 = &(1u32 + u32::MAX); //~ ERROR: overflow -const _NU128_ADD: u128 = 1u128 + u128::MAX; //~ ERROR: evaluation of constant value failed -const _NU128_ADD_P: &u128 = &(1u128 + u128::MAX); //~ ERROR: evaluation of constant value failed +const _NU64_ADD: u64 = 1u64 + u64::MAX; //~ ERROR: overflow +const _NU64_ADD_P: &u64 = &(1u64 + u64::MAX); //~ ERROR: overflow -const _NISIZE_ADD: isize = 1isize + isize::MAX; //~ ERROR: evaluation of constant value failed -const _NISIZE_ADD_P: &isize = &(1isize + isize::MAX); //~ ERROR: evaluation of constant value failed +const _NU128_ADD: u128 = 1u128 + u128::MAX; //~ ERROR: overflow +const _NU128_ADD_P: &u128 = &(1u128 + u128::MAX); //~ ERROR: overflow -const _NUSIZE_ADD: usize = 1usize + usize::MAX; //~ ERROR: evaluation of constant value failed -const _NUSIZE_ADD_P: &usize = &(1usize + usize::MAX); //~ ERROR: evaluation of constant value failed +const _NISIZE_ADD: isize = 1isize + isize::MAX; //~ ERROR: overflow +const _NISIZE_ADD_P: &isize = &(1isize + isize::MAX); //~ ERROR: overflow +const _NUSIZE_ADD: usize = 1usize + usize::MAX; //~ ERROR: overflow +const _NUSIZE_ADD_P: &usize = &(1usize + usize::MAX); //~ ERROR: overflow // Subtraction -const _NI8_SUB: i8 = -5i8 - i8::MAX; //~ ERROR: evaluation of constant value failed -const _NI8_SUB_P: &i8 = &(-5i8 - i8::MAX); //~ ERROR: evaluation of constant value failed +const _NI8_SUB: i8 = -5i8 - i8::MAX; //~ ERROR: overflow +const _NI8_SUB_P: &i8 = &(-5i8 - i8::MAX); //~ ERROR: overflow -const _NI16_SUB: i16 = -5i16 - i16::MAX; //~ ERROR: evaluation of constant value failed -const _NI16_SUB_P: &i16 = &(-5i16 - i16::MAX); //~ ERROR: evaluation of constant value failed +const _NI16_SUB: i16 = -5i16 - i16::MAX; //~ ERROR: overflow +const _NI16_SUB_P: &i16 = &(-5i16 - i16::MAX); //~ ERROR: overflow -const _NI32_SUB: i32 = -5i32 - i32::MAX; //~ ERROR: evaluation of constant value failed -const _NI32_SUB_P: &i32 = &(-5i32 - i32::MAX); //~ ERROR: evaluation of constant value failed +const _NI32_SUB: i32 = -5i32 - i32::MAX; //~ ERROR: overflow +const _NI32_SUB_P: &i32 = &(-5i32 - i32::MAX); //~ ERROR: overflow -const _NI64_SUB: i64 = -5i64 - i64::MAX; //~ ERROR: evaluation of constant value failed -const _NI64_SUB_P: &i64 = &(-5i64 - i64::MAX); //~ ERROR: evaluation of constant value failed +const _NI64_SUB: i64 = -5i64 - i64::MAX; //~ ERROR: overflow +const _NI64_SUB_P: &i64 = &(-5i64 - i64::MAX); //~ ERROR: overflow -const _NI128_SUB: i128 = -5i128 - i128::MAX; //~ ERROR: evaluation of constant value failed -const _NI128_SUB_P: &i128 = &(-5i128 - i128::MAX); //~ ERROR: evaluation of constant value failed +const _NI128_SUB: i128 = -5i128 - i128::MAX; //~ ERROR: overflow +const _NI128_SUB_P: &i128 = &(-5i128 - i128::MAX); //~ ERROR: overflow -const _NU8_SUB: u8 = 1u8 - 5; //~ ERROR: evaluation of constant value failed -const _NU8_SUB_P: &u8 = &(1u8 - 5); //~ ERROR: evaluation of constant value failed +const _NU8_SUB: u8 = 1u8 - 5; //~ ERROR: overflow +const _NU8_SUB_P: &u8 = &(1u8 - 5); //~ ERROR: overflow -const _NU16_SUB: u16 = 1u16 - 5; //~ ERROR: evaluation of constant value failed -const _NU16_SUB_P: &u16 = &(1u16 - 5); //~ ERROR: evaluation of constant value failed +const _NU16_SUB: u16 = 1u16 - 5; //~ ERROR: overflow +const _NU16_SUB_P: &u16 = &(1u16 - 5); //~ ERROR: overflow -const _NU32_SUB: u32 = 1u32 - 5; //~ ERROR: evaluation of constant value failed -const _NU32_SUB_P: &u32 = &(1u32 - 5); //~ ERROR: evaluation of constant value failed +const _NU32_SUB: u32 = 1u32 - 5; //~ ERROR: overflow +const _NU32_SUB_P: &u32 = &(1u32 - 5); //~ ERROR: overflow -const _NU64_SUB: u64 = 1u64 - 5; //~ ERROR: evaluation of constant value failed -const _NU64_SUB_P: &u64 = &(1u64 - 5); //~ ERROR: evaluation of constant value failed +const _NU64_SUB: u64 = 1u64 - 5; //~ ERROR: overflow +const _NU64_SUB_P: &u64 = &(1u64 - 5); //~ ERROR: overflow -const _NU128_SUB: u128 = 1u128 - 5; //~ ERROR: evaluation of constant value failed -const _NU128_SUB_P: &u128 = &(1u128 - 5); //~ ERROR: evaluation of constant value failed +const _NU128_SUB: u128 = 1u128 - 5; //~ ERROR: overflow +const _NU128_SUB_P: &u128 = &(1u128 - 5); //~ ERROR: overflow -const _NISIZE_SUB: isize = -5isize - isize::MAX; //~ ERROR: evaluation of constant value failed -const _NISIZE_SUB_P: &isize = &(-5isize - isize::MAX); //~ ERROR: evaluation of constant value failed - -const _NUSIZE_SUB: usize = 1usize - 5 ; //~ ERROR: evaluation of constant value failed -const _NUSIZE_SUB_P: &usize = &(1usize - 5 ); //~ ERROR: evaluation of constant value failed +const _NISIZE_SUB: isize = -5isize - isize::MAX; //~ ERROR: overflow +const _NISIZE_SUB_P: &isize = &(-5isize - isize::MAX); //~ ERROR: overflow +const _NUSIZE_SUB: usize = 1usize - 5; //~ ERROR: overflow +const _NUSIZE_SUB_P: &usize = &(1usize - 5); //~ ERROR: overflow // Multiplication -const _NI8_MUL: i8 = i8::MAX * 5; //~ ERROR: evaluation of constant value failed -const _NI8_MUL_P: &i8 = &(i8::MAX * 5); //~ ERROR: evaluation of constant value failed - -const _NI16_MUL: i16 = i16::MAX * 5; //~ ERROR: evaluation of constant value failed -const _NI16_MUL_P: &i16 = &(i16::MAX * 5); //~ ERROR: evaluation of constant value failed +const _NI8_MUL: i8 = i8::MAX * 5; //~ ERROR: overflow +const _NI8_MUL_P: &i8 = &(i8::MAX * 5); //~ ERROR: overflow -const _NI32_MUL: i32 = i32::MAX * 5; //~ ERROR: evaluation of constant value failed -const _NI32_MUL_P: &i32 = &(i32::MAX * 5); //~ ERROR: evaluation of constant value failed +const _NI16_MUL: i16 = i16::MAX * 5; //~ ERROR: overflow +const _NI16_MUL_P: &i16 = &(i16::MAX * 5); //~ ERROR: overflow -const _NI64_MUL: i64 = i64::MAX * 5; //~ ERROR: evaluation of constant value failed -const _NI64_MUL_P: &i64 = &(i64::MAX * 5); //~ ERROR: evaluation of constant value failed +const _NI32_MUL: i32 = i32::MAX * 5; //~ ERROR: overflow +const _NI32_MUL_P: &i32 = &(i32::MAX * 5); //~ ERROR: overflow -const _NI128_MUL: i128 = i128::MAX * 5; //~ ERROR: evaluation of constant value failed -const _NI128_MUL_P: &i128 = &(i128::MAX * 5); //~ ERROR: evaluation of constant value failed +const _NI64_MUL: i64 = i64::MAX * 5; //~ ERROR: overflow +const _NI64_MUL_P: &i64 = &(i64::MAX * 5); //~ ERROR: overflow -const _NU8_MUL: u8 = u8::MAX * 5; //~ ERROR: evaluation of constant value failed -const _NU8_MUL_P: &u8 = &(u8::MAX * 5); //~ ERROR: evaluation of constant value failed +const _NI128_MUL: i128 = i128::MAX * 5; //~ ERROR: overflow +const _NI128_MUL_P: &i128 = &(i128::MAX * 5); //~ ERROR: overflow -const _NU16_MUL: u16 = u16::MAX * 5; //~ ERROR: evaluation of constant value failed -const _NU16_MUL_P: &u16 = &(u16::MAX * 5); //~ ERROR: evaluation of constant value failed +const _NU8_MUL: u8 = u8::MAX * 5; //~ ERROR: overflow +const _NU8_MUL_P: &u8 = &(u8::MAX * 5); //~ ERROR: overflow -const _NU32_MUL: u32 = u32::MAX * 5; //~ ERROR: evaluation of constant value failed -const _NU32_MUL_P: &u32 = &(u32::MAX * 5); //~ ERROR: evaluation of constant value failed +const _NU16_MUL: u16 = u16::MAX * 5; //~ ERROR: overflow +const _NU16_MUL_P: &u16 = &(u16::MAX * 5); //~ ERROR: overflow -const _NU64_MUL: u64 = u64::MAX * 5; //~ ERROR: evaluation of constant value failed -const _NU64_MUL_P: &u64 = &(u64::MAX * 5); //~ ERROR: evaluation of constant value failed +const _NU32_MUL: u32 = u32::MAX * 5; //~ ERROR: overflow +const _NU32_MUL_P: &u32 = &(u32::MAX * 5); //~ ERROR: overflow -const _NU128_MUL: u128 = u128::MAX * 5; //~ ERROR: evaluation of constant value failed -const _NU128_MUL_P: &u128 = &(u128::MAX * 5); //~ ERROR: evaluation of constant value failed +const _NU64_MUL: u64 = u64::MAX * 5; //~ ERROR: overflow +const _NU64_MUL_P: &u64 = &(u64::MAX * 5); //~ ERROR: overflow -const _NISIZE_MUL: isize = isize::MAX * 5; //~ ERROR: evaluation of constant value failed -const _NISIZE_MUL_P: &isize = &(isize::MAX * 5); //~ ERROR: evaluation of constant value failed +const _NU128_MUL: u128 = u128::MAX * 5; //~ ERROR: overflow +const _NU128_MUL_P: &u128 = &(u128::MAX * 5); //~ ERROR: overflow -const _NUSIZE_MUL: usize = usize::MAX * 5; //~ ERROR: evaluation of constant value failed -const _NUSIZE_MUL_P: &usize = &(usize::MAX * 5); //~ ERROR: evaluation of constant value failed +const _NISIZE_MUL: isize = isize::MAX * 5; //~ ERROR: overflow +const _NISIZE_MUL_P: &isize = &(isize::MAX * 5); //~ ERROR: overflow +const _NUSIZE_MUL: usize = usize::MAX * 5; //~ ERROR: overflow +const _NUSIZE_MUL_P: &usize = &(usize::MAX * 5); //~ ERROR: overflow // Division -const _NI8_DIV: i8 = 1i8 / 0; //~ ERROR: evaluation of constant value failed -const _NI8_DIV_P: &i8 = &(1i8 / 0); //~ ERROR: evaluation of constant value failed +const _NI8_DIV: i8 = 1i8 / 0; //~ ERROR: by zero +const _NI8_DIV_P: &i8 = &(1i8 / 0); //~ ERROR: by zero -const _NI16_DIV: i16 = 1i16 / 0; //~ ERROR: evaluation of constant value failed -const _NI16_DIV_P: &i16 = &(1i16 / 0); //~ ERROR: evaluation of constant value failed +const _NI16_DIV: i16 = 1i16 / 0; //~ ERROR: by zero +const _NI16_DIV_P: &i16 = &(1i16 / 0); //~ ERROR: by zero -const _NI32_DIV: i32 = 1i32 / 0; //~ ERROR: evaluation of constant value failed -const _NI32_DIV_P: &i32 = &(1i32 / 0); //~ ERROR: evaluation of constant value failed +const _NI32_DIV: i32 = 1i32 / 0; //~ ERROR: by zero +const _NI32_DIV_P: &i32 = &(1i32 / 0); //~ ERROR: by zero -const _NI64_DIV: i64 = 1i64 / 0; //~ ERROR: evaluation of constant value failed -const _NI64_DIV_P: &i64 = &(1i64 / 0); //~ ERROR: evaluation of constant value failed +const _NI64_DIV: i64 = 1i64 / 0; //~ ERROR: by zero +const _NI64_DIV_P: &i64 = &(1i64 / 0); //~ ERROR: by zero -const _NI128_DIV: i128 = 1i128 / 0; //~ ERROR: evaluation of constant value failed -const _NI128_DIV_P: &i128 = &(1i128 / 0); //~ ERROR: evaluation of constant value failed +const _NI128_DIV: i128 = 1i128 / 0; //~ ERROR: by zero +const _NI128_DIV_P: &i128 = &(1i128 / 0); //~ ERROR: by zero -const _NU8_DIV: u8 = 1u8 / 0; //~ ERROR: evaluation of constant value failed -const _NU8_DIV_P: &u8 = &(1u8 / 0); //~ ERROR: evaluation of constant value failed +const _NU8_DIV: u8 = 1u8 / 0; //~ ERROR: by zero +const _NU8_DIV_P: &u8 = &(1u8 / 0); //~ ERROR: by zero -const _NU16_DIV: u16 = 1u16 / 0; //~ ERROR: evaluation of constant value failed -const _NU16_DIV_P: &u16 = &(1u16 / 0); //~ ERROR: evaluation of constant value failed +const _NU16_DIV: u16 = 1u16 / 0; //~ ERROR: by zero +const _NU16_DIV_P: &u16 = &(1u16 / 0); //~ ERROR: by zero -const _NU32_DIV: u32 = 1u32 / 0; //~ ERROR: evaluation of constant value failed -const _NU32_DIV_P: &u32 = &(1u32 / 0); //~ ERROR: evaluation of constant value failed +const _NU32_DIV: u32 = 1u32 / 0; //~ ERROR: by zero +const _NU32_DIV_P: &u32 = &(1u32 / 0); //~ ERROR: by zero -const _NU64_DIV: u64 = 1u64 / 0; //~ ERROR: evaluation of constant value failed -const _NU64_DIV_P: &u64 = &(1u64 / 0); //~ ERROR: evaluation of constant value failed +const _NU64_DIV: u64 = 1u64 / 0; //~ ERROR: by zero +const _NU64_DIV_P: &u64 = &(1u64 / 0); //~ ERROR: by zero -const _NU128_DIV: u128 = 1u128 / 0; //~ ERROR: evaluation of constant value failed -const _NU128_DIV_P: &u128 = &(1u128 / 0); //~ ERROR: evaluation of constant value failed +const _NU128_DIV: u128 = 1u128 / 0; //~ ERROR: by zero +const _NU128_DIV_P: &u128 = &(1u128 / 0); //~ ERROR: by zero -const _NISIZE_DIV: isize = 1isize / 0; //~ ERROR: evaluation of constant value failed -const _NISIZE_DIV_P: &isize = &(1isize / 0); //~ ERROR: evaluation of constant value failed +const _NISIZE_DIV: isize = 1isize / 0; //~ ERROR: by zero +const _NISIZE_DIV_P: &isize = &(1isize / 0); //~ ERROR: by zero -const _NUSIZE_DIV: usize = 1usize / 0; //~ ERROR: evaluation of constant value failed -const _NUSIZE_DIV_P: &usize = &(1usize / 0); //~ ERROR: evaluation of constant value failed +const _NUSIZE_DIV: usize = 1usize / 0; //~ ERROR: by zero +const _NUSIZE_DIV_P: &usize = &(1usize / 0); //~ ERROR: by zero // Modulus -const _NI8_MOD: i8 = 1i8 % 0; //~ ERROR: evaluation of constant value failed -const _NI8_MOD_P: &i8 = &(1i8 % 0); //~ ERROR: evaluation of constant value failed +const _NI8_MOD: i8 = 1i8 % 0; //~ ERROR: divisor of zero +const _NI8_MOD_P: &i8 = &(1i8 % 0); //~ ERROR: divisor of zero -const _NI16_MOD: i16 = 1i16 % 0; //~ ERROR: evaluation of constant value failed -const _NI16_MOD_P: &i16 = &(1i16 % 0); //~ ERROR: evaluation of constant value failed +const _NI16_MOD: i16 = 1i16 % 0; //~ ERROR: divisor of zero +const _NI16_MOD_P: &i16 = &(1i16 % 0); //~ ERROR: divisor of zero -const _NI32_MOD: i32 = 1i32 % 0; //~ ERROR: evaluation of constant value failed -const _NI32_MOD_P: &i32 = &(1i32 % 0); //~ ERROR: evaluation of constant value failed +const _NI32_MOD: i32 = 1i32 % 0; //~ ERROR: divisor of zero +const _NI32_MOD_P: &i32 = &(1i32 % 0); //~ ERROR: divisor of zero -const _NI64_MOD: i64 = 1i64 % 0; //~ ERROR: evaluation of constant value failed -const _NI64_MOD_P: &i64 = &(1i64 % 0); //~ ERROR: evaluation of constant value failed +const _NI64_MOD: i64 = 1i64 % 0; //~ ERROR: divisor of zero +const _NI64_MOD_P: &i64 = &(1i64 % 0); //~ ERROR: divisor of zero -const _NI128_MOD: i128 = 1i128 % 0; //~ ERROR: evaluation of constant value failed -const _NI128_MOD_P: &i128 = &(1i128 % 0); //~ ERROR: evaluation of constant value failed +const _NI128_MOD: i128 = 1i128 % 0; //~ ERROR: divisor of zero +const _NI128_MOD_P: &i128 = &(1i128 % 0); //~ ERROR: divisor of zero -const _NU8_MOD: u8 = 1u8 % 0; //~ ERROR: evaluation of constant value failed -const _NU8_MOD_P: &u8 = &(1u8 % 0); //~ ERROR: evaluation of constant value failed +const _NU8_MOD: u8 = 1u8 % 0; //~ ERROR: divisor of zero +const _NU8_MOD_P: &u8 = &(1u8 % 0); //~ ERROR: divisor of zero -const _NU16_MOD: u16 = 1u16 % 0; //~ ERROR: evaluation of constant value failed -const _NU16_MOD_P: &u16 = &(1u16 % 0); //~ ERROR: evaluation of constant value failed +const _NU16_MOD: u16 = 1u16 % 0; //~ ERROR: divisor of zero +const _NU16_MOD_P: &u16 = &(1u16 % 0); //~ ERROR: divisor of zero -const _NU32_MOD: u32 = 1u32 % 0; //~ ERROR: evaluation of constant value failed -const _NU32_MOD_P: &u32 = &(1u32 % 0); //~ ERROR: evaluation of constant value failed +const _NU32_MOD: u32 = 1u32 % 0; //~ ERROR: divisor of zero +const _NU32_MOD_P: &u32 = &(1u32 % 0); //~ ERROR: divisor of zero -const _NU64_MOD: u64 = 1u64 % 0; //~ ERROR: evaluation of constant value failed -const _NU64_MOD_P: &u64 = &(1u64 % 0); //~ ERROR: evaluation of constant value failed +const _NU64_MOD: u64 = 1u64 % 0; //~ ERROR: divisor of zero +const _NU64_MOD_P: &u64 = &(1u64 % 0); //~ ERROR: divisor of zero -const _NU128_MOD: u128 = 1u128 % 0; //~ ERROR: evaluation of constant value failed -const _NU128_MOD_P: &u128 = &(1u128 % 0); //~ ERROR: evaluation of constant value failed +const _NU128_MOD: u128 = 1u128 % 0; //~ ERROR: divisor of zero +const _NU128_MOD_P: &u128 = &(1u128 % 0); //~ ERROR: divisor of zero -const _NISIZE_MOD: isize = 1isize % 0; //~ ERROR: evaluation of constant value failed -const _NISIZE_MOD_P: &isize = &(1isize % 0); //~ ERROR: evaluation of constant value failed - -const _NUSIZE_MOD: usize = 1usize % 0; //~ ERROR: evaluation of constant value failed -const _NUSIZE_MOD_P: &usize = &(1usize % 0); //~ ERROR: evaluation of constant value failed +const _NISIZE_MOD: isize = 1isize % 0; //~ ERROR: divisor of zero +const _NISIZE_MOD_P: &isize = &(1isize % 0); //~ ERROR: divisor of zero +const _NUSIZE_MOD: usize = 1usize % 0; //~ ERROR: divisor of zero +const _NUSIZE_MOD_P: &usize = &(1usize % 0); //~ ERROR: divisor of zero // Out of bounds access -const _NI32_OOB: i32 = [1, 2, 3][4]; //~ ERROR: evaluation of constant value failed -const _NI32_OOB_P: &i32 = &([1, 2, 3][4]); //~ ERROR: evaluation of constant value failed - +const _NI32_OOB: i32 = [1, 2, 3][4]; //~ ERROR: the length is 3 but the index is 4 +const _NI32_OOB_P: &i32 = &([1, 2, 3][4]); //~ ERROR: the length is 3 but the index is 4 pub fn main() {} diff --git a/tests/ui/consts/promoted_running_out_of_memory_issue-130687.rs b/tests/ui/consts/promoted_running_out_of_memory_issue-130687.rs index e458a6f98adf5..d7977bfba77ca 100644 --- a/tests/ui/consts/promoted_running_out_of_memory_issue-130687.rs +++ b/tests/ui/consts/promoted_running_out_of_memory_issue-130687.rs @@ -11,7 +11,6 @@ pub struct Data([u8; (1 << 47) - 1]); const _: &'static Data = &Data([0; (1 << 47) - 1]); -//~^ERROR: evaluation of constant value failed -//~| NOTE tried to allocate more memory than available to compiler +//~^ ERROR: tried to allocate more memory than available to compiler fn main() {} diff --git a/tests/ui/consts/promoted_running_out_of_memory_issue-130687.stderr b/tests/ui/consts/promoted_running_out_of_memory_issue-130687.stderr index 02180c1e4c683..6c09a1faed203 100644 --- a/tests/ui/consts/promoted_running_out_of_memory_issue-130687.stderr +++ b/tests/ui/consts/promoted_running_out_of_memory_issue-130687.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: tried to allocate more memory than available to compiler --> $DIR/promoted_running_out_of_memory_issue-130687.rs:13:32 | LL | const _: &'static Data = &Data([0; (1 << 47) - 1]); - | ^^^^^^^^^^^^^^^^^^ tried to allocate more memory than available to compiler + | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/promoted_size_overflow.rs b/tests/ui/consts/promoted_size_overflow.rs index ebd5ab0648717..232fb76c75b0c 100644 --- a/tests/ui/consts/promoted_size_overflow.rs +++ b/tests/ui/consts/promoted_size_overflow.rs @@ -1,7 +1,6 @@ //@ only-64bit pub struct Data([u8; usize::MAX >> 2]); const _: &'static [Data] = &[]; -//~^ERROR: evaluation of constant value failed -//~| NOTE too big for the target architecture +//~^ ERROR: too big for the target architecture fn main() {} diff --git a/tests/ui/consts/promoted_size_overflow.stderr b/tests/ui/consts/promoted_size_overflow.stderr index cfb8260bed040..226c78ec01b5f 100644 --- a/tests/ui/consts/promoted_size_overflow.stderr +++ b/tests/ui/consts/promoted_size_overflow.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: values of the type `[u8; 4611686018427387903]` are too big for the target architecture --> $DIR/promoted_size_overflow.rs:3:29 | LL | const _: &'static [Data] = &[]; - | ^^ values of the type `[u8; 4611686018427387903]` are too big for the target architecture + | ^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/qualif-indirect-mutation-fail.rs b/tests/ui/consts/qualif-indirect-mutation-fail.rs index 4abb231c29f66..b70fca7b86430 100644 --- a/tests/ui/consts/qualif-indirect-mutation-fail.rs +++ b/tests/ui/consts/qualif-indirect-mutation-fail.rs @@ -15,7 +15,7 @@ pub const A1: () = { let b = &mut y; std::mem::swap(a, b); std::mem::forget(y); -}; //~ ERROR evaluation of constant value failed +}; //~ ERROR calling non-const function ` as Drop>::drop` // Mutable borrow of a type with drop impl. pub const A2: () = { @@ -26,7 +26,7 @@ pub const A2: () = { std::mem::swap(a, b); std::mem::forget(y); let _z = x; //~ ERROR destructor of -}; //~ ERROR evaluation of constant value failed +}; //~ ERROR calling non-const function ` as Drop>::drop` // Shared borrow of a type that might be !Freeze and Drop. pub const fn g1() { diff --git a/tests/ui/consts/qualif-indirect-mutation-fail.stderr b/tests/ui/consts/qualif-indirect-mutation-fail.stderr index dd575e07c2013..6cd7741103fc8 100644 --- a/tests/ui/consts/qualif-indirect-mutation-fail.stderr +++ b/tests/ui/consts/qualif-indirect-mutation-fail.stderr @@ -7,11 +7,11 @@ LL | let mut x = None; LL | }; | - value is dropped here -error[E0080]: evaluation of constant value failed +error[E0080]: calling non-const function ` as Drop>::drop` --> $DIR/qualif-indirect-mutation-fail.rs:18:1 | LL | }; - | ^ calling non-const function ` as Drop>::drop` + | ^ evaluation of constant value failed here | note: inside `drop_in_place::> - shim(Some(Option))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL @@ -28,11 +28,11 @@ LL | let _z = x; LL | }; | - value is dropped here -error[E0080]: evaluation of constant value failed +error[E0080]: calling non-const function ` as Drop>::drop` --> $DIR/qualif-indirect-mutation-fail.rs:29:1 | LL | }; - | ^ calling non-const function ` as Drop>::drop` + | ^ evaluation of constant value failed here | note: inside `drop_in_place::> - shim(Some(Option))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL diff --git a/tests/ui/consts/recursive-zst-static.default.stderr b/tests/ui/consts/recursive-zst-static.default.stderr index dedca16db8d8a..80661825d53d7 100644 --- a/tests/ui/consts/recursive-zst-static.default.stderr +++ b/tests/ui/consts/recursive-zst-static.default.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: encountered static that tried to initialize itself with itself --> $DIR/recursive-zst-static.rs:10:18 | LL | static FOO: () = FOO; - | ^^^ encountered static that tried to initialize itself with itself + | ^^^ evaluation of static initializer failed here error[E0391]: cycle detected when evaluating initializer of static `A` --> $DIR/recursive-zst-static.rs:13:16 diff --git a/tests/ui/consts/recursive-zst-static.rs b/tests/ui/consts/recursive-zst-static.rs index a52624fada8dd..852caae949341 100644 --- a/tests/ui/consts/recursive-zst-static.rs +++ b/tests/ui/consts/recursive-zst-static.rs @@ -8,7 +8,7 @@ // See https://github.com/rust-lang/rust/issues/71078 for more details. static FOO: () = FOO; -//~^ ERROR could not evaluate static initializer +//~^ ERROR encountered static that tried to initialize itself with itself static A: () = B; //~ ERROR cycle detected when evaluating initializer of static `A` static B: () = A; diff --git a/tests/ui/consts/recursive-zst-static.unleash.stderr b/tests/ui/consts/recursive-zst-static.unleash.stderr index dedca16db8d8a..80661825d53d7 100644 --- a/tests/ui/consts/recursive-zst-static.unleash.stderr +++ b/tests/ui/consts/recursive-zst-static.unleash.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: encountered static that tried to initialize itself with itself --> $DIR/recursive-zst-static.rs:10:18 | LL | static FOO: () = FOO; - | ^^^ encountered static that tried to initialize itself with itself + | ^^^ evaluation of static initializer failed here error[E0391]: cycle detected when evaluating initializer of static `A` --> $DIR/recursive-zst-static.rs:13:16 diff --git a/tests/ui/consts/recursive.rs b/tests/ui/consts/recursive.rs index b5703d11310fd..ed23baf07682e 100644 --- a/tests/ui/consts/recursive.rs +++ b/tests/ui/consts/recursive.rs @@ -4,6 +4,6 @@ const fn f(x: T) { //~ WARN function cannot return without recursing f(x); } -const X: () = f(1); //~ ERROR evaluation of constant value failed +const X: () = f(1); //~ ERROR reached the configured maximum number of stack frames fn main() {} diff --git a/tests/ui/consts/recursive.stderr b/tests/ui/consts/recursive.stderr index fd38b078b94ea..97fa9e7e75e21 100644 --- a/tests/ui/consts/recursive.stderr +++ b/tests/ui/consts/recursive.stderr @@ -9,11 +9,11 @@ LL | f(x); = help: a `loop` may express intention better if this is on purpose = note: `#[warn(unconditional_recursion)]` on by default -error[E0080]: evaluation of constant value failed +error[E0080]: reached the configured maximum number of stack frames --> $DIR/recursive.rs:7:15 | LL | const X: () = f(1); - | ^^^^ reached the configured maximum number of stack frames + | ^^^^ evaluation of constant value failed here | note: [... 126 additional calls inside `f::` ...] --> $DIR/recursive.rs:4:5 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 6812b3734efb8..7d7bbbc5e36c7 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,8 +1,8 @@ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-called-fn.rs:10:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/collect-in-called-fn.rs:19:17 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 6812b3734efb8..7d7bbbc5e36c7 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,8 +1,8 @@ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-called-fn.rs:10:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/collect-in-called-fn.rs:19:17 diff --git a/tests/ui/consts/required-consts/collect-in-called-fn.rs b/tests/ui/consts/required-consts/collect-in-called-fn.rs index 93947950af2a1..2045b8266c792 100644 --- a/tests/ui/consts/required-consts/collect-in-called-fn.rs +++ b/tests/ui/consts/required-consts/collect-in-called-fn.rs @@ -7,7 +7,7 @@ struct Fail(T); impl Fail { - const C: () = panic!(); //~ERROR evaluation of `Fail::::C` failed + const C: () = panic!(); //~ERROR evaluation panicked: explicit panic } #[inline(never)] 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 661aea71604a0..239e9cb147238 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,8 +1,8 @@ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-closure.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-closure.rs:17:17 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 661aea71604a0..239e9cb147238 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,8 +1,8 @@ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-closure.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-closure.rs:17:17 diff --git a/tests/ui/consts/required-consts/collect-in-dead-closure.rs b/tests/ui/consts/required-consts/collect-in-dead-closure.rs index a00214c62db2c..5f8b6bbb174c4 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-closure.rs +++ b/tests/ui/consts/required-consts/collect-in-dead-closure.rs @@ -6,7 +6,7 @@ struct Fail(T); impl Fail { - const C: () = panic!(); //~ERROR evaluation of `Fail::::C` failed + const C: () = panic!(); //~ERROR evaluation panicked: explicit panic } // This function is not actually called, but it is mentioned in a closure that is coerced to a 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 31e6b2f487f32..7c6219ccf9344 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,8 +1,8 @@ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-drop.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-drop.rs:16:17 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 31e6b2f487f32..7c6219ccf9344 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,8 +1,8 @@ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-drop.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-drop.rs:16:17 diff --git a/tests/ui/consts/required-consts/collect-in-dead-drop.rs b/tests/ui/consts/required-consts/collect-in-dead-drop.rs index 389fcf5dfc99c..f7293d162df7b 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-drop.rs +++ b/tests/ui/consts/required-consts/collect-in-dead-drop.rs @@ -6,7 +6,7 @@ struct Fail(T); impl Fail { - const C: () = panic!(); //~ERROR evaluation of `Fail::::C` failed + const C: () = panic!(); //~ERROR evaluation panicked: explicit panic } // This function is not actually called, but is mentioned implicitly as destructor in dead code in a 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 32dc1cb304b6c..e1a82fd52310b 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,8 +1,8 @@ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn-behind-assoc-type.rs:10:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-fn-behind-assoc-type.rs:16:17 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 32dc1cb304b6c..e1a82fd52310b 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,8 +1,8 @@ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn-behind-assoc-type.rs:10:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-fn-behind-assoc-type.rs:16:17 diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.rs b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.rs index 9c36af50bb7cf..e6be9f56cb7a0 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.rs +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.rs @@ -7,7 +7,7 @@ struct Fail(T); impl Fail { - const C: () = panic!(); //~ERROR evaluation of `Fail::::C` failed + const C: () = panic!(); //~ERROR evaluation panicked: explicit panic } #[inline(never)] 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 d22cf579448bf..1d2af342a4435 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,8 +1,8 @@ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn-behind-generic.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-fn-behind-generic.rs:15:17 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 d22cf579448bf..1d2af342a4435 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,8 +1,8 @@ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn-behind-generic.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-fn-behind-generic.rs:15:17 diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.rs b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.rs index 5829d914ee1b3..a86902af52677 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.rs +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.rs @@ -6,7 +6,7 @@ struct Fail(T); impl Fail { - const C: () = panic!(); //~ERROR evaluation of `Fail::::C` failed + const C: () = panic!(); //~ERROR evaluation panicked: explicit panic } #[inline(never)] 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 91daa2f9bc33d..a480a8c5a3996 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,8 +1,8 @@ -error[E0080]: evaluation of `m::Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn-behind-opaque-type.rs:11:23 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `m::Fail::::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-fn-behind-opaque-type.rs:19:21 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 91daa2f9bc33d..a480a8c5a3996 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,8 +1,8 @@ -error[E0080]: evaluation of `m::Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn-behind-opaque-type.rs:11:23 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `m::Fail::::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-fn-behind-opaque-type.rs:19:21 diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.rs b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.rs index f333f3462c751..4cdb27413540f 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.rs +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.rs @@ -8,7 +8,7 @@ mod m { struct Fail(T); impl Fail { - const C: () = panic!(); //~ERROR evaluation of `m::Fail::::C` failed + const C: () = panic!(); //~ERROR: evaluation panicked: explicit panic } pub type NotCalledFn = impl Fn(); 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 d254fc60c0ca2..f253a7cbbee38 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,8 +1,8 @@ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-fn.rs:19:17 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 d254fc60c0ca2..f253a7cbbee38 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,8 +1,8 @@ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-fn.rs:19:17 diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn.rs b/tests/ui/consts/required-consts/collect-in-dead-fn.rs index 1c95e0c303fa3..0c4795801068d 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn.rs +++ b/tests/ui/consts/required-consts/collect-in-dead-fn.rs @@ -6,7 +6,7 @@ struct Fail(T); impl Fail { - const C: () = panic!(); //~ERROR evaluation of `Fail::::C` failed + const C: () = panic!(); //~ERROR evaluation panicked: explicit panic } // This function is not actually called, but it is mentioned in dead code in a function that is 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 c14837ce4422f..b962630ca016c 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,8 +1,8 @@ -error[E0080]: evaluation of `Late::::FAIL` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fnptr-in-const.rs:9:22 | LL | const FAIL: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Late::::FAIL` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-fnptr-in-const.rs:10:28 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 c14837ce4422f..b962630ca016c 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,8 +1,8 @@ -error[E0080]: evaluation of `Late::::FAIL` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fnptr-in-const.rs:9:22 | LL | const FAIL: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Late::::FAIL` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-fnptr-in-const.rs:10:28 diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.rs b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.rs index 8b6344c93f329..04544cb413984 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.rs +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.rs @@ -6,7 +6,7 @@ struct Late(T); impl Late { - const FAIL: () = panic!(); //~ERROR evaluation of `Late::::FAIL` failed + const FAIL: () = panic!(); //~ERROR evaluation panicked: explicit panic const FNPTR: fn() = || Self::FAIL; } 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 284e1a70a20c0..29e6711153c9e 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,8 +1,8 @@ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fnptr.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-fnptr.rs:18:17 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 284e1a70a20c0..29e6711153c9e 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,8 +1,8 @@ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fnptr.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-fnptr.rs:18:17 diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr.rs b/tests/ui/consts/required-consts/collect-in-dead-fnptr.rs index acbe34829e8cb..4cdb50f4385a1 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr.rs +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr.rs @@ -6,7 +6,7 @@ struct Fail(T); impl Fail { - const C: () = panic!(); //~ERROR evaluation of `Fail::::C` failed + const C: () = panic!(); //~ERROR evaluation panicked: explicit panic } // This function is not actually called, but it is mentioned in dead code in a function that is 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 8b43c67c085ba..6c8edc00260dd 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,8 +1,8 @@ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-move.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-move.rs:16:17 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 8b43c67c085ba..6c8edc00260dd 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,8 +1,8 @@ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-move.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-move.rs:16:17 diff --git a/tests/ui/consts/required-consts/collect-in-dead-move.rs b/tests/ui/consts/required-consts/collect-in-dead-move.rs index 6a224a375cfdc..4e2d959db32c7 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-move.rs +++ b/tests/ui/consts/required-consts/collect-in-dead-move.rs @@ -6,7 +6,7 @@ struct Fail(T); impl Fail { - const C: () = panic!(); //~ERROR evaluation of `Fail::::C` failed + const C: () = panic!(); //~ERROR evaluation panicked: explicit panic } // This function is not actually called, but is mentioned implicitly as destructor in dead code in a 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 4056f28541d07..4e35beadbf484 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,8 +1,8 @@ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-vtable.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-vtable.rs:22:21 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 4056f28541d07..4e35beadbf484 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,8 +1,8 @@ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-vtable.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-vtable.rs:22:21 diff --git a/tests/ui/consts/required-consts/collect-in-dead-vtable.rs b/tests/ui/consts/required-consts/collect-in-dead-vtable.rs index f63207eafec51..d4ad730837730 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-vtable.rs +++ b/tests/ui/consts/required-consts/collect-in-dead-vtable.rs @@ -6,7 +6,7 @@ struct Fail(T); impl Fail { - const C: () = panic!(); //~ERROR evaluation of `Fail::::C` failed + const C: () = panic!(); //~ERROR evaluation panicked: explicit panic } trait MyTrait { 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 c5f3b0009f541..67f5009c4ffcf 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,8 +1,8 @@ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-promoted-const.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/collect-in-promoted-const.rs:20:21 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 6f36aaf314da2..5c3edf68d95f7 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,8 +1,8 @@ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-promoted-const.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/collect-in-promoted-const.rs:20:21 @@ -10,11 +10,11 @@ note: erroneous constant encountered LL | let _val = &Fail::::C; | ^^^^^^^^^^^^ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-promoted-const.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/collect-in-promoted-const.rs:20:21 diff --git a/tests/ui/consts/required-consts/collect-in-promoted-const.rs b/tests/ui/consts/required-consts/collect-in-promoted-const.rs index 4a3ce92e8f90d..25c8cb7e80490 100644 --- a/tests/ui/consts/required-consts/collect-in-promoted-const.rs +++ b/tests/ui/consts/required-consts/collect-in-promoted-const.rs @@ -6,8 +6,8 @@ struct Fail(T); impl Fail { - const C: () = panic!(); //~ERROR evaluation of `Fail::::C` failed - //[opt]~^ ERROR evaluation of `Fail::::C` failed + const C: () = panic!(); //~ERROR evaluation panicked: explicit panic + //[opt]~^ ERROR evaluation panicked: explicit panic // (Not sure why optimizations lead to this being emitted twice, but as long as compilation // fails either way it's fine.) } 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 f98e2c172024e..c9fd476bd8b72 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,8 +1,8 @@ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/interpret-in-const-called-fn.rs:8:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/interpret-in-const-called-fn.rs:18:9 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 f98e2c172024e..c9fd476bd8b72 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,8 +1,8 @@ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/interpret-in-const-called-fn.rs:8:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/interpret-in-const-called-fn.rs:18:9 diff --git a/tests/ui/consts/required-consts/interpret-in-const-called-fn.rs b/tests/ui/consts/required-consts/interpret-in-const-called-fn.rs index 1ed6853f0a49b..9309457e22a46 100644 --- a/tests/ui/consts/required-consts/interpret-in-const-called-fn.rs +++ b/tests/ui/consts/required-consts/interpret-in-const-called-fn.rs @@ -5,7 +5,7 @@ struct Fail(T); impl Fail { - const C: () = panic!(); //~ERROR evaluation of `Fail::::C` failed + const C: () = panic!(); //~ERROR explicit panic //~| NOTE in this expansion of panic! } 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 1375ac751f22b..b14c9aff7ba46 100644 --- a/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: entering unreachable code --> $DIR/interpret-in-promoted.rs:15:28 | LL | let _x: &'static () = &ub(); - | ^^^^ entering unreachable code + | ^^^^ evaluation of constant value failed here | note: inside `ub` --> $DIR/interpret-in-promoted.rs:9:5 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 1375ac751f22b..b14c9aff7ba46 100644 --- a/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: entering unreachable code --> $DIR/interpret-in-promoted.rs:15:28 | LL | let _x: &'static () = &ub(); - | ^^^^ entering unreachable code + | ^^^^ evaluation of constant value failed here | note: inside `ub` --> $DIR/interpret-in-promoted.rs:9:5 diff --git a/tests/ui/consts/required-consts/interpret-in-promoted.rs b/tests/ui/consts/required-consts/interpret-in-promoted.rs index 85d2ea3418cdf..b223e6d16aa12 100644 --- a/tests/ui/consts/required-consts/interpret-in-promoted.rs +++ b/tests/ui/consts/required-consts/interpret-in-promoted.rs @@ -12,7 +12,7 @@ const unsafe fn ub() { pub const FOO: () = unsafe { // Make sure that this gets promoted and then fails to evaluate, and we deal with that // correctly. - let _x: &'static () = &ub(); //~ ERROR evaluation of constant value failed + let _x: &'static () = &ub(); //~ ERROR unreachable code }; fn main() {} 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 28daf265af4a0..8b8d375250d21 100644 --- a/tests/ui/consts/required-consts/interpret-in-static.noopt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-static.noopt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/interpret-in-static.rs:8:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/interpret-in-static.rs:17:9 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 28daf265af4a0..8b8d375250d21 100644 --- a/tests/ui/consts/required-consts/interpret-in-static.opt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-static.opt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/interpret-in-static.rs:8:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::::C` failed here note: erroneous constant encountered --> $DIR/interpret-in-static.rs:17:9 diff --git a/tests/ui/consts/required-consts/interpret-in-static.rs b/tests/ui/consts/required-consts/interpret-in-static.rs index 7ddf15f912121..19ad6be1c9fa7 100644 --- a/tests/ui/consts/required-consts/interpret-in-static.rs +++ b/tests/ui/consts/required-consts/interpret-in-static.rs @@ -5,7 +5,7 @@ struct Fail(T); impl Fail { - const C: () = panic!(); //~ERROR evaluation of `Fail::::C` failed + const C: () = panic!(); //~ERROR explicit panic //~| NOTE in this expansion of panic! } diff --git a/tests/ui/consts/slice-index-overflow-issue-130284.rs b/tests/ui/consts/slice-index-overflow-issue-130284.rs index 6877ebe147689..f5235b0e1f17b 100644 --- a/tests/ui/consts/slice-index-overflow-issue-130284.rs +++ b/tests/ui/consts/slice-index-overflow-issue-130284.rs @@ -5,8 +5,7 @@ const C: () = { unsafe { // This used to ICE, but it should just report UB. let _ice = (*fat)[usize::MAX - 1]; - //~^ERROR: constant value failed - //~| NOTE overflow + //~^ERROR: overflow } }; diff --git a/tests/ui/consts/slice-index-overflow-issue-130284.stderr b/tests/ui/consts/slice-index-overflow-issue-130284.stderr index e3e676c894947..641aed349dd14 100644 --- a/tests/ui/consts/slice-index-overflow-issue-130284.stderr +++ b/tests/ui/consts/slice-index-overflow-issue-130284.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +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 | let _ice = (*fat)[usize::MAX - 1]; - | ^^^^^^^^^^^^^^^^^^^^^^ overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize` + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/static_mut_containing_mut_ref2.rs b/tests/ui/consts/static_mut_containing_mut_ref2.rs index 2b1fe55df78b3..e9910816fc12f 100644 --- a/tests/ui/consts/static_mut_containing_mut_ref2.rs +++ b/tests/ui/consts/static_mut_containing_mut_ref2.rs @@ -4,7 +4,7 @@ static mut STDERR_BUFFER_SPACE: u8 = 0; pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; - //~^ ERROR could not evaluate static initializer + //~^ ERROR modifying a static's initial value }; fn main() {} diff --git a/tests/ui/consts/static_mut_containing_mut_ref2.stderr b/tests/ui/consts/static_mut_containing_mut_ref2.stderr index 37cd2b51ad143..49b35dacd3a7a 100644 --- a/tests/ui/consts/static_mut_containing_mut_ref2.stderr +++ b/tests/ui/consts/static_mut_containing_mut_ref2.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: modifying a static's initial value from another static's initializer --> $DIR/static_mut_containing_mut_ref2.rs:6:5 | LL | *(&mut STDERR_BUFFER_SPACE) = 42; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ modifying a static's initial value from another static's initializer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/static_mut_containing_mut_ref3.rs b/tests/ui/consts/static_mut_containing_mut_ref3.rs index c24c7e2792079..42a4d04cde6e6 100644 --- a/tests/ui/consts/static_mut_containing_mut_ref3.rs +++ b/tests/ui/consts/static_mut_containing_mut_ref3.rs @@ -1,6 +1,6 @@ static mut FOO: (u8, u8) = (42, 43); static mut BAR: () = unsafe { FOO.0 = 99; }; -//~^ ERROR could not evaluate static initializer +//~^ ERROR modifying a static's initial value fn main() {} diff --git a/tests/ui/consts/static_mut_containing_mut_ref3.stderr b/tests/ui/consts/static_mut_containing_mut_ref3.stderr index be84608acf785..71d701434a3fb 100644 --- a/tests/ui/consts/static_mut_containing_mut_ref3.stderr +++ b/tests/ui/consts/static_mut_containing_mut_ref3.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: modifying a static's initial value from another static's initializer --> $DIR/static_mut_containing_mut_ref3.rs:3:31 | LL | static mut BAR: () = unsafe { FOO.0 = 99; }; - | ^^^^^^^^^^ modifying a static's initial value from another static's initializer + | ^^^^^^^^^^ evaluation of static initializer failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/uninhabited-const-issue-61744.rs b/tests/ui/consts/uninhabited-const-issue-61744.rs index 802d422888bae..d33f9c268a51f 100644 --- a/tests/ui/consts/uninhabited-const-issue-61744.rs +++ b/tests/ui/consts/uninhabited-const-issue-61744.rs @@ -10,7 +10,7 @@ pub const unsafe fn hint_unreachable() -> ! { } trait Const { - const CONSTANT: i32 = unsafe { fake_type() }; //~ ERROR evaluation of `fake_type::` failed + const CONSTANT: i32 = unsafe { fake_type() }; //~ ERROR reached the configured maximum number of stack frames } impl Const for T {} diff --git a/tests/ui/consts/uninhabited-const-issue-61744.stderr b/tests/ui/consts/uninhabited-const-issue-61744.stderr index d0e90f9a423fa..3c5b5196aebf8 100644 --- a/tests/ui/consts/uninhabited-const-issue-61744.stderr +++ b/tests/ui/consts/uninhabited-const-issue-61744.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `fake_type::` failed +error[E0080]: reached the configured maximum number of stack frames --> $DIR/uninhabited-const-issue-61744.rs:13:36 | LL | const CONSTANT: i32 = unsafe { fake_type() }; - | ^^^^^^^^^^^ reached the configured maximum number of stack frames + | ^^^^^^^^^^^ evaluation of `fake_type::` failed here | note: inside `fake_type::` --> $DIR/uninhabited-const-issue-61744.rs:5:5 diff --git a/tests/ui/consts/validate_never_arrays.rs b/tests/ui/consts/validate_never_arrays.rs index 055bb1c69c896..b0ea064188bcf 100644 --- a/tests/ui/consts/validate_never_arrays.rs +++ b/tests/ui/consts/validate_never_arrays.rs @@ -3,10 +3,10 @@ //@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?()?─*╼ )+ *│.*" -> "HEX_DUMP" #![feature(never_type)] -const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR undefined behavior +const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR invalid value const _: &[!; 0] = unsafe { &*(1_usize as *const [!; 0]) }; // ok const _: &[!] = unsafe { &*(1_usize as *const [!; 0]) }; // ok -const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR undefined behavior -const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; //~ ERROR undefined behavior +const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR invalid value +const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; //~ ERROR invalid value fn main() {} diff --git a/tests/ui/consts/validate_never_arrays.stderr b/tests/ui/consts/validate_never_arrays.stderr index 12090e483a4e6..0f503df406093 100644 --- a/tests/ui/consts/validate_never_arrays.stderr +++ b/tests/ui/consts/validate_never_arrays.stderr @@ -1,30 +1,30 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered a reference pointing to uninhabited type [!; 1] --> $DIR/validate_never_arrays.rs:6:1 | LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; - | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type [!; 1] + | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .[0]: encountered a value of the never type `!` --> $DIR/validate_never_arrays.rs:9:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; - | ^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a value of the never type `!` + | ^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .[0]: encountered a value of the never type `!` --> $DIR/validate_never_arrays.rs:10:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; - | ^^^^^^^^^^^^^ constructing invalid value at .[0]: encountered a value of the never type `!` + | ^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { diff --git a/tests/ui/consts/write-to-static-mut-in-static.rs b/tests/ui/consts/write-to-static-mut-in-static.rs index a2985d05a7930..ce15d9e912b64 100644 --- a/tests/ui/consts/write-to-static-mut-in-static.rs +++ b/tests/ui/consts/write-to-static-mut-in-static.rs @@ -1,10 +1,10 @@ pub static mut A: u32 = 0; pub static mut B: () = unsafe { A = 1; }; -//~^ ERROR could not evaluate static initializer +//~^ ERROR modifying a static's initial value pub static mut C: u32 = unsafe { C = 1; 0 }; pub static D: u32 = D; -//~^ ERROR could not evaluate static initializer +//~^ ERROR static that tried to initialize itself with itself fn main() {} diff --git a/tests/ui/consts/write-to-static-mut-in-static.stderr b/tests/ui/consts/write-to-static-mut-in-static.stderr index 9616f8eeeb766..c98c7d895fc63 100644 --- a/tests/ui/consts/write-to-static-mut-in-static.stderr +++ b/tests/ui/consts/write-to-static-mut-in-static.stderr @@ -1,14 +1,14 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: modifying a static's initial value from another static's initializer --> $DIR/write-to-static-mut-in-static.rs:2:33 | LL | pub static mut B: () = unsafe { A = 1; }; - | ^^^^^ modifying a static's initial value from another static's initializer + | ^^^^^ evaluation of static initializer failed here -error[E0080]: could not evaluate static initializer +error[E0080]: encountered static that tried to initialize itself with itself --> $DIR/write-to-static-mut-in-static.rs:7:21 | LL | pub static D: u32 = D; - | ^ encountered static that tried to initialize itself with itself + | ^ evaluation of static initializer failed here error: aborting due to 2 previous errors diff --git a/tests/ui/coroutine/const_gen_fn.rs b/tests/ui/coroutine/const_gen_fn.rs index 2701139ffed93..b044c185e0f06 100644 --- a/tests/ui/coroutine/const_gen_fn.rs +++ b/tests/ui/coroutine/const_gen_fn.rs @@ -4,8 +4,10 @@ const gen fn a() {} //~^ ERROR functions cannot be both `const` and `gen` +//~^^ ERROR `gen` fn bodies are not allowed in constant functions const async gen fn b() {} //~^ ERROR functions cannot be both `const` and `async gen` +//~^^ ERROR `async gen` fn bodies are not allowed in constant functions fn main() {} diff --git a/tests/ui/coroutine/const_gen_fn.stderr b/tests/ui/coroutine/const_gen_fn.stderr index 4f3c73d16787b..400ee216d0645 100644 --- a/tests/ui/coroutine/const_gen_fn.stderr +++ b/tests/ui/coroutine/const_gen_fn.stderr @@ -8,7 +8,7 @@ LL | const gen fn a() {} | `const` because of this error: functions cannot be both `const` and `async gen` - --> $DIR/const_gen_fn.rs:8:1 + --> $DIR/const_gen_fn.rs:9:1 | LL | const async gen fn b() {} | ^^^^^-^^^^^^^^^---------- @@ -16,5 +16,17 @@ LL | const async gen fn b() {} | | `async gen` because of this | `const` because of this -error: aborting due to 2 previous errors +error: `gen` fn bodies are not allowed in constant functions + --> $DIR/const_gen_fn.rs:5:18 + | +LL | const gen fn a() {} + | ^^ + +error: `async gen` fn bodies are not allowed in constant functions + --> $DIR/const_gen_fn.rs:9:24 + | +LL | const async gen fn b() {} + | ^^ + +error: aborting due to 4 previous errors diff --git a/tests/ui/coroutine/gen_block.none.stderr b/tests/ui/coroutine/gen_block.none.stderr index ed744f2957ac5..b793033b5216a 100644 --- a/tests/ui/coroutine/gen_block.none.stderr +++ b/tests/ui/coroutine/gen_block.none.stderr @@ -31,7 +31,7 @@ LL | let _ = || yield true; | ^^^^^^^^^^ | = note: see issue #43122 for more information - = help: add `#![feature(coroutines)]` to the crate attributes to enable + = help: add `#![feature(yield_expr)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: yield syntax is experimental @@ -41,7 +41,7 @@ LL | let _ = #[coroutine] || yield true; | ^^^^^^^^^^ | = note: see issue #43122 for more information - = help: add `#![feature(coroutines)]` to the crate attributes to enable + = help: add `#![feature(yield_expr)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the `#[coroutine]` attribute is an experimental feature diff --git a/tests/ui/enum-discriminant/eval-error.rs b/tests/ui/enum-discriminant/eval-error.rs index 08b71d52a8b03..45ac9472a4b7b 100644 --- a/tests/ui/enum-discriminant/eval-error.rs +++ b/tests/ui/enum-discriminant/eval-error.rs @@ -6,7 +6,7 @@ union Foo { enum Bar { Boo = { - let _: Option = None; //~ ERROR evaluation of constant value failed + let _: Option = None; //~ ERROR `Foo` has an unknown layout 0 }, } diff --git a/tests/ui/enum-discriminant/eval-error.stderr b/tests/ui/enum-discriminant/eval-error.stderr index 6bec2c8b420f7..b4061d7777bda 100644 --- a/tests/ui/enum-discriminant/eval-error.stderr +++ b/tests/ui/enum-discriminant/eval-error.stderr @@ -45,11 +45,11 @@ help: wrap the field type in `ManuallyDrop<...>` LL | a: std::mem::ManuallyDrop, | +++++++++++++++++++++++ + -error[E0080]: evaluation of constant value failed +error[E0080]: the type `Foo` has an unknown layout --> $DIR/eval-error.rs:9:30 | LL | let _: Option = None; - | ^^^^ the type `Foo` has an unknown layout + | ^^^^ evaluation of constant value failed here error: aborting due to 5 previous errors diff --git a/tests/ui/error-codes/E0080.rs b/tests/ui/error-codes/E0080.rs index 55f45055f013c..0d19f02a9f108 100644 --- a/tests/ui/error-codes/E0080.rs +++ b/tests/ui/error-codes/E0080.rs @@ -1,9 +1,6 @@ enum Enum { - X = (1 << 500), //~ ERROR E0080 - //~| NOTE attempt to shift left by `500_i32`, which would overflow - Y = (1 / 0) //~ ERROR E0080 - //~| NOTE attempt to divide `1_isize` by zero + X = (1 << 500), //~ ERROR attempt to shift left by `500_i32`, which would overflow + Y = (1 / 0), //~ ERROR attempt to divide `1_isize` by zero } -fn main() { -} +fn main() {} diff --git a/tests/ui/error-codes/E0080.stderr b/tests/ui/error-codes/E0080.stderr index 60ed9a4358f12..431d4e04454d1 100644 --- a/tests/ui/error-codes/E0080.stderr +++ b/tests/ui/error-codes/E0080.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to shift left by `500_i32`, which would overflow --> $DIR/E0080.rs:2:9 | LL | X = (1 << 500), - | ^^^^^^^^^^ attempt to shift left by `500_i32`, which would overflow + | ^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/E0080.rs:4:9 +error[E0080]: attempt to divide `1_isize` by zero + --> $DIR/E0080.rs:3:9 | -LL | Y = (1 / 0) - | ^^^^^^^ attempt to divide `1_isize` by zero +LL | Y = (1 / 0), + | ^^^^^^^ evaluation of constant value failed here error: aborting due to 2 previous errors 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 8fb51f5b637c3..2d558e9a5619a 100644 --- a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr +++ b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: reached the configured maximum number of stack frames --> $DIR/ctfe-id-unlimited.rs:28:20 | LL | const ID_ED: u32 = rec_id(ORIGINAL); - | ^^^^^^^^^^^^^^^^ reached the configured maximum number of stack frames + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `rec_id` --> $DIR/ctfe-id-unlimited.rs:21:5 diff --git a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.rs b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.rs index 9e89f4066bb70..53cccb38e2b88 100644 --- a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.rs +++ b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.rs @@ -25,7 +25,7 @@ const fn rec_id(n: u32) -> u32 { const ORIGINAL: u32 = 12345; // Original number, but with identity function applied // (this is the same, but requires execution of the recursion) -const ID_ED: u32 = rec_id(ORIGINAL); //[return]~ error: evaluation of constant value failed +const ID_ED: u32 = rec_id(ORIGINAL); //[return]~ ERROR: reached the configured maximum number of stack frames // Assert to make absolutely sure the computation actually happens const ASSERT: () = assert!(ORIGINAL == ID_ED); diff --git a/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.rs b/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.rs index e7038a01d2dee..bf32232cee3d1 100644 --- a/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.rs +++ b/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.rs @@ -10,7 +10,7 @@ const fn g() { //~^ NOTE in this expansion of panic! } -const _: () = f(); //~ ERROR evaluation of constant value failed -//~^ NOTE explicit panic +const _: () = f(); //~ NOTE evaluation of constant value failed +//~^ ERROR explicit panic fn main() {} diff --git a/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.stderr b/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.stderr index 3bdd09e9683d3..457290b76b8ad 100644 --- a/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.stderr +++ b/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/ctfe-tail-call-panic.rs:13:15 | LL | const _: () = f(); - | ^^^ evaluation panicked: explicit panic + | ^^^ evaluation of constant value failed here | note: inside `g` --> $DIR/ctfe-tail-call-panic.rs:9:5 diff --git a/tests/ui/extern/issue-28324.rs b/tests/ui/extern/issue-28324.rs index a5e240fa283b7..4af400d823bb1 100644 --- a/tests/ui/extern/issue-28324.rs +++ b/tests/ui/extern/issue-28324.rs @@ -4,6 +4,6 @@ extern "C" { pub static BAZ: u32 = *&error_message_count; //~^ ERROR use of extern static is unsafe and requires -//~| ERROR could not evaluate static initializer +//~| ERROR cannot access extern static fn main() {} diff --git a/tests/ui/extern/issue-28324.stderr b/tests/ui/extern/issue-28324.stderr index 93eb6ff8174e9..89dfab945be46 100644 --- a/tests/ui/extern/issue-28324.stderr +++ b/tests/ui/extern/issue-28324.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: cannot access extern static `error_message_count` --> $DIR/issue-28324.rs:5:23 | LL | pub static BAZ: u32 = *&error_message_count; - | ^^^^^^^^^^^^^^^^^^^^^ cannot access extern static `error_message_count` + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here error[E0133]: use of extern static is unsafe and requires unsafe function or block --> $DIR/issue-28324.rs:5:25 diff --git a/tests/ui/feature-gates/feature-gate-coroutines.e2024.stderr b/tests/ui/feature-gates/feature-gate-coroutines.e2024.stderr index 381e7a210be06..c29c328ac143e 100644 --- a/tests/ui/feature-gates/feature-gate-coroutines.e2024.stderr +++ b/tests/ui/feature-gates/feature-gate-coroutines.e2024.stderr @@ -5,7 +5,7 @@ LL | yield true; | ^^^^^^^^^^ | = note: see issue #43122 for more information - = help: add `#![feature(coroutines)]` to the crate attributes to enable + = help: add `#![feature(yield_expr)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: yield syntax is experimental @@ -15,7 +15,7 @@ LL | let _ = || yield true; | ^^^^^^^^^^ | = note: see issue #43122 for more information - = help: add `#![feature(coroutines)]` to the crate attributes to enable + = help: add `#![feature(yield_expr)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: yield syntax is experimental @@ -25,7 +25,7 @@ LL | yield; | ^^^^^ | = note: see issue #43122 for more information - = help: add `#![feature(coroutines)]` to the crate attributes to enable + = help: add `#![feature(yield_expr)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: yield syntax is experimental @@ -35,7 +35,7 @@ LL | yield 0; | ^^^^^^^ | = note: see issue #43122 for more information - = help: add `#![feature(coroutines)]` to the crate attributes to enable + = help: add `#![feature(yield_expr)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: yield syntax is experimental diff --git a/tests/ui/feature-gates/feature-gate-coroutines.none.stderr b/tests/ui/feature-gates/feature-gate-coroutines.none.stderr index 381e7a210be06..c29c328ac143e 100644 --- a/tests/ui/feature-gates/feature-gate-coroutines.none.stderr +++ b/tests/ui/feature-gates/feature-gate-coroutines.none.stderr @@ -5,7 +5,7 @@ LL | yield true; | ^^^^^^^^^^ | = note: see issue #43122 for more information - = help: add `#![feature(coroutines)]` to the crate attributes to enable + = help: add `#![feature(yield_expr)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: yield syntax is experimental @@ -15,7 +15,7 @@ LL | let _ = || yield true; | ^^^^^^^^^^ | = note: see issue #43122 for more information - = help: add `#![feature(coroutines)]` to the crate attributes to enable + = help: add `#![feature(yield_expr)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: yield syntax is experimental @@ -25,7 +25,7 @@ LL | yield; | ^^^^^ | = note: see issue #43122 for more information - = help: add `#![feature(coroutines)]` to the crate attributes to enable + = help: add `#![feature(yield_expr)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: yield syntax is experimental @@ -35,7 +35,7 @@ LL | yield 0; | ^^^^^^^ | = note: see issue #43122 for more information - = help: add `#![feature(coroutines)]` to the crate attributes to enable + = help: add `#![feature(yield_expr)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: yield syntax is experimental diff --git a/tests/ui/feature-gates/feature-gate-yield-expr.stderr b/tests/ui/feature-gates/feature-gate-yield-expr.stderr index ad8a15a0f3650..bfac9e498037d 100644 --- a/tests/ui/feature-gates/feature-gate-yield-expr.stderr +++ b/tests/ui/feature-gates/feature-gate-yield-expr.stderr @@ -5,7 +5,7 @@ LL | yield (); | ^^^^^^^^ | = note: see issue #43122 for more information - = help: add `#![feature(coroutines)]` to the crate attributes to enable + = help: add `#![feature(yield_expr)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: yield syntax is experimental diff --git a/tests/ui/generic-const-items/def-site-eval.fail.stderr b/tests/ui/generic-const-items/def-site-eval.fail.stderr index 4e7d9d8154a0e..b861654739023 100644 --- a/tests/ui/generic-const-items/def-site-eval.fail.stderr +++ b/tests/ui/generic-const-items/def-site-eval.fail.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/def-site-eval.rs:13:20 | LL | const _<'_a>: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/generic-const-items/def-site-eval.rs b/tests/ui/generic-const-items/def-site-eval.rs index b95e40c05d4d8..fa3ef5907b26d 100644 --- a/tests/ui/generic-const-items/def-site-eval.rs +++ b/tests/ui/generic-const-items/def-site-eval.rs @@ -10,6 +10,6 @@ const _<_T>: () = panic!(); const _: () = panic!(); #[cfg(fail)] -const _<'_a>: () = panic!(); //[fail]~ ERROR evaluation of constant value failed +const _<'_a>: () = panic!(); //[fail]~ ERROR evaluation panicked: explicit panic fn main() {} diff --git a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.rs b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.rs index 93f01c9577c04..102c7b1e5f938 100644 --- a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.rs +++ b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.rs @@ -3,7 +3,7 @@ // Ensure that we check if trivial bounds on const items hold or not. -const UNUSABLE: () = () //~ ERROR evaluation of constant value failed +const UNUSABLE: () = () //~ ERROR entering unreachable code where String: Copy; diff --git a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.stderr b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.stderr index 407682fee5664..a89356fadfdc1 100644 --- a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.stderr +++ b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.stderr @@ -1,10 +1,10 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: entering unreachable code --> $DIR/trivially-unsatisfied-bounds-0.rs:6:1 | LL | / const UNUSABLE: () = () LL | | where LL | | String: Copy; - | |_________________^ entering unreachable code + | |_________________^ evaluation of constant value failed here error[E0277]: the trait bound `String: Copy` is not satisfied --> $DIR/trivially-unsatisfied-bounds-0.rs:11:13 diff --git a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.rs b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.rs index 9243deac8704a..ebe97a65bbf31 100644 --- a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.rs +++ b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.rs @@ -7,6 +7,6 @@ const UNUSED: () = () where String: Copy; -//~^^^ ERROR evaluation of constant value failed +//~^^^ ERROR unreachable code fn main() {} diff --git a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.stderr b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.stderr index b8438a0589c5c..3aa26eb16567c 100644 --- a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.stderr +++ b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.stderr @@ -1,10 +1,10 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: entering unreachable code --> $DIR/trivially-unsatisfied-bounds-1.rs:7:1 | LL | / const UNUSED: () = () LL | | where LL | | String: Copy; - | |_________________^ entering unreachable code + | |_________________^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.rs b/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.rs index 961e5b4aeeb86..13ce1f7de5bd6 100644 --- a/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.rs +++ b/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.rs @@ -5,7 +5,7 @@ const POSITIVE: usize = N where - [(); N - 1]:; //~ ERROR evaluation of `POSITIVE::<0>::{constant#0}` failed + [(); N - 1]:; //~ ERROR overflow fn main() { let _ = POSITIVE::<0>; diff --git a/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.stderr b/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.stderr index f522190e8aa32..a9f11ac31c3e8 100644 --- a/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.stderr +++ b/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `POSITIVE::<0>::{constant#0}` failed +error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow --> $DIR/unsatisfied-evaluatable-bounds.rs:8:10 | LL | [(); N - 1]:; - | ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow + | ^^^^^ evaluation of `POSITIVE::<0>::{constant#0}` failed here error: aborting due to 1 previous error diff --git a/tests/ui/generics/post_monomorphization_error_backtrace.rs b/tests/ui/generics/post_monomorphization_error_backtrace.rs index f5f36ef03ae66..9f53751584b1e 100644 --- a/tests/ui/generics/post_monomorphization_error_backtrace.rs +++ b/tests/ui/generics/post_monomorphization_error_backtrace.rs @@ -4,12 +4,12 @@ fn assert_zst() { struct F(T); impl F { const V: () = assert!(std::mem::size_of::() == 0); - //~^ ERROR: evaluation of `assert_zst::F::::V` failed [E0080] + //~^ NOTE: evaluation of `assert_zst::F::::V` failed //~| NOTE: in this expansion of assert! - //~| NOTE: assertion failed - //~| ERROR: evaluation of `assert_zst::F::::V` failed [E0080] + //~| ERROR: assertion failed + //~| NOTE: evaluation of `assert_zst::F::::V` failed //~| NOTE: in this expansion of assert! - //~| NOTE: assertion failed + //~| ERROR: assertion failed } F::::V; //~^NOTE: erroneous constant @@ -23,7 +23,6 @@ fn foo() { //~| NOTE: the above error was encountered while instantiating `fn assert_zst::` } - fn bar() { foo::() } diff --git a/tests/ui/generics/post_monomorphization_error_backtrace.stderr b/tests/ui/generics/post_monomorphization_error_backtrace.stderr index 96aa04ee359a9..6953414f0c235 100644 --- a/tests/ui/generics/post_monomorphization_error_backtrace.stderr +++ b/tests/ui/generics/post_monomorphization_error_backtrace.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `assert_zst::F::::V` failed +error[E0080]: evaluation panicked: assertion failed: std::mem::size_of::() == 0 --> $DIR/post_monomorphization_error_backtrace.rs:6:23 | LL | const V: () = assert!(std::mem::size_of::() == 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: assertion failed: std::mem::size_of::() == 0 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `assert_zst::F::::V` failed here note: erroneous constant encountered --> $DIR/post_monomorphization_error_backtrace.rs:14:5 @@ -16,11 +16,11 @@ note: the above error was encountered while instantiating `fn assert_zst::` LL | assert_zst::() | ^^^^^^^^^^^^^^^^^ -error[E0080]: evaluation of `assert_zst::F::::V` failed +error[E0080]: evaluation panicked: assertion failed: std::mem::size_of::() == 0 --> $DIR/post_monomorphization_error_backtrace.rs:6:23 | LL | const V: () = assert!(std::mem::size_of::() == 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: assertion failed: std::mem::size_of::() == 0 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `assert_zst::F::::V` failed here note: erroneous constant encountered --> $DIR/post_monomorphization_error_backtrace.rs:14:5 diff --git a/tests/ui/infinite/infinite-recursion-const-fn.rs b/tests/ui/infinite/infinite-recursion-const-fn.rs index 7b7f6fafab5f7..3c0b3b9741bd6 100644 --- a/tests/ui/infinite/infinite-recursion-const-fn.rs +++ b/tests/ui/infinite/infinite-recursion-const-fn.rs @@ -6,6 +6,6 @@ const fn a() -> usize { const fn b() -> usize { a() } -const ARR: [i32; a()] = [5; 6]; //~ ERROR evaluation of constant value failed [E0080] +const ARR: [i32; a()] = [5; 6]; //~ ERROR reached the configured maximum number of stack frames fn main() {} diff --git a/tests/ui/infinite/infinite-recursion-const-fn.stderr b/tests/ui/infinite/infinite-recursion-const-fn.stderr index 524abdf4d7ad0..529bad510c9dc 100644 --- a/tests/ui/infinite/infinite-recursion-const-fn.stderr +++ b/tests/ui/infinite/infinite-recursion-const-fn.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: reached the configured maximum number of stack frames --> $DIR/infinite-recursion-const-fn.rs:9:18 | LL | const ARR: [i32; a()] = [5; 6]; - | ^^^ reached the configured maximum number of stack frames + | ^^^ evaluation of constant value failed here | note: inside `a` --> $DIR/infinite-recursion-const-fn.rs:4:5 diff --git a/tests/ui/inline-const/const-expr-generic-err.stderr b/tests/ui/inline-const/const-expr-generic-err.stderr index a40e8bceb3605..26039ba6d4449 100644 --- a/tests/ui/inline-const/const-expr-generic-err.stderr +++ b/tests/ui/inline-const/const-expr-generic-err.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `foo::::{constant#0}` failed +error[E0080]: evaluation panicked: assertion failed: std::mem::size_of::() == 0 --> $DIR/const-expr-generic-err.rs:4:13 | LL | const { assert!(std::mem::size_of::() == 0); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: assertion failed: std::mem::size_of::() == 0 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `foo::::{constant#0}` failed here note: erroneous constant encountered --> $DIR/const-expr-generic-err.rs:4:5 @@ -16,11 +16,11 @@ note: the above error was encountered while instantiating `fn foo::` LL | foo::(); | ^^^^^^^^^^^^ -error[E0080]: evaluation of `bar::<0>::{constant#0}` failed +error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow --> $DIR/const-expr-generic-err.rs:8:13 | LL | const { N - 1 } - | ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow + | ^^^^^ evaluation of `bar::<0>::{constant#0}` failed here note: erroneous constant encountered --> $DIR/const-expr-generic-err.rs:8:5 diff --git a/tests/ui/inline-const/required-const.stderr b/tests/ui/inline-const/required-const.stderr index 2f618e54ed3f4..a517ea2fec0f1 100644 --- a/tests/ui/inline-const/required-const.stderr +++ b/tests/ui/inline-const/required-const.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `foo::::{constant#0}` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/required-const.rs:6:17 | LL | const { panic!() } - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `foo::::{constant#0}` failed here note: erroneous constant encountered --> $DIR/required-const.rs:6:9 diff --git a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs index fdb25a3ae3f5e..15f4a9a778ed6 100644 --- a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs +++ b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs @@ -2,22 +2,19 @@ const RAW_EQ_PADDING: bool = unsafe { std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16)) -//~^ ERROR evaluation of constant value failed -//~| NOTE requires initialized memory +//~^ ERROR requires initialized memory }; const RAW_EQ_PTR: bool = unsafe { std::intrinsics::raw_eq(&(&0), &(&1)) -//~^ ERROR evaluation of constant value failed -//~| NOTE unable to turn pointer into integer +//~^ ERROR unable to turn pointer into integer }; const RAW_EQ_NOT_ALIGNED: bool = unsafe { let arr = [0u8; 4]; let aref = &*arr.as_ptr().cast::(); std::intrinsics::raw_eq(aref, aref) -//~^ ERROR evaluation of constant value failed -//~| NOTE alignment +//~^ ERROR alignment }; pub fn main() { diff --git a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr index b8fdfe7bef35a..1d2c263baf167 100644 --- a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr +++ b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr @@ -1,23 +1,23 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory --> $DIR/intrinsic-raw_eq-const-bad.rs:4:5 | LL | std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/intrinsic-raw_eq-const-bad.rs:10:5 +error[E0080]: unable to turn pointer into integer + --> $DIR/intrinsic-raw_eq-const-bad.rs:9:5 | LL | std::intrinsics::raw_eq(&(&0), &(&1)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/intrinsic-raw_eq-const-bad.rs:18:5 +error[E0080]: accessing memory with alignment 1, but alignment 4 is required + --> $DIR/intrinsic-raw_eq-const-bad.rs:16:5 | LL | std::intrinsics::raw_eq(aref, aref) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ accessing memory with alignment 1, but alignment 4 is required + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 3 previous errors diff --git a/tests/ui/issues/auxiliary/issue-11224.rs b/tests/ui/issues/auxiliary/issue-11224.rs index 63543621a80d8..94fb1f3abd587 100644 --- a/tests/ui/issues/auxiliary/issue-11224.rs +++ b/tests/ui/issues/auxiliary/issue-11224.rs @@ -11,6 +11,6 @@ mod inner { } pub fn foo() { - let a = &1isize as &inner::Trait; + let a = &1isize as &dyn inner::Trait; a.f(); } diff --git a/tests/ui/issues/auxiliary/issue-13507.rs b/tests/ui/issues/auxiliary/issue-13507.rs index c91013043eb77..4160cf99f53e8 100644 --- a/tests/ui/issues/auxiliary/issue-13507.rs +++ b/tests/ui/issues/auxiliary/issue-13507.rs @@ -16,7 +16,7 @@ pub mod testtypes { TypeId::of::(), TypeId::of::(), TypeId::of::(), - TypeId::of::(), + TypeId::of::(), TypeId::of::(), TypeId::of::() ] diff --git a/tests/ui/issues/auxiliary/issue-17662.rs b/tests/ui/issues/auxiliary/issue-17662.rs index 75efe110cdfd9..5ecec31deb018 100644 --- a/tests/ui/issues/auxiliary/issue-17662.rs +++ b/tests/ui/issues/auxiliary/issue-17662.rs @@ -4,9 +4,9 @@ pub trait Foo<'a, T> { fn foo(&'a self) -> T; } -pub fn foo<'a, T>(x: &'a Foo<'a, T>) -> T { - let x: &'a Foo = x; - // ^ the lifetime parameter of Foo is left to be inferred. +pub fn foo<'a, T>(x: &'a dyn Foo<'a, T>) -> T { + let x: &'a dyn Foo = x; + // ^ the lifetime parameter of Foo is left to be inferred. x.foo() // ^ encoding this method call in metadata triggers an ICE. } diff --git a/tests/ui/issues/auxiliary/issue-2380.rs b/tests/ui/issues/auxiliary/issue-2380.rs index 79fd62d16332f..9ec829b417f81 100644 --- a/tests/ui/issues/auxiliary/issue-2380.rs +++ b/tests/ui/issues/auxiliary/issue-2380.rs @@ -6,8 +6,8 @@ pub trait i fn dummy(&self, t: T) -> T { panic!() } } -pub fn f() -> Box+'static> { +pub fn f() -> Box+'static> { impl i for () { } - Box::new(()) as Box+'static> + Box::new(()) as Box+'static> } diff --git a/tests/ui/issues/auxiliary/issue-25467.rs b/tests/ui/issues/auxiliary/issue-25467.rs index ca9b3097c830f..16c2869dc75cc 100644 --- a/tests/ui/issues/auxiliary/issue-25467.rs +++ b/tests/ui/issues/auxiliary/issue-25467.rs @@ -7,4 +7,4 @@ pub trait Trait { type Issue25467BarT; } -pub type Object = Option>>; +pub type Object = Option>>; diff --git a/tests/ui/issues/auxiliary/issue-34796-aux.rs b/tests/ui/issues/auxiliary/issue-34796-aux.rs index 09c69b90329ff..0e91bb4bcdc1f 100644 --- a/tests/ui/issues/auxiliary/issue-34796-aux.rs +++ b/tests/ui/issues/auxiliary/issue-34796-aux.rs @@ -9,7 +9,7 @@ impl Future for u32 { type Error = Box<()>; } -fn foo() -> Box>> { +fn foo() -> Box>> { Box::new(0u32) } diff --git a/tests/ui/issues/auxiliary/issue-38226-aux.rs b/tests/ui/issues/auxiliary/issue-38226-aux.rs index f968017199f50..a8e964e016fd1 100644 --- a/tests/ui/issues/auxiliary/issue-38226-aux.rs +++ b/tests/ui/issues/auxiliary/issue-38226-aux.rs @@ -2,7 +2,7 @@ #[inline(never)] pub fn foo() { - let _: Box = Box::new(SomeTraitImpl); + let _: Box = Box::new(SomeTraitImpl); } pub fn bar() { diff --git a/tests/ui/issues/auxiliary/issue-8401.rs b/tests/ui/issues/auxiliary/issue-8401.rs index e35dbbfabfcdd..7d0eb5cd8762e 100644 --- a/tests/ui/issues/auxiliary/issue-8401.rs +++ b/tests/ui/issues/auxiliary/issue-8401.rs @@ -8,9 +8,9 @@ trait A { struct B; impl A for B {} -fn bar(_: &mut A, _: &T) {} +fn bar(_: &mut dyn A, _: &T) {} fn foo(t: &T) { let mut b = B; - bar(&mut b as &mut A, t) + bar(&mut b as &mut dyn A, t) } diff --git a/tests/ui/issues/issue-34373.rs b/tests/ui/issues/issue-34373.rs index 707aa8cf33833..5b05811a4eb3f 100644 --- a/tests/ui/issues/issue-34373.rs +++ b/tests/ui/issues/issue-34373.rs @@ -4,7 +4,7 @@ trait Trait { fn foo(_: T) {} } -pub struct Foo>>; //~ ERROR cycle detected +pub struct Foo>>; //~ ERROR cycle detected //~^ ERROR `T` is never used type DefaultFoo = Foo; diff --git a/tests/ui/issues/issue-34373.stderr b/tests/ui/issues/issue-34373.stderr index 0636555821730..03d7719313416 100644 --- a/tests/ui/issues/issue-34373.stderr +++ b/tests/ui/issues/issue-34373.stderr @@ -1,8 +1,8 @@ error[E0391]: cycle detected when computing type of `Foo::T` - --> $DIR/issue-34373.rs:7:30 + --> $DIR/issue-34373.rs:7:34 | -LL | pub struct Foo>>; - | ^^^^^^^^^^ +LL | pub struct Foo>>; + | ^^^^^^^^^^ | note: ...which requires expanding type alias `DefaultFoo`... --> $DIR/issue-34373.rs:9:19 @@ -13,15 +13,15 @@ LL | type DefaultFoo = Foo; note: cycle used when checking that `Foo` is well-formed --> $DIR/issue-34373.rs:7:1 | -LL | pub struct Foo>>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | pub struct Foo>>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error[E0392]: type parameter `T` is never used --> $DIR/issue-34373.rs:7:16 | -LL | pub struct Foo>>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unused type parameter +LL | pub struct Foo>>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused type parameter | = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead diff --git a/tests/ui/issues/issue-76191.rs b/tests/ui/issues/issue-76191.rs index 277624c005a56..d2de44380c372 100644 --- a/tests/ui/issues/issue-76191.rs +++ b/tests/ui/issues/issue-76191.rs @@ -6,7 +6,7 @@ use std::ops::RangeInclusive; const RANGE: RangeInclusive = 0..=255; const RANGE2: RangeInclusive = panic!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked: explicit panic fn main() { let n: i32 = 1; diff --git a/tests/ui/issues/issue-76191.stderr b/tests/ui/issues/issue-76191.stderr index ac1bdfaa847eb..1f19db49c43ee 100644 --- a/tests/ui/issues/issue-76191.stderr +++ b/tests/ui/issues/issue-76191.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/issue-76191.rs:8:37 | LL | const RANGE2: RangeInclusive = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of constant value failed here error[E0308]: mismatched types --> $DIR/issue-76191.rs:14:9 diff --git a/tests/ui/iterators/generator.rs b/tests/ui/iterators/generator.rs new file mode 100644 index 0000000000000..e633efb11c1da --- /dev/null +++ b/tests/ui/iterators/generator.rs @@ -0,0 +1,24 @@ +//@ run-pass + +#![feature(iter_macro, yield_expr)] + +use std::iter::iter; + +fn main() { + let i = iter! { || { + yield 0; + for x in 5..10 { + yield x * 2; + } + } }; + let mut i = i(); + assert_eq!(i.next(), Some(0)); + assert_eq!(i.next(), Some(10)); + assert_eq!(i.next(), Some(12)); + assert_eq!(i.next(), Some(14)); + assert_eq!(i.next(), Some(16)); + assert_eq!(i.next(), Some(18)); + assert_eq!(i.next(), None); + assert_eq!(i.next(), None); + assert_eq!(i.next(), None); +} diff --git a/tests/ui/iterators/generator_args.rs b/tests/ui/iterators/generator_args.rs new file mode 100644 index 0000000000000..c9da9e5fba609 --- /dev/null +++ b/tests/ui/iterators/generator_args.rs @@ -0,0 +1,24 @@ +//@ run-pass + +#![feature(iter_macro, yield_expr)] + +use std::iter::iter; + +fn main() { + let i = iter! {|foo| { + yield foo; + for x in 5..10 { + yield x * 2; + } + }}; + let mut i = i(3); + assert_eq!(i.next(), Some(3)); + assert_eq!(i.next(), Some(10)); + assert_eq!(i.next(), Some(12)); + assert_eq!(i.next(), Some(14)); + assert_eq!(i.next(), Some(16)); + assert_eq!(i.next(), Some(18)); + assert_eq!(i.next(), None); + assert_eq!(i.next(), None); + assert_eq!(i.next(), None); +} diff --git a/tests/ui/iterators/generator_capture.rs b/tests/ui/iterators/generator_capture.rs new file mode 100644 index 0000000000000..c790b7a4b968e --- /dev/null +++ b/tests/ui/iterators/generator_capture.rs @@ -0,0 +1,27 @@ +//@ run-pass + +#![feature(iter_macro, yield_expr)] + +use std::iter::iter; + +fn main() { + let i = { + let s = String::new(); + iter! { move || { + yield s.len(); + for x in 5..10 { + yield x * 2; + } + }} + }; + let mut i = i(); + assert_eq!(i.next(), Some(0)); + assert_eq!(i.next(), Some(10)); + assert_eq!(i.next(), Some(12)); + assert_eq!(i.next(), Some(14)); + assert_eq!(i.next(), Some(16)); + assert_eq!(i.next(), Some(18)); + assert_eq!(i.next(), None); + assert_eq!(i.next(), None); + assert_eq!(i.next(), None); +} diff --git a/tests/ui/iterators/generator_capture_.rs b/tests/ui/iterators/generator_capture_.rs new file mode 100644 index 0000000000000..f630bc64b974c --- /dev/null +++ b/tests/ui/iterators/generator_capture_.rs @@ -0,0 +1,26 @@ +// This test exercises lending behavior for iterator closures which is not yet supported. + +#![feature(iter_macro, yield_expr)] + +use std::iter::iter; + +fn main() { + let f = { + let s = "foo".to_string(); + iter! { move || { + for c in s.chars() { + yield c; + } + }} + }; + let mut i = f(); + assert_eq!(i.next(), Some('f')); + assert_eq!(i.next(), Some('o')); + assert_eq!(i.next(), Some('o')); + assert_eq!(i.next(), None); + 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')); + assert_eq!(i.next(), None); +} diff --git a/tests/ui/iterators/generator_capture_.stderr b/tests/ui/iterators/generator_capture_.stderr new file mode 100644 index 0000000000000..3d9647ae16f32 --- /dev/null +++ b/tests/ui/iterators/generator_capture_.stderr @@ -0,0 +1,25 @@ +error[E0382]: use of moved value: `f` + --> $DIR/generator_capture_.rs:21:17 + | +LL | let f = { + | - move occurs because `f` has type `{gen closure@$DIR/generator_capture_.rs:10:17: 10: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_.rs:16: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_fail.rs b/tests/ui/iterators/generator_capture_fail.rs new file mode 100644 index 0000000000000..d987b2df01164 --- /dev/null +++ b/tests/ui/iterators/generator_capture_fail.rs @@ -0,0 +1,25 @@ +#![feature(iter_macro, yield_expr)] + +use std::iter::iter; + +fn main() { + let i = { + let s = String::new(); + iter! { || { //~ ERROR `s` does not live long enough + yield s.len(); + for x in 5..10 { + yield x * 2; + } + } } + }; + let mut i = i(); + assert_eq!(i.next(), Some(0)); + assert_eq!(i.next(), Some(10)); + assert_eq!(i.next(), Some(12)); + assert_eq!(i.next(), Some(14)); + assert_eq!(i.next(), Some(16)); + assert_eq!(i.next(), Some(18)); + assert_eq!(i.next(), None); + assert_eq!(i.next(), None); + assert_eq!(i.next(), None); +} diff --git a/tests/ui/iterators/generator_capture_fail.stderr b/tests/ui/iterators/generator_capture_fail.stderr new file mode 100644 index 0000000000000..225a385d6a0fa --- /dev/null +++ b/tests/ui/iterators/generator_capture_fail.stderr @@ -0,0 +1,20 @@ +error[E0597]: `s` does not live long enough + --> $DIR/generator_capture_fail.rs:8:17 + | +LL | let i = { + | - borrow later stored here +LL | let s = String::new(); +LL | iter! { || { + | _________________^ +LL | | yield s.len(); +LL | | for x in 5..10 { +LL | | yield x * 2; +LL | | } +LL | | } } + | |_________^ borrowed value does not live long enough +LL | }; + | - `s` dropped here while still borrowed + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/tests/ui/iterators/generator_capture_fnonce.rs b/tests/ui/iterators/generator_capture_fnonce.rs new file mode 100644 index 0000000000000..090727eb9b7e4 --- /dev/null +++ b/tests/ui/iterators/generator_capture_fnonce.rs @@ -0,0 +1,32 @@ +//@ run-pass + +#![feature(iter_macro, yield_expr)] + +use std::iter::iter; + +fn main() { + let i = { + let s = String::new(); + iter! { move || { + yield s.len(); + for x in 5..10 { + yield x * 2; + } + }} + }; + test_iterator(i); +} + +/// Exercise the iterator in a separate function to ensure it's not capturing anything it shoudln't. +fn test_iterator>(i: impl FnOnce() -> I) { + let mut i = i(); + assert_eq!(i.next(), Some(0)); + assert_eq!(i.next(), Some(10)); + assert_eq!(i.next(), Some(12)); + assert_eq!(i.next(), Some(14)); + assert_eq!(i.next(), Some(16)); + assert_eq!(i.next(), Some(18)); + assert_eq!(i.next(), None); + assert_eq!(i.next(), None); + assert_eq!(i.next(), None); +} diff --git a/tests/ui/iterators/generator_capture_no_lend.rs b/tests/ui/iterators/generator_capture_no_lend.rs new file mode 100644 index 0000000000000..822db58d48df2 --- /dev/null +++ b/tests/ui/iterators/generator_capture_no_lend.rs @@ -0,0 +1,30 @@ +//@ run-pass + +#![feature(iter_macro, yield_expr)] + +// This test creates an iterator that captures a reference and ensure that doesn't force the +// iterator to become lending. + +use std::iter::iter; + +fn main() { + let s = "foo".to_string(); + let f = iter! { || { + for c in s.chars() { + yield c; + } + }}; + + let mut i = f(); + let mut j = f(); + + assert_eq!(i.next(), Some('f')); + assert_eq!(i.next(), Some('o')); + assert_eq!(i.next(), Some('o')); + assert_eq!(i.next(), None); + + assert_eq!(j.next(), Some('f')); + assert_eq!(j.next(), Some('o')); + assert_eq!(j.next(), Some('o')); + assert_eq!(j.next(), None); +} diff --git a/tests/ui/iterators/generator_returned_from_fn.rs b/tests/ui/iterators/generator_returned_from_fn.rs new file mode 100644 index 0000000000000..bd0317b1ffb7f --- /dev/null +++ b/tests/ui/iterators/generator_returned_from_fn.rs @@ -0,0 +1,63 @@ +#![feature(iter_macro, impl_trait_in_fn_trait_return, yield_expr)] + +use std::iter::iter; + +fn plain() -> impl Fn() -> impl Iterator { + iter! { || { + yield 0; + for x in 5..10 { + yield x * 2; + } + } } +} + +fn arg() -> impl Fn(u32) -> impl Iterator { + iter! { |arg| { + yield arg; + for x in 5..10 { + yield x * 2; + } + } } +} + +fn capture<'a>(a: &'a u32) -> impl Fn() -> (impl Iterator + 'a) { + iter! { || { //~ ERROR cannot return reference to function parameter `a` + yield *a; + for x in 5..10 { + yield x * 2; + } + } } +} + +fn capture_move(a: &u32) -> impl Fn() -> impl Iterator { + iter! { move || { //~ ERROR does not implement `Fn` because it captures + yield *a; + for x in 5..10 { + yield x * 2; + } + } } +} + +fn capture_move_once(a: &u32) -> impl FnOnce() -> impl Iterator { + iter! { move || { + //~^ ERROR captures lifetime + //~| ERROR: captures lifetime + yield *a; + for x in 5..10 { + yield x * 2; + } + } } +} + +fn capture_move_once_lifetimes<'a>( + a: &'a u32, +) -> impl FnOnce() -> (impl Iterator + 'a) { + iter! { move || { + yield *a; + for x in 5..10 { + yield x * 2; + } + } } +} + +fn main() {} diff --git a/tests/ui/iterators/generator_returned_from_fn.stderr b/tests/ui/iterators/generator_returned_from_fn.stderr new file mode 100644 index 0000000000000..b2324af6d5e40 --- /dev/null +++ b/tests/ui/iterators/generator_returned_from_fn.stderr @@ -0,0 +1,70 @@ +error[E0515]: cannot return reference to function parameter `a` + --> $DIR/generator_returned_from_fn.rs:24:13 + | +LL | iter! { || { + | _____________^ +LL | | yield *a; +LL | | for x in 5..10 { +LL | | yield x * 2; +LL | | } +LL | | } } + | |_____^ returns a reference to data owned by the current function + +error: gen closure does not implement `Fn` because it captures state from its environment + --> $DIR/generator_returned_from_fn.rs:33:13 + | +LL | iter! { move || { + | _____________-^^^^^^ +LL | | yield *a; +LL | | for x in 5..10 { +LL | | yield x * 2; +LL | | } +LL | | } } + | |_____- return type was inferred to be `{gen closure@$DIR/generator_returned_from_fn.rs:33:13: 33:20}` here + +error[E0700]: hidden type for `impl FnOnce() -> impl Iterator` captures lifetime that does not appear in bounds + --> $DIR/generator_returned_from_fn.rs:42:13 + | +LL | fn capture_move_once(a: &u32) -> impl FnOnce() -> impl Iterator { + | ---- ------------------------------------------ opaque type defined here + | | + | hidden type `{gen closure@$DIR/generator_returned_from_fn.rs:42:13: 42:20}` captures the anonymous lifetime defined here +LL | iter! { move || { + | _____________^ +LL | | +LL | | +LL | | yield *a; +... | +LL | | } } + | |_____^ + | +help: add a `use<...>` bound to explicitly capture `'_` + | +LL | fn capture_move_once(a: &u32) -> impl FnOnce() -> impl Iterator + use<'_> { + | +++++++++ + +error[E0700]: hidden type for `impl Iterator` captures lifetime that does not appear in bounds + --> $DIR/generator_returned_from_fn.rs:42:13 + | +LL | fn capture_move_once(a: &u32) -> impl FnOnce() -> impl Iterator { + | ---- ------------------------- opaque type defined here + | | + | hidden type `{gen closure body@$DIR/generator_returned_from_fn.rs:42:21: 49:6}` captures the anonymous lifetime defined here +LL | iter! { move || { + | _____________^ +LL | | +LL | | +LL | | yield *a; +... | +LL | | } } + | |_____^ + | +help: add a `use<...>` bound to explicitly capture `'_` + | +LL | fn capture_move_once(a: &u32) -> impl FnOnce() -> impl Iterator + use<'_> { + | +++++++++ + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0515, E0700. +For more information about an error, try `rustc --explain E0515`. 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 new file mode 100644 index 0000000000000..4e0dabade2de0 --- /dev/null +++ b/tests/ui/iterators/iter-macro-not-async-closure-simplified.narrow.stderr @@ -0,0 +1,18 @@ +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:21:21: 21:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure-simplified.rs:27: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:21:21: 21:28}` +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure-simplified.rs:18:28 + | +LL | ...pl 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 new file mode 100644 index 0000000000000..4fa14fda661cf --- /dev/null +++ b/tests/ui/iterators/iter-macro-not-async-closure-simplified.rs @@ -0,0 +1,29 @@ +// This test ensures iterators created with the `iter!` macro are not +// accidentally async closures. +// +// We test this both in a `narrow` and `wide` configuration because +// the way that the diagnostic is emitted varies depending on the +// diagnostic width. If it's too narrow to fit the explanation, that +// explanation is moved to the `help` instead of the span label. +// +//@ edition: 2024 +//@ revisions: narrow wide +//@[narrow] compile-flags: --diagnostic-width=20 +//@[wide] compile-flags: --diagnostic-width=300 + +#![feature(yield_expr, iter_macro)] + +use std::iter::iter; + +fn call_async_once(_: impl AsyncFnOnce()) {} + +fn main() { + let f = iter! { move || { + for i in 0..10 { + yield i; + } + }}; + + call_async_once(f); + //~^ 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 new file mode 100644 index 0000000000000..a6c239c181b5f --- /dev/null +++ b/tests/ui/iterators/iter-macro-not-async-closure-simplified.wide.stderr @@ -0,0 +1,17 @@ +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:21:21: 21:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure-simplified.rs:27:21 + | +LL | call_async_once(f); + | --------------- ^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:21:21: 21: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:18: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.narrow.stderr b/tests/ui/iterators/iter-macro-not-async-closure.narrow.stderr new file mode 100644 index 0000000000000..af3289c3d4e04 --- /dev/null +++ b/tests/ui/iterators/iter-macro-not-async-closure.narrow.stderr @@ -0,0 +1,72 @@ +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:32:34 + | +LL | ...n!(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.rs:26:21: 26:28}` +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:21:34 + | +LL | ...pl AsyncFnOnce()) { + | ^^^^^^^^^^^^^ required by this bound in `call_async_once` + +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:32:18 + | +LL | ...n!(call_async_once(f)); + | ^^^^^^^^^^^^^^^^^^ unsatisfied trait bound + | + = help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}` +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:21:34 + | +LL | ...pl AsyncFnOnce()) { + | ^^^^^^^^^^^^^ required by this bound in `call_async_once` + +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:32:13 + | +LL | ... = pin!(call_async_once(f)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound + | + = help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}` +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:21:34 + | +LL | ...pl AsyncFnOnce()) { + | ^^^^^^^^^^^^^ required by this bound in `call_async_once` + = note: this error originates in the macro `pin` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:32:13 + | +LL | ... = pin!(call_async_once(f)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound + | + = help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}` +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:21:34 + | +LL | ...pl AsyncFnOnce()) { + | ^^^^^^^^^^^^^ required by this bound in `call_async_once` + = note: this error originates in the macro `pin` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:37:5 + | +LL | ...::noop())); + | ...^^^^^^^^^^ unsatisfied trait bound + | + = help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}` +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:21:34 + | +LL | ...pl AsyncFnOnce()) { + | ^^^^^^^^^^^^^ required by this bound in `call_async_once` + +error: aborting due to 5 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 new file mode 100644 index 0000000000000..634391883ea73 --- /dev/null +++ b/tests/ui/iterators/iter-macro-not-async-closure.rs @@ -0,0 +1,32 @@ +// This test ensures iterators created with the `iter!` macro are not +// accidentally async closures. +// +//@ edition: 2024 +//@ remap-src-base + +#![feature(yield_expr, iter_macro)] + +use std::task::{Waker, Context}; +use std::iter::iter; +use std::pin::pin; +use std::future::Future; + +async fn call_async_once(f: impl AsyncFnOnce()) { + f().await +} + +fn main() { + let f = iter! { move || { + for i in 0..10 { + yield i; + } + }}; + + let x = pin!(call_async_once(f)); + //~^ 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())); + //~^ ERROR AsyncFnOnce()` is not satisfied +} diff --git a/tests/ui/iterators/iter-macro-not-async-closure.stderr b/tests/ui/iterators/iter-macro-not-async-closure.stderr new file mode 100644 index 0000000000000..2f0343a2d0d62 --- /dev/null +++ b/tests/ui/iterators/iter-macro-not-async-closure.stderr @@ -0,0 +1,67 @@ +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:19:21: 19:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:25: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:19:21: 19: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:14: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:19:21: 19:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:25: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:19:21: 19:28}` + | +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:14: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:19:21: 19:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:25: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:19:21: 19:28}` + | +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:14:34 + | +LL | async fn call_async_once(f: impl AsyncFnOnce()) { + | ^^^^^^^^^^^^^ required by this bound in `call_async_once` + = note: this error originates in the macro `pin` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:19:21: 19:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:25: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:19:21: 19:28}` + | +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:14:34 + | +LL | async fn call_async_once(f: impl AsyncFnOnce()) { + | ^^^^^^^^^^^^^ required by this bound in `call_async_once` + = note: this error originates in the macro `pin` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:19:21: 19:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:30: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:19:21: 19:28}` + | +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:14:34 + | +LL | async fn call_async_once(f: impl AsyncFnOnce()) { + | ^^^^^^^^^^^^^ required by this bound in `call_async_once` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/layout/invalid-unsized-const-eval.rs b/tests/ui/layout/invalid-unsized-const-eval.rs index 1f664d30055d6..94fa6449e670d 100644 --- a/tests/ui/layout/invalid-unsized-const-eval.rs +++ b/tests/ui/layout/invalid-unsized-const-eval.rs @@ -10,6 +10,6 @@ struct LazyLock { } static EMPTY_SET: LazyLock = todo!(); -//~^ ERROR could not evaluate static initializer +//~^ ERROR the type `(dyn Sync, ())` has an unknown layout fn main() {} diff --git a/tests/ui/layout/invalid-unsized-const-eval.stderr b/tests/ui/layout/invalid-unsized-const-eval.stderr index a434ca9b2c7cf..073568883c4ed 100644 --- a/tests/ui/layout/invalid-unsized-const-eval.stderr +++ b/tests/ui/layout/invalid-unsized-const-eval.stderr @@ -7,11 +7,11 @@ LL | data: (dyn Sync, ()), = help: the trait `Sized` is not implemented for `(dyn Sync + 'static)` = note: only the last element of a tuple may have a dynamically sized type -error[E0080]: could not evaluate static initializer +error[E0080]: the type `(dyn Sync, ())` has an unknown layout --> $DIR/invalid-unsized-const-eval.rs:12:1 | LL | static EMPTY_SET: LazyLock = todo!(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `(dyn Sync, ())` has an unknown layout + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here error: aborting due to 2 previous errors diff --git a/tests/ui/layout/invalid-unsized-in-always-sized-tail.rs b/tests/ui/layout/invalid-unsized-in-always-sized-tail.rs index c6d5f2bfa0ee3..8da2bb385ef25 100644 --- a/tests/ui/layout/invalid-unsized-in-always-sized-tail.rs +++ b/tests/ui/layout/invalid-unsized-in-always-sized-tail.rs @@ -12,6 +12,7 @@ struct P2 { //~^ ERROR: the size for values of type `[bool]` cannot be known at compilation time } -static CHECK: () = assert!(align_of::() == 1); //~ ERROR could not evaluate static initializer +static CHECK: () = assert!(align_of::() == 1); +//~^ ERROR the type `MySlice<[bool]>` has an unknown layout fn main() {} 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 3a4735e4832fc..e08107f5f8ec2 100644 --- a/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr +++ b/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr @@ -18,11 +18,11 @@ LL | struct MySlice(T); | | | this could be changed to `T: ?Sized`... -error[E0080]: could not evaluate static initializer +error[E0080]: the type `MySlice<[bool]>` has an unknown layout --> $DIR/invalid-unsized-in-always-sized-tail.rs:15:28 | LL | static CHECK: () = assert!(align_of::() == 1); - | ^^^^^^^^^^^^^^^^ the type `MySlice<[bool]>` has an unknown layout + | ^^^^^^^^^^^^^^^^ evaluation of static initializer failed here | note: inside `align_of::` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL diff --git a/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.rs b/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.rs index f84c10d8e5c03..92295704615f2 100644 --- a/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.rs +++ b/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.rs @@ -6,6 +6,6 @@ struct ArenaSet::Target>(V, U); //~^ ERROR the size for values of type `V` cannot be known at compilation time const DATA: *const ArenaSet> = std::ptr::null_mut(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR the type `ArenaSet, [u8]>` has an unknown layout pub fn main() {} diff --git a/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.stderr b/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.stderr index 220951fab86f8..c85c40d5bdafc 100644 --- a/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.stderr +++ b/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.stderr @@ -22,11 +22,11 @@ help: the `Box` type always has a statically known size and allocates its conten LL | struct ArenaSet::Target>(Box, U); | ++++ + -error[E0080]: evaluation of constant value failed +error[E0080]: the type `ArenaSet, [u8]>` has an unknown layout --> $DIR/issue-unsized-tail-restatic-ice-122488.rs:8:1 | LL | const DATA: *const ArenaSet> = std::ptr::null_mut(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `ArenaSet, [u8]>` has an unknown layout + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 2 previous errors diff --git a/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.rs b/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.rs index 91280e49dcd7e..4423b83e24d47 100644 --- a/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.rs +++ b/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.rs @@ -5,7 +5,7 @@ where str: Sized, { [(); { let _a: Option = None; 0 }]; - //~^ ERROR evaluation of constant value failed + //~^ ERROR the type `Option` has an unknown layout } fn main() {} 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 6c7c51db8df7f..fa58b1f8fe403 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,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: the type `Option` has an unknown layout --> $DIR/uncomputable-due-to-trivial-bounds-ice-135138.rs:7:16 | LL | [(); { let _a: Option = None; 0 }]; - | ^^ the type `Option` has an unknown layout + | ^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/layout/unknown-when-no-type-parameter.rs b/tests/ui/layout/unknown-when-no-type-parameter.rs index 87f90aa438ab3..81386feaacfe6 100644 --- a/tests/ui/layout/unknown-when-no-type-parameter.rs +++ b/tests/ui/layout/unknown-when-no-type-parameter.rs @@ -4,10 +4,14 @@ trait Project { type Assoc; } -fn foo() where (): Project { - [(); size_of::<<() as Project>::Assoc>()]; //~ ERROR evaluation of constant value failed - //~| NOTE the type `<() as Project>::Assoc` has an unknown layout +fn foo() +where + (): Project, +{ + [(); size_of::<<() as Project>::Assoc>()]; + //~^ ERROR the type `<() as Project>::Assoc` has an unknown layout //~| NOTE inside `std::mem::size_of::<<() as Project>::Assoc>` + //~| NOTE evaluation of constant value failed } fn main() {} diff --git a/tests/ui/layout/unknown-when-no-type-parameter.stderr b/tests/ui/layout/unknown-when-no-type-parameter.stderr index 35fbb11f156ab..f0a64960c6ad5 100644 --- a/tests/ui/layout/unknown-when-no-type-parameter.stderr +++ b/tests/ui/layout/unknown-when-no-type-parameter.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/unknown-when-no-type-parameter.rs:8:10 +error[E0080]: the type `<() as Project>::Assoc` has an unknown layout + --> $DIR/unknown-when-no-type-parameter.rs:11:10 | LL | [(); size_of::<<() as Project>::Assoc>()]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `<() as Project>::Assoc` has an unknown layout + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `std::mem::size_of::<<() as Project>::Assoc>` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL diff --git a/tests/ui/layout/unknown-when-ptr-metadata-is-DST.rs b/tests/ui/layout/unknown-when-ptr-metadata-is-DST.rs index 973235fe65afc..54f339711d5c1 100644 --- a/tests/ui/layout/unknown-when-ptr-metadata-is-DST.rs +++ b/tests/ui/layout/unknown-when-ptr-metadata-is-DST.rs @@ -6,7 +6,7 @@ where str: std::ptr::Pointee, { [(); { let _a: Option<&str> = None; 0 }]; - //~^ ERROR evaluation of constant value failed + //~^ ERROR the type `str` has an unknown layout } fn main() {} 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 68bba2e967826..8cf5ce7c22d9d 100644 --- a/tests/ui/layout/unknown-when-ptr-metadata-is-DST.stderr +++ b/tests/ui/layout/unknown-when-ptr-metadata-is-DST.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: the type `str` has an unknown layout --> $DIR/unknown-when-ptr-metadata-is-DST.rs:8:16 | LL | [(); { let _a: Option<&str> = None; 0 }]; - | ^^ the type `str` has an unknown layout + | ^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/lazy-type-alias/def-site-param-defaults-wf.rs b/tests/ui/lazy-type-alias/def-site-param-defaults-wf.rs index 90bb0a294f810..7f417de5fd33d 100644 --- a/tests/ui/lazy-type-alias/def-site-param-defaults-wf.rs +++ b/tests/ui/lazy-type-alias/def-site-param-defaults-wf.rs @@ -2,8 +2,8 @@ #![feature(lazy_type_alias)] #![allow(incomplete_features)] -type Alias, const N: usize = {0 - 1}> = T; -//~^ ERROR evaluation of constant value failed +type Alias, const N: usize = { 0 - 1 }> = T; +//~^ ERROR attempt to compute `0_usize - 1_usize`, which would overflow //~| ERROR the size for values of type `str` cannot be known at compilation time fn main() {} diff --git a/tests/ui/lazy-type-alias/def-site-param-defaults-wf.stderr b/tests/ui/lazy-type-alias/def-site-param-defaults-wf.stderr index da0021ccaf4d3..e0d2574250275 100644 --- a/tests/ui/lazy-type-alias/def-site-param-defaults-wf.stderr +++ b/tests/ui/lazy-type-alias/def-site-param-defaults-wf.stderr @@ -1,13 +1,13 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/def-site-param-defaults-wf.rs:5:44 +error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow + --> $DIR/def-site-param-defaults-wf.rs:5:45 | -LL | type Alias, const N: usize = {0 - 1}> = T; - | ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow +LL | type Alias, const N: usize = { 0 - 1 }> = T; + | ^^^^^ evaluation of constant value failed here error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/def-site-param-defaults-wf.rs:5:16 | -LL | type Alias, const N: usize = {0 - 1}> = T; +LL | type Alias, const N: usize = { 0 - 1 }> = T; | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` diff --git a/tests/ui/lifetimes/auxiliary/lifetime_bound_will_change_warning_lib.rs b/tests/ui/lifetimes/auxiliary/lifetime_bound_will_change_warning_lib.rs index 58f1b81cf4d56..e351cc9e8fe90 100644 --- a/tests/ui/lifetimes/auxiliary/lifetime_bound_will_change_warning_lib.rs +++ b/tests/ui/lifetimes/auxiliary/lifetime_bound_will_change_warning_lib.rs @@ -3,9 +3,8 @@ // Helper for testing that we get suitable warnings when lifetime // bound change will cause breakage. -pub fn just_ref(x: &Fn()) { -} +pub fn just_ref(x: &dyn Fn()) {} -pub fn ref_obj(x: &Box) { +pub fn ref_obj(x: &Box) { // this will change to &Box... } diff --git a/tests/ui/limits/huge-static.rs b/tests/ui/limits/huge-static.rs index 4c3641ac7d4b1..1473fd6054edc 100644 --- a/tests/ui/limits/huge-static.rs +++ b/tests/ui/limits/huge-static.rs @@ -5,22 +5,19 @@ const HUGE_SIZE: usize = 1 << 61; - pub struct TooBigArray { arr: [u8; HUGE_SIZE], } impl TooBigArray { pub const fn new() -> Self { - TooBigArray { arr: [0x00; HUGE_SIZE], } + TooBigArray { arr: [0x00; HUGE_SIZE] } } } static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new(); -//~^ ERROR could not evaluate static initializer -//~| NOTE too big +//~^ ERROR too big static MY_TOO_BIG_ARRAY_2: [u8; HUGE_SIZE] = [0x00; HUGE_SIZE]; -//~^ ERROR could not evaluate static initializer -//~| NOTE too big +//~^ ERROR too big -fn main() { } +fn main() {} diff --git a/tests/ui/limits/huge-static.stderr b/tests/ui/limits/huge-static.stderr index 684efeeb4a3b7..63d04b75d99bb 100644 --- a/tests/ui/limits/huge-static.stderr +++ b/tests/ui/limits/huge-static.stderr @@ -1,14 +1,14 @@ -error[E0080]: could not evaluate static initializer - --> $DIR/huge-static.rs:19:1 +error[E0080]: values of the type `[u8; 2305843009213693952]` are too big for the target architecture + --> $DIR/huge-static.rs:18:1 | LL | static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ values of the type `[u8; 2305843009213693952]` are too big for the target architecture + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here -error[E0080]: could not evaluate static initializer - --> $DIR/huge-static.rs:22:1 +error[E0080]: values of the type `[u8; 2305843009213693952]` are too big for the target architecture + --> $DIR/huge-static.rs:20:1 | LL | static MY_TOO_BIG_ARRAY_2: [u8; HUGE_SIZE] = [0x00; HUGE_SIZE]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ values of the type `[u8; 2305843009213693952]` are too big for the target architecture + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here error: aborting due to 2 previous errors diff --git a/tests/ui/limits/issue-55878.rs b/tests/ui/limits/issue-55878.rs index 614ff328bf5ed..9e75f00a408f9 100644 --- a/tests/ui/limits/issue-55878.rs +++ b/tests/ui/limits/issue-55878.rs @@ -2,5 +2,5 @@ fn main() { println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); - //~^ ERROR evaluation of constant value failed + //~^ ERROR too big for the target architecture } diff --git a/tests/ui/limits/issue-55878.stderr b/tests/ui/limits/issue-55878.stderr index 9b3922d7933dd..27357796c1833 100644 --- a/tests/ui/limits/issue-55878.stderr +++ b/tests/ui/limits/issue-55878.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture --> $DIR/issue-55878.rs:4:26 | LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ values of the type `[u8; usize::MAX]` are too big for the target architecture + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `std::mem::size_of::<[u8; usize::MAX]>` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL diff --git a/tests/ui/parser/bounds-obj-parens.rs b/tests/ui/parser/bounds-obj-parens.rs index eea4bccdc09cb..5ba90b50d2f1f 100644 --- a/tests/ui/parser/bounds-obj-parens.rs +++ b/tests/ui/parser/bounds-obj-parens.rs @@ -1,7 +1,5 @@ //@ check-pass -#![allow(bare_trait_objects)] - -type A = Box<(Fn(u8) -> u8) + 'static + Send + Sync>; // OK (but see #39318) +type A = Box u8) + 'static + Send + Sync>; // OK (but see #39318) fn main() {} diff --git a/tests/ui/parser/trailing-plus-in-bounds.rs b/tests/ui/parser/trailing-plus-in-bounds.rs index ef9bdadb2825a..aa5bc3aca5980 100644 --- a/tests/ui/parser/trailing-plus-in-bounds.rs +++ b/tests/ui/parser/trailing-plus-in-bounds.rs @@ -1,9 +1,7 @@ //@ check-pass -#![allow(bare_trait_objects)] - use std::fmt::Debug; fn main() { - let x: Box = Box::new(3) as Box; // Trailing `+` is OK + let x: Box = Box::new(3) as Box; // Trailing `+` is OK } diff --git a/tests/ui/recursion/recursive-static-definition.rs b/tests/ui/recursion/recursive-static-definition.rs index 5317c47076e50..55db6a86bf1fc 100644 --- a/tests/ui/recursion/recursive-static-definition.rs +++ b/tests/ui/recursion/recursive-static-definition.rs @@ -1,5 +1,5 @@ pub static FOO: u32 = FOO; -//~^ ERROR could not evaluate static initializer +//~^ ERROR encountered static that tried to initialize itself with itself #[derive(Copy, Clone)] pub union Foo { @@ -7,6 +7,6 @@ pub union Foo { } pub static BAR: Foo = BAR; -//~^ ERROR could not evaluate static initializer +//~^ ERROR encountered static that tried to initialize itself with itself fn main() {} diff --git a/tests/ui/recursion/recursive-static-definition.stderr b/tests/ui/recursion/recursive-static-definition.stderr index 86a22c990e9f6..7063e5c3c6671 100644 --- a/tests/ui/recursion/recursive-static-definition.stderr +++ b/tests/ui/recursion/recursive-static-definition.stderr @@ -1,14 +1,14 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: encountered static that tried to initialize itself with itself --> $DIR/recursive-static-definition.rs:1:23 | LL | pub static FOO: u32 = FOO; - | ^^^ encountered static that tried to initialize itself with itself + | ^^^ evaluation of static initializer failed here -error[E0080]: could not evaluate static initializer +error[E0080]: encountered static that tried to initialize itself with itself --> $DIR/recursive-static-definition.rs:9:23 | LL | pub static BAR: Foo = BAR; - | ^^^ encountered static that tried to initialize itself with itself + | ^^^ evaluation of static initializer failed here error: aborting due to 2 previous errors diff --git a/tests/ui/regions/region-object-lifetime-1.rs b/tests/ui/regions/region-object-lifetime-1.rs index 11e3c8a1a3328..7ff37d7a5251e 100644 --- a/tests/ui/regions/region-object-lifetime-1.rs +++ b/tests/ui/regions/region-object-lifetime-1.rs @@ -10,7 +10,7 @@ trait Foo { // Here the receiver and return value all have the same lifetime, // so no error results. -fn borrowed_receiver_same_lifetime<'a>(x: &'a Foo) -> &'a () { +fn borrowed_receiver_same_lifetime<'a>(x: &'a dyn Foo) -> &'a () { x.borrowed() } diff --git a/tests/ui/regions/region-object-lifetime-3.rs b/tests/ui/regions/region-object-lifetime-3.rs index ddeeec902f10f..fee32f9205997 100644 --- a/tests/ui/regions/region-object-lifetime-3.rs +++ b/tests/ui/regions/region-object-lifetime-3.rs @@ -10,7 +10,7 @@ trait Foo { // Borrowed receiver with two distinct lifetimes, but we know that // 'b:'a, hence &'a () is permitted. -fn borrowed_receiver_related_lifetimes<'a,'b>(x: &'a (Foo+'b)) -> &'a () { +fn borrowed_receiver_related_lifetimes<'a,'b>(x: &'a (dyn Foo+'b)) -> &'a () { x.borrowed() } diff --git a/tests/ui/simd/const-err-trumps-simd-err.rs b/tests/ui/simd/const-err-trumps-simd-err.rs index 05a224d037ac4..8d9870855f807 100644 --- a/tests/ui/simd/const-err-trumps-simd-err.rs +++ b/tests/ui/simd/const-err-trumps-simd-err.rs @@ -16,8 +16,7 @@ struct int8x4_t([u8; 4]); fn get_elem(a: int8x4_t) -> u8 { const { assert!(LANE < 4); } // the error should be here... - //~^ ERROR failed - //~| NOTE assertion failed + //~^ ERROR assertion failed unsafe { simd_extract(a, LANE) } // ...not here } diff --git a/tests/ui/simd/const-err-trumps-simd-err.stderr b/tests/ui/simd/const-err-trumps-simd-err.stderr index 389f75492c645..d4ba54a28da7e 100644 --- a/tests/ui/simd/const-err-trumps-simd-err.stderr +++ b/tests/ui/simd/const-err-trumps-simd-err.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `get_elem::<4>::{constant#0}` failed +error[E0080]: evaluation panicked: assertion failed: LANE < 4 --> $DIR/const-err-trumps-simd-err.rs:18:13 | LL | const { assert!(LANE < 4); } // the error should be here... - | ^^^^^^^^^^^^^^^^^ evaluation panicked: assertion failed: LANE < 4 + | ^^^^^^^^^^^^^^^^^ evaluation of `get_elem::<4>::{constant#0}` failed here note: erroneous constant encountered --> $DIR/const-err-trumps-simd-err.rs:18:5 @@ -11,7 +11,7 @@ LL | const { assert!(LANE < 4); } // the error should be here... | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: the above error was encountered while instantiating `fn get_elem::<4>` - --> $DIR/const-err-trumps-simd-err.rs:25:5 + --> $DIR/const-err-trumps-simd-err.rs:24:5 | LL | get_elem::<4>(int8x4_t([0, 0, 0, 0])); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/sized/stack-overflow-trait-infer-98842.32bit.stderr b/tests/ui/sized/stack-overflow-trait-infer-98842.32bit.stderr index c01b2ccd1637c..354ca78c7bee3 100644 --- a/tests/ui/sized/stack-overflow-trait-infer-98842.32bit.stderr +++ b/tests/ui/sized/stack-overflow-trait-infer-98842.32bit.stderr @@ -9,11 +9,11 @@ LL | const _: *const Foo = 0 as _; | ^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information -error[E0080]: evaluation of constant value failed +error[E0080]: a cycle occurred during layout computation --> $DIR/stack-overflow-trait-infer-98842.rs:14:1 | LL | const _: *const Foo = 0 as _; - | ^^^^^^^^^^^^^^^^^^^ a cycle occurred during layout computation + | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 2 previous errors diff --git a/tests/ui/sized/stack-overflow-trait-infer-98842.64bit.stderr b/tests/ui/sized/stack-overflow-trait-infer-98842.64bit.stderr index c01b2ccd1637c..354ca78c7bee3 100644 --- a/tests/ui/sized/stack-overflow-trait-infer-98842.64bit.stderr +++ b/tests/ui/sized/stack-overflow-trait-infer-98842.64bit.stderr @@ -9,11 +9,11 @@ LL | const _: *const Foo = 0 as _; | ^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information -error[E0080]: evaluation of constant value failed +error[E0080]: a cycle occurred during layout computation --> $DIR/stack-overflow-trait-infer-98842.rs:14:1 | LL | const _: *const Foo = 0 as _; - | ^^^^^^^^^^^^^^^^^^^ a cycle occurred during layout computation + | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 2 previous errors diff --git a/tests/ui/sized/stack-overflow-trait-infer-98842.rs b/tests/ui/sized/stack-overflow-trait-infer-98842.rs index 8a958870b0e17..1c9f6c593f447 100644 --- a/tests/ui/sized/stack-overflow-trait-infer-98842.rs +++ b/tests/ui/sized/stack-overflow-trait-infer-98842.rs @@ -12,6 +12,6 @@ struct Foo(<&'static Foo as ::core::ops::Deref>::Target); // and it will infinitely recurse somewhere trying to figure out the // size of this pointer (is my guess): const _: *const Foo = 0 as _; -//~^ ERROR evaluation of constant value failed +//~^ ERROR a cycle occurred during layout computation pub fn main() {} diff --git a/tests/ui/statics/issue-14227.rs b/tests/ui/statics/issue-14227.rs index 8a70f51d3b4bb..84994f033d1dd 100644 --- a/tests/ui/statics/issue-14227.rs +++ b/tests/ui/statics/issue-14227.rs @@ -3,6 +3,6 @@ extern "C" { } static CRASH: u32 = symbol; //~^ ERROR use of extern static is unsafe and requires -//~| ERROR could not evaluate static initializer +//~| ERROR cannot access extern static `symbol` fn main() {} diff --git a/tests/ui/statics/issue-14227.stderr b/tests/ui/statics/issue-14227.stderr index 3551821a3dadb..372a06ae1ed76 100644 --- a/tests/ui/statics/issue-14227.stderr +++ b/tests/ui/statics/issue-14227.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: cannot access extern static `symbol` --> $DIR/issue-14227.rs:4:21 | LL | static CRASH: u32 = symbol; - | ^^^^^^ cannot access extern static `symbol` + | ^^^^^^ evaluation of static initializer failed here error[E0133]: use of extern static is unsafe and requires unsafe function or block --> $DIR/issue-14227.rs:4:21 diff --git a/tests/ui/statics/mutable_memory_validation.rs b/tests/ui/statics/mutable_memory_validation.rs index 3bb572d38bc59..033c2bc283965 100644 --- a/tests/ui/statics/mutable_memory_validation.rs +++ b/tests/ui/statics/mutable_memory_validation.rs @@ -11,7 +11,7 @@ struct Meh { } const MUH: Meh = Meh { x: unsafe { &mut *(&READONLY as *const _ as *mut _) } }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: invalid value at .x.: encountered `UnsafeCell` in read-only memory static READONLY: i32 = 0; diff --git a/tests/ui/statics/mutable_memory_validation.stderr b/tests/ui/statics/mutable_memory_validation.stderr index 76e1827ea12a6..df36287cc69e6 100644 --- a/tests/ui/statics/mutable_memory_validation.stderr +++ b/tests/ui/statics/mutable_memory_validation.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .x.: encountered `UnsafeCell` in read-only memory --> $DIR/mutable_memory_validation.rs:13:1 | LL | const MUH: Meh = Meh { x: unsafe { &mut *(&READONLY as *const _ as *mut _) } }; - | ^^^^^^^^^^^^^^ constructing invalid value at .x.: encountered `UnsafeCell` in read-only memory + | ^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { diff --git a/tests/ui/statics/uninhabited-static.rs b/tests/ui/statics/uninhabited-static.rs index 0f7c5ae6ef4a3..955d489d3133e 100644 --- a/tests/ui/statics/uninhabited-static.rs +++ b/tests/ui/statics/uninhabited-static.rs @@ -11,9 +11,9 @@ extern "C" { static VOID2: Void = unsafe { std::mem::transmute(()) }; //~ ERROR static of uninhabited type //~| WARN: previously accepted -//~| ERROR could not evaluate static initializer +//~| ERROR value of uninhabited type `Void` static NEVER2: Void = unsafe { std::mem::transmute(()) }; //~ ERROR static of uninhabited type //~| WARN: previously accepted -//~| ERROR could not evaluate static initializer +//~| ERROR value of uninhabited type `Void` fn main() {} diff --git a/tests/ui/statics/uninhabited-static.stderr b/tests/ui/statics/uninhabited-static.stderr index f891c0ce25b55..60268ad356218 100644 --- a/tests/ui/statics/uninhabited-static.stderr +++ b/tests/ui/statics/uninhabited-static.stderr @@ -43,17 +43,17 @@ LL | static NEVER2: Void = unsafe { std::mem::transmute(()) }; = note: for more information, see issue #74840 = note: uninhabited statics cannot be initialized, and any access would be an immediate error -error[E0080]: could not evaluate static initializer +error[E0080]: constructing invalid value: encountered a value of uninhabited type `Void` --> $DIR/uninhabited-static.rs:12:31 | LL | static VOID2: Void = unsafe { std::mem::transmute(()) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type `Void` + | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here -error[E0080]: could not evaluate static initializer +error[E0080]: constructing invalid value: encountered a value of uninhabited type `Void` --> $DIR/uninhabited-static.rs:15:32 | LL | static NEVER2: Void = unsafe { std::mem::transmute(()) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type `Void` + | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here error: aborting due to 6 previous errors diff --git a/tests/ui/stats/input-stats.stderr b/tests/ui/stats/input-stats.stderr index 58ab1a72556f7..f2598bd7eaf85 100644 --- a/tests/ui/stats/input-stats.stderr +++ b/tests/ui/stats/input-stats.stderr @@ -1,120 +1,63 @@ -ast-stats-1 PRE EXPANSION AST STATS -ast-stats-1 Name Accumulated Size Count Item Size -ast-stats-1 ---------------------------------------------------------------- -ast-stats-1 Crate 40 (NN.N%) 1 40 -ast-stats-1 GenericArgs 40 (NN.N%) 1 40 -ast-stats-1 - AngleBracketed 40 (NN.N%) 1 -ast-stats-1 ExprField 48 (NN.N%) 1 48 -ast-stats-1 Attribute 64 (NN.N%) 2 32 -ast-stats-1 - DocComment 32 (NN.N%) 1 -ast-stats-1 - Normal 32 (NN.N%) 1 -ast-stats-1 WherePredicate 72 (NN.N%) 1 72 -ast-stats-1 - BoundPredicate 72 (NN.N%) 1 -ast-stats-1 ForeignItem 80 (NN.N%) 1 80 -ast-stats-1 - Fn 80 (NN.N%) 1 -ast-stats-1 Arm 96 (NN.N%) 2 48 -ast-stats-1 Local 96 (NN.N%) 1 96 -ast-stats-1 FnDecl 120 (NN.N%) 5 24 -ast-stats-1 Param 160 (NN.N%) 4 40 -ast-stats-1 Stmt 160 (NN.N%) 5 32 -ast-stats-1 - Let 32 (NN.N%) 1 -ast-stats-1 - MacCall 32 (NN.N%) 1 -ast-stats-1 - Expr 96 (NN.N%) 3 -ast-stats-1 Block 192 (NN.N%) 6 32 -ast-stats-1 FieldDef 208 (NN.N%) 2 104 -ast-stats-1 Variant 208 (NN.N%) 2 104 -ast-stats-1 AssocItem 320 (NN.N%) 4 80 -ast-stats-1 - Fn 160 (NN.N%) 2 -ast-stats-1 - Type 160 (NN.N%) 2 -ast-stats-1 GenericBound 352 (NN.N%) 4 88 -ast-stats-1 - Trait 352 (NN.N%) 4 -ast-stats-1 GenericParam 480 (NN.N%) 5 96 -ast-stats-1 Pat 504 (NN.N%) 7 72 -ast-stats-1 - Struct 72 (NN.N%) 1 -ast-stats-1 - Wild 72 (NN.N%) 1 -ast-stats-1 - Ident 360 (NN.N%) 5 -ast-stats-1 Expr 576 (NN.N%) 8 72 -ast-stats-1 - Match 72 (NN.N%) 1 -ast-stats-1 - Path 72 (NN.N%) 1 -ast-stats-1 - Struct 72 (NN.N%) 1 -ast-stats-1 - Lit 144 (NN.N%) 2 -ast-stats-1 - Block 216 (NN.N%) 3 -ast-stats-1 PathSegment 744 (NN.N%) 31 24 -ast-stats-1 Ty 896 (NN.N%) 14 64 -ast-stats-1 - Ptr 64 (NN.N%) 1 -ast-stats-1 - Ref 64 (NN.N%) 1 -ast-stats-1 - ImplicitSelf 128 (NN.N%) 2 -ast-stats-1 - Path 640 (NN.N%) 10 -ast-stats-1 Item 1_296 (NN.N%) 9 144 -ast-stats-1 - Enum 144 (NN.N%) 1 -ast-stats-1 - ForeignMod 144 (NN.N%) 1 -ast-stats-1 - Impl 144 (NN.N%) 1 -ast-stats-1 - Trait 144 (NN.N%) 1 -ast-stats-1 - Fn 288 (NN.N%) 2 -ast-stats-1 - Use 432 (NN.N%) 3 -ast-stats-1 ---------------------------------------------------------------- -ast-stats-1 Total 6_752 116 -ast-stats-1 -ast-stats-2 POST EXPANSION AST STATS -ast-stats-2 Name Accumulated Size Count Item Size -ast-stats-2 ---------------------------------------------------------------- -ast-stats-2 Crate 40 (NN.N%) 1 40 -ast-stats-2 GenericArgs 40 (NN.N%) 1 40 -ast-stats-2 - AngleBracketed 40 (NN.N%) 1 -ast-stats-2 ExprField 48 (NN.N%) 1 48 -ast-stats-2 WherePredicate 72 (NN.N%) 1 72 -ast-stats-2 - BoundPredicate 72 (NN.N%) 1 -ast-stats-2 ForeignItem 80 (NN.N%) 1 80 -ast-stats-2 - Fn 80 (NN.N%) 1 -ast-stats-2 Arm 96 (NN.N%) 2 48 -ast-stats-2 Local 96 (NN.N%) 1 96 -ast-stats-2 FnDecl 120 (NN.N%) 5 24 -ast-stats-2 InlineAsm 120 (NN.N%) 1 120 -ast-stats-2 Attribute 128 (NN.N%) 4 32 -ast-stats-2 - DocComment 32 (NN.N%) 1 -ast-stats-2 - Normal 96 (NN.N%) 3 -ast-stats-2 Param 160 (NN.N%) 4 40 -ast-stats-2 Stmt 160 (NN.N%) 5 32 -ast-stats-2 - Let 32 (NN.N%) 1 -ast-stats-2 - Semi 32 (NN.N%) 1 -ast-stats-2 - Expr 96 (NN.N%) 3 -ast-stats-2 Block 192 (NN.N%) 6 32 -ast-stats-2 FieldDef 208 (NN.N%) 2 104 -ast-stats-2 Variant 208 (NN.N%) 2 104 -ast-stats-2 AssocItem 320 (NN.N%) 4 80 -ast-stats-2 - Fn 160 (NN.N%) 2 -ast-stats-2 - Type 160 (NN.N%) 2 -ast-stats-2 GenericBound 352 (NN.N%) 4 88 -ast-stats-2 - Trait 352 (NN.N%) 4 -ast-stats-2 GenericParam 480 (NN.N%) 5 96 -ast-stats-2 Pat 504 (NN.N%) 7 72 -ast-stats-2 - Struct 72 (NN.N%) 1 -ast-stats-2 - Wild 72 (NN.N%) 1 -ast-stats-2 - Ident 360 (NN.N%) 5 -ast-stats-2 Expr 648 (NN.N%) 9 72 -ast-stats-2 - InlineAsm 72 (NN.N%) 1 -ast-stats-2 - Match 72 (NN.N%) 1 -ast-stats-2 - Path 72 (NN.N%) 1 -ast-stats-2 - Struct 72 (NN.N%) 1 -ast-stats-2 - Lit 144 (NN.N%) 2 -ast-stats-2 - Block 216 (NN.N%) 3 -ast-stats-2 PathSegment 864 (NN.N%) 36 24 -ast-stats-2 Ty 896 (NN.N%) 14 64 -ast-stats-2 - Ptr 64 (NN.N%) 1 -ast-stats-2 - Ref 64 (NN.N%) 1 -ast-stats-2 - ImplicitSelf 128 (NN.N%) 2 -ast-stats-2 - Path 640 (NN.N%) 10 -ast-stats-2 Item 1_584 (NN.N%) 11 144 -ast-stats-2 - Enum 144 (NN.N%) 1 -ast-stats-2 - ExternCrate 144 (NN.N%) 1 -ast-stats-2 - ForeignMod 144 (NN.N%) 1 -ast-stats-2 - Impl 144 (NN.N%) 1 -ast-stats-2 - Trait 144 (NN.N%) 1 -ast-stats-2 - Fn 288 (NN.N%) 2 -ast-stats-2 - Use 576 (NN.N%) 4 -ast-stats-2 ---------------------------------------------------------------- -ast-stats-2 Total 7_416 127 -ast-stats-2 +ast-stats POST EXPANSION AST STATS +ast-stats Name Accumulated Size Count Item Size +ast-stats ---------------------------------------------------------------- +ast-stats Crate 40 (NN.N%) 1 40 +ast-stats GenericArgs 40 (NN.N%) 1 40 +ast-stats - AngleBracketed 40 (NN.N%) 1 +ast-stats ExprField 48 (NN.N%) 1 48 +ast-stats WherePredicate 72 (NN.N%) 1 72 +ast-stats - BoundPredicate 72 (NN.N%) 1 +ast-stats ForeignItem 80 (NN.N%) 1 80 +ast-stats - Fn 80 (NN.N%) 1 +ast-stats Arm 96 (NN.N%) 2 48 +ast-stats Local 96 (NN.N%) 1 96 +ast-stats FnDecl 120 (NN.N%) 5 24 +ast-stats InlineAsm 120 (NN.N%) 1 120 +ast-stats Attribute 128 (NN.N%) 4 32 +ast-stats - DocComment 32 (NN.N%) 1 +ast-stats - Normal 96 (NN.N%) 3 +ast-stats Param 160 (NN.N%) 4 40 +ast-stats Stmt 160 (NN.N%) 5 32 +ast-stats - Let 32 (NN.N%) 1 +ast-stats - Semi 32 (NN.N%) 1 +ast-stats - Expr 96 (NN.N%) 3 +ast-stats Block 192 (NN.N%) 6 32 +ast-stats FieldDef 208 (NN.N%) 2 104 +ast-stats Variant 208 (NN.N%) 2 104 +ast-stats AssocItem 320 (NN.N%) 4 80 +ast-stats - Fn 160 (NN.N%) 2 +ast-stats - Type 160 (NN.N%) 2 +ast-stats GenericBound 352 (NN.N%) 4 88 +ast-stats - Trait 352 (NN.N%) 4 +ast-stats GenericParam 480 (NN.N%) 5 96 +ast-stats Pat 504 (NN.N%) 7 72 +ast-stats - Struct 72 (NN.N%) 1 +ast-stats - Wild 72 (NN.N%) 1 +ast-stats - Ident 360 (NN.N%) 5 +ast-stats Expr 648 (NN.N%) 9 72 +ast-stats - InlineAsm 72 (NN.N%) 1 +ast-stats - Match 72 (NN.N%) 1 +ast-stats - Path 72 (NN.N%) 1 +ast-stats - Struct 72 (NN.N%) 1 +ast-stats - Lit 144 (NN.N%) 2 +ast-stats - Block 216 (NN.N%) 3 +ast-stats PathSegment 864 (NN.N%) 36 24 +ast-stats Ty 896 (NN.N%) 14 64 +ast-stats - Ptr 64 (NN.N%) 1 +ast-stats - Ref 64 (NN.N%) 1 +ast-stats - ImplicitSelf 128 (NN.N%) 2 +ast-stats - Path 640 (NN.N%) 10 +ast-stats Item 1_584 (NN.N%) 11 144 +ast-stats - Enum 144 (NN.N%) 1 +ast-stats - ExternCrate 144 (NN.N%) 1 +ast-stats - ForeignMod 144 (NN.N%) 1 +ast-stats - Impl 144 (NN.N%) 1 +ast-stats - Trait 144 (NN.N%) 1 +ast-stats - Fn 288 (NN.N%) 2 +ast-stats - Use 576 (NN.N%) 4 +ast-stats ---------------------------------------------------------------- +ast-stats Total 7_416 127 +ast-stats hir-stats HIR STATS hir-stats Name Accumulated Size Count Item Size hir-stats ---------------------------------------------------------------- diff --git a/tests/ui/structs/default-field-values/invalid-const.rs b/tests/ui/structs/default-field-values/invalid-const.rs index 203a712868b7e..ddb73f688659c 100644 --- a/tests/ui/structs/default-field-values/invalid-const.rs +++ b/tests/ui/structs/default-field-values/invalid-const.rs @@ -3,13 +3,13 @@ pub struct Bat { pub bax: u8 = panic!("asdf"), - //~^ ERROR evaluation of constant value failed + //~^ ERROR evaluation panicked: asdf } pub struct Baz { pub bax: u8 = 130 + C, // ok pub bat: u8 = 130 + 130, - //~^ ERROR evaluation of `Baz::::bat::{constant#0}` failed + //~^ ERROR attempt to compute `130_u8 + 130_u8`, which would overflow pub bay: u8 = 1, // ok } diff --git a/tests/ui/structs/default-field-values/invalid-const.stderr b/tests/ui/structs/default-field-values/invalid-const.stderr index 030bdbfcc3ea9..f4a74ef9fdcf9 100644 --- a/tests/ui/structs/default-field-values/invalid-const.stderr +++ b/tests/ui/structs/default-field-values/invalid-const.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: asdf --> $DIR/invalid-const.rs:5:19 | LL | pub bax: u8 = panic!("asdf"), - | ^^^^^^^^^^^^^^ evaluation panicked: asdf + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of `Baz::::bat::{constant#0}` failed +error[E0080]: attempt to compute `130_u8 + 130_u8`, which would overflow --> $DIR/invalid-const.rs:11:19 | LL | pub bat: u8 = 130 + 130, - | ^^^^^^^^^ attempt to compute `130_u8 + 130_u8`, which would overflow + | ^^^^^^^^^ evaluation of `Baz::::bat::{constant#0}` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/structs/default-field-values/post-mono.direct.stderr b/tests/ui/structs/default-field-values/post-mono.direct.stderr index cdd80620c48a9..74e37795f0697 100644 --- a/tests/ui/structs/default-field-values/post-mono.direct.stderr +++ b/tests/ui/structs/default-field-values/post-mono.direct.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Z::<1>::post_mono::{constant#0}` failed +error[E0080]: attempt to divide `1_usize` by zero --> $DIR/post-mono.rs:7:24 | LL | post_mono: usize = X / 0, - | ^^^^^ attempt to divide `1_usize` by zero + | ^^^^^ evaluation of `Z::<1>::post_mono::{constant#0}` failed here note: erroneous constant encountered --> $DIR/post-mono.rs:17:19 diff --git a/tests/ui/structs/default-field-values/post-mono.indirect.stderr b/tests/ui/structs/default-field-values/post-mono.indirect.stderr index 56c27a6e5dc81..c8af9c959c103 100644 --- a/tests/ui/structs/default-field-values/post-mono.indirect.stderr +++ b/tests/ui/structs/default-field-values/post-mono.indirect.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Z::<1>::post_mono::{constant#0}` failed +error[E0080]: attempt to divide `1_usize` by zero --> $DIR/post-mono.rs:7:24 | LL | post_mono: usize = X / 0, - | ^^^^^ attempt to divide `1_usize` by zero + | ^^^^^ evaluation of `Z::<1>::post_mono::{constant#0}` failed here note: erroneous constant encountered --> $DIR/post-mono.rs:12:19 diff --git a/tests/ui/structs/default-field-values/post-mono.rs b/tests/ui/structs/default-field-values/post-mono.rs index 4de31f6e2fbac..68dfa391bb485 100644 --- a/tests/ui/structs/default-field-values/post-mono.rs +++ b/tests/ui/structs/default-field-values/post-mono.rs @@ -5,7 +5,7 @@ struct Z { post_mono: usize = X / 0, - //~^ ERROR evaluation of `Z::<1>::post_mono::{constant#0}` failed + //~^ ERROR attempt to divide `1_usize` by zero } fn indirect() { diff --git a/tests/ui/suggestions/unnamable-types.rs b/tests/ui/suggestions/unnamable-types.rs index 094584ff850b3..6772217a2f6ff 100644 --- a/tests/ui/suggestions/unnamable-types.rs +++ b/tests/ui/suggestions/unnamable-types.rs @@ -1,7 +1,7 @@ // Test that we do not suggest to add type annotations for unnamable types. #![crate_type="lib"] -#![feature(coroutines, stmt_expr_attributes)] +#![feature(coroutines, stmt_expr_attributes, const_async_blocks)] const A = 5; //~^ ERROR: missing type for `const` item diff --git a/tests/ui/transmutability/uninhabited.rs b/tests/ui/transmutability/uninhabited.rs index 274104ffb3915..4e48b590c428c 100644 --- a/tests/ui/transmutability/uninhabited.rs +++ b/tests/ui/transmutability/uninhabited.rs @@ -38,7 +38,7 @@ fn yawning_void_struct() { const _: () = { assert!(std::mem::size_of::() == std::mem::size_of::()); // Just to be sure the above constant actually evaluated: - assert!(false); //~ ERROR: evaluation of constant value failed + assert!(false); //~ ERROR: evaluation panicked: assertion failed: false }; // This transmutation is vacuously acceptable; since one cannot construct a @@ -60,7 +60,7 @@ fn yawning_void_enum() { const _: () = { assert!(std::mem::size_of::() == std::mem::size_of::()); // Just to be sure the above constant actually evaluated: - assert!(false); //~ ERROR: evaluation of constant value failed + assert!(false); //~ ERROR: evaluation panicked: assertion failed: false }; // This transmutation is vacuously acceptable; since one cannot construct a @@ -84,7 +84,7 @@ fn distant_void() { const _: () = { assert!(std::mem::size_of::() == std::mem::size_of::()); // Just to be sure the above constant actually evaluated: - assert!(false); //~ ERROR: evaluation of constant value failed + assert!(false); //~ ERROR: evaluation panicked: assertion failed: false }; assert::is_maybe_transmutable::(); diff --git a/tests/ui/transmutability/uninhabited.stderr b/tests/ui/transmutability/uninhabited.stderr index 3044b502d3146..79cd75ce27997 100644 --- a/tests/ui/transmutability/uninhabited.stderr +++ b/tests/ui/transmutability/uninhabited.stderr @@ -40,11 +40,11 @@ LL | | lifetimes: true, LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: assertion failed: false --> $DIR/uninhabited.rs:41:9 | LL | assert!(false); - | ^^^^^^^^^^^^^^ evaluation panicked: assertion failed: false + | ^^^^^^^^^^^^^^ evaluation of constant value failed here error[E0277]: `()` cannot be safely transmuted into `yawning_void_enum::Void` --> $DIR/uninhabited.rs:71:41 @@ -67,11 +67,11 @@ LL | | lifetimes: true, LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: assertion failed: false --> $DIR/uninhabited.rs:63:9 | LL | assert!(false); - | ^^^^^^^^^^^^^^ evaluation panicked: assertion failed: false + | ^^^^^^^^^^^^^^ evaluation of constant value failed here error[E0277]: `u128` cannot be safely transmuted into `DistantVoid` --> $DIR/uninhabited.rs:92:43 @@ -94,11 +94,11 @@ LL | | lifetimes: true, LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: assertion failed: false --> $DIR/uninhabited.rs:87:9 | LL | assert!(false); - | ^^^^^^^^^^^^^^ evaluation panicked: assertion failed: false + | ^^^^^^^^^^^^^^ evaluation of constant value failed here error[E0277]: `Src` cannot be safely transmuted into `issue_126267::Error` --> $DIR/uninhabited.rs:108:42 diff --git a/tests/ui/treat-err-as-bug/err.rs b/tests/ui/treat-err-as-bug/err.rs index 7868c06fee1c5..6f0e3c55fbb8a 100644 --- a/tests/ui/treat-err-as-bug/err.rs +++ b/tests/ui/treat-err-as-bug/err.rs @@ -7,7 +7,7 @@ #![crate_type = "rlib"] pub static C: u32 = 0 - 1; -//~^ ERROR could not evaluate static initializer +//~^ ERROR attempt to compute `0_u32 - 1_u32`, which would overflow //~? RAW aborting due to `-Z treat-err-as-bug=1` //~? RAW [eval_static_initializer] evaluating initializer of static `C` diff --git a/tests/ui/treat-err-as-bug/err.stderr b/tests/ui/treat-err-as-bug/err.stderr index 2049df22000a1..3279392e1f498 100644 --- a/tests/ui/treat-err-as-bug/err.stderr +++ b/tests/ui/treat-err-as-bug/err.stderr @@ -1,8 +1,8 @@ -error: internal compiler error[E0080]: could not evaluate static initializer +error: internal compiler error[E0080]: attempt to compute `0_u32 - 1_u32`, which would overflow --> $DIR/err.rs:9:21 | LL | pub static C: u32 = 0 - 1; - | ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow + | ^^^^^ evaluation of static initializer failed here error: the compiler unexpectedly panicked. this is a bug. diff --git a/tests/ui/type-alias-impl-trait/issue-53678-coroutine-and-const-fn.rs b/tests/ui/type-alias-impl-trait/issue-53678-coroutine-and-const-fn.rs index f02ccbbb93c4c..b258d2e156d03 100644 --- a/tests/ui/type-alias-impl-trait/issue-53678-coroutine-and-const-fn.rs +++ b/tests/ui/type-alias-impl-trait/issue-53678-coroutine-and-const-fn.rs @@ -1,4 +1,4 @@ -#![feature(coroutines, coroutine_trait, rustc_attrs)] +#![feature(coroutines, coroutine_trait, rustc_attrs, const_async_blocks)] #![feature(type_alias_impl_trait)] //@ check-pass diff --git a/tests/ui/type/pattern_types/literals.rs b/tests/ui/type/pattern_types/literals.rs index b2a83a2a8bdce..fbca421aa9ad4 100644 --- a/tests/ui/type/pattern_types/literals.rs +++ b/tests/ui/type/pattern_types/literals.rs @@ -84,12 +84,12 @@ fn single_element_range_exclusive() -> pattern_type!(u32 is 0..1) { } fn empty_range_at_base_type_min() -> pattern_type!(u32 is 0..0) { - //~^ ERROR evaluation of constant value failed + //~^ ERROR evaluation panicked: exclusive range end at minimum value of type 0 } fn empty_range_at_base_type_min2() -> pattern_type!(u32 is 0..0) { - //~^ ERROR evaluation of constant value failed + //~^ ERROR evaluation panicked: exclusive range end at minimum value of type 1 } @@ -104,17 +104,17 @@ fn empty_range2() -> pattern_type!(u32 is 1..1) { } fn wraparound_range_at_base_ty_end() -> pattern_type!(u32 is 1..0) { - //~^ ERROR evaluation of constant value failed + //~^ ERROR evaluation panicked: exclusive range end at minimum value of type 1 } fn wraparound_range_at_base_ty_end2() -> pattern_type!(u32 is 1..0) { - //~^ ERROR evaluation of constant value failed + //~^ ERROR evaluation panicked: exclusive range end at minimum value of type 0 } fn wraparound_range_at_base_ty_end3() -> pattern_type!(u32 is 1..0) { - //~^ ERROR evaluation of constant value failed + //~^ ERROR evaluation panicked: exclusive range end at minimum value of type 2 } diff --git a/tests/ui/type/pattern_types/literals.stderr b/tests/ui/type/pattern_types/literals.stderr index 5c926742f3cdb..72c812ed3ba3e 100644 --- a/tests/ui/type/pattern_types/literals.stderr +++ b/tests/ui/type/pattern_types/literals.stderr @@ -1,32 +1,32 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: exclusive range end at minimum value of type --> $DIR/literals.rs:86:62 | LL | fn empty_range_at_base_type_min() -> pattern_type!(u32 is 0..0) { - | ^ evaluation panicked: exclusive range end at minimum value of type + | ^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: exclusive range end at minimum value of type --> $DIR/literals.rs:91:63 | LL | fn empty_range_at_base_type_min2() -> pattern_type!(u32 is 0..0) { - | ^ evaluation panicked: exclusive range end at minimum value of type + | ^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: exclusive range end at minimum value of type --> $DIR/literals.rs:106:65 | LL | fn wraparound_range_at_base_ty_end() -> pattern_type!(u32 is 1..0) { - | ^ evaluation panicked: exclusive range end at minimum value of type + | ^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: exclusive range end at minimum value of type --> $DIR/literals.rs:111:66 | LL | fn wraparound_range_at_base_ty_end2() -> pattern_type!(u32 is 1..0) { - | ^ evaluation panicked: exclusive range end at minimum value of type + | ^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: exclusive range end at minimum value of type --> $DIR/literals.rs:116:66 | LL | fn wraparound_range_at_base_ty_end3() -> pattern_type!(u32 is 1..0) { - | ^ evaluation panicked: exclusive range end at minimum value of type + | ^ evaluation of constant value failed here error[E0308]: mismatched types --> $DIR/literals.rs:9:5 diff --git a/tests/ui/type/pattern_types/range_patterns.rs b/tests/ui/type/pattern_types/range_patterns.rs index 21c1454d6cd53..86b618a8d243f 100644 --- a/tests/ui/type/pattern_types/range_patterns.rs +++ b/tests/ui/type/pattern_types/range_patterns.rs @@ -23,7 +23,7 @@ type EMPTY = pattern_type!(u32 is 1..1); //~ ERROR unknown layout #[rustc_layout(debug)] type WRAP = pattern_type!(u32 is 1..0); //~ ERROR unknown layout -//~^ ERROR: evaluation of constant value failed +//~^ ERROR: evaluation panicked: exclusive range end at minimum value of type #[rustc_layout(debug)] type WRAP2 = pattern_type!(u32 is 5..2); //~ ERROR unknown layout diff --git a/tests/ui/type/pattern_types/range_patterns.stderr b/tests/ui/type/pattern_types/range_patterns.stderr index a05995a33f9ba..bcb602a70dd6a 100644 --- a/tests/ui/type/pattern_types/range_patterns.stderr +++ b/tests/ui/type/pattern_types/range_patterns.stderr @@ -365,11 +365,11 @@ error: the type has an unknown layout LL | type EMPTY = pattern_type!(u32 is 1..1); | ^^^^^^^^^^ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: exclusive range end at minimum value of type --> $DIR/range_patterns.rs:25:37 | LL | type WRAP = pattern_type!(u32 is 1..0); - | ^ evaluation panicked: exclusive range end at minimum value of type + | ^ evaluation of constant value failed here error: the type has an unknown layout --> $DIR/range_patterns.rs:25:1 diff --git a/tests/ui/type/pattern_types/reverse_range.rs b/tests/ui/type/pattern_types/reverse_range.rs index e698e9dd541d5..34c931e4e965a 100644 --- a/tests/ui/type/pattern_types/reverse_range.rs +++ b/tests/ui/type/pattern_types/reverse_range.rs @@ -5,7 +5,6 @@ use std::pat::pattern_type; const NONE: pattern_type!(u8 is 1..0) = unsafe { std::mem::transmute(3_u8) }; -//~^ NOTE: exclusive range end at minimum value of type -//~| ERROR: evaluation of constant value failed +//~^ ERROR: exclusive range end at minimum value of type fn main() {} diff --git a/tests/ui/type/pattern_types/reverse_range.stderr b/tests/ui/type/pattern_types/reverse_range.stderr index 90f8ef3261a0b..8f5b86c7db9fb 100644 --- a/tests/ui/type/pattern_types/reverse_range.stderr +++ b/tests/ui/type/pattern_types/reverse_range.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: exclusive range end at minimum value of type --> $DIR/reverse_range.rs:7:36 | LL | const NONE: pattern_type!(u8 is 1..0) = unsafe { std::mem::transmute(3_u8) }; - | ^ evaluation panicked: exclusive range end at minimum value of type + | ^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/type/pattern_types/validity.rs b/tests/ui/type/pattern_types/validity.rs index c61bb71ac252f..a4e49692c98c6 100644 --- a/tests/ui/type/pattern_types/validity.rs +++ b/tests/ui/type/pattern_types/validity.rs @@ -8,32 +8,32 @@ use std::pat::pattern_type; const BAD: pattern_type!(u32 is 1..) = unsafe { std::mem::transmute(0) }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: constructing invalid value: encountered 0 const BAD_UNINIT: pattern_type!(u32 is 1..) = - //~^ ERROR: evaluation of constant value failed + //~^ ERROR: using uninitialized data, but this operation requires initialized memory unsafe { std::mem::transmute(std::mem::MaybeUninit::::uninit()) }; const BAD_PTR: pattern_type!(usize is 1..) = unsafe { std::mem::transmute(&42) }; -//~^ ERROR: evaluation of constant value failed +//~^ ERROR: unable to turn pointer into integer const BAD_AGGREGATE: (pattern_type!(u32 is 1..), u32) = (unsafe { std::mem::transmute(0) }, 0); -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: constructing invalid value at .0: encountered 0 struct Foo(Bar); struct Bar(pattern_type!(u32 is 1..)); const BAD_FOO: Foo = Foo(Bar(unsafe { std::mem::transmute(0) })); -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: constructing invalid value at .0.0: encountered 0 const CHAR_UNINIT: pattern_type!(char is 'A'..'Z') = - //~^ ERROR: evaluation of constant value failed + //~^ ERROR: using uninitialized data, but this operation requires initialized memory unsafe { std::mem::transmute(std::mem::MaybeUninit::::uninit()) }; const CHAR_OOB_PAT: pattern_type!(char is 'A'..'Z') = unsafe { std::mem::transmute('a') }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: constructing invalid value: encountered 97, but expected something in the range 65..=89 const CHAR_OOB: pattern_type!(char is 'A'..'Z') = unsafe { std::mem::transmute(u32::MAX) }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: constructing invalid value: encountered 0xffffffff fn main() {} diff --git a/tests/ui/type/pattern_types/validity.stderr b/tests/ui/type/pattern_types/validity.stderr index b990ec2d3682f..7ba73aacc2440 100644 --- a/tests/ui/type/pattern_types/validity.stderr +++ b/tests/ui/type/pattern_types/validity.stderr @@ -1,73 +1,73 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1 --> $DIR/validity.rs:10:1 | LL | const BAD: pattern_type!(u32 is 1..) = unsafe { std::mem::transmute(0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/validity.rs:13:1 | LL | const BAD_UNINIT: pattern_type!(u32 is 1..) = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/validity.rs:17:1 | LL | const BAD_PTR: pattern_type!(usize is 1..) = unsafe { std::mem::transmute(&42) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 --> $DIR/validity.rs:20:1 | LL | const BAD_AGGREGATE: (pattern_type!(u32 is 1..), u32) = (unsafe { std::mem::transmute(0) }, 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .0.0: encountered 0, but expected something greater or equal to 1 --> $DIR/validity.rs:26:1 | LL | const BAD_FOO: Foo = Foo(Bar(unsafe { std::mem::transmute(0) })); - | ^^^^^^^^^^^^^^^^^^ constructing invalid value at .0.0: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/validity.rs:29:1 | LL | const CHAR_UNINIT: pattern_type!(char is 'A'..'Z') = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 97, but expected something in the range 65..=89 --> $DIR/validity.rs:33:1 | LL | const CHAR_OOB_PAT: pattern_type!(char is 'A'..'Z') = unsafe { std::mem::transmute('a') }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 97, but expected something in the range 65..=89 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) --> $DIR/validity.rs:36:1 | LL | const CHAR_OOB: pattern_type!(char is 'A'..'Z') = unsafe { std::mem::transmute(u32::MAX) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) {