From 6ce845caf40cfc34685383590fd2fadc37546412 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Mon, 16 Jun 2025 09:20:57 +0000 Subject: [PATCH 01/21] Use the .drectve section for exporting symbols from dlls on Windows While it would be reasonable to expect the Windows linker to handle linker args in the .drectve section identical to cli arguments, as it turns out exporting weak symbols only works when the /EXPORT is in the .drectve section, not when it is a linker argument or when a .DEF file is used. --- compiler/rustc_codegen_ssa/src/back/link.rs | 52 +++++++++++++++++-- compiler/rustc_codegen_ssa/src/back/linker.rs | 48 ++--------------- tests/ui/linking/dll-weak-definition.rs | 20 +++++++ 3 files changed, 72 insertions(+), 48 deletions(-) create mode 100644 tests/ui/linking/dll-weak-definition.rs diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 07c713a006994..b88742de8acfd 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -2196,9 +2196,11 @@ fn add_linked_symbol_object( cmd: &mut dyn Linker, sess: &Session, tmpdir: &Path, - symbols: &[(String, SymbolExportKind)], + crate_type: CrateType, + linked_symbols: &[(String, SymbolExportKind)], + exported_symbols: &[(String, SymbolExportKind)], ) { - if symbols.is_empty() { + if linked_symbols.is_empty() && exported_symbols.is_empty() { return; } @@ -2235,7 +2237,7 @@ fn add_linked_symbol_object( None }; - for (sym, kind) in symbols.iter() { + for (sym, kind) in linked_symbols.iter() { let symbol = file.add_symbol(object::write::Symbol { name: sym.clone().into(), value: 0, @@ -2293,6 +2295,41 @@ fn add_linked_symbol_object( } } + if sess.target.is_like_msvc { + // Symbol visibility takes care of this for executables typically + let should_filter_symbols = if crate_type == CrateType::Executable { + sess.opts.unstable_opts.export_executable_symbols + } else { + true + }; + if should_filter_symbols { + // Currently the compiler doesn't use `dllexport` (an LLVM attribute) to + // export symbols from a dynamic library. When building a dynamic library, + // however, we're going to want some symbols exported, so this adds a + // `.drectve` section which lists all the symbols using /EXPORT arguments. + // + // The linker will read these arguments from the `.drectve` section and + // export all the symbols from the dynamic library. Note that this is not + // as simple as just exporting all the symbols in the current crate (as + // specified by `codegen.reachable`) but rather we also need to possibly + // export the symbols of upstream crates. Upstream rlibs may be linked + // statically to this dynamic library, in which case they may continue to + // transitively be used and hence need their symbols exported. + let drectve = exported_symbols + .into_iter() + .map(|(sym, kind)| match kind { + SymbolExportKind::Text | SymbolExportKind::Tls => format!(" /EXPORT:\"{sym}\""), + SymbolExportKind::Data => format!(" /EXPORT:\"{sym}\",DATA"), + }) + .collect::>() + .join(""); + + let section = + file.add_section(vec![], b".drectve".to_vec(), object::SectionKind::Linker); + file.append_section_data(section, drectve.as_bytes(), 1); + } + } + let path = tmpdir.join("symbols.o"); let result = std::fs::write(&path, file.write().unwrap()); if let Err(error) = result { @@ -2629,7 +2666,14 @@ fn linker_with_args( // Pre-link CRT objects. add_pre_link_objects(cmd, sess, flavor, link_output_kind, self_contained_crt_objects); - add_linked_symbol_object(cmd, sess, tmpdir, &crate_info.linked_symbols[&crate_type]); + add_linked_symbol_object( + cmd, + sess, + tmpdir, + crate_type, + &crate_info.linked_symbols[&crate_type], + &export_symbols, + ); // Sanitizer libraries. add_sanitizer_libraries(sess, flavor, crate_type, cmd); diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index 4041bfaa24cf0..0622fba408a12 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -1126,53 +1126,13 @@ impl<'a> Linker for MsvcLinker<'a> { } } - // Currently the compiler doesn't use `dllexport` (an LLVM attribute) to - // export symbols from a dynamic library. When building a dynamic library, - // however, we're going to want some symbols exported, so this function - // generates a DEF file which lists all the symbols. - // - // The linker will read this `*.def` file and export all the symbols from - // the dynamic library. Note that this is not as simple as just exporting - // all the symbols in the current crate (as specified by `codegen.reachable`) - // but rather we also need to possibly export the symbols of upstream - // crates. Upstream rlibs may be linked statically to this dynamic library, - // in which case they may continue to transitively be used and hence need - // their symbols exported. fn export_symbols( &mut self, - tmpdir: &Path, - crate_type: CrateType, - symbols: &[(String, SymbolExportKind)], + _tmpdir: &Path, + _crate_type: CrateType, + _symbols: &[(String, SymbolExportKind)], ) { - // Symbol visibility takes care of this typically - if crate_type == CrateType::Executable { - let should_export_executable_symbols = - self.sess.opts.unstable_opts.export_executable_symbols; - if !should_export_executable_symbols { - return; - } - } - - let path = tmpdir.join("lib.def"); - let res = try { - let mut f = File::create_buffered(&path)?; - - // Start off with the standard module name header and then go - // straight to exports. - writeln!(f, "LIBRARY")?; - writeln!(f, "EXPORTS")?; - for (symbol, kind) in symbols { - let kind_marker = if *kind == SymbolExportKind::Data { " DATA" } else { "" }; - debug!(" _{symbol}"); - writeln!(f, " {symbol}{kind_marker}")?; - } - }; - if let Err(error) = res { - self.sess.dcx().emit_fatal(errors::LibDefWriteFailure { error }); - } - let mut arg = OsString::from("/DEF:"); - arg.push(path); - self.link_arg(&arg); + // We already add /EXPORT arguments to the .drectve section of symbols.o. } fn windows_subsystem(&mut self, subsystem: WindowsSubsystemKind) { diff --git a/tests/ui/linking/dll-weak-definition.rs b/tests/ui/linking/dll-weak-definition.rs new file mode 100644 index 0000000000000..198a94ccee97e --- /dev/null +++ b/tests/ui/linking/dll-weak-definition.rs @@ -0,0 +1,20 @@ +// Regression test for MSVC link.exe failing to export weak definitions from dlls. +// See https://github.com/rust-lang/rust/pull/142568 + +//@ build-pass +//@ only-msvc +//@ revisions: link_exe lld +//@[lld] needs-rust-lld +//@[link_exe] compile-flags: -Zunstable-options -Clink-self-contained=-linker -Clinker-features=-lld +//@[lld] compile-flags: -Zunstable-options -Clink-self-contained=+linker -Clinker-features=+lld + +#![feature(linkage)] +#![crate_type = "cdylib"] + +#[linkage = "weak"] +#[no_mangle] +pub fn weak_function() {} + +#[linkage = "weak"] +#[no_mangle] +pub static WEAK_STATIC: u8 = 42; From 729ca3fb4b21642bc4ff223598f51b1e2284ca06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=9D=E5=80=89=E6=B0=B4=E5=B8=8C?= Date: Tue, 23 Jun 2026 15:15:44 +0800 Subject: [PATCH 02/21] Fix MSVC drectve exports for decorated symbols --- compiler/rustc_codegen_ssa/src/back/link.rs | 83 ++++----- compiler/rustc_codegen_ssa/src/back/linker.rs | 159 +++++++++--------- .../src/back/symbol_export.rs | 5 +- compiler/rustc_codegen_ssa/src/lib.rs | 24 ++- typos.toml | 1 + 5 files changed, 147 insertions(+), 125 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index b88742de8acfd..c41f6f30a1da3 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -63,7 +63,10 @@ use super::rmeta_link::RmetaLinkCache; use super::rpath::{self, RPathConfig}; use super::{apple, rmeta_link, versioned_llvm_target}; use crate::base::needs_allocator_shim_for_linking; -use crate::{CodegenLintLevelSpecs, CompiledModule, CompiledModules, CrateInfo, NativeLib, errors}; +use crate::{ + CodegenLintLevelSpecs, CompiledModule, CompiledModules, CrateInfo, NativeLib, SymbolExport, + errors, +}; pub fn ensure_removed(dcx: DiagCtxtHandle<'_>, path: &Path) { if let Err(e) = fs::remove_file(path) { @@ -593,7 +596,7 @@ fn link_staticlib( crate_info .exported_symbols .get(&CrateType::StaticLib) - .map(|symbols| symbols.iter().map(|(s, _)| s.clone()).collect()) + .map(|symbols| symbols.iter().map(|symbol| symbol.name.clone()).collect()) } } else { None @@ -2198,9 +2201,13 @@ fn add_linked_symbol_object( tmpdir: &Path, crate_type: CrateType, linked_symbols: &[(String, SymbolExportKind)], - exported_symbols: &[(String, SymbolExportKind)], + exported_symbols: &[SymbolExport], ) { - if linked_symbols.is_empty() && exported_symbols.is_empty() { + let should_export_symbols = sess.target.is_like_msvc + && !exported_symbols.is_empty() + && (crate_type != CrateType::Executable + || sess.opts.unstable_opts.export_executable_symbols); + if linked_symbols.is_empty() && !should_export_symbols { return; } @@ -2295,39 +2302,35 @@ fn add_linked_symbol_object( } } - if sess.target.is_like_msvc { - // Symbol visibility takes care of this for executables typically - let should_filter_symbols = if crate_type == CrateType::Executable { - sess.opts.unstable_opts.export_executable_symbols - } else { - true - }; - if should_filter_symbols { - // Currently the compiler doesn't use `dllexport` (an LLVM attribute) to - // export symbols from a dynamic library. When building a dynamic library, - // however, we're going to want some symbols exported, so this adds a - // `.drectve` section which lists all the symbols using /EXPORT arguments. - // - // The linker will read these arguments from the `.drectve` section and - // export all the symbols from the dynamic library. Note that this is not - // as simple as just exporting all the symbols in the current crate (as - // specified by `codegen.reachable`) but rather we also need to possibly - // export the symbols of upstream crates. Upstream rlibs may be linked - // statically to this dynamic library, in which case they may continue to - // transitively be used and hence need their symbols exported. - let drectve = exported_symbols - .into_iter() - .map(|(sym, kind)| match kind { - SymbolExportKind::Text | SymbolExportKind::Tls => format!(" /EXPORT:\"{sym}\""), - SymbolExportKind::Data => format!(" /EXPORT:\"{sym}\",DATA"), - }) - .collect::>() - .join(""); - - let section = - file.add_section(vec![], b".drectve".to_vec(), object::SectionKind::Linker); - file.append_section_data(section, drectve.as_bytes(), 1); + if should_export_symbols { + // Currently the compiler doesn't use `dllexport` (an LLVM attribute) to + // export symbols from a dynamic library. When building a dynamic library, + // however, we're going to want some symbols exported, so this adds a + // `.drectve` section which lists all the symbols using /EXPORT arguments. + // + // The linker will read these arguments from the `.drectve` section and + // export all the symbols from the dynamic library. Note that this is not + // as simple as just exporting all the symbols in the current crate (as + // specified by `codegen.reachable`) but rather we also need to possibly + // export the symbols of upstream crates. Upstream rlibs may be linked + // statically to this dynamic library, in which case they may continue to + // transitively be used and hence need their symbols exported. + fn msvc_drectve_export(symbol: &SymbolExport) -> String { + let data = if symbol.kind == SymbolExportKind::Data { ",DATA" } else { "" }; + + if let Some(link_name) = symbol.link_name.as_deref() { + // The first name is the decorated symbol used by the import library, while + // EXPORTAS gives the public name written to the DLL export table. + format!(" /EXPORT:\"{link_name}\"{data},EXPORTAS,\"{}\"", symbol.name) + } else { + format!(" /EXPORT:\"{}\"{data}", symbol.name) + } } + + let drectve = exported_symbols.iter().map(msvc_drectve_export).collect::(); + + let section = file.add_section(vec![], b".drectve".to_vec(), object::SectionKind::Linker); + file.append_section_data(section, drectve.as_bytes(), 1); } let path = tmpdir.join("symbols.o"); @@ -2523,7 +2526,7 @@ fn undecorate_c_symbol<'a>( fn add_c_staticlib_symbols( sess: &Session, lib: &NativeLib, - out: &mut Vec<(String, SymbolExportKind)>, + out: &mut Vec, ) -> io::Result<()> { let file_path = find_native_static_library(lib.name.as_str(), lib.verbatim, sess); @@ -2586,7 +2589,11 @@ fn add_c_staticlib_symbols( let Some(undecorated) = undecorate_c_symbol(name, sess, export_kind) else { continue; }; - out.push((undecorated.to_string(), export_kind)); + out.push(SymbolExport::with_link_name( + undecorated.to_string(), + export_kind, + name.to_string(), + )); } } diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index 0622fba408a12..9f981016c18af 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -15,7 +15,7 @@ use rustc_middle::middle::dependency_format::Linkage; use rustc_middle::middle::exported_symbols::{ self, ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel, }; -use rustc_middle::ty::TyCtxt; +use rustc_middle::ty::{SymbolName, TyCtxt}; use rustc_session::Session; use rustc_session::config::{self, CrateType, DebugInfo, LinkerPluginLto, Lto, OptLevel, Strip}; use rustc_target::spec::{Arch, Cc, CfgAbi, LinkOutputKind, LinkerFlavor, Lld, Os}; @@ -25,7 +25,7 @@ use super::command::Command; use super::symbol_export; use crate::back::symbol_export::allocator_shim_symbols; use crate::base::needs_allocator_shim_for_linking; -use crate::errors; +use crate::{SymbolExport, errors}; #[cfg(test)] mod tests; @@ -338,12 +338,7 @@ pub(crate) trait Linker { fn debuginfo(&mut self, strip: Strip, natvis_debugger_visualizers: &[PathBuf]); fn no_crt_objects(&mut self); fn no_default_libraries(&mut self); - fn export_symbols( - &mut self, - tmpdir: &Path, - crate_type: CrateType, - symbols: &[(String, SymbolExportKind)], - ); + fn export_symbols(&mut self, tmpdir: &Path, crate_type: CrateType, symbols: &[SymbolExport]); fn windows_subsystem(&mut self, subsystem: WindowsSubsystemKind); fn linker_plugin_lto(&mut self); fn add_eh_frame_header(&mut self) {} @@ -794,12 +789,7 @@ impl<'a> Linker for GccLinker<'a> { } } - fn export_symbols( - &mut self, - tmpdir: &Path, - crate_type: CrateType, - symbols: &[(String, SymbolExportKind)], - ) { + fn export_symbols(&mut self, tmpdir: &Path, crate_type: CrateType, symbols: &[SymbolExport]) { // Symbol visibility in object files typically takes care of this. if crate_type == CrateType::Executable { let should_export_executable_symbols = @@ -826,9 +816,9 @@ impl<'a> Linker for GccLinker<'a> { // Write a plain, newline-separated list of symbols let res = try { let mut f = File::create_buffered(&path)?; - for (sym, _) in symbols { - debug!(" _{sym}"); - writeln!(f, "_{sym}")?; + for sym in symbols { + debug!(" _{}", sym.name); + writeln!(f, "_{}", sym.name)?; } }; if let Err(error) = res { @@ -842,12 +832,13 @@ impl<'a> Linker for GccLinker<'a> { // .def file similar to MSVC one but without LIBRARY section // because LD doesn't like when it's empty writeln!(f, "EXPORTS")?; - for (symbol, kind) in symbols { - let kind_marker = if *kind == SymbolExportKind::Data { " DATA" } else { "" }; - debug!(" _{symbol}"); + for symbol in symbols { + let kind_marker = + if symbol.kind == SymbolExportKind::Data { " DATA" } else { "" }; + debug!(" _{}", symbol.name); // Quote the name in case it's reserved by linker in some way // (this accounts for names with dots in particular). - writeln!(f, " \"{symbol}\"{kind_marker}")?; + writeln!(f, " \"{}\"{kind_marker}", symbol.name)?; } }; if let Err(error) = res { @@ -856,16 +847,16 @@ impl<'a> Linker for GccLinker<'a> { self.link_arg(path); } else if self.sess.target.is_like_wasm { self.link_arg("--no-export-dynamic"); - for (sym, _) in symbols { - self.link_arg("--export").link_arg(sym); + for sym in symbols { + self.link_arg("--export").link_arg(&sym.name); } } else if crate_type == CrateType::Executable && !self.sess.target.is_like_solaris { let res = try { let mut f = File::create_buffered(&path)?; writeln!(f, "{{")?; - for (sym, _) in symbols { - debug!(sym); - writeln!(f, " {sym};")?; + for sym in symbols { + debug!("{}", sym.name); + writeln!(f, " {};", sym.name)?; } writeln!(f, "}};")?; }; @@ -880,9 +871,9 @@ impl<'a> Linker for GccLinker<'a> { writeln!(f, "{{")?; if !symbols.is_empty() { writeln!(f, " global:")?; - for (sym, _) in symbols { - debug!(" {sym};"); - writeln!(f, " {sym};")?; + for sym in symbols { + debug!(" {};", sym.name); + writeln!(f, " {};", sym.name)?; } } writeln!(f, "\n local:\n *;\n}};")?; @@ -1130,7 +1121,7 @@ impl<'a> Linker for MsvcLinker<'a> { &mut self, _tmpdir: &Path, _crate_type: CrateType, - _symbols: &[(String, SymbolExportKind)], + _symbols: &[SymbolExport], ) { // We already add /EXPORT arguments to the .drectve section of symbols.o. } @@ -1273,19 +1264,14 @@ impl<'a> Linker for EmLinker<'a> { self.cc_arg("-nodefaultlibs"); } - fn export_symbols( - &mut self, - _tmpdir: &Path, - _crate_type: CrateType, - symbols: &[(String, SymbolExportKind)], - ) { + fn export_symbols(&mut self, _tmpdir: &Path, _crate_type: CrateType, symbols: &[SymbolExport]) { debug!("EXPORTED SYMBOLS:"); self.cc_arg("-s"); let mut arg = OsString::from("EXPORTED_FUNCTIONS="); let encoded = serde_json::to_string( - &symbols.iter().map(|(sym, _)| "_".to_owned() + sym).collect::>(), + &symbols.iter().map(|sym| "_".to_owned() + &sym.name).collect::>(), ) .unwrap(); debug!("{encoded}"); @@ -1413,14 +1399,9 @@ impl<'a> Linker for WasmLd<'a> { fn no_default_libraries(&mut self) {} - fn export_symbols( - &mut self, - _tmpdir: &Path, - _crate_type: CrateType, - symbols: &[(String, SymbolExportKind)], - ) { - for (sym, _) in symbols { - self.link_args(&["--export", sym]); + fn export_symbols(&mut self, _tmpdir: &Path, _crate_type: CrateType, symbols: &[SymbolExport]) { + for sym in symbols { + self.link_args(&["--export", &sym.name]); } } @@ -1541,7 +1522,7 @@ impl<'a> Linker for L4Bender<'a> { self.cc_arg("-nostdlib"); } - fn export_symbols(&mut self, _: &Path, _: CrateType, _: &[(String, SymbolExportKind)]) { + fn export_symbols(&mut self, _: &Path, _: CrateType, _: &[SymbolExport]) { // ToDo, not implemented, copy from GCC self.sess.dcx().emit_warn(errors::L4BenderExportingSymbolsUnimplemented); } @@ -1695,19 +1676,14 @@ impl<'a> Linker for AixLinker<'a> { fn no_default_libraries(&mut self) {} - fn export_symbols( - &mut self, - tmpdir: &Path, - _crate_type: CrateType, - symbols: &[(String, SymbolExportKind)], - ) { + fn export_symbols(&mut self, tmpdir: &Path, _crate_type: CrateType, symbols: &[SymbolExport]) { let path = tmpdir.join("list.exp"); let res = try { let mut f = File::create_buffered(&path)?; // FIXME: use llvm-nm to generate export list. - for (symbol, _) in symbols { - debug!(" _{symbol}"); - writeln!(f, " {symbol}")?; + for symbol in symbols { + debug!(" _{}", symbol.name); + writeln!(f, " {}", symbol.name)?; } }; if let Err(e) = res { @@ -1752,15 +1728,36 @@ fn for_each_exported_symbols_include_dep<'tcx>( } } -pub(crate) fn exported_symbols( +fn symbol_export_from_exported_symbol<'tcx>( + tcx: TyCtxt<'tcx>, + symbol: ExportedSymbol<'tcx>, + kind: SymbolExportKind, + cnum: CrateNum, +) -> SymbolExport { + let name = symbol_export::exporting_symbol_name_for_instance_in_crate(tcx, symbol, cnum); + let link_name = + symbol_export::linking_symbol_name_for_instance_in_crate(tcx, symbol, kind, cnum); + SymbolExport::with_link_name(name, kind, link_name) +} + +fn symbol_export_from_raw_name( tcx: TyCtxt<'_>, - crate_type: CrateType, -) -> Vec<(String, SymbolExportKind)> { + name: String, + kind: SymbolExportKind, +) -> SymbolExport { + let symbol = ExportedSymbol::NoDefId(SymbolName::new(tcx, &name)); + let link_name = + symbol_export::linking_symbol_name_for_instance_in_crate(tcx, symbol, kind, LOCAL_CRATE); + SymbolExport::with_link_name(name, kind, link_name) +} + +pub(crate) fn exported_symbols(tcx: TyCtxt<'_>, crate_type: CrateType) -> Vec { if let Some(ref exports) = tcx.sess.target.override_export_symbols { return exports .iter() .map(|name| { - ( + symbol_export_from_raw_name( + tcx, name.to_string(), // FIXME use the correct export kind for this symbol. override_export_symbols // can't directly specify the SymbolExportKind as it is defined in rustc_middle @@ -1785,7 +1782,11 @@ pub(crate) fn exported_symbols( && !tcx.sess.target.is_like_wasm { let metadata_symbol_name = exported_symbols::metadata_symbol_name(tcx); - symbols.push((metadata_symbol_name, SymbolExportKind::Data)); + symbols.push(symbol_export_from_raw_name( + tcx, + metadata_symbol_name, + SymbolExportKind::Data, + )); } symbols @@ -1794,7 +1795,7 @@ pub(crate) fn exported_symbols( fn exported_symbols_for_non_proc_macro( tcx: TyCtxt<'_>, crate_type: CrateType, -) -> Vec<(String, SymbolExportKind)> { +) -> Vec { let mut symbols = Vec::new(); let export_threshold = symbol_export::crates_export_threshold(&[crate_type]); for_each_exported_symbols_include_dep(tcx, crate_type, |symbol, info, cnum| { @@ -1802,10 +1803,7 @@ fn exported_symbols_for_non_proc_macro( // from any dylib. The latter doesn't work anyway as we use hidden visibility for // compiler-builtins. Most linkers silently ignore it, but ld64 gives a warning. if info.level.is_below_threshold(export_threshold) && !tcx.is_compiler_builtins(cnum) { - symbols.push(( - symbol_export::exporting_symbol_name_for_instance_in_crate(tcx, symbol, cnum), - info.kind, - )); + symbols.push(symbol_export_from_exported_symbol(tcx, symbol, info.kind, cnum)); symbol_export::extend_exported_symbols(&mut symbols, tcx, symbol, cnum); } }); @@ -1815,13 +1813,16 @@ fn exported_symbols_for_non_proc_macro( && needs_allocator_shim_for_linking(tcx.dependency_formats(()), crate_type) && let Some(kind) = tcx.allocator_kind(()) { - symbols.extend(allocator_shim_symbols(tcx, kind)); + symbols.extend( + allocator_shim_symbols(tcx, kind) + .map(|(name, kind)| symbol_export_from_raw_name(tcx, name, kind)), + ); } symbols } -fn exported_symbols_for_proc_macro_crate(tcx: TyCtxt<'_>) -> Vec<(String, SymbolExportKind)> { +fn exported_symbols_for_proc_macro_crate(tcx: TyCtxt<'_>) -> Vec { // `exported_symbols` will be empty when !should_codegen. if !tcx.sess.opts.output_types.should_codegen() { return Vec::new(); @@ -1830,7 +1831,7 @@ fn exported_symbols_for_proc_macro_crate(tcx: TyCtxt<'_>) -> Vec<(String, Symbol let stable_crate_id = tcx.stable_crate_id(LOCAL_CRATE); let proc_macro_decls_name = rustc_session::generate_proc_macro_decls_symbol(stable_crate_id); - vec![(proc_macro_decls_name, SymbolExportKind::Data)] + vec![symbol_export_from_raw_name(tcx, proc_macro_decls_name, SymbolExportKind::Data)] } pub(crate) fn linked_symbols( @@ -1944,16 +1945,11 @@ impl<'a> Linker for LlbcLinker<'a> { fn ehcont_guard(&mut self) {} - fn export_symbols( - &mut self, - _tmpdir: &Path, - _crate_type: CrateType, - symbols: &[(String, SymbolExportKind)], - ) { + fn export_symbols(&mut self, _tmpdir: &Path, _crate_type: CrateType, symbols: &[SymbolExport]) { match _crate_type { CrateType::Cdylib => { - for (sym, _) in symbols { - self.link_args(&["--export-symbol", sym]); + for sym in symbols { + self.link_args(&["--export-symbol", &sym.name]); } } _ => (), @@ -2024,17 +2020,12 @@ impl<'a> Linker for BpfLinker<'a> { fn ehcont_guard(&mut self) {} - fn export_symbols( - &mut self, - tmpdir: &Path, - _crate_type: CrateType, - symbols: &[(String, SymbolExportKind)], - ) { + fn export_symbols(&mut self, tmpdir: &Path, _crate_type: CrateType, symbols: &[SymbolExport]) { let path = tmpdir.join("symbols"); let res = try { let mut f = File::create_buffered(&path)?; - for (sym, _) in symbols { - writeln!(f, "{sym}")?; + for sym in symbols { + writeln!(f, "{}", sym.name)?; } }; if let Err(error) = res { diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index dfc8c8be5c03f..42e2b646e4793 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -21,6 +21,7 @@ use rustc_symbol_mangling::mangle_internal_symbol; use rustc_target::spec::{Arch, Os, TlsModel}; use tracing::debug; +use crate::SymbolExport; use crate::back::symbol_export; use crate::base::allocator_shim_contents; @@ -721,7 +722,7 @@ pub(crate) fn exporting_symbol_name_for_instance_in_crate<'tcx>( /// Add it to the symbols list for all kernel functions, so that it is exported in the linked /// object. pub(crate) fn extend_exported_symbols<'tcx>( - symbols: &mut Vec<(String, SymbolExportKind)>, + symbols: &mut Vec, tcx: TyCtxt<'tcx>, symbol: ExportedSymbol<'tcx>, instantiating_crate: CrateNum, @@ -737,7 +738,7 @@ pub(crate) fn extend_exported_symbols<'tcx>( // Add the symbol for the kernel descriptor (with .kd suffix) // Per https://llvm.org/docs/AMDGPUUsage.html#symbols these will always be `STT_OBJECT` so // export as data. - symbols.push((format!("{undecorated}.kd"), SymbolExportKind::Data)); + symbols.push(SymbolExport::new(format!("{undecorated}.kd"), SymbolExportKind::Data)); } fn maybe_emutls_symbol_name<'tcx>( diff --git a/compiler/rustc_codegen_ssa/src/lib.rs b/compiler/rustc_codegen_ssa/src/lib.rs index 10ae8a9ee0b38..f3f19f9e90d83 100644 --- a/compiler/rustc_codegen_ssa/src/lib.rs +++ b/compiler/rustc_codegen_ssa/src/lib.rs @@ -233,6 +233,28 @@ impl From<&cstore::NativeLib> for NativeLib { } } +/// A symbol to make visible from a linked artifact. +#[derive(Clone, Debug, Encodable, Decodable)] +pub struct SymbolExport { + /// Name to make visible from the linked artifact. + pub name: String, + /// Kind of symbol, used for target-specific export directives and name decoration. + pub kind: SymbolExportKind, + /// Name of the symbol as seen by the linker, when it differs from `name`. + pub link_name: Option, +} + +impl SymbolExport { + pub fn new(name: String, kind: SymbolExportKind) -> SymbolExport { + SymbolExport { name, kind, link_name: None } + } + + pub fn with_link_name(name: String, kind: SymbolExportKind, link_name: String) -> SymbolExport { + let link_name = if link_name == name { None } else { Some(link_name) }; + SymbolExport { name, kind, link_name } + } +} + /// Misc info we load from metadata to persist beyond the tcx. /// /// Note: though `CrateNum` is only meaningful within the same tcx, information within `CrateInfo` @@ -247,7 +269,7 @@ pub struct CrateInfo { pub target_cpu: String, pub target_features: Vec, pub crate_types: Vec, - pub exported_symbols: UnordMap>, + pub exported_symbols: UnordMap>, pub linked_symbols: FxIndexMap>, pub local_crate_name: Symbol, pub compiler_builtins: Option, diff --git a/typos.toml b/typos.toml index f680f5b0e8abf..1e3d5c5e89d09 100644 --- a/typos.toml +++ b/typos.toml @@ -21,6 +21,7 @@ extend-exclude = [ # right now. Entries should look like `mipsel = "mipsel"`. # # tidy-alphabetical-start +EXPORTAS = "EXPORTAS" # MSVC linker keyword used with /EXPORT directives anser = "anser" # an ANSI parsing package used by rust-analyzer arange = "arange" # short for A-range childs = "childs" From c84bcbe972ae59876db601e9a84d7381ff6ad50f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=9D=E5=80=89=E6=B0=B4=E5=B8=8C?= Date: Mon, 29 Jun 2026 14:18:48 +0800 Subject: [PATCH 03/21] Use rust-lld for dll-weak-definition test --- tests/ui/linking/dll-weak-definition.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ui/linking/dll-weak-definition.rs b/tests/ui/linking/dll-weak-definition.rs index 198a94ccee97e..47ae6aeb43366 100644 --- a/tests/ui/linking/dll-weak-definition.rs +++ b/tests/ui/linking/dll-weak-definition.rs @@ -4,9 +4,9 @@ //@ build-pass //@ only-msvc //@ revisions: link_exe lld +//@[link_exe] compile-flags: -Clinker=link.exe //@[lld] needs-rust-lld -//@[link_exe] compile-flags: -Zunstable-options -Clink-self-contained=-linker -Clinker-features=-lld -//@[lld] compile-flags: -Zunstable-options -Clink-self-contained=+linker -Clinker-features=+lld +//@[lld] compile-flags: -Clinker=rust-lld #![feature(linkage)] #![crate_type = "cdylib"] From 800fdb75b3d9623f111627336d53e4cb9a8bf130 Mon Sep 17 00:00:00 2001 From: heinwol Date: Tue, 9 Jun 2026 14:45:06 +0300 Subject: [PATCH 04/21] Actual fix inside `fn normalize_output` --- src/tools/compiletest/src/runtest.rs | 69 ++++++++++++++++++---------- 1 file changed, 45 insertions(+), 24 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 60d526d3d46ea..4243c60001244 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2580,31 +2580,52 @@ impl<'test> TestCx<'test> { // that actually appear in the output. // We use uppercase ALLOC to distinguish from the non-normalized version. { - let mut seen_allocs = indexmap::IndexSet::new(); - - // The alloc-id appears in pretty-printed allocations. - normalized = static_regex!( - r"╾─*a(lloc)?([0-9]+)(\+0x[0-9a-f]+)?()?( \([0-9]+ ptr bytes\))?─*╼" - ) - .replace_all(&normalized, |caps: &Captures<'_>| { - // Renumber the captured index. - let index = caps.get(2).unwrap().as_str().to_string(); - let (index, _) = seen_allocs.insert_full(index); - let offset = caps.get(3).map_or("", |c| c.as_str()); - let imm = caps.get(4).map_or("", |c| c.as_str()); - // Do not bother keeping it pretty, just make it deterministic. - format!("╾ALLOC{index}{offset}{imm}╼") - }) - .into_owned(); + match self.config.mode { + // Unfortunately, due to parallel frontend assigning alloc-ids + // nondeterministically we resort to dropping ids altogether for now + // in ui tests + TestMode::Ui => { + // The alloc-id appears in pretty-printed allocations. + normalized = static_regex!( + r"╾─*(a(lloc)?|A(LLOC)?)\d+(\+0x[0-9a-f]+)?()?( ?\(\d+ ptr bytes\))?─*╼" + ) + .replace_all(&normalized, |_: &Captures<'_>| "╾ALLOC$ID╼".to_string()) + .into_owned(); - // The alloc-id appears in a sentence. - normalized = static_regex!(r"\balloc([0-9]+)\b") - .replace_all(&normalized, |caps: &Captures<'_>| { - let index = caps.get(1).unwrap().as_str().to_string(); - let (index, _) = seen_allocs.insert_full(index); - format!("ALLOC{index}") - }) - .into_owned(); + // The alloc-id appears in a sentence. + normalized = static_regex!(r"\b(alloc|ALLOC)\d+\b") + .replace_all(&normalized, |_: &Captures<'_>| "ALLOC$ID".to_string()) + .into_owned(); + } + // use consistent `AllocId`s in other test modes, where parallel frontend + // should not (theoretically) be an issue + _ => { + let mut seen_allocs = indexmap::IndexSet::new(); + // The alloc-id appears in pretty-printed allocations. + normalized = static_regex!( + r"╾─*a(lloc)?([0-9]+)(\+0x[0-9a-f]+)?()?( \([0-9]+ ptr bytes\))?─*╼" + ) + .replace_all(&normalized, |caps: &Captures<'_>| { + // Renumber the captured index. + let index = caps.get(2).unwrap().as_str().to_string(); + let (index, _) = seen_allocs.insert_full(index); + let offset = caps.get(3).map_or("", |c| c.as_str()); + let imm = caps.get(4).map_or("", |c| c.as_str()); + // Do not bother keeping it pretty, just make it deterministic. + format!("╾ALLOC{index}{offset}{imm}╼") + }) + .into_owned(); + + // The alloc-id appears in a sentence. + normalized = static_regex!(r"\balloc([0-9]+)\b") + .replace_all(&normalized, |caps: &Captures<'_>| { + let index = caps.get(1).unwrap().as_str().to_string(); + let (index, _) = seen_allocs.insert_full(index); + format!("ALLOC{index}") + }) + .into_owned(); + } + } } // Custom normalization rules From 15ceff0918cdec1e8f4079bda04e6e8ee573a3da Mon Sep 17 00:00:00 2001 From: heinwol Date: Tue, 9 Jun 2026 16:34:37 +0300 Subject: [PATCH 05/21] additional: remove unnecessary `//@ normalize-stderr` in `tests/ui/consts/const-eval/raw-bytes.rs` as we now handle this in our modified regex in `runtest` --- tests/ui/consts/const-eval/raw-bytes.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/ui/consts/const-eval/raw-bytes.rs b/tests/ui/consts/const-eval/raw-bytes.rs index acaf8c8310aab..0374538010c06 100644 --- a/tests/ui/consts/const-eval/raw-bytes.rs +++ b/tests/ui/consts/const-eval/raw-bytes.rs @@ -1,7 +1,6 @@ //@ stderr-per-bitwidth //@ ignore-endian-big // ignore-tidy-linelength -//@ normalize-stderr: "╾─*ALLOC[0-9]+(\+[a-z0-9]+)?()?─*╼" -> "╾ALLOC_ID$1╼" //@ dont-require-annotations: NOTE //@ ignore-parallel-frontend different alloc ids #![allow(invalid_value, unnecessary_transmutes)] From 5b76fe04064aea0b41f164b83092f7b3c776313b Mon Sep 17 00:00:00 2001 From: heinwol Date: Tue, 9 Jun 2026 16:47:05 +0300 Subject: [PATCH 06/21] Remove ignore directives Specifically, all `//@ ignore-parallel-frontend different alloc ids` --- tests/ui/const-generics/issues/issue-100313.rs | 2 +- tests/ui/const-generics/min_const_generics/invalid-patterns.rs | 2 +- tests/ui/const-ptr/forbidden_slices.rs | 2 +- tests/ui/const-ptr/out_of_bounds_read.rs | 2 +- tests/ui/consts/const-compare-bytes-ub.rs | 2 +- tests/ui/consts/const-err-enum-discriminant.rs | 2 +- tests/ui/consts/const-eval/c-variadic-fail.rs | 2 +- .../consts/const-eval/const-pointer-values-in-various-types.rs | 2 +- tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs | 2 +- tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs | 2 +- tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.rs | 2 +- .../const-eval/heap/dealloc_intrinsic_incorrect_layout.rs | 2 +- tests/ui/consts/const-eval/heap/make-global-dangling.rs | 2 +- tests/ui/consts/const-eval/heap/make-global-other.rs | 2 +- tests/ui/consts/const-eval/heap/make-global-twice.rs | 2 +- tests/ui/consts/const-eval/heap/ptr_made_global_mutated.rs | 2 +- tests/ui/consts/const-eval/issue-49296.rs | 2 +- tests/ui/consts/const-eval/ptr_fragments_mixed.rs | 2 +- tests/ui/consts/const-eval/raw-bytes.rs | 2 +- tests/ui/consts/const-eval/raw-pointer-ub.rs | 2 +- tests/ui/consts/const-eval/read_partial_ptr.rs | 2 +- tests/ui/consts/const-eval/ub-enum-overwrite.rs | 2 +- tests/ui/consts/const-eval/ub-enum.rs | 2 +- tests/ui/consts/const-eval/ub-incorrect-vtable.rs | 2 +- tests/ui/consts/const-eval/ub-nonnull.rs | 2 +- tests/ui/consts/const-eval/ub-ref-ptr.rs | 2 +- tests/ui/consts/const-eval/ub-upvars.rs | 2 +- tests/ui/consts/const-eval/ub-wide-ptr.rs | 2 +- tests/ui/consts/const-eval/union-const-eval-field.rs | 2 +- tests/ui/consts/const-eval/union-ice.rs | 2 +- tests/ui/consts/const-eval/union-ub.rs | 2 +- tests/ui/consts/copy-intrinsic.rs | 2 +- tests/ui/consts/interior-mut-const-via-union.rs | 2 +- tests/ui/consts/issue-63952.rs | 2 +- tests/ui/consts/issue-79690.rs | 2 +- tests/ui/consts/miri_unleashed/static-no-inner-mut.rs | 2 +- tests/ui/consts/missing_span_in_backtrace.rs | 2 +- tests/ui/consts/offset_ub.rs | 2 +- tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs | 2 +- tests/ui/type/pattern_types/validity.rs | 2 +- 40 files changed, 40 insertions(+), 40 deletions(-) diff --git a/tests/ui/const-generics/issues/issue-100313.rs b/tests/ui/const-generics/issues/issue-100313.rs index 3eed2e71ae859..1f61356162ca6 100644 --- a/tests/ui/const-generics/issues/issue-100313.rs +++ b/tests/ui/const-generics/issues/issue-100313.rs @@ -1,5 +1,5 @@ //@ dont-require-annotations: NOTE -//@ ignore-parallel-frontend different alloc ids + #![allow(incomplete_features)] #![feature(adt_const_params, unsized_const_params)] 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 847b51abb6af5..85f019adf6649 100644 --- a/tests/ui/const-generics/min_const_generics/invalid-patterns.rs +++ b/tests/ui/const-generics/min_const_generics/invalid-patterns.rs @@ -1,6 +1,6 @@ //@ stderr-per-bitwidth //@ dont-require-annotations: NOTE -//@ ignore-parallel-frontend different alloc ids + use std::mem::transmute; fn get_flag() -> Option { diff --git a/tests/ui/const-ptr/forbidden_slices.rs b/tests/ui/const-ptr/forbidden_slices.rs index b7c02e6735b4e..fcb0dccf750e3 100644 --- a/tests/ui/const-ptr/forbidden_slices.rs +++ b/tests/ui/const-ptr/forbidden_slices.rs @@ -1,7 +1,7 @@ // Strip out raw byte dumps to make comparison platform-independent: //@ 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] |╾─*A(LLOC)?[0-9]+(\+[a-z0-9]+)?()?─*╼ )+ *│.*" -> "HEX_DUMP" -//@ ignore-parallel-frontend different alloc ids + #![feature( slice_from_ptr_range, const_slice_from_ptr_range, diff --git a/tests/ui/const-ptr/out_of_bounds_read.rs b/tests/ui/const-ptr/out_of_bounds_read.rs index 51accc657b81f..b09978badde5f 100644 --- a/tests/ui/const-ptr/out_of_bounds_read.rs +++ b/tests/ui/const-ptr/out_of_bounds_read.rs @@ -1,6 +1,6 @@ fn main() { use std::ptr; -//@ ignore-parallel-frontend different alloc ids + const DATA: [u32; 1] = [42]; const PAST_END_PTR: *const u32 = unsafe { DATA.as_ptr().add(1) }; diff --git a/tests/ui/consts/const-compare-bytes-ub.rs b/tests/ui/consts/const-compare-bytes-ub.rs index f30507858f209..7e3df92a2bf5a 100644 --- a/tests/ui/consts/const-compare-bytes-ub.rs +++ b/tests/ui/consts/const-compare-bytes-ub.rs @@ -1,5 +1,5 @@ //@ check-fail -//@ ignore-parallel-frontend different alloc ids + #![feature(core_intrinsics, const_cmp)] use std::intrinsics::compare_bytes; use std::mem::MaybeUninit; diff --git a/tests/ui/consts/const-err-enum-discriminant.rs b/tests/ui/consts/const-err-enum-discriminant.rs index f6142707f9223..5567460058434 100644 --- a/tests/ui/consts/const-err-enum-discriminant.rs +++ b/tests/ui/consts/const-err-enum-discriminant.rs @@ -1,5 +1,5 @@ //@ stderr-per-bitwidth -//@ ignore-parallel-frontend different alloc ids + #[derive(Copy, Clone)] union Foo { a: isize, diff --git a/tests/ui/consts/const-eval/c-variadic-fail.rs b/tests/ui/consts/const-eval/c-variadic-fail.rs index 087e649af95f9..a57311fcb78ed 100644 --- a/tests/ui/consts/const-eval/c-variadic-fail.rs +++ b/tests/ui/consts/const-eval/c-variadic-fail.rs @@ -1,5 +1,5 @@ //@ build-fail -//@ ignore-parallel-frontend different alloc ids + #![feature(c_variadic)] #![feature(const_c_variadic)] #![feature(const_trait_impl)] 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 c6aae902c8bdb..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 @@ -1,7 +1,7 @@ //@ only-x86_64 //@ stderr-per-bitwidth //@ dont-require-annotations: NOTE -//@ ignore-parallel-frontend different alloc ids + #[repr(C)] union Nonsense { u: usize, 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 3ef18a5f43695..c54115de2045d 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs @@ -3,7 +3,7 @@ #![feature(core_intrinsics)] #![feature(const_heap)] use std::intrinsics; -//@ ignore-parallel-frontend different alloc ids + const BAR: &i32 = unsafe { //~ ERROR: uninitialized memory // Make the pointer immutable to avoid errors related to mutable pointers in constants. &*(intrinsics::const_make_global(intrinsics::const_allocate(4, 4)) as *const i32) 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 a377ee35d92b2..de9fc5d092137 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs @@ -1,6 +1,6 @@ #![feature(core_intrinsics)] #![feature(const_heap)] -//@ ignore-parallel-frontend different alloc ids + // Strip out raw byte dumps to make comparison platform-independent: //@ 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] |╾─*A(LLOC)?[0-9]+(\+[a-z0-9]+)?()?─*╼ )+ *│.*" -> "HEX_DUMP" 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 bc9227b31f807..5b7cd039b9baa 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.rs +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.rs @@ -1,6 +1,6 @@ #![feature(core_intrinsics)] #![feature(const_heap)] -//@ ignore-parallel-frontend different alloc ids + use std::intrinsics; const _X: () = unsafe { 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 8800188e9036c..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 @@ -1,6 +1,6 @@ #![feature(core_intrinsics)] #![feature(const_heap)] -//@ ignore-parallel-frontend different alloc ids + use std::intrinsics; const _X: () = unsafe { diff --git a/tests/ui/consts/const-eval/heap/make-global-dangling.rs b/tests/ui/consts/const-eval/heap/make-global-dangling.rs index 12b9ca7a6980f..f4c5929bc416d 100644 --- a/tests/ui/consts/const-eval/heap/make-global-dangling.rs +++ b/tests/ui/consts/const-eval/heap/make-global-dangling.rs @@ -1,5 +1,5 @@ // Ensure that we can't call `const_make_global` on dangling pointers. -//@ ignore-parallel-frontend different alloc ids + #![feature(core_intrinsics)] #![feature(const_heap)] diff --git a/tests/ui/consts/const-eval/heap/make-global-other.rs b/tests/ui/consts/const-eval/heap/make-global-other.rs index 9250f7a55be41..4e2a59de13edc 100644 --- a/tests/ui/consts/const-eval/heap/make-global-other.rs +++ b/tests/ui/consts/const-eval/heap/make-global-other.rs @@ -1,5 +1,5 @@ // Ensure that we can't call `const_make_global` on pointers not in the current interpreter. -//@ ignore-parallel-frontend different alloc ids + #![feature(core_intrinsics)] #![feature(const_heap)] diff --git a/tests/ui/consts/const-eval/heap/make-global-twice.rs b/tests/ui/consts/const-eval/heap/make-global-twice.rs index a4d01170812cc..0cd617cea3e6e 100644 --- a/tests/ui/consts/const-eval/heap/make-global-twice.rs +++ b/tests/ui/consts/const-eval/heap/make-global-twice.rs @@ -1,5 +1,5 @@ // Ensure that we can't call `const_make_global` twice. -//@ ignore-parallel-frontend different alloc ids + #![feature(core_intrinsics)] #![feature(const_heap)] diff --git a/tests/ui/consts/const-eval/heap/ptr_made_global_mutated.rs b/tests/ui/consts/const-eval/heap/ptr_made_global_mutated.rs index c405f73160481..bea2a5949c261 100644 --- a/tests/ui/consts/const-eval/heap/ptr_made_global_mutated.rs +++ b/tests/ui/consts/const-eval/heap/ptr_made_global_mutated.rs @@ -2,7 +2,7 @@ #![feature(core_intrinsics)] #![feature(const_heap)] use std::intrinsics; -//@ ignore-parallel-frontend different alloc ids + const A: &u8 = unsafe { let ptr = intrinsics::const_allocate(1, 1); *ptr = 1; diff --git a/tests/ui/consts/const-eval/issue-49296.rs b/tests/ui/consts/const-eval/issue-49296.rs index 35797fbf248bf..a427b642899a5 100644 --- a/tests/ui/consts/const-eval/issue-49296.rs +++ b/tests/ui/consts/const-eval/issue-49296.rs @@ -1,5 +1,5 @@ // issue-49296: Unsafe shenigans in constants can result in missing errors -//@ ignore-parallel-frontend different alloc ids + use std::mem::transmute; const fn wat(x: u64) -> &'static u64 { diff --git a/tests/ui/consts/const-eval/ptr_fragments_mixed.rs b/tests/ui/consts/const-eval/ptr_fragments_mixed.rs index 471d464055960..24169eac4780d 100644 --- a/tests/ui/consts/const-eval/ptr_fragments_mixed.rs +++ b/tests/ui/consts/const-eval/ptr_fragments_mixed.rs @@ -1,6 +1,6 @@ //! This mixes fragments from different pointers, in a way that we should not accept. //! See . -//@ ignore-parallel-frontend different alloc ids + static A: u8 = 123; static B: u8 = 123; diff --git a/tests/ui/consts/const-eval/raw-bytes.rs b/tests/ui/consts/const-eval/raw-bytes.rs index 0374538010c06..5c8253ee2b41f 100644 --- a/tests/ui/consts/const-eval/raw-bytes.rs +++ b/tests/ui/consts/const-eval/raw-bytes.rs @@ -2,7 +2,7 @@ //@ ignore-endian-big // ignore-tidy-linelength //@ dont-require-annotations: NOTE -//@ ignore-parallel-frontend different alloc ids + #![allow(invalid_value, unnecessary_transmutes)] #![feature(never_type, rustc_attrs, ptr_metadata, slice_from_ptr_range, const_slice_from_ptr_range)] #![feature(pattern_types, pattern_type_macro)] diff --git a/tests/ui/consts/const-eval/raw-pointer-ub.rs b/tests/ui/consts/const-eval/raw-pointer-ub.rs index 0998617b5b71d..df7bc2fe4fb18 100644 --- a/tests/ui/consts/const-eval/raw-pointer-ub.rs +++ b/tests/ui/consts/const-eval/raw-pointer-ub.rs @@ -4,7 +4,7 @@ const MISALIGNED_LOAD: () = unsafe { let _val = *ptr; //~NOTE: failed here //~^ERROR: based on pointer with alignment 1, but alignment 4 is required }; -//@ ignore-parallel-frontend different alloc ids + const MISALIGNED_STORE: () = unsafe { let mut mem = [0u32; 8]; let ptr = mem.as_mut_ptr().byte_add(1); diff --git a/tests/ui/consts/const-eval/read_partial_ptr.rs b/tests/ui/consts/const-eval/read_partial_ptr.rs index 5248f92a92db4..bccef9c0bc6ca 100644 --- a/tests/ui/consts/const-eval/read_partial_ptr.rs +++ b/tests/ui/consts/const-eval/read_partial_ptr.rs @@ -1,5 +1,5 @@ //! Ensure we error when trying to load from a pointer whose provenance has been messed with. -//@ ignore-parallel-frontend different alloc ids + const PARTIAL_OVERWRITE: () = { let mut p = &42; // Overwrite one byte with a no-provenance value. diff --git a/tests/ui/consts/const-eval/ub-enum-overwrite.rs b/tests/ui/consts/const-eval/ub-enum-overwrite.rs index a1bd49f53acea..005f3c78c1d7d 100644 --- a/tests/ui/consts/const-eval/ub-enum-overwrite.rs +++ b/tests/ui/consts/const-eval/ub-enum-overwrite.rs @@ -2,7 +2,7 @@ enum E { A(u8), B, } -//@ ignore-parallel-frontend different alloc ids + const _: u8 = { let mut e = E::A(1); let p = if let E::A(x) = &mut e { x as *mut u8 } else { unreachable!() }; diff --git a/tests/ui/consts/const-eval/ub-enum.rs b/tests/ui/consts/const-eval/ub-enum.rs index 8feb78e0b11e8..cea8b6b6403c4 100644 --- a/tests/ui/consts/const-eval/ub-enum.rs +++ b/tests/ui/consts/const-eval/ub-enum.rs @@ -4,7 +4,7 @@ //@ normalize-stderr: "0x0+" -> "0x0" //@ normalize-stderr: "0x[0-9](\.\.|\])" -> "0x%$1" //@ dont-require-annotations: NOTE -//@ ignore-parallel-frontend different alloc ids + #![feature(never_type)] #![allow(invalid_value, unnecessary_transmutes)] diff --git a/tests/ui/consts/const-eval/ub-incorrect-vtable.rs b/tests/ui/consts/const-eval/ub-incorrect-vtable.rs index 09129012e083c..4185b0261b296 100644 --- a/tests/ui/consts/const-eval/ub-incorrect-vtable.rs +++ b/tests/ui/consts/const-eval/ub-incorrect-vtable.rs @@ -12,7 +12,7 @@ //@ stderr-per-bitwidth //@ dont-require-annotations: NOTE -//@ ignore-parallel-frontend different alloc ids + trait Trait {} const INVALID_VTABLE_ALIGNMENT: &dyn Trait = diff --git a/tests/ui/consts/const-eval/ub-nonnull.rs b/tests/ui/consts/const-eval/ub-nonnull.rs index b6aca0684b84d..99afde5e20afe 100644 --- a/tests/ui/consts/const-eval/ub-nonnull.rs +++ b/tests/ui/consts/const-eval/ub-nonnull.rs @@ -2,7 +2,7 @@ //@ 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 -//@ ignore-parallel-frontend different alloc ids + #![allow(invalid_value)] // make sure we cannot allow away the errors tested here #![feature(rustc_attrs, ptr_metadata)] diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.rs b/tests/ui/consts/const-eval/ub-ref-ptr.rs index 1f92e8edec2ca..d1a1ef61bdc42 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.rs +++ b/tests/ui/consts/const-eval/ub-ref-ptr.rs @@ -6,7 +6,7 @@ //@ normalize-stderr: "0x[0-9](\.\.|\])" -> "0x%$1" #![feature(pattern_types, pattern_type_macro)] #![allow(invalid_value)] -//@ ignore-parallel-frontend different alloc ids + use std::{mem, pat::pattern_type}; #[repr(C)] diff --git a/tests/ui/consts/const-eval/ub-upvars.rs b/tests/ui/consts/const-eval/ub-upvars.rs index 7270d90bf7927..c5bf074ec4626 100644 --- a/tests/ui/consts/const-eval/ub-upvars.rs +++ b/tests/ui/consts/const-eval/ub-upvars.rs @@ -1,7 +1,7 @@ //@ edition:2015..2021 //@ stderr-per-bitwidth #![allow(invalid_value)] // make sure we cannot allow away the errors tested here -//@ ignore-parallel-frontend different alloc ids + use std::mem; const BAD_UPVAR: &dyn FnOnce() = &{ //~ ERROR null reference diff --git a/tests/ui/consts/const-eval/ub-wide-ptr.rs b/tests/ui/consts/const-eval/ub-wide-ptr.rs index 6297d2f3d3af3..0bbb104c0322c 100644 --- a/tests/ui/consts/const-eval/ub-wide-ptr.rs +++ b/tests/ui/consts/const-eval/ub-wide-ptr.rs @@ -3,7 +3,7 @@ #![feature(ptr_metadata)] use std::{ptr, mem}; -//@ ignore-parallel-frontend different alloc ids + // Strip out raw byte dumps to make comparison platform-independent: //@ 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" 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 92d056b3b1ef8..2c9061a7a50f8 100644 --- a/tests/ui/consts/const-eval/union-const-eval-field.rs +++ b/tests/ui/consts/const-eval/union-const-eval-field.rs @@ -1,7 +1,7 @@ //@ dont-require-annotations: NOTE //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" //@ normalize-stderr: "([[:xdigit:]]{2}\s){4}(__\s){4}\s+│\s+([?|\.]){4}\W{4}" -> "HEX_DUMP" -//@ ignore-parallel-frontend different alloc ids + type Field1 = i32; type Field2 = f32; type Field3 = i64; diff --git a/tests/ui/consts/const-eval/union-ice.rs b/tests/ui/consts/const-eval/union-ice.rs index 055a130cf0e89..7a4909e8ce281 100644 --- a/tests/ui/consts/const-eval/union-ice.rs +++ b/tests/ui/consts/const-eval/union-ice.rs @@ -1,5 +1,5 @@ //@ only-x86_64 -//@ ignore-parallel-frontend different alloc ids + type Field1 = i32; type Field3 = i64; diff --git a/tests/ui/consts/const-eval/union-ub.rs b/tests/ui/consts/const-eval/union-ub.rs index 8de54f5749f35..0fa5d31285604 100644 --- a/tests/ui/consts/const-eval/union-ub.rs +++ b/tests/ui/consts/const-eval/union-ub.rs @@ -1,6 +1,6 @@ //@ stderr-per-bitwidth //@ dont-require-annotations: NOTE -//@ ignore-parallel-frontend different alloc ids + #[repr(C)] union DummyUnion { unit: (), diff --git a/tests/ui/consts/copy-intrinsic.rs b/tests/ui/consts/copy-intrinsic.rs index 5329e5bc242ed..480f1c5f460d0 100644 --- a/tests/ui/consts/copy-intrinsic.rs +++ b/tests/ui/consts/copy-intrinsic.rs @@ -1,6 +1,6 @@ // ignore-tidy-linelength #![feature(core_intrinsics)] -//@ ignore-parallel-frontend different alloc ids + use std::intrinsics::{copy, copy_nonoverlapping}; use std::mem; diff --git a/tests/ui/consts/interior-mut-const-via-union.rs b/tests/ui/consts/interior-mut-const-via-union.rs index cba3b36bd98a0..5e624671aee02 100644 --- a/tests/ui/consts/interior-mut-const-via-union.rs +++ b/tests/ui/consts/interior-mut-const-via-union.rs @@ -3,7 +3,7 @@ // //@ build-fail //@ stderr-per-bitwidth -//@ ignore-parallel-frontend different alloc ids + use std::cell::Cell; use std::mem::ManuallyDrop; diff --git a/tests/ui/consts/issue-63952.rs b/tests/ui/consts/issue-63952.rs index c0ee7a5dc1e7e..fce6013b4d310 100644 --- a/tests/ui/consts/issue-63952.rs +++ b/tests/ui/consts/issue-63952.rs @@ -1,6 +1,6 @@ // Regression test for #63952, shouldn't hang. //@ stderr-per-bitwidth -//@ ignore-parallel-frontend different alloc ids + #[repr(C)] #[derive(Copy, Clone)] struct SliceRepr { diff --git a/tests/ui/consts/issue-79690.rs b/tests/ui/consts/issue-79690.rs index 5e1e65cdb8d57..24e3220155d18 100644 --- a/tests/ui/consts/issue-79690.rs +++ b/tests/ui/consts/issue-79690.rs @@ -1,7 +1,7 @@ //@ ignore-32bit // This test gives a different error on 32-bit architectures. //@ stderr-per-bitwidth -//@ ignore-parallel-frontend different alloc ids + union Transmute { t: T, u: U, 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 27eb9a6c7c344..0e87442f6a698 100644 --- a/tests/ui/consts/miri_unleashed/static-no-inner-mut.rs +++ b/tests/ui/consts/miri_unleashed/static-no-inner-mut.rs @@ -1,6 +1,6 @@ //@ stderr-per-bitwidth //@ compile-flags: -Zunleash-the-miri-inside-of-you -//@ ignore-parallel-frontend different alloc ids + // All "inner" allocations that come with a `static` are interned immutably. This means it is // crucial that we do not accept any form of (interior) mutability there. use std::sync::atomic::*; diff --git a/tests/ui/consts/missing_span_in_backtrace.rs b/tests/ui/consts/missing_span_in_backtrace.rs index 897b37b3e65ae..b679493eb08eb 100644 --- a/tests/ui/consts/missing_span_in_backtrace.rs +++ b/tests/ui/consts/missing_span_in_backtrace.rs @@ -1,7 +1,7 @@ //! Check what happens when the error occurs inside a std function that we can't print the span of. //@ ignore-backends: gcc //@ compile-flags: -Z ui-testing=no --diagnostic-width=80 -//@ ignore-parallel-frontend different alloc ids + use std::{ mem::{self, MaybeUninit}, ptr, diff --git a/tests/ui/consts/offset_ub.rs b/tests/ui/consts/offset_ub.rs index c9c34e19e4dd6..98a50156a9487 100644 --- a/tests/ui/consts/offset_ub.rs +++ b/tests/ui/consts/offset_ub.rs @@ -1,5 +1,5 @@ use std::ptr; -//@ ignore-parallel-frontend different alloc ids + //@ normalize-stderr: "0xf+" -> "0xf..f" //@ normalize-stderr: "0x7f+" -> "0x7f..f" //@ normalize-stderr: "\d+ bytes" -> "$$BYTES bytes" diff --git a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs index d2e5e158b7226..ed15f5bba9622 100644 --- a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs +++ b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs @@ -1,6 +1,6 @@ //@ normalize-stderr: "[[:xdigit:]]{2} __ ([[:xdigit:]]{2}\s){2}" -> "HEX_DUMP" #![feature(core_intrinsics)] -//@ ignore-parallel-frontend different alloc ids + const RAW_EQ_PADDING: bool = unsafe { std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16)) //~^ ERROR requires initialized memory diff --git a/tests/ui/type/pattern_types/validity.rs b/tests/ui/type/pattern_types/validity.rs index 6c630fc2633b6..f4c62dc6712e9 100644 --- a/tests/ui/type/pattern_types/validity.rs +++ b/tests/ui/type/pattern_types/validity.rs @@ -1,7 +1,7 @@ //! Check that pattern types have their validity checked // Strip out raw byte dumps to make tests platform-independent: //@ normalize-stderr: "([[:xdigit:]]{2}\s){4,8}\s+│\s.{4,8}" -> "HEX_DUMP" -//@ ignore-parallel-frontend different alloc ids + #![feature(pattern_types, const_trait_impl, pattern_type_range_trait)] #![feature(pattern_type_macro)] From d06599e0df7c543ed333ce41a4de3f1357f9b88e Mon Sep 17 00:00:00 2001 From: heinwol Date: Tue, 9 Jun 2026 17:04:38 +0300 Subject: [PATCH 07/21] bless stderr --- .../const-generics/issues/issue-100313.stderr | 2 +- .../invalid-patterns.64bit.stderr | 4 +- tests/ui/const-ptr/forbidden_slices.stderr | 24 +-- tests/ui/const-ptr/out_of_bounds_read.stderr | 6 +- tests/ui/consts/const-compare-bytes-ub.stderr | 8 +- .../const-err-enum-discriminant.64bit.stderr | 2 +- .../consts/const-eval/c-variadic-fail.stderr | 8 +- ...inter-values-in-various-types.64bit.stderr | 8 +- .../heap/alloc_intrinsic_uninit.64bit.stderr | 2 +- .../heap/dealloc_intrinsic_dangling.stderr | 4 +- .../heap/dealloc_intrinsic_duplicate.stderr | 2 +- .../dealloc_intrinsic_incorrect_layout.stderr | 6 +- .../const-eval/heap/make-global-other.stderr | 2 +- .../const-eval/heap/make-global-twice.stderr | 2 +- .../heap/ptr_made_global_mutated.stderr | 2 +- tests/ui/consts/const-eval/issue-49296.stderr | 2 +- .../const-eval/ptr_fragments_mixed.stderr | 4 +- .../consts/const-eval/raw-bytes.64bit.stderr | 176 +++++++++--------- .../consts/const-eval/raw-pointer-ub.stderr | 2 +- .../consts/const-eval/read_partial_ptr.stderr | 8 +- .../const-eval/ub-enum-overwrite.stderr | 2 +- tests/ui/consts/const-eval/ub-enum.stderr | 2 +- .../ub-incorrect-vtable.64bit.stderr | 22 +-- tests/ui/consts/const-eval/ub-nonnull.stderr | 8 +- tests/ui/consts/const-eval/ub-ref-ptr.stderr | 18 +- .../consts/const-eval/ub-upvars.64bit.stderr | 2 +- tests/ui/consts/const-eval/ub-wide-ptr.stderr | 66 +++---- .../const-eval/union-const-eval-field.stderr | 2 +- tests/ui/consts/const-eval/union-ice.stderr | 6 +- .../consts/const-eval/union-ub.64bit.stderr | 2 +- .../const-mut-refs/mut_ref_in_final.stderr | 8 +- .../const_refs_to_static_fail_invalid.stderr | 2 +- .../ui/consts/const_transmute_type_id7.stderr | 2 +- tests/ui/consts/copy-intrinsic.stderr | 2 +- tests/ui/consts/dangling-alloc-id-ice.stderr | 2 +- .../dangling-zst-ice-issue-126393.stderr | 2 +- .../interior-mut-const-via-union.64bit.stderr | 2 +- tests/ui/consts/issue-63952.64bit.stderr | 2 +- tests/ui/consts/issue-79690.64bit.stderr | 2 +- .../miri_unleashed/mutable_references.stderr | 14 +- .../static-no-inner-mut.64bit.stderr | 8 +- .../consts/missing_span_in_backtrace.stderr | 2 +- tests/ui/consts/offset_ub.stderr | 10 +- .../intrinsic-raw_eq-const-bad.stderr | 2 +- .../statics/mutable_memory_validation.stderr | 2 +- tests/ui/type/pattern_types/validity.stderr | 4 +- 46 files changed, 235 insertions(+), 235 deletions(-) diff --git a/tests/ui/const-generics/issues/issue-100313.stderr b/tests/ui/const-generics/issues/issue-100313.stderr index d1a0249728ebd..17bad92d8dfa5 100644 --- a/tests/ui/const-generics/issues/issue-100313.stderr +++ b/tests/ui/const-generics/issues/issue-100313.stderr @@ -1,4 +1,4 @@ -error[E0080]: writing to ALLOC0 which is read-only +error[E0080]: writing to ALLOC$ID which is read-only --> $DIR/issue-100313.rs:18:5 | LL | x.set_false(); 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 ec39cc27efb41..31a2accccd7fd 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 @@ -46,7 +46,7 @@ note: expected because of the type of the const parameter LL | fn get_flag() -> Option { | ^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory --> $DIR/invalid-patterns.rs:40:32 | LL | get_flag::(); @@ -78,7 +78,7 @@ LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character 42 │ B } -error[E0080]: reading memory at ALLOC1[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory --> $DIR/invalid-patterns.rs:44:58 | LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); diff --git a/tests/ui/const-ptr/forbidden_slices.stderr b/tests/ui/const-ptr/forbidden_slices.stderr index fb74be3bb52f6..e23b4e5b1aa75 100644 --- a/tests/ui/const-ptr/forbidden_slices.stderr +++ b/tests/ui/const-ptr/forbidden_slices.stderr @@ -28,7 +28,7 @@ LL | pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) }; | = 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 + ╾ALLOC$ID╼ HEX_DUMP } error[E0080]: constructing invalid value of type &[u8]: at .[0], encountered uninitialized memory, but expected an integer @@ -39,7 +39,7 @@ LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) } | = 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 + ╾ALLOC$ID╼ HEX_DUMP } error[E0080]: constructing invalid value of type &[u8]: at .[0], encountered a pointer, but expected an integer @@ -52,7 +52,7 @@ LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size = 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 + ╾ALLOC$ID╼ HEX_DUMP } error[E0080]: constructing invalid value of type &[bool]: at .[0], encountered 0x11, but expected a boolean @@ -63,7 +63,7 @@ LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) | = 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 + ╾ALLOC$ID╼ HEX_DUMP } error[E0080]: constructing invalid value of type &[u16]: at .[1], encountered uninitialized memory, but expected an integer @@ -74,7 +74,7 @@ LL | pub static S7: &[u16] = unsafe { | = 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 + ╾ALLOC$ID╼ HEX_DUMP } error[E0080]: constructing invalid value of type &[u64]: encountered a dangling reference (going beyond the bounds of its allocation) @@ -85,7 +85,7 @@ LL | pub static S8: &[u64] = unsafe { | = 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 + ╾ALLOC$ID╼ HEX_DUMP } error[E0080]: constructing invalid value of type &[u32]: encountered a null reference @@ -105,7 +105,7 @@ error[E0080]: evaluation panicked: assertion failed: 0 < pointee_size && pointee LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; // errors inside libcore | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `R1` failed here -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 +error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC$ID which is only 4 bytes from the end of the allocation --> $DIR/forbidden_slices.rs:54:25 | LL | from_ptr_range(ptr..ptr.add(2)) // errors inside libcore @@ -119,7 +119,7 @@ LL | pub static R4: &[u8] = unsafe { | = 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 + ╾ALLOC$ID╼ HEX_DUMP } error[E0080]: constructing invalid value of type &[u8]: at .[0], encountered a pointer, but expected an integer @@ -132,7 +132,7 @@ LL | pub static R5: &[u8] = unsafe { = 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 + ╾ALLOC$ID╼ HEX_DUMP } error[E0080]: constructing invalid value of type &[bool]: at .[0], encountered 0x11, but expected a boolean @@ -143,7 +143,7 @@ LL | pub static R6: &[bool] = unsafe { | = 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 + ╾ALLOC$ID╼ HEX_DUMP } error[E0080]: constructing invalid value of type &[u16]: encountered an unaligned reference (required 2 byte alignment but found 1) @@ -154,10 +154,10 @@ LL | pub static R7: &[u16] = unsafe { | = 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 + ╾ALLOC$ID╼ HEX_DUMP } -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 +error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC$ID+0x1 which is only 7 bytes from the end of the allocation --> $DIR/forbidden_slices.rs:79:25 | LL | from_ptr_range(ptr..ptr.add(1)) diff --git a/tests/ui/const-ptr/out_of_bounds_read.stderr b/tests/ui/const-ptr/out_of_bounds_read.stderr index a98765b15f267..8465d69db28e7 100644 --- a/tests/ui/const-ptr/out_of_bounds_read.stderr +++ b/tests/ui/const-ptr/out_of_bounds_read.stderr @@ -1,16 +1,16 @@ -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 +error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID+0x4 which is at or beyond the end of the allocation of size 4 bytes --> $DIR/out_of_bounds_read.rs:8:33 | LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) }; | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_READ` failed here -error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes +error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID+0x4 which is at or beyond the end of the allocation of size 4 bytes --> $DIR/out_of_bounds_read.rs:10:39 | LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; | ^^^^^^^^^^^^^^^^^^^ evaluation of `main::_CONST_READ` failed here -error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes +error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID+0x4 which is at or beyond the end of the allocation of size 4 bytes --> $DIR/out_of_bounds_read.rs:12:37 | LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() }; diff --git a/tests/ui/consts/const-compare-bytes-ub.stderr b/tests/ui/consts/const-compare-bytes-ub.stderr index 770a55cc7267d..94098c1e26407 100644 --- a/tests/ui/consts/const-compare-bytes-ub.stderr +++ b/tests/ui/consts/const-compare-bytes-ub.stderr @@ -16,19 +16,19 @@ error[E0080]: memory access failed: attempting to access 1 byte, but got 0x1[noa LL | compare_bytes(1 as *const u8, 2 as *const u8, 1) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::DANGLING_PTR_NON_ZERO_LENGTH` failed here -error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0 which is only 3 bytes from the end of the allocation +error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID which is only 3 bytes from the end of the allocation --> $DIR/const-compare-bytes-ub.rs:21:9 | LL | compare_bytes([1, 2, 3].as_ptr(), [1, 2, 3, 4].as_ptr(), 4) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::LHS_OUT_OF_BOUNDS` failed here -error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC1 which is only 3 bytes from the end of the allocation +error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID which is only 3 bytes from the end of the allocation --> $DIR/const-compare-bytes-ub.rs:25:9 | LL | compare_bytes([1, 2, 3, 4].as_ptr(), [1, 2, 3].as_ptr(), 4) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::RHS_OUT_OF_BOUNDS` failed here -error[E0080]: reading memory at ALLOC2[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory --> $DIR/const-compare-bytes-ub.rs:29:9 | LL | compare_bytes(MaybeUninit::uninit().as_ptr(), [1].as_ptr(), 1) @@ -38,7 +38,7 @@ LL | compare_bytes(MaybeUninit::uninit().as_ptr(), [1].as_ptr(), 1) __ │ ░ } -error[E0080]: reading memory at ALLOC3[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory --> $DIR/const-compare-bytes-ub.rs:33:9 | LL | compare_bytes([1].as_ptr(), MaybeUninit::uninit().as_ptr(), 1) diff --git a/tests/ui/consts/const-err-enum-discriminant.64bit.stderr b/tests/ui/consts/const-err-enum-discriminant.64bit.stderr index 1d32851aac176..9212299bffbd4 100644 --- a/tests/ui/consts/const-err-enum-discriminant.64bit.stderr +++ b/tests/ui/consts/const-err-enum-discriminant.64bit.stderr @@ -1,4 +1,4 @@ -error[E0080]: reading memory at ALLOC0[0x0..0x8], but memory is uninitialized at [0x0..0x8], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x0..0x8], but memory is uninitialized at [0x0..0x8], and this operation requires initialized memory --> $DIR/const-err-enum-discriminant.rs:10:21 | LL | Boo = [unsafe { Foo { b: () }.a }; 4][3], diff --git a/tests/ui/consts/const-eval/c-variadic-fail.stderr b/tests/ui/consts/const-eval/c-variadic-fail.stderr index c1f9ed0fb398a..e32edfb3ea453 100644 --- a/tests/ui/consts/const-eval/c-variadic-fail.stderr +++ b/tests/ui/consts/const-eval/c-variadic-fail.stderr @@ -418,7 +418,7 @@ LL | const { read_as::<*const fn(&'static ())>(std::ptr::dangling:: | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0080]: memory access failed: ALLOC0 has been freed, so this pointer is dangling +error[E0080]: memory access failed: ALLOC$ID has been freed, so this pointer is dangling --> $DIR/c-variadic-fail.rs:140:13 | LL | ap.next_arg::(); @@ -451,7 +451,7 @@ LL | | }; | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0080]: using ALLOC1 as variable argument list pointer but it does not point to a variable argument list +error[E0080]: using ALLOC$ID as variable argument list pointer but it does not point to a variable argument list --> $DIR/c-variadic-fail.rs:162:22 | LL | const { unsafe { helper(1, 2, 3) } }; @@ -483,7 +483,7 @@ LL | const { unsafe { helper(1, 2, 3) } }; | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0080]: using ALLOC2 as variable argument list pointer but it does not point to a variable argument list +error[E0080]: using ALLOC$ID as variable argument list pointer but it does not point to a variable argument list --> $DIR/c-variadic-fail.rs:178:22 | LL | const { unsafe { helper(1, 2, 3) } }; @@ -515,7 +515,7 @@ LL | const { unsafe { helper(1, 2, 3) } }; | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0080]: using ALLOC3 as variable argument list pointer but it does not point to a variable argument list +error[E0080]: using ALLOC$ID as variable argument list pointer but it does not point to a variable argument list --> $DIR/c-variadic-fail.rs:191:22 | LL | const { unsafe { helper(1, 2, 3) } }; 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 60f6ef0f64b1c..f68ef6f96988f 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 @@ -43,14 +43,14 @@ LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uin = 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]: reading memory at ALLOC2[0x0..0x10], but memory is uninitialized at [0x8..0x10], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x0..0x10], but memory is uninitialized at [0x8..0x10], and this operation requires initialized memory --> $DIR/const-pointer-values-in-various-types.rs:42:47 | LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_U128_UNION` failed here | = note: the raw bytes of the constant (size: 16, align: 16) { - ╾ALLOC0╼ __ __ __ __ __ __ __ __ │ ╾──────╼░░░░░░░░ + ╾ALLOC$ID╼ __ __ __ __ __ __ __ __ │ ╾──────╼░░░░░░░░ } error[E0080]: unable to turn pointer into integer @@ -89,14 +89,14 @@ LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int = 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]: reading memory at ALLOC3[0x0..0x10], but memory is uninitialized at [0x8..0x10], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x0..0x10], but memory is uninitialized at [0x8..0x10], and this operation requires initialized memory --> $DIR/const-pointer-values-in-various-types.rs:57:47 | LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_I128_UNION` failed here | = note: the raw bytes of the constant (size: 16, align: 16) { - ╾ALLOC1╼ __ __ __ __ __ __ __ __ │ ╾──────╼░░░░░░░░ + ╾ALLOC$ID╼ __ __ __ __ __ __ __ __ │ ╾──────╼░░░░░░░░ } error[E0080]: unable to turn pointer into integer 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 f7b652f7e43b1..e0138e4b3aebe 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 @@ -6,7 +6,7 @@ LL | const BAR: &i32 = unsafe { | = 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╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾──────╼ } error: aborting due to 1 previous error 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 0942924464091..807781634d2c2 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr @@ -6,10 +6,10 @@ LL | const _X: &'static u8 = unsafe { | = 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 + ╾ALLOC$ID╼ │ ╾──────╼ } -error[E0080]: memory access failed: ALLOC1 has been freed, so this pointer is dangling +error[E0080]: memory access failed: ALLOC$ID has been freed, so this pointer is dangling --> $DIR/dealloc_intrinsic_dangling.rs:22:5 | LL | *reference 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 803b772615f24..eb73857143877 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr @@ -1,4 +1,4 @@ -error[E0080]: memory access failed: ALLOC0 has been freed, so this pointer is dangling +error[E0080]: memory access failed: ALLOC$ID has been freed, so this pointer is dangling --> $DIR/dealloc_intrinsic_duplicate.rs:9:5 | LL | intrinsics::const_deallocate(ptr, 4, 4); 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 2d61f06ac5c62..cc7f14d6ddb35 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,16 +1,16 @@ -error[E0080]: incorrect layout on deallocation: ALLOC0 has size 4 and alignment 4, but gave size 4 and alignment 2 +error[E0080]: incorrect layout on deallocation: ALLOC$ID has size 4 and alignment 4, but gave size 4 and alignment 2 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:8:5 | LL | intrinsics::const_deallocate(ptr, 4, 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_X` failed here -error[E0080]: incorrect layout on deallocation: ALLOC1 has size 4 and alignment 4, but gave size 2 and alignment 4 +error[E0080]: incorrect layout on deallocation: ALLOC$ID has size 4 and alignment 4, but gave size 2 and alignment 4 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:13:5 | LL | intrinsics::const_deallocate(ptr, 2, 4); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_Y` failed here -error[E0080]: incorrect layout on deallocation: ALLOC2 has size 4 and alignment 4, but gave size 3 and alignment 4 +error[E0080]: incorrect layout on deallocation: ALLOC$ID has size 4 and alignment 4, but gave size 3 and alignment 4 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:19:5 | LL | intrinsics::const_deallocate(ptr, 3, 4); diff --git a/tests/ui/consts/const-eval/heap/make-global-other.stderr b/tests/ui/consts/const-eval/heap/make-global-other.stderr index ed0d768cf379f..f97c25bdc4957 100644 --- a/tests/ui/consts/const-eval/heap/make-global-other.stderr +++ b/tests/ui/consts/const-eval/heap/make-global-other.stderr @@ -1,4 +1,4 @@ -error[E0080]: pointer passed to `const_make_global` does not point to a heap allocation: ALLOC0 +error[E0080]: pointer passed to `const_make_global` does not point to a heap allocation: ALLOC$ID --> $DIR/make-global-other.rs:11:8 | LL | &*(intrinsics::const_make_global(X as *const i32 as *mut u8) as *const i32) diff --git a/tests/ui/consts/const-eval/heap/make-global-twice.stderr b/tests/ui/consts/const-eval/heap/make-global-twice.stderr index 95cdb9694d8b9..a499299d5297f 100644 --- a/tests/ui/consts/const-eval/heap/make-global-twice.stderr +++ b/tests/ui/consts/const-eval/heap/make-global-twice.stderr @@ -1,4 +1,4 @@ -error[E0080]: attempting to call `const_make_global` twice on the same allocation ALLOC0 +error[E0080]: attempting to call `const_make_global` twice on the same allocation ALLOC$ID --> $DIR/make-global-twice.rs:13:5 | LL | intrinsics::const_make_global(ptr); diff --git a/tests/ui/consts/const-eval/heap/ptr_made_global_mutated.stderr b/tests/ui/consts/const-eval/heap/ptr_made_global_mutated.stderr index 0e88ea77d1ca0..8e56ff1cbb7c6 100644 --- a/tests/ui/consts/const-eval/heap/ptr_made_global_mutated.stderr +++ b/tests/ui/consts/const-eval/heap/ptr_made_global_mutated.stderr @@ -1,4 +1,4 @@ -error[E0080]: writing to ALLOC0 which is read-only +error[E0080]: writing to ALLOC$ID which is read-only --> $DIR/ptr_made_global_mutated.rs:10:5 | LL | *(ptr as *mut u8) = 2; diff --git a/tests/ui/consts/const-eval/issue-49296.stderr b/tests/ui/consts/const-eval/issue-49296.stderr index 9da3e3d6d30b1..64e892e61af47 100644 --- a/tests/ui/consts/const-eval/issue-49296.stderr +++ b/tests/ui/consts/const-eval/issue-49296.stderr @@ -1,4 +1,4 @@ -error[E0080]: memory access failed: ALLOC0 has been freed, so this pointer is dangling +error[E0080]: memory access failed: ALLOC$ID has been freed, so this pointer is dangling --> $DIR/issue-49296.rs:9:16 | LL | const X: u64 = *wat(42); diff --git a/tests/ui/consts/const-eval/ptr_fragments_mixed.stderr b/tests/ui/consts/const-eval/ptr_fragments_mixed.stderr index 608f09d24bf42..a9be41f10d410 100644 --- a/tests/ui/consts/const-eval/ptr_fragments_mixed.stderr +++ b/tests/ui/consts/const-eval/ptr_fragments_mixed.stderr @@ -1,4 +1,4 @@ -error[E0080]: unable to read parts of a pointer from memory at ALLOC0 +error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID --> $DIR/ptr_fragments_mixed.rs:19:9 | LL | y @@ -7,7 +7,7 @@ LL | y = 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]: unable to read parts of a pointer from memory at ALLOC1 +error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID --> $DIR/ptr_fragments_mixed.rs:33:9 | LL | y diff --git a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr index 07deb955d24e7..b74aee7980aa4 100644 --- a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr @@ -1,5 +1,5 @@ error[E0080]: constructing invalid value of type Enum: at ., encountered 0x0000000000000001, but expected a valid enum tag - --> $DIR/raw-bytes.rs:24:1 + --> $DIR/raw-bytes.rs:23:1 | LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -10,7 +10,7 @@ LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; } error[E0080]: constructing invalid value of type Enum2: at ., encountered 0x0000000000000000, but expected a valid enum tag - --> $DIR/raw-bytes.rs:32:1 + --> $DIR/raw-bytes.rs:31:1 | LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -21,7 +21,7 @@ LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; } error[E0080]: constructing invalid value of type UninhDiscriminant: at ., encountered an uninhabited enum variant - --> $DIR/raw-bytes.rs:46:1 + --> $DIR/raw-bytes.rs:45:1 | LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -32,7 +32,7 @@ LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute } error[E0080]: constructing invalid value of type UninhDiscriminant: at ., encountered 0x03, but expected a valid enum tag - --> $DIR/raw-bytes.rs:48:1 + --> $DIR/raw-bytes.rs:47:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -43,7 +43,7 @@ LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute } error[E0080]: constructing invalid value of type Option<(char, char)>: at ..0.1, encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) - --> $DIR/raw-bytes.rs:54:1 + --> $DIR/raw-bytes.rs:53:1 | LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -54,7 +54,7 @@ LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::tran } error[E0080]: constructing invalid value of type NonNull: at .pointer, encountered 0, but expected something greater or equal to 1 - --> $DIR/raw-bytes.rs:59:1 + --> $DIR/raw-bytes.rs:58:1 | LL | const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -65,7 +65,7 @@ LL | const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; } error[E0080]: constructing invalid value of type NonZero: at .0.0, encountered 0, but expected something greater or equal to 1 - --> $DIR/raw-bytes.rs:62:1 + --> $DIR/raw-bytes.rs:61:1 | LL | const NULL_U8: NonZero = unsafe { mem::transmute(0u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -76,7 +76,7 @@ LL | const NULL_U8: NonZero = unsafe { mem::transmute(0u8) }; } error[E0080]: constructing invalid value of type NonZero: at .0.0, encountered 0, but expected something greater or equal to 1 - --> $DIR/raw-bytes.rs:64:1 + --> $DIR/raw-bytes.rs:63:1 | LL | const NULL_USIZE: NonZero = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -87,7 +87,7 @@ LL | const NULL_USIZE: NonZero = unsafe { mem::transmute(0usize) }; } error[E0080]: constructing invalid value of type RestrictedRange1: at .0, encountered 42, but expected something in the range 10..=30 - --> $DIR/raw-bytes.rs:68:1 + --> $DIR/raw-bytes.rs:67:1 | LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(mem::transmute(42_u32)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -98,7 +98,7 @@ LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(mem::transmu } error[E0080]: constructing invalid value of type RestrictedRange2: at .0, encountered 20, but expected something less or equal to 10, or greater or equal to 30 - --> $DIR/raw-bytes.rs:72:1 + --> $DIR/raw-bytes.rs:71:1 | LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(mem::transmute(20_i32)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -109,40 +109,40 @@ LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(mem::transmu } error[E0080]: constructing invalid value of type NonNull: at .pointer, encountered 0, but expected something greater or equal to 1 - --> $DIR/raw-bytes.rs:75:1 + --> $DIR/raw-bytes.rs:74:1 | LL | const NULL_FAT_PTR: NonNull = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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╼ │ ........╾──────╼ + 00 00 00 00 00 00 00 00 ╾ALLOC$ID╼ │ ........╾──────╼ } error[E0080]: constructing invalid value of type &u16: encountered an unaligned reference (required 2 byte alignment but found 1) - --> $DIR/raw-bytes.rs:82:1 + --> $DIR/raw-bytes.rs:81:1 | LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; | ^^^^^^^^^^^^^^^^^^^^^ 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╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾──────╼ } error[E0080]: constructing invalid value of type Box: encountered an unaligned box (required 2 byte alignment but found 1) - --> $DIR/raw-bytes.rs:85:1 + --> $DIR/raw-bytes.rs:84:1 | LL | const UNALIGNED_BOX: Box = unsafe { mem::transmute(&[0u8; 4]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾──────╼ } error[E0080]: constructing invalid value of type &u16: encountered a null reference - --> $DIR/raw-bytes.rs:88:1 + --> $DIR/raw-bytes.rs:87:1 | LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -153,7 +153,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; } error[E0080]: constructing invalid value of type Box: encountered a null box - --> $DIR/raw-bytes.rs:91:1 + --> $DIR/raw-bytes.rs:90:1 | LL | const NULL_BOX: Box = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -164,7 +164,7 @@ LL | const NULL_BOX: Box = unsafe { mem::transmute(0usize) }; } error[E0080]: constructing invalid value of type &u8: encountered a dangling reference (0x539[noalloc] has no provenance) - --> $DIR/raw-bytes.rs:94:1 + --> $DIR/raw-bytes.rs:93:1 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -175,7 +175,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; } error[E0080]: constructing invalid value of type Box: encountered a dangling box (0x539[noalloc] has no provenance) - --> $DIR/raw-bytes.rs:97:1 + --> $DIR/raw-bytes.rs:96:1 | LL | const USIZE_AS_BOX: Box = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -186,7 +186,7 @@ LL | const USIZE_AS_BOX: Box = unsafe { mem::transmute(1337usize) }; } error[E0080]: constructing invalid value of type fn(): encountered null pointer, but expected a function pointer - --> $DIR/raw-bytes.rs:100:1 + --> $DIR/raw-bytes.rs:99:1 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -197,7 +197,7 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; } error[E0080]: constructing invalid value of type fn(): encountered 0xd[noalloc], but expected a function pointer - --> $DIR/raw-bytes.rs:102:1 + --> $DIR/raw-bytes.rs:101:1 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -207,19 +207,19 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; 0d 00 00 00 00 00 00 00 │ ........ } -error[E0080]: constructing invalid value of type fn(): encountered ALLOC3, but expected a function pointer - --> $DIR/raw-bytes.rs:104:1 +error[E0080]: constructing invalid value of type fn(): encountered ALLOC$ID, but expected a function pointer + --> $DIR/raw-bytes.rs:103:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; | ^^^^^^^^^^^^^^^^^^^^^^^ 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╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾──────╼ } error[E0080]: constructing invalid value of type &Bar: encountered a reference pointing to uninhabited type Bar - --> $DIR/raw-bytes.rs:110:1 + --> $DIR/raw-bytes.rs:109:1 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -230,62 +230,62 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; } error[E0080]: constructing invalid value of type &str: encountered a dangling reference (going beyond the bounds of its allocation) - --> $DIR/raw-bytes.rs:134:1 + --> $DIR/raw-bytes.rs:133:1 | LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──────╼........ + ╾ALLOC$ID╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........ } error[E0080]: constructing invalid value of type (&str,): at .0, encountered invalid reference metadata: slice is bigger than largest supported object - --> $DIR/raw-bytes.rs:136:1 + --> $DIR/raw-bytes.rs:135:1 | LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──────╼........ + ╾ALLOC$ID╼ ff ff ff ff ff ff ff ff │ ╾──────╼........ } error[E0080]: constructing invalid value of type &MyStr: encountered invalid reference metadata: slice is bigger than largest supported object - --> $DIR/raw-bytes.rs:138:1 + --> $DIR/raw-bytes.rs:137:1 | LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──────╼........ + ╾ALLOC$ID╼ ff ff ff ff ff ff ff ff │ ╾──────╼........ } error[E0080]: constructing invalid value of type &str: at ., encountered uninitialized memory, but expected a string - --> $DIR/raw-bytes.rs:141:1 + --> $DIR/raw-bytes.rs:140:1 | LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──────╼........ + ╾ALLOC$ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } error[E0080]: constructing invalid value of type &MyStr: at ..0, encountered uninitialized memory, but expected a string - --> $DIR/raw-bytes.rs:143:1 + --> $DIR/raw-bytes.rs:142:1 | LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──────╼........ + ╾ALLOC$ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } error[E0080]: constructing invalid value of type &MyStr: at ..0, encountered a pointer, but expected a string - --> $DIR/raw-bytes.rs:145:1 + --> $DIR/raw-bytes.rs:144:1 | LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -294,172 +294,172 @@ LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _> = 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 │ ╾──────╼........ + ╾ALLOC$ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } error[E0080]: constructing invalid value of type &[u8]: encountered a dangling reference (going beyond the bounds of its allocation) - --> $DIR/raw-bytes.rs:149:1 + --> $DIR/raw-bytes.rs:148:1 | LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──────╼........ + ╾ALLOC$ID╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........ } error[E0080]: constructing invalid value of type &[u32]: encountered invalid reference metadata: slice is bigger than largest supported object - --> $DIR/raw-bytes.rs:151:1 + --> $DIR/raw-bytes.rs:150:1 | LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──────╼........ + ╾ALLOC$ID╼ ff ff ff ff ff ff ff 7f │ ╾──────╼........ } error[E0080]: constructing invalid value of type Box<[u8]>: encountered a dangling box (going beyond the bounds of its allocation) - --> $DIR/raw-bytes.rs:154:1 + --> $DIR/raw-bytes.rs:153:1 | LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──────╼........ + ╾ALLOC$ID╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........ } error[E0080]: constructing invalid value of type &[bool; 1]: at .[0], encountered 0x03, but expected a boolean - --> $DIR/raw-bytes.rs:157:1 + --> $DIR/raw-bytes.rs:156:1 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾──────╼ } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:157:40 + --> $DIR/raw-bytes.rs:156:40 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: constructing invalid value of type &MySlice<[bool; 1]>: at ..0, encountered 0x03, but expected a boolean - --> $DIR/raw-bytes.rs:161:1 + --> $DIR/raw-bytes.rs:160:1 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾──────╼ } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:161:42 + --> $DIR/raw-bytes.rs:160:42 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: constructing invalid value of type &MySlice<[bool; 1]>: at ..1[0], encountered 0x03, but expected a boolean - --> $DIR/raw-bytes.rs:164:1 + --> $DIR/raw-bytes.rs:163:1 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾──────╼ } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:164:42 + --> $DIR/raw-bytes.rs:163:42 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC17, but expected a vtable pointer - --> $DIR/raw-bytes.rs:168:1 +error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID, but expected a vtable pointer + --> $DIR/raw-bytes.rs:167:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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╼ │ ╾──────╼╾──────╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ } -error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC19, but expected a vtable pointer - --> $DIR/raw-bytes.rs:171:1 +error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID, but expected a vtable pointer + --> $DIR/raw-bytes.rs:170:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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╼ │ ╾──────╼╾──────╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ } error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered 0x4[noalloc], but expected a vtable pointer - --> $DIR/raw-bytes.rs:174:1 + --> $DIR/raw-bytes.rs:173:1 | LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──────╼........ + ╾ALLOC$ID╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC22, but expected a vtable pointer - --> $DIR/raw-bytes.rs:176:1 +error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID, but expected a vtable pointer + --> $DIR/raw-bytes.rs:175:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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╼ │ ╾──────╼╾──────╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ } error[E0080]: constructing invalid value of type &dyn Trait: at .., encountered 0x03, but expected a boolean - --> $DIR/raw-bytes.rs:179:1 + --> $DIR/raw-bytes.rs:178:1 | LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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╼ │ ╾──────╼╾──────╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ } error[E0080]: constructing invalid value of type *const dyn Trait: encountered null pointer, but expected a vtable pointer - --> $DIR/raw-bytes.rs:182:1 + --> $DIR/raw-bytes.rs:181:1 | LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──────╼........ + ╾ALLOC$ID╼ 00 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: constructing invalid value of type *const dyn Trait: encountered ALLOC27, but expected a vtable pointer - --> $DIR/raw-bytes.rs:184:1 +error[E0080]: constructing invalid value of type *const dyn Trait: encountered ALLOC$ID, but expected a vtable pointer + --> $DIR/raw-bytes.rs:183:1 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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╼ │ ╾──────╼╾──────╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ } error[E0080]: constructing invalid value of type &[!; 1]: encountered a reference pointing to uninhabited type [!; 1] - --> $DIR/raw-bytes.rs:188:1 + --> $DIR/raw-bytes.rs:187:1 | LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -470,7 +470,7 @@ LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; } error[E0080]: constructing invalid value of type &[!]: at .[0], encountered a value of the never type `!` - --> $DIR/raw-bytes.rs:189:1 + --> $DIR/raw-bytes.rs:188:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; | ^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -481,7 +481,7 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; } error[E0080]: constructing invalid value of type &[!]: at .[0], encountered a value of the never type `!` - --> $DIR/raw-bytes.rs:190:1 + --> $DIR/raw-bytes.rs:189:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; | ^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -492,18 +492,18 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; } error[E0080]: constructing invalid value of type &[u8]: at .[0], encountered uninitialized memory, but expected an integer - --> $DIR/raw-bytes.rs:193:1 + --> $DIR/raw-bytes.rs:192:1 | LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 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) { - ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ + ╾ALLOC$ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } error[E0080]: constructing invalid value of type &[u8]: at .[0], encountered a pointer, but expected an integer - --> $DIR/raw-bytes.rs:196:1 + --> $DIR/raw-bytes.rs:195:1 | LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) }; | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -512,44 +512,44 @@ LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem: = 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 │ ╾──────╼........ + ╾ALLOC$ID╼ 08 00 00 00 00 00 00 00 │ ╾──────╼........ } error[E0080]: constructing invalid value of type &[bool]: at .[0], encountered 0x11, but expected a boolean - --> $DIR/raw-bytes.rs:199:1 + --> $DIR/raw-bytes.rs:198:1 | LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; | ^^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──────╼........ + ╾ALLOC$ID╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ } error[E0080]: constructing invalid value of type &[u16]: at .[1], encountered uninitialized memory, but expected an integer - --> $DIR/raw-bytes.rs:203:1 + --> $DIR/raw-bytes.rs:202:1 | LL | pub static S7: &[u16] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──────╼........ + ╾ALLOC$ID╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ } error[E0080]: constructing invalid value of type &[u8]: at .[0], encountered uninitialized memory, but expected an integer - --> $DIR/raw-bytes.rs:210:1 + --> $DIR/raw-bytes.rs:209:1 | LL | pub static R4: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──────╼........ + ╾ALLOC$ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } error[E0080]: constructing invalid value of type &[u8]: at .[0], encountered a pointer, but expected an integer - --> $DIR/raw-bytes.rs:215:1 + --> $DIR/raw-bytes.rs:214:1 | LL | pub static R5: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -558,18 +558,18 @@ LL | pub static R5: &[u8] = unsafe { = 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 │ ╾──────╼........ + ╾ALLOC$ID╼ 08 00 00 00 00 00 00 00 │ ╾──────╼........ } error[E0080]: constructing invalid value of type &[bool]: at .[0], encountered 0x11, but expected a boolean - --> $DIR/raw-bytes.rs:220:1 + --> $DIR/raw-bytes.rs:219:1 | LL | pub static R6: &[bool] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──────╼........ + ╾ALLOC$ID╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ } error: aborting due to 50 previous errors diff --git a/tests/ui/consts/const-eval/raw-pointer-ub.stderr b/tests/ui/consts/const-eval/raw-pointer-ub.stderr index 00af20a722dae..5769f46022ff1 100644 --- a/tests/ui/consts/const-eval/raw-pointer-ub.stderr +++ b/tests/ui/consts/const-eval/raw-pointer-ub.stderr @@ -25,7 +25,7 @@ error[E0080]: accessing memory based on pointer with alignment 4, but alignment LL | let _val = (*ptr).0; | ^^^^^^^^ evaluation of `MISALIGNED_FIELD` failed here -error[E0080]: memory access failed: attempting to access 8 bytes, but got ALLOC0 which is only 4 bytes from the end of the allocation +error[E0080]: memory access failed: attempting to access 8 bytes, but got ALLOC$ID which is only 4 bytes from the end of the allocation --> $DIR/raw-pointer-ub.rs:40:16 | LL | let _val = *ptr; diff --git a/tests/ui/consts/const-eval/read_partial_ptr.stderr b/tests/ui/consts/const-eval/read_partial_ptr.stderr index 196606c77a37f..c2d220b2e1e21 100644 --- a/tests/ui/consts/const-eval/read_partial_ptr.stderr +++ b/tests/ui/consts/const-eval/read_partial_ptr.stderr @@ -1,4 +1,4 @@ -error[E0080]: unable to read parts of a pointer from memory at ALLOC0 +error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID --> $DIR/read_partial_ptr.rs:10:13 | LL | let x = *p; @@ -7,7 +7,7 @@ LL | let x = *p; = 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]: unable to read parts of a pointer from memory at ALLOC1 +error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID --> $DIR/read_partial_ptr.rs:23:13 | LL | let x = *p; @@ -16,7 +16,7 @@ LL | let x = *p; = 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]: unable to read parts of a pointer from memory at ALLOC2 +error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID --> $DIR/read_partial_ptr.rs:34:13 | LL | let x = *p; @@ -25,7 +25,7 @@ LL | let x = *p; = 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]: unable to read parts of a pointer from memory at ALLOC3 +error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID --> $DIR/read_partial_ptr.rs:46:13 | LL | let x = *p; diff --git a/tests/ui/consts/const-eval/ub-enum-overwrite.stderr b/tests/ui/consts/const-eval/ub-enum-overwrite.stderr index 2fd01b67c4928..bda771bd38e88 100644 --- a/tests/ui/consts/const-eval/ub-enum-overwrite.stderr +++ b/tests/ui/consts/const-eval/ub-enum-overwrite.stderr @@ -1,4 +1,4 @@ -error[E0080]: reading memory at ALLOC0[0x1..0x2], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x1..0x2], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory --> $DIR/ub-enum-overwrite.rs:11:14 | LL | unsafe { *p } diff --git a/tests/ui/consts/const-eval/ub-enum.stderr b/tests/ui/consts/const-eval/ub-enum.stderr index bb2c58796b1c4..2fbc115fe4f6e 100644 --- a/tests/ui/consts/const-eval/ub-enum.stderr +++ b/tests/ui/consts/const-eval/ub-enum.stderr @@ -56,7 +56,7 @@ LL | const BAD_ENUM2_WRAPPED: Wrap = unsafe { mem::transmute(&0) }; = 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]: reading memory at ALLOC0[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory --> $DIR/ub-enum.rs:62:41 | LL | const BAD_ENUM2_UNDEF: Enum2 = unsafe { MaybeUninit { uninit: () }.init }; 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 4c8a1802317b2..bc26c93513964 100644 --- a/tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr +++ b/tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr @@ -1,4 +1,4 @@ -error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC1, but expected a vtable pointer +error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC$ID, but expected a vtable pointer --> $DIR/ub-incorrect-vtable.rs:18:1 | LL | const INVALID_VTABLE_ALIGNMENT: &dyn Trait = @@ -6,10 +6,10 @@ LL | const INVALID_VTABLE_ALIGNMENT: &dyn Trait = | = 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╼ │ ╾──────╼╾──────╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ } -error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC3, but expected a vtable pointer +error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC$ID, but expected a vtable pointer --> $DIR/ub-incorrect-vtable.rs:22:1 | LL | const INVALID_VTABLE_SIZE: &dyn Trait = @@ -17,10 +17,10 @@ LL | const INVALID_VTABLE_SIZE: &dyn Trait = | = 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╼ │ ╾──────╼╾──────╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ } -error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC5, but expected a vtable pointer +error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID, but expected a vtable pointer --> $DIR/ub-incorrect-vtable.rs:31:1 | LL | const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> = @@ -28,10 +28,10 @@ LL | const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> = | = 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╼ │ ╾──────╼╾──────╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ } -error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC7, but expected a vtable pointer +error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID, but expected a vtable pointer --> $DIR/ub-incorrect-vtable.rs:35:1 | LL | const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> = @@ -39,10 +39,10 @@ LL | const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> = | = 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╼ │ ╾──────╼╾──────╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ } -error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC9, but expected a vtable pointer +error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID, but expected a vtable pointer --> $DIR/ub-incorrect-vtable.rs:40:1 | LL | const INVALID_VTABLE_UB: W<&dyn Trait> = @@ -50,7 +50,7 @@ LL | const INVALID_VTABLE_UB: W<&dyn Trait> = | = 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╼ │ ╾──────╼╾──────╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ } error[E0080]: constructing invalid value of type Wide<'_>: at .1, encountered a dangling reference (going beyond the bounds of its allocation) @@ -61,7 +61,7 @@ LL | const G: Wide = unsafe { Transmute { t: FOO }.u }; | = 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) { - ╾ALLOC10╼ ╾ALLOC11╼ │ ╾──────╼╾──────╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ } error: aborting due to 6 previous errors diff --git a/tests/ui/consts/const-eval/ub-nonnull.stderr b/tests/ui/consts/const-eval/ub-nonnull.stderr index 5bd23944ed5be..8eb9481af6306 100644 --- a/tests/ui/consts/const-eval/ub-nonnull.stderr +++ b/tests/ui/consts/const-eval/ub-nonnull.stderr @@ -9,7 +9,7 @@ LL | const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; HEX_DUMP } -error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 255 bytes, but got ALLOC2 which is only 1 byte from the end of the allocation +error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 255 bytes, but got ALLOC$ID which is only 1 byte from the end of the allocation --> $DIR/ub-nonnull.rs:22:29 | LL | let out_of_bounds_ptr = &ptr[255]; @@ -37,7 +37,7 @@ LL | const NULL_USIZE: NonZero = unsafe { mem::transmute(0usize) }; HEX_DUMP } -error[E0080]: reading memory at ALLOC3[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory --> $DIR/ub-nonnull.rs:36:38 | LL | const UNINIT: NonZero = unsafe { MaybeUninit { uninit: () }.init }; @@ -55,7 +55,7 @@ LL | const NULL_FAT_PTR: NonNull = unsafe { | = 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 + 00 00 00 00 00 00 00 00 ╾ALLOC$ID╼ │ ........╾──────╼ } error[E0080]: constructing invalid value of type NonNull<()>: at .pointer, encountered a maybe-null pointer, but expected something that is definitely non-zero @@ -66,7 +66,7 @@ LL | const MAYBE_NULL_PTR: NonNull<()> = unsafe { mem::transmute((&raw const S). | = 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 + ╾ALLOC$ID╼ │ ╾──────╼ } error: aborting due to 7 previous errors diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.stderr b/tests/ui/consts/const-eval/ub-ref-ptr.stderr index 1087d89f6389d..0dc586b36dec3 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-ref-ptr.stderr @@ -6,7 +6,7 @@ LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; | = 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 + ╾ALLOC$ID╼ │ ╾──────╼ } error[E0080]: constructing invalid value of type Box: encountered an unaligned box (required 2 byte alignment but found 1) @@ -17,7 +17,7 @@ LL | const UNALIGNED_BOX: Box = unsafe { mem::transmute(&[0u8; 4]) }; | = 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 + ╾ALLOC$ID╼ │ ╾──────╼ } error[E0080]: constructing invalid value of type &u16: encountered a null reference @@ -50,7 +50,7 @@ LL | const MAYBE_NULL_BOX: Box<()> = unsafe { mem::transmute({ | = 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 + ╾ALLOC$ID╼ │ ╾──────╼ } error[E0080]: unable to turn pointer into integer @@ -114,7 +114,7 @@ LL | const USIZE_AS_BOX: Box = unsafe { mem::transmute(1337usize) }; HEX_DUMP } -error[E0080]: reading memory at ALLOC5[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory --> $DIR/ub-ref-ptr.rs:54:41 | LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init }; @@ -135,7 +135,7 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; HEX_DUMP } -error[E0080]: reading memory at ALLOC6[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory --> $DIR/ub-ref-ptr.rs:59:38 | LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init }; @@ -156,7 +156,7 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; HEX_DUMP } -error[E0080]: constructing invalid value of type fn(): encountered ALLOC3, but expected a function pointer +error[E0080]: constructing invalid value of type fn(): encountered ALLOC$ID, but expected a function pointer --> $DIR/ub-ref-ptr.rs:63:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; @@ -164,10 +164,10 @@ LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; | = 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 + ╾ALLOC$ID╼ │ ╾──────╼ } -error[E0080]: constructing invalid value of type fn(): encountered ALLOC4+0xa, but expected a function pointer +error[E0080]: constructing invalid value of type fn(): encountered ALLOC$ID+0xa, but expected a function pointer --> $DIR/ub-ref-ptr.rs:65:1 | LL | const MAYBE_NULL_FN_PTR: fn() = unsafe { mem::transmute({ @@ -175,7 +175,7 @@ LL | const MAYBE_NULL_FN_PTR: fn() = unsafe { mem::transmute({ | = 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 + ╾ALLOC$ID╼ │ ╾──────╼ } error[E0080]: accessing memory based on pointer with alignment 1, but alignment 4 is required diff --git a/tests/ui/consts/const-eval/ub-upvars.64bit.stderr b/tests/ui/consts/const-eval/ub-upvars.64bit.stderr index c45ad7856e6ea..7ce7467d77441 100644 --- a/tests/ui/consts/const-eval/ub-upvars.64bit.stderr +++ b/tests/ui/consts/const-eval/ub-upvars.64bit.stderr @@ -6,7 +6,7 @@ LL | const BAD_UPVAR: &dyn FnOnce() = &{ | = 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╼ │ ╾──────╼╾──────╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ } error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/ub-wide-ptr.stderr b/tests/ui/consts/const-eval/ub-wide-ptr.stderr index 9603710e4fd8c..aa1741eb6a8e9 100644 --- a/tests/ui/consts/const-eval/ub-wide-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-wide-ptr.stderr @@ -6,7 +6,7 @@ LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; | = 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 + ╾ALLOC$ID╼ HEX_DUMP } error[E0080]: constructing invalid value of type (&str,): at .0, encountered invalid reference metadata: slice is bigger than largest supported object @@ -17,7 +17,7 @@ LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, us | = 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 + ╾ALLOC$ID╼ HEX_DUMP } error[E0080]: unable to turn pointer into integer @@ -46,7 +46,7 @@ LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize: | = 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 + ╾ALLOC$ID╼ HEX_DUMP } error[E0080]: constructing invalid value of type &str: at ., encountered uninitialized memory, but expected a string @@ -57,7 +57,7 @@ LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit: | = 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 + ╾ALLOC$ID╼ HEX_DUMP } error[E0080]: constructing invalid value of type &MyStr: at ..0, encountered uninitialized memory, but expected a string @@ -68,10 +68,10 @@ LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUni | = 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 + ╾ALLOC$ID╼ HEX_DUMP } -error[E0080]: reading memory at ALLOC32[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory --> $DIR/ub-wide-ptr.rs:64:1 | LL | const SLICE_LENGTH_UNINIT: &[u8] = unsafe { @@ -89,7 +89,7 @@ LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; | = 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 + ╾ALLOC$ID╼ HEX_DUMP } error[E0080]: constructing invalid value of type &[u32]: encountered invalid reference metadata: slice is bigger than largest supported object @@ -100,7 +100,7 @@ LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, is | = 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 + ╾ALLOC$ID╼ HEX_DUMP } error[E0080]: unable to turn pointer into integer @@ -120,7 +120,7 @@ LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999us | = 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 + ╾ALLOC$ID╼ HEX_DUMP } error[E0080]: unable to turn pointer into integer @@ -140,7 +140,7 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | = 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 + ╾ALLOC$ID╼ │ ╾──────╼ } note: erroneous constant encountered @@ -157,7 +157,7 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3 | = 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 + ╾ALLOC$ID╼ │ ╾──────╼ } note: erroneous constant encountered @@ -174,7 +174,7 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran | = 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 + ╾ALLOC$ID╼ │ ╾──────╼ } note: erroneous constant encountered @@ -183,7 +183,7 @@ note: erroneous constant encountered LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: reading memory at ALLOC33[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory --> $DIR/ub-wide-ptr.rs:102:1 | LL | const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe { @@ -193,7 +193,7 @@ LL | const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe { HEX_DUMP } -error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC12, but expected a vtable pointer +error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID, but expected a vtable pointer --> $DIR/ub-wide-ptr.rs:110:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; @@ -201,10 +201,10 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W(( | = 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 + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ } -error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC14, but expected a vtable pointer +error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID, but expected a vtable pointer --> $DIR/ub-wide-ptr.rs:113:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; @@ -212,7 +212,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W(( | = 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 + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ } error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered 0x4[noalloc], but expected a vtable pointer @@ -223,10 +223,10 @@ LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u | = 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 + ╾ALLOC$ID╼ HEX_DUMP } -error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC17, but expected a vtable pointer +error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC$ID, but expected a vtable pointer --> $DIR/ub-wide-ptr.rs:118:1 | LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) }; @@ -234,10 +234,10 @@ LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92 | = 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 + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ } -error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC19, but expected a vtable pointer +error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC$ID, but expected a vtable pointer --> $DIR/ub-wide-ptr.rs:120:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) }; @@ -245,10 +245,10 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92 | = 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 + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ } -error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC21, but expected a vtable pointer +error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC$ID, but expected a vtable pointer --> $DIR/ub-wide-ptr.rs:122:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) }; @@ -256,10 +256,10 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u | = 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 + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ } -error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC23, but expected a vtable pointer +error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID, but expected a vtable pointer --> $DIR/ub-wide-ptr.rs:124:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; @@ -267,7 +267,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::trans | = 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 + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ } error[E0080]: constructing invalid value of type &dyn Trait: at .., encountered 0x03, but expected a boolean @@ -278,7 +278,7 @@ LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, | = 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 + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ } error[E0080]: constructing invalid value of type *const dyn Trait: encountered null pointer, but expected a vtable pointer @@ -289,10 +289,10 @@ LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute | = 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 + ╾ALLOC$ID╼ HEX_DUMP } -error[E0080]: constructing invalid value of type *const dyn Trait: encountered ALLOC28, but expected a vtable pointer +error[E0080]: constructing invalid value of type *const dyn Trait: encountered ALLOC$ID, but expected a vtable pointer --> $DIR/ub-wide-ptr.rs:134:1 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; @@ -300,7 +300,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transm | = 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 + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ } error[E0080]: constructing invalid value of type *const dyn Trait: encountered null pointer, but expected a vtable pointer @@ -311,10 +311,10 @@ LL | static mut RAW_TRAIT_OBJ_VTABLE_NULL_THROUGH_REF: *const dyn Trait = unsafe | = 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 + ╾ALLOC$ID╼ HEX_DUMP } -error[E0080]: constructing invalid value of type *const dyn Trait: encountered ALLOC31, but expected a vtable pointer +error[E0080]: constructing invalid value of type *const dyn Trait: encountered ALLOC$ID, but expected a vtable pointer --> $DIR/ub-wide-ptr.rs:145:1 | LL | static mut RAW_TRAIT_OBJ_VTABLE_INVALID_THROUGH_REF: *const dyn Trait = unsafe { @@ -322,7 +322,7 @@ LL | static mut RAW_TRAIT_OBJ_VTABLE_INVALID_THROUGH_REF: *const dyn Trait = uns | = 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 + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ } error: aborting due to 29 previous errors 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 3b7e5508d56c4..e86e1fa22a7e5 100644 --- a/tests/ui/consts/const-eval/union-const-eval-field.stderr +++ b/tests/ui/consts/const-eval/union-const-eval-field.stderr @@ -1,4 +1,4 @@ -error[E0080]: reading memory at ALLOC0[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory --> $DIR/union-const-eval-field.rs:30:37 | LL | const FIELD3: Field3 = unsafe { UNION.field3 }; diff --git a/tests/ui/consts/const-eval/union-ice.stderr b/tests/ui/consts/const-eval/union-ice.stderr index 0506be63ea6f1..6a4927e42d240 100644 --- a/tests/ui/consts/const-eval/union-ice.stderr +++ b/tests/ui/consts/const-eval/union-ice.stderr @@ -1,4 +1,4 @@ -error[E0080]: reading memory at ALLOC0[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory --> $DIR/union-ice.rs:14:33 | LL | const FIELD3: Field3 = unsafe { UNION.field3 }; @@ -8,7 +8,7 @@ LL | const FIELD3: Field3 = unsafe { UNION.field3 }; 00 00 80 3f __ __ __ __ │ ...?░░░░ } -error[E0080]: reading memory at ALLOC1[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory --> $DIR/union-ice.rs:19:17 | LL | b: unsafe { UNION.field3 }, @@ -18,7 +18,7 @@ LL | b: unsafe { UNION.field3 }, 00 00 80 3f __ __ __ __ │ ...?░░░░ } -error[E0080]: reading memory at ALLOC2[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory --> $DIR/union-ice.rs:31:18 | LL | unsafe { UNION.field3 }, diff --git a/tests/ui/consts/const-eval/union-ub.64bit.stderr b/tests/ui/consts/const-eval/union-ub.64bit.stderr index 95960d1c77dc7..071a6ae99183f 100644 --- a/tests/ui/consts/const-eval/union-ub.64bit.stderr +++ b/tests/ui/consts/const-eval/union-ub.64bit.stderr @@ -9,7 +9,7 @@ LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool }; 2a │ * } -error[E0080]: reading memory at ALLOC0[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory --> $DIR/union-ub.rs:35:36 | LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool }; 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 9b289f4306b8f..bc9048e78cdb4 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 @@ -36,7 +36,7 @@ LL | const IMMUT_MUT_REF: &mut u16 = unsafe { mem::transmute(&13) }; | = 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 + ╾ALLOC$ID╼ │ ╾──────╼ } error[E0080]: constructing invalid value of type &mut u16: encountered mutable reference or box pointing to read-only memory @@ -47,7 +47,7 @@ LL | static IMMUT_MUT_REF_STATIC: &mut u16 = unsafe { mem::transmute(&13) }; | = 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 + ╾ALLOC$ID╼ │ ╾──────╼ } error[E0716]: temporary value dropped while borrowed @@ -150,7 +150,7 @@ LL | const DANGLING: Option<&mut i32> = helper_dangling(); | = 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 + ╾ALLOC$ID╼ │ ╾──────╼ } error[E0080]: constructing invalid value of type Option<&mut i32>: at ..0, encountered a dangling reference (use-after-free) @@ -161,7 +161,7 @@ LL | static DANGLING_STATIC: Option<&mut i32> = helper_dangling(); | = 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 + ╾ALLOC$ID╼ │ ╾──────╼ } error: aborting due to 16 previous errors 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 b0150fc596669..c355b6efb062f 100644 --- a/tests/ui/consts/const_refs_to_static_fail_invalid.stderr +++ b/tests/ui/consts/const_refs_to_static_fail_invalid.stderr @@ -6,7 +6,7 @@ LL | const C: &bool = unsafe { std::mem::transmute(&S) }; | = 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 + ╾ALLOC$ID╼ │ ╾──────╼ } error: constant extern_::C cannot be used as pattern diff --git a/tests/ui/consts/const_transmute_type_id7.stderr b/tests/ui/consts/const_transmute_type_id7.stderr index a1c37f2b36feb..f4787208f9183 100644 --- a/tests/ui/consts/const_transmute_type_id7.stderr +++ b/tests/ui/consts/const_transmute_type_id7.stderr @@ -6,7 +6,7 @@ LL | const A: [&(); 16 / size_of::<*const ()>()] = unsafe { transmute(TypeId::of | = 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 + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ } error: aborting due to 1 previous error diff --git a/tests/ui/consts/copy-intrinsic.stderr b/tests/ui/consts/copy-intrinsic.stderr index 41cf7e513572b..4c56304e4c157 100644 --- a/tests/ui/consts/copy-intrinsic.stderr +++ b/tests/ui/consts/copy-intrinsic.stderr @@ -4,7 +4,7 @@ error[E0080]: memory access failed: attempting to access 4 bytes, but got 0x100[ LL | copy_nonoverlapping(0x100 as *const i32, dangle, 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `COPY_OOB_1` failed here -error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0+0x28 which is at or beyond the end of the allocation of size 4 bytes +error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID+0x28 which is at or beyond the end of the allocation of size 4 bytes --> $DIR/copy-intrinsic.rs:28:5 | LL | copy_nonoverlapping(dangle, 0x100 as *mut i32, 1); diff --git a/tests/ui/consts/dangling-alloc-id-ice.stderr b/tests/ui/consts/dangling-alloc-id-ice.stderr index 5b92bef890acb..729f70092db89 100644 --- a/tests/ui/consts/dangling-alloc-id-ice.stderr +++ b/tests/ui/consts/dangling-alloc-id-ice.stderr @@ -6,7 +6,7 @@ LL | const FOO: &() = { | = 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 + ╾ALLOC$ID╼ │ ╾──────╼ } error: aborting due to 1 previous error diff --git a/tests/ui/consts/dangling-zst-ice-issue-126393.stderr b/tests/ui/consts/dangling-zst-ice-issue-126393.stderr index 0824afd862ad2..0287313415b4c 100644 --- a/tests/ui/consts/dangling-zst-ice-issue-126393.stderr +++ b/tests/ui/consts/dangling-zst-ice-issue-126393.stderr @@ -6,7 +6,7 @@ LL | pub static MAGIC_FFI_REF: &'static Wrapper = unsafe { | = 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 + ╾ALLOC$ID╼ │ ╾──────╼ } error: aborting due to 1 previous error 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 f2301560faae7..5f0ec6aa2b959 100644 --- a/tests/ui/consts/interior-mut-const-via-union.64bit.stderr +++ b/tests/ui/consts/interior-mut-const-via-union.64bit.stderr @@ -6,7 +6,7 @@ LL | fn main() { | = 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╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾──────╼ } note: erroneous constant encountered diff --git a/tests/ui/consts/issue-63952.64bit.stderr b/tests/ui/consts/issue-63952.64bit.stderr index da1d05eb5dc55..4ce50ec0da4dc 100644 --- a/tests/ui/consts/issue-63952.64bit.stderr +++ b/tests/ui/consts/issue-63952.64bit.stderr @@ -6,7 +6,7 @@ LL | const SLICE_WAY_TOO_LONG: &[u8] = unsafe { | = 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╼ ff ff ff ff ff ff ff ff │ ╾──────╼........ + ╾ALLOC$ID╼ ff ff ff ff ff ff ff ff │ ╾──────╼........ } 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 c3f89d243335e..4e3df27f470a3 100644 --- a/tests/ui/consts/issue-79690.64bit.stderr +++ b/tests/ui/consts/issue-79690.64bit.stderr @@ -6,7 +6,7 @@ LL | const G: Fat = unsafe { Transmute { t: FOO }.u }; | = 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╼ │ ╾──────╼╾──────╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ } error: aborting due to 1 previous error diff --git a/tests/ui/consts/miri_unleashed/mutable_references.stderr b/tests/ui/consts/miri_unleashed/mutable_references.stderr index 68c6dd1ed6004..2f37f7861843c 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references.stderr +++ b/tests/ui/consts/miri_unleashed/mutable_references.stderr @@ -6,7 +6,7 @@ LL | static FOO: &&mut u32 = &&mut 42; | = 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 + ╾ALLOC$ID╼ │ ╾──────╼ } error[E0080]: constructing invalid value of type &mut i32: encountered mutable reference or box pointing to read-only memory @@ -17,7 +17,7 @@ LL | static OH_YES: &mut i32 = &mut 42; | = 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 + ╾ALLOC$ID╼ │ ╾──────╼ } error: encountered mutable pointer in final value of static @@ -40,7 +40,7 @@ LL | const BLUNT: &mut i32 = &mut 42; | = 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 + ╾ALLOC$ID╼ │ ╾──────╼ } error[E0080]: constructing invalid value of type Meh: at .x., encountered `UnsafeCell` in read-only memory @@ -51,7 +51,7 @@ LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) }; | = 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 + ╾ALLOC$ID╼ │ ╾──────╼ } error[E0080]: constructing invalid value of type Meh: at .x., encountered `UnsafeCell` in read-only memory @@ -62,7 +62,7 @@ LL | const MUH: Meh = Meh { | = 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 + ╾ALLOC$ID╼ │ ╾──────╼ } error[E0080]: constructing invalid value of type &dyn Sync: at ...x, encountered `UnsafeCell` in read-only memory @@ -73,7 +73,7 @@ LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; | = 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 + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ } error[E0080]: constructing invalid value of type &mut i32: encountered mutable reference or box pointing to read-only memory @@ -84,7 +84,7 @@ LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const | = 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 + ╾ALLOC$ID╼ │ ╾──────╼ } error[E0080]: constant accesses mutable global memory 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 673c1b3c0b6e2..fa63b920be535 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 @@ -6,7 +6,7 @@ LL | static REF: &AtomicI32 = &AtomicI32::new(42); | = 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╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾──────╼ } error[E0080]: constructing invalid value of type &mut i32: encountered mutable reference or box pointing to read-only memory @@ -17,7 +17,7 @@ LL | static REFMUT: &mut i32 = &mut 0; | = 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╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾──────╼ } error[E0080]: constructing invalid value of type &Atomic: at ..v, encountered `UnsafeCell` in read-only memory @@ -28,7 +28,7 @@ LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}}; | = 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╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾──────╼ } error[E0080]: constructing invalid value of type &mut i32: encountered mutable reference or box pointing to read-only memory @@ -39,7 +39,7 @@ LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}}; | = 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) { - ╾ALLOC3╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾──────╼ } error: encountered mutable pointer in final value of static diff --git a/tests/ui/consts/missing_span_in_backtrace.stderr b/tests/ui/consts/missing_span_in_backtrace.stderr index b86911e7057b2..ccba98050e79a 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]: memory access failed: attempting to access 1 byte, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes +error[E0080]: memory access failed: attempting to access 1 byte, but got ALLOC$ID+0x4 which is at or beyond the end of the allocation of size 4 bytes --> $DIR/missing_span_in_backtrace.rs:16:9 | 16 | / ... ptr::swap_nonoverlapping( diff --git a/tests/ui/consts/offset_ub.stderr b/tests/ui/consts/offset_ub.stderr index f40d342758360..c3bfca27925a2 100644 --- a/tests/ui/consts/offset_ub.stderr +++ b/tests/ui/consts/offset_ub.stderr @@ -1,16 +1,16 @@ -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 +error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got ALLOC$ID 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) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BEFORE_START` failed here -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 +error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got ALLOC$ID 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) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `AFTER_END` failed here -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 +error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got ALLOC$ID 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) }; @@ -40,13 +40,13 @@ error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNDERFLOW_ADDRESS_SPACE` failed here -error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got ALLOC3-0x2 which points to before the beginning of the allocation +error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got ALLOC$ID-0x2 which points to before the beginning of the allocation --> $DIR/offset_ub.rs:16:49 | LL | ...nst u8 = unsafe { [0u8; 1].as_ptr().wrapping_offset(-2).offset(-2) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `NEGATIVE_OFFSET` failed here -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 +error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 1 byte, but got ALLOC$ID 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) }; diff --git a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr index 329da35297e1c..268527c0e5bf8 100644 --- a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr +++ b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr @@ -1,4 +1,4 @@ -error[E0080]: reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory --> $DIR/intrinsic-raw_eq-const-bad.rs:5:5 | LL | std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16)) diff --git a/tests/ui/statics/mutable_memory_validation.stderr b/tests/ui/statics/mutable_memory_validation.stderr index 297a965420340..30aa286808533 100644 --- a/tests/ui/statics/mutable_memory_validation.stderr +++ b/tests/ui/statics/mutable_memory_validation.stderr @@ -6,7 +6,7 @@ LL | const MUH: Meh = Meh { x: unsafe { &mut *(&READONLY as *const _ as *mut _) | = 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 + ╾ALLOC$ID╼ │ ╾──────╼ } error: aborting due to 1 previous error diff --git a/tests/ui/type/pattern_types/validity.stderr b/tests/ui/type/pattern_types/validity.stderr index a4fb46cf3ed05..a0941c9b718a6 100644 --- a/tests/ui/type/pattern_types/validity.stderr +++ b/tests/ui/type/pattern_types/validity.stderr @@ -9,7 +9,7 @@ LL | const BAD: pattern_type!(u32 is 1..) = unsafe { std::mem::transmute(0) }; HEX_DUMP } -error[E0080]: reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory --> $DIR/validity.rs:13:1 | LL | const BAD_UNINIT: pattern_type!(u32 is 1..) = @@ -50,7 +50,7 @@ LL | const BAD_FOO: Foo = Foo(Bar(unsafe { std::mem::transmute(0) })); HEX_DUMP } -error[E0080]: reading memory at ALLOC1[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory --> $DIR/validity.rs:29:1 | LL | const CHAR_UNINIT: pattern_type!(char is 'A'..'Z') = From 9803c28fc9b915699f9084795794fb6d77773793 Mon Sep 17 00:00:00 2001 From: heinwol Date: Tue, 9 Jun 2026 17:09:53 +0300 Subject: [PATCH 08/21] Rename several `//~ ERROR <...> ALLOC0` directives across other tests because they fail with our normalization strategy: `ALLOC0` -> `ALLOC$ID` --- tests/ui/const-generics/issues/issue-100313.rs | 2 +- tests/ui/consts/const-eval/c-variadic-fail.rs | 8 ++++---- tests/ui/consts/const-eval/heap/make-global-other.rs | 2 +- tests/ui/consts/const-eval/heap/make-global-twice.rs | 2 +- .../ui/consts/const-eval/heap/ptr_made_global_mutated.rs | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/ui/const-generics/issues/issue-100313.rs b/tests/ui/const-generics/issues/issue-100313.rs index 1f61356162ca6..6a70a9f81e925 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 writing to ALLOC0 which is read-only + x.set_false(); //~ ERROR writing to ALLOC$ID which is read-only }; fn main() {} diff --git a/tests/ui/consts/const-eval/c-variadic-fail.rs b/tests/ui/consts/const-eval/c-variadic-fail.rs index a57311fcb78ed..410fa273f98f8 100644 --- a/tests/ui/consts/const-eval/c-variadic-fail.rs +++ b/tests/ui/consts/const-eval/c-variadic-fail.rs @@ -138,7 +138,7 @@ fn use_after_free() { let ap = helper(1, 2, 3); let mut ap = std::mem::transmute::<_, VaList>(ap); ap.next_arg::(); - //~^ ERROR memory access failed: ALLOC0 has been freed, so this pointer is dangling [E0080] + //~^ ERROR memory access failed: ALLOC$ID has been freed, so this pointer is dangling [E0080] } }; } @@ -160,7 +160,7 @@ fn manual_copy_drop() { } const { unsafe { helper(1, 2, 3) } }; - //~^ ERROR using ALLOC0 as variable argument list pointer but it does not point to a variable argument list [E0080] + //~^ ERROR using ALLOC$ID as variable argument list pointer but it does not point to a variable argument list [E0080] } fn manual_copy_forget() { @@ -176,7 +176,7 @@ fn manual_copy_forget() { } const { unsafe { helper(1, 2, 3) } }; - //~^ ERROR using ALLOC0 as variable argument list pointer but it does not point to a variable argument list [E0080] + //~^ ERROR using ALLOC$ID as variable argument list pointer but it does not point to a variable argument list [E0080] } fn manual_copy_read() { @@ -189,7 +189,7 @@ fn manual_copy_read() { } const { unsafe { helper(1, 2, 3) } }; - //~^ ERROR using ALLOC0 as variable argument list pointer but it does not point to a variable argument list [E0080] + //~^ ERROR using ALLOC$ID as variable argument list pointer but it does not point to a variable argument list [E0080] } fn drop_of_invalid() { diff --git a/tests/ui/consts/const-eval/heap/make-global-other.rs b/tests/ui/consts/const-eval/heap/make-global-other.rs index 4e2a59de13edc..1a4ec29af1767 100644 --- a/tests/ui/consts/const-eval/heap/make-global-other.rs +++ b/tests/ui/consts/const-eval/heap/make-global-other.rs @@ -9,7 +9,7 @@ const X: &i32 = &0; const Y: &i32 = unsafe { &*(intrinsics::const_make_global(X as *const i32 as *mut u8) as *const i32) - //~^ error: pointer passed to `const_make_global` does not point to a heap allocation: ALLOC0 + //~^ error: pointer passed to `const_make_global` does not point to a heap allocation: ALLOC$ID }; fn main() {} diff --git a/tests/ui/consts/const-eval/heap/make-global-twice.rs b/tests/ui/consts/const-eval/heap/make-global-twice.rs index 0cd617cea3e6e..38769ef4d199a 100644 --- a/tests/ui/consts/const-eval/heap/make-global-twice.rs +++ b/tests/ui/consts/const-eval/heap/make-global-twice.rs @@ -11,7 +11,7 @@ const Y: &i32 = unsafe { *i = 20; intrinsics::const_make_global(ptr); intrinsics::const_make_global(ptr); - //~^ error: attempting to call `const_make_global` twice on the same allocation ALLOC0 + //~^ error: attempting to call `const_make_global` twice on the same allocation ALLOC$ID &*i }; diff --git a/tests/ui/consts/const-eval/heap/ptr_made_global_mutated.rs b/tests/ui/consts/const-eval/heap/ptr_made_global_mutated.rs index bea2a5949c261..77c12f3dbe0f9 100644 --- a/tests/ui/consts/const-eval/heap/ptr_made_global_mutated.rs +++ b/tests/ui/consts/const-eval/heap/ptr_made_global_mutated.rs @@ -8,7 +8,7 @@ const A: &u8 = unsafe { *ptr = 1; let ptr: *const u8 = intrinsics::const_make_global(ptr); *(ptr as *mut u8) = 2; - //~^ error: writing to ALLOC0 which is read-only + //~^ error: writing to ALLOC$ID which is read-only &*ptr }; From 2f749bdc65b91a74b2175839d43b3b68773504d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=9D=E5=80=89=E6=B0=B4=E5=B8=8C?= Date: Tue, 30 Jun 2026 12:31:28 +0800 Subject: [PATCH 09/21] Preserve MSVC import libs for empty cdylibs --- compiler/rustc_codegen_ssa/src/back/linker.rs | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index 9f981016c18af..8c20db5791774 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -1117,13 +1117,30 @@ impl<'a> Linker for MsvcLinker<'a> { } } - fn export_symbols( - &mut self, - _tmpdir: &Path, - _crate_type: CrateType, - _symbols: &[SymbolExport], - ) { + fn export_symbols(&mut self, tmpdir: &Path, crate_type: CrateType, _symbols: &[SymbolExport]) { // We already add /EXPORT arguments to the .drectve section of symbols.o. + // Keep passing an empty .def file: link.exe otherwise skips the import + // library for DLLs with no exports. + if crate_type == CrateType::Executable { + let should_export_executable_symbols = + self.sess.opts.unstable_opts.export_executable_symbols; + if !should_export_executable_symbols { + return; + } + } + + let path = tmpdir.join("lib.def"); + let res = try { + let mut f = File::create_buffered(&path)?; + writeln!(f, "LIBRARY")?; + writeln!(f, "EXPORTS")?; + }; + if let Err(error) = res { + self.sess.dcx().emit_fatal(errors::LibDefWriteFailure { error }); + } + let mut arg = OsString::from("/DEF:"); + arg.push(path); + self.link_arg(&arg); } fn windows_subsystem(&mut self, subsystem: WindowsSubsystemKind) { From d3e3e6781f8679ba045655e47438197a2afc4fb1 Mon Sep 17 00:00:00 2001 From: jyn Date: Thu, 25 Jun 2026 11:54:32 +0200 Subject: [PATCH 10/21] give a better error when `getrandom` fails --- library/std/src/sys/random/linux.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/std/src/sys/random/linux.rs b/library/std/src/sys/random/linux.rs index 9b6d16e196ac1..6a4e4f3e670db 100644 --- a/library/std/src/sys/random/linux.rs +++ b/library/std/src/sys/random/linux.rs @@ -123,7 +123,9 @@ fn getrandom(mut bytes: &mut [u8], insecure: bool) { GETRANDOM_AVAILABLE.store(false, Relaxed); break; } - _ => panic!("failed to generate random data"), + other => { + panic!("failed to generate random data: errno={other:?}, flags={flags:?}") + } } } } From 3886e7ff0d4bb5c8bfd95a657e98e56466dbbcc2 Mon Sep 17 00:00:00 2001 From: Rachel Barker Date: Thu, 25 Jun 2026 14:27:34 +0100 Subject: [PATCH 11/21] Mark linux-getrandom-fallback test as needs-unwind Fixes test failures on {aarch64*-none, armv7r-eabihf, thumbv7em-eabi*} targets which have panic=abort by default --- tests/ui/std/linux-getrandom-fallback.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/ui/std/linux-getrandom-fallback.rs b/tests/ui/std/linux-getrandom-fallback.rs index c50fbe8257af6..81c0fa623d835 100644 --- a/tests/ui/std/linux-getrandom-fallback.rs +++ b/tests/ui/std/linux-getrandom-fallback.rs @@ -1,5 +1,6 @@ //@ only-linux //@ run-pass +//@ needs-unwind #![feature(random)] #![feature(rustc_private)] From 03d78511882193e5b3a19839ee04a69a37746605 Mon Sep 17 00:00:00 2001 From: bit-aloo Date: Tue, 30 Jun 2026 15:32:00 +0000 Subject: [PATCH 12/21] add EarlyBinder::def_id helper and remove direct calls to instantiate_identity().skip_norm_wip().def_id --- compiler/rustc_hir_analysis/src/check/check.rs | 5 ++--- compiler/rustc_mir_transform/src/check_call_recursion.rs | 2 +- compiler/rustc_type_ir/src/binder.rs | 6 ++++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 0aa31c3a016b9..aa204a20e2d57 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -839,9 +839,8 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), tcx.ensure_ok().associated_items(def_id); if of_trait { let impl_trait_header = tcx.impl_trait_header(def_id); - res = res.and(tcx.ensure_result().coherent_trait( - impl_trait_header.trait_ref.instantiate_identity().skip_norm_wip().def_id, - )); + res = res + .and(tcx.ensure_result().coherent_trait(impl_trait_header.trait_ref.def_id())); if res.is_ok() { // Checking this only makes sense if the all trait impls satisfy basic diff --git a/compiler/rustc_mir_transform/src/check_call_recursion.rs b/compiler/rustc_mir_transform/src/check_call_recursion.rs index 216ada600ce34..73c1510b9a0e2 100644 --- a/compiler/rustc_mir_transform/src/check_call_recursion.rs +++ b/compiler/rustc_mir_transform/src/check_call_recursion.rs @@ -45,7 +45,7 @@ impl<'tcx> MirLint<'tcx> for CheckDropRecursion { if let DefKind::AssocFn = tcx.def_kind(def_id) && let Some(impl_id) = tcx.trait_impl_of_assoc(def_id.to_def_id()) && let trait_ref = tcx.impl_trait_ref(impl_id) - && tcx.is_lang_item(trait_ref.instantiate_identity().skip_norm_wip().def_id, LangItem::Drop) + && tcx.is_lang_item(trait_ref.def_id(), LangItem::Drop) // avoid erroneous `Drop` impls from causing ICEs below && let sig = tcx.fn_sig(def_id).instantiate_identity().skip_norm_wip() && sig.inputs().skip_binder().len() == 1 diff --git a/compiler/rustc_type_ir/src/binder.rs b/compiler/rustc_type_ir/src/binder.rs index 8ddc53b8e0ab5..6f41a608763e3 100644 --- a/compiler/rustc_type_ir/src/binder.rs +++ b/compiler/rustc_type_ir/src/binder.rs @@ -448,6 +448,12 @@ impl EarlyBinder { } } +impl EarlyBinder> { + pub fn def_id(&self) -> I::TraitId { + self.value.def_id + } +} + impl EarlyBinder> { pub fn transpose(self) -> Option> { self.value.map(|value| EarlyBinder { value, _tcx: PhantomData }) From cd642bb6f95767991625d6be37bdc05ce957077b Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 1 Jul 2026 08:36:07 +1000 Subject: [PATCH 13/21] Remove unnecessary `Clone` derives on resolver types The starting point of this commit is that `ModuleData`, `ImportData`, and `DeclData` are all interned, and don't need to be `Clone`. Then there are various types nestled within these types that also don't need to be `Clone`. --- compiler/rustc_expand/src/base.rs | 2 +- compiler/rustc_resolve/src/error_helper.rs | 2 +- compiler/rustc_resolve/src/imports.rs | 9 ++++----- compiler/rustc_resolve/src/late/diagnostics.rs | 2 +- compiler/rustc_resolve/src/lib.rs | 4 ++-- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index 31c776f3fef00..821f541170f62 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -1199,7 +1199,7 @@ pub trait LintStoreExpand { type LintStoreExpandDyn<'a> = Option<&'a (dyn LintStoreExpand + 'a)>; -#[derive(Debug, Clone, Default)] +#[derive(Debug, Default)] pub struct ModuleData { /// Path to the module starting from the crate name, like `my_crate::foo::bar`. pub mod_path: Vec, diff --git a/compiler/rustc_resolve/src/error_helper.rs b/compiler/rustc_resolve/src/error_helper.rs index 1b7d799cadd35..c8abc3556f8fe 100644 --- a/compiler/rustc_resolve/src/error_helper.rs +++ b/compiler/rustc_resolve/src/error_helper.rs @@ -109,7 +109,7 @@ impl TypoSuggestion { } /// A free importable items suggested in case of resolution failure. -#[derive(Debug, Clone)] +#[derive(Debug)] pub(crate) struct ImportSuggestion { pub did: Option, pub descr: &'static str, diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index a3cb526e60a87..303e333c4100e 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -69,7 +69,6 @@ impl<'ra> PendingDecl<'ra> { } /// Contains data for specific kinds of imports. -#[derive(Clone)] pub(crate) enum ImportKind<'ra> { Single { /// `source` in `use prefix::source as target`. @@ -157,7 +156,7 @@ impl<'ra> std::fmt::Debug for ImportKind<'ra> { } /// One import. -#[derive(Debug, Clone)] +#[derive(Debug)] pub(crate) struct ImportData<'ra> { pub kind: ImportKind<'ra>, @@ -280,7 +279,7 @@ impl<'ra> ImportData<'ra> { } /// Records information about the resolution of a name in a namespace of a module. -#[derive(Clone, Debug)] +#[derive(Debug)] pub(crate) struct NameResolution<'ra> { /// Single imports that may define the name in the namespace. /// Imports are arena-allocated, so it's ok to use pointers as keys. @@ -322,7 +321,7 @@ impl<'ra> NameResolution<'ra> { /// An error that may be transformed into a diagnostic later. Used to combine multiple unresolved /// import errors within the same use tree into a single diagnostic. -#[derive(Debug, Clone)] +#[derive(Debug)] pub(crate) struct UnresolvedImportError { pub(crate) span: Span, pub(crate) label: Option, @@ -341,7 +340,7 @@ fn pub_use_of_private_extern_crate_hack( import: ImportSummary, decl: Decl<'_>, ) -> Option { - match (import.is_single, decl.kind) { + match (import.is_single, &decl.kind) { (true, DeclKind::Import { import: decl_import, .. }) if let ImportKind::ExternCrate { def_id, .. } = decl_import.kind && import.vis.is_public() => diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 045e0ff523c7d..8c5c7f5b2d76d 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -133,7 +133,7 @@ pub(super) struct MissingLifetime { /// Description of the lifetimes appearing in a function parameter. /// This is used to provide a literal explanation to the elision failure. -#[derive(Clone, Debug)] +#[derive(Debug)] pub(super) struct ElisionFnParameter { /// The index of the argument in the original definition. pub index: usize, diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index e6cfa469e91d0..382a3eecb455f 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -992,7 +992,7 @@ impl<'ra> fmt::Debug for LocalModule<'ra> { } /// Data associated with any name declaration. -#[derive(Clone, Debug)] +#[derive(Debug)] struct DeclData<'ra> { kind: DeclKind<'ra>, ambiguity: CmCell, bool /*warning*/)>>, @@ -1026,7 +1026,7 @@ impl std::hash::Hash for DeclData<'_> { } /// Name declaration kind. -#[derive(Clone, Copy, Debug)] +#[derive(Debug)] enum DeclKind<'ra> { /// The name declaration is a definition (possibly without a `DefId`), /// can be provided by source code or built into the language. From c6f92dcae05d07e723733f2c82cbe923480af832 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 1 Jul 2026 10:19:48 +1000 Subject: [PATCH 14/21] Add missing `needs_drop` check to `DroplessArena`. Three of the four public allocation functions in `DroplessArena` check that the allocated type doesn't implement `Drop`: `alloc`, `alloc_slice`, `alloc_from_iter`. This commit adds the missing check to `try_alloc_from_iter`. It also moves and reorders some lines in `alloc_from_iter` for consistency with the other methods. --- compiler/rustc_arena/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_arena/src/lib.rs b/compiler/rustc_arena/src/lib.rs index 24ade7300c33b..a4248a82bce73 100644 --- a/compiler/rustc_arena/src/lib.rs +++ b/compiler/rustc_arena/src/lib.rs @@ -542,11 +542,12 @@ impl DroplessArena { #[inline] pub fn alloc_from_iter>(&self, iter: I) -> &mut [T] { + assert!(!mem::needs_drop::()); + assert!(size_of::() != 0); + // Warning: this function is reentrant: `iter` could hold a reference to `&self` and // allocate additional elements while we're iterating. let iter = iter.into_iter(); - assert!(size_of::() != 0); - assert!(!mem::needs_drop::()); let size_hint = iter.size_hint(); @@ -577,6 +578,7 @@ impl DroplessArena { ) -> Result<&mut [T], E> { // Despite the similarity with `alloc_from_iter`, we cannot reuse their fast case, as we // cannot know the minimum length of the iterator in this case. + assert!(!mem::needs_drop::()); assert!(size_of::() != 0); // Takes care of reentrancy. From 296ba6a90cf5304063d53a6963a227d8fef71ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=9D=E5=80=89=E6=B0=B4=E5=B8=8C?= Date: Tue, 30 Jun 2026 23:56:44 +0800 Subject: [PATCH 15/21] Rewrite dll-weak-definition test to run-make --- tests/run-make/dll-weak-definition/rmake.rs | 23 +++++++++++++++++++++ tests/run-make/dll-weak-definition/weak.rs | 10 +++++++++ tests/ui/linking/dll-weak-definition.rs | 20 ------------------ 3 files changed, 33 insertions(+), 20 deletions(-) create mode 100644 tests/run-make/dll-weak-definition/rmake.rs create mode 100644 tests/run-make/dll-weak-definition/weak.rs delete mode 100644 tests/ui/linking/dll-weak-definition.rs diff --git a/tests/run-make/dll-weak-definition/rmake.rs b/tests/run-make/dll-weak-definition/rmake.rs new file mode 100644 index 0000000000000..1b05bdecc2cdf --- /dev/null +++ b/tests/run-make/dll-weak-definition/rmake.rs @@ -0,0 +1,23 @@ +// Regression test for MSVC link.exe failing to export weak definitions from dlls. +// See https://github.com/rust-lang/rust/pull/158294 + +//@ only-msvc +//@ needs-rust-lld + +use run_make_support::{dynamic_lib_name, llvm_readobj, rustc}; + +fn test_with_linker(linker: &str) { + rustc().input("weak.rs").linker(linker).run(); + + llvm_readobj() + .arg("--coff-exports") + .input(dynamic_lib_name("weak")) + .run() + .assert_stdout_contains("Name: weak_function") + .assert_stdout_contains("Name: WEAK_STATIC"); +} + +fn main() { + test_with_linker("link"); + test_with_linker("rust-lld"); +} diff --git a/tests/run-make/dll-weak-definition/weak.rs b/tests/run-make/dll-weak-definition/weak.rs new file mode 100644 index 0000000000000..93b19ad627910 --- /dev/null +++ b/tests/run-make/dll-weak-definition/weak.rs @@ -0,0 +1,10 @@ +#![feature(linkage)] +#![crate_type = "cdylib"] + +#[linkage = "weak"] +#[no_mangle] +pub fn weak_function() {} + +#[linkage = "weak"] +#[no_mangle] +pub static WEAK_STATIC: u8 = 42; diff --git a/tests/ui/linking/dll-weak-definition.rs b/tests/ui/linking/dll-weak-definition.rs deleted file mode 100644 index 47ae6aeb43366..0000000000000 --- a/tests/ui/linking/dll-weak-definition.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Regression test for MSVC link.exe failing to export weak definitions from dlls. -// See https://github.com/rust-lang/rust/pull/142568 - -//@ build-pass -//@ only-msvc -//@ revisions: link_exe lld -//@[link_exe] compile-flags: -Clinker=link.exe -//@[lld] needs-rust-lld -//@[lld] compile-flags: -Clinker=rust-lld - -#![feature(linkage)] -#![crate_type = "cdylib"] - -#[linkage = "weak"] -#[no_mangle] -pub fn weak_function() {} - -#[linkage = "weak"] -#[no_mangle] -pub static WEAK_STATIC: u8 = 42; From 4f436ab72ebd285b22a36170db0e807804b3f306 Mon Sep 17 00:00:00 2001 From: "Tim (Theemathas) Chirananthavat" Date: Wed, 1 Jul 2026 15:56:39 +0700 Subject: [PATCH 16/21] Document `strip_circumfix` behavior on overlapping prefix and suffix. Fixes https://github.com/rust-lang/rust/issues/158388, as per T-libs-api decision there. --- library/core/src/slice/mod.rs | 9 ++++++--- library/core/src/str/mod.rs | 7 +++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 7ab476e785d16..4b02e73a4dcc3 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -2738,10 +2738,12 @@ impl [T] { /// Returns a subslice with the prefix and suffix removed. /// - /// If the slice starts with `prefix` and ends with `suffix`, returns the subslice after the - /// prefix and before the suffix, wrapped in `Some`. + /// If the slice starts with `prefix`, ends with `suffix`, and + /// the prefix and suffix don't overlap, returns the subslice after + /// the prefix and before the suffix, wrapped in `Some`. /// - /// If the slice does not start with `prefix` or does not end with `suffix`, returns `None`. + /// If the slice does not start with `prefix`, does not end with `suffix`, + /// or the prefix and suffix overlap in the slice, returns `None`. /// /// # Examples /// @@ -2754,6 +2756,7 @@ impl [T] { /// assert_eq!(v.strip_circumfix(&[10], &[40]), None); /// assert_eq!(v.strip_circumfix(&[], &[40, 30]), Some(&[10, 50][..])); /// assert_eq!(v.strip_circumfix(&[10, 50], &[]), Some(&[40, 30][..])); + /// assert_eq!(v.strip_circumfix(&[10, 50, 40], &[50, 40, 30]), None); /// ``` #[must_use = "returns the subslice without modifying the original"] #[stable(feature = "strip_circumfix", since = "CURRENT_RUSTC_VERSION")] diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index 78cb8ca665e1e..2128ce328a9c6 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -2492,12 +2492,14 @@ impl str { /// Returns a string slice with the prefix and suffix removed. /// - /// If the string starts with the pattern `prefix` and ends with the pattern `suffix`, returns + /// If the string starts with the pattern `prefix` and ends with + /// the pattern `suffix`, and the prefix and suffix don't overlap, returns /// the substring after the prefix and before the suffix, wrapped in `Some`. /// Unlike [`trim_start_matches`] and [`trim_end_matches`], this method removes both the prefix /// and suffix exactly once. /// - /// If the string does not start with `prefix` or does not end with `suffix`, returns `None`. + /// If the string does not start with `prefix`, does not end with `suffix`, + /// or the prefix and suffix overlap in the string, returns `None`. /// /// Each [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a /// function or closure that determines if a character matches. @@ -2513,6 +2515,7 @@ impl str { /// assert_eq!("bar:hello:foo".strip_circumfix("bar:", ":foo"), Some("hello")); /// assert_eq!("bar:foo".strip_circumfix("foo", "foo"), None); /// assert_eq!("foo:bar;".strip_circumfix("foo:", ';'), Some("bar")); + /// assert_eq!("foo:bar:baz".strip_circumfix("foo:bar:", ":bar:baz"), None); /// ``` #[must_use = "this returns the remaining substring as a new slice, \ without modifying the original"] From 7026b5b0f178dde27af4373ad6c8f0467cda55ab Mon Sep 17 00:00:00 2001 From: heinwol Date: Mon, 29 Jun 2026 13:24:39 +0300 Subject: [PATCH 17/21] fix regexes in problematic files manually --- .../heap/dealloc_intrinsic_dangling.rs | 1 + .../heap/dealloc_intrinsic_dangling.stderr | 6 +- tests/ui/consts/const-eval/ub-nonnull.rs | 2 + tests/ui/consts/const-eval/ub-nonnull.stderr | 18 ++-- tests/ui/consts/const-eval/ub-ref-ptr.rs | 2 + tests/ui/consts/const-eval/ub-ref-ptr.stderr | 48 +++++------ tests/ui/consts/const-eval/ub-wide-ptr.rs | 2 +- tests/ui/consts/const-eval/ub-wide-ptr.stderr | 84 +++++++++---------- .../consts/const-mut-refs/mut_ref_in_final.rs | 1 + .../const-mut-refs/mut_ref_in_final.stderr | 40 ++++----- .../miri_unleashed/mutable_references.rs | 1 + .../miri_unleashed/mutable_references.stderr | 72 ++++++++-------- 12 files changed, 142 insertions(+), 135 deletions(-) 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 de9fc5d092137..80cf3ffef11a5 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs @@ -5,6 +5,7 @@ //@ 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] |╾─*A(LLOC)?[0-9]+(\+[a-z0-9]+)?()?─*╼ )+ *│.*" -> "HEX_DUMP" //@ normalize-stderr: "HEX_DUMP\s*\n\s*HEX_DUMP" -> "HEX_DUMP" +//@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼" use std::intrinsics; 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 807781634d2c2..e9b7f99ee6d99 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr @@ -1,16 +1,16 @@ error[E0080]: constructing invalid value of type &u8: encountered a dangling reference (use-after-free) - --> $DIR/dealloc_intrinsic_dangling.rs:11:1 + --> $DIR/dealloc_intrinsic_dangling.rs:12:1 | LL | const _X: &'static u8 = unsafe { | ^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾─╼ } error[E0080]: memory access failed: ALLOC$ID has been freed, so this pointer is dangling - --> $DIR/dealloc_intrinsic_dangling.rs:22:5 + --> $DIR/dealloc_intrinsic_dangling.rs:23:5 | LL | *reference | ^^^^^^^^^^ evaluation of `_Y` failed here diff --git a/tests/ui/consts/const-eval/ub-nonnull.rs b/tests/ui/consts/const-eval/ub-nonnull.rs index 99afde5e20afe..679de8b0cf101 100644 --- a/tests/ui/consts/const-eval/ub-nonnull.rs +++ b/tests/ui/consts/const-eval/ub-nonnull.rs @@ -1,6 +1,8 @@ // Strip out raw byte dumps to make comparison platform-independent: //@ 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" +//@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼" +//@ normalize-stderr: "[0-9a-f][0-9a-f]( [0-9a-f][0-9a-f]){3,7} ╾ALLOC\$ID╼" -> "HEX_DUMP ╾ALLOC$$ID╼ │ ╾─╼" //@ dont-require-annotations: NOTE #![allow(invalid_value)] // make sure we cannot allow away the errors tested here diff --git a/tests/ui/consts/const-eval/ub-nonnull.stderr b/tests/ui/consts/const-eval/ub-nonnull.stderr index 8eb9481af6306..81f2ff3ca5fa4 100644 --- a/tests/ui/consts/const-eval/ub-nonnull.stderr +++ b/tests/ui/consts/const-eval/ub-nonnull.stderr @@ -1,5 +1,5 @@ error[E0080]: constructing invalid value of type NonNull: at .pointer, encountered 0, but expected something greater or equal to 1 - --> $DIR/ub-nonnull.rs:16:1 + --> $DIR/ub-nonnull.rs:18:1 | LL | const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -10,13 +10,13 @@ LL | const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; } error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 255 bytes, but got ALLOC$ID which is only 1 byte from the end of the allocation - --> $DIR/ub-nonnull.rs:22:29 + --> $DIR/ub-nonnull.rs:24:29 | LL | let out_of_bounds_ptr = &ptr[255]; | ^^^^^^^^^ evaluation of `OUT_OF_BOUNDS_PTR` failed here error[E0080]: constructing invalid value of type NonZero: at .0.0, encountered 0, but expected something greater or equal to 1 - --> $DIR/ub-nonnull.rs:26:1 + --> $DIR/ub-nonnull.rs:28:1 | LL | const NULL_U8: NonZero = unsafe { mem::transmute(0u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -27,7 +27,7 @@ LL | const NULL_U8: NonZero = unsafe { mem::transmute(0u8) }; } error[E0080]: constructing invalid value of type NonZero: at .0.0, encountered 0, but expected something greater or equal to 1 - --> $DIR/ub-nonnull.rs:28:1 + --> $DIR/ub-nonnull.rs:30:1 | LL | const NULL_USIZE: NonZero = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -38,7 +38,7 @@ LL | const NULL_USIZE: NonZero = unsafe { mem::transmute(0usize) }; } error[E0080]: reading memory at ALLOC$ID[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory - --> $DIR/ub-nonnull.rs:36:38 + --> $DIR/ub-nonnull.rs:38:38 | LL | const UNINIT: NonZero = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNINIT` failed here @@ -48,25 +48,25 @@ LL | const UNINIT: NonZero = unsafe { MaybeUninit { uninit: () }.init }; } error[E0080]: constructing invalid value of type NonNull: at .pointer, encountered 0, but expected something greater or equal to 1 - --> $DIR/ub-nonnull.rs:39:1 + --> $DIR/ub-nonnull.rs:41:1 | LL | const NULL_FAT_PTR: NonNull = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) { - 00 00 00 00 00 00 00 00 ╾ALLOC$ID╼ │ ........╾──────╼ + HEX_DUMP ╾ALLOC$ID╼ │ ╾─╼ │ ╾─╼ } error[E0080]: constructing invalid value of type NonNull<()>: at .pointer, encountered a maybe-null pointer, but expected something that is definitely non-zero - --> $DIR/ub-nonnull.rs:47:1 + --> $DIR/ub-nonnull.rs:49:1 | LL | const MAYBE_NULL_PTR: NonNull<()> = unsafe { mem::transmute((&raw const S).wrapping_add(4)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾─╼ } error: aborting due to 7 previous errors diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.rs b/tests/ui/consts/const-eval/ub-ref-ptr.rs index d1a1ef61bdc42..dedfd3a676f87 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.rs +++ b/tests/ui/consts/const-eval/ub-ref-ptr.rs @@ -4,6 +4,8 @@ //@ normalize-stderr: "([0-9a-f][0-9a-f] |__ |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?()?─*╼ )+ *│.*" -> "HEX_DUMP" //@ dont-require-annotations: NOTE //@ normalize-stderr: "0x[0-9](\.\.|\])" -> "0x%$1" +//@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼" + #![feature(pattern_types, pattern_type_macro)] #![allow(invalid_value)] diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.stderr b/tests/ui/consts/const-eval/ub-ref-ptr.stderr index 0dc586b36dec3..f1f219243c385 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-ref-ptr.stderr @@ -1,27 +1,27 @@ error[E0080]: constructing invalid value of type &u16: encountered an unaligned reference (required 2 byte alignment but found 1) - --> $DIR/ub-ref-ptr.rs:18:1 + --> $DIR/ub-ref-ptr.rs:20:1 | LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; | ^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾─╼ } error[E0080]: constructing invalid value of type Box: encountered an unaligned box (required 2 byte alignment but found 1) - --> $DIR/ub-ref-ptr.rs:21:1 + --> $DIR/ub-ref-ptr.rs:23:1 | LL | const UNALIGNED_BOX: Box = unsafe { mem::transmute(&[0u8; 4]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾─╼ } error[E0080]: constructing invalid value of type &u16: encountered a null reference - --> $DIR/ub-ref-ptr.rs:24:1 + --> $DIR/ub-ref-ptr.rs:26:1 | LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -32,7 +32,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; } error[E0080]: constructing invalid value of type Box: encountered a null box - --> $DIR/ub-ref-ptr.rs:27:1 + --> $DIR/ub-ref-ptr.rs:29:1 | LL | const NULL_BOX: Box = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -43,18 +43,18 @@ LL | const NULL_BOX: Box = unsafe { mem::transmute(0usize) }; } error[E0080]: constructing invalid value of type Box<()>: encountered a maybe-null box - --> $DIR/ub-ref-ptr.rs:30:1 + --> $DIR/ub-ref-ptr.rs:32:1 | LL | const MAYBE_NULL_BOX: Box<()> = unsafe { mem::transmute({ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾─╼ } error[E0080]: unable to turn pointer into integer - --> $DIR/ub-ref-ptr.rs:39:1 + --> $DIR/ub-ref-ptr.rs:41:1 | LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `REF_AS_USIZE` failed here @@ -63,7 +63,7 @@ LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: unable to turn pointer into integer - --> $DIR/ub-ref-ptr.rs:42:39 + --> $DIR/ub-ref-ptr.rs:44:39 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `REF_AS_USIZE_SLICE` failed here @@ -72,13 +72,13 @@ LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; = 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:42:38 + --> $DIR/ub-ref-ptr.rs:44:38 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: unable to turn pointer into integer - --> $DIR/ub-ref-ptr.rs:45:86 + --> $DIR/ub-ref-ptr.rs:47:86 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; | ^^^^^^^^^^^^^^^^^^^^ evaluation of `REF_AS_USIZE_BOX_SLICE` failed here @@ -87,13 +87,13 @@ LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[us = 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:45:85 + --> $DIR/ub-ref-ptr.rs:47:85 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; | ^^^^^^^^^^^^^^^^^^^^^ error[E0080]: constructing invalid value of type &u8: encountered a dangling reference (0x539[noalloc] has no provenance) - --> $DIR/ub-ref-ptr.rs:48:1 + --> $DIR/ub-ref-ptr.rs:50:1 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -104,7 +104,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; } error[E0080]: constructing invalid value of type Box: encountered a dangling box (0x539[noalloc] has no provenance) - --> $DIR/ub-ref-ptr.rs:51:1 + --> $DIR/ub-ref-ptr.rs:53:1 | LL | const USIZE_AS_BOX: Box = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -115,7 +115,7 @@ LL | const USIZE_AS_BOX: Box = unsafe { mem::transmute(1337usize) }; } error[E0080]: reading memory at ALLOC$ID[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory - --> $DIR/ub-ref-ptr.rs:54:41 + --> $DIR/ub-ref-ptr.rs:56:41 | LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNINIT_PTR` failed here @@ -125,7 +125,7 @@ LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init }; } error[E0080]: constructing invalid value of type fn(): encountered null pointer, but expected a function pointer - --> $DIR/ub-ref-ptr.rs:57:1 + --> $DIR/ub-ref-ptr.rs:59:1 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -136,7 +136,7 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; } error[E0080]: reading memory at ALLOC$ID[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory - --> $DIR/ub-ref-ptr.rs:59:38 + --> $DIR/ub-ref-ptr.rs:61:38 | LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNINIT_FN_PTR` failed here @@ -146,7 +146,7 @@ LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init }; } error[E0080]: constructing invalid value of type fn(): encountered 0xd[noalloc], but expected a function pointer - --> $DIR/ub-ref-ptr.rs:61:1 + --> $DIR/ub-ref-ptr.rs:63:1 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -157,29 +157,29 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; } error[E0080]: constructing invalid value of type fn(): encountered ALLOC$ID, but expected a function pointer - --> $DIR/ub-ref-ptr.rs:63:1 + --> $DIR/ub-ref-ptr.rs:65:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; | ^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾─╼ } error[E0080]: constructing invalid value of type fn(): encountered ALLOC$ID+0xa, but expected a function pointer - --> $DIR/ub-ref-ptr.rs:65:1 + --> $DIR/ub-ref-ptr.rs:67:1 | LL | const MAYBE_NULL_FN_PTR: fn() = unsafe { mem::transmute({ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾─╼ } error[E0080]: accessing memory based on pointer with alignment 1, but alignment 4 is required - --> $DIR/ub-ref-ptr.rs:75:5 + --> $DIR/ub-ref-ptr.rs:77:5 | LL | ptr.read(); | ^^^^^^^^^^ evaluation of `UNALIGNED_READ` failed here diff --git a/tests/ui/consts/const-eval/ub-wide-ptr.rs b/tests/ui/consts/const-eval/ub-wide-ptr.rs index 0bbb104c0322c..a5c0b6f628e9c 100644 --- a/tests/ui/consts/const-eval/ub-wide-ptr.rs +++ b/tests/ui/consts/const-eval/ub-wide-ptr.rs @@ -10,6 +10,7 @@ use std::{ptr, mem}; //@ normalize-stderr: "offset \d+" -> "offset N" //@ normalize-stderr: "size \d+" -> "size N" //@ normalize-stderr: "0x[0-9](\.\.|\])" -> "0x%$1" +//@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼" //@ dont-require-annotations: NOTE /// A newtype wrapper to prevent MIR generation from inserting reborrows that would affect the error @@ -137,7 +138,6 @@ const RAW_TRAIT_OBJ_CONTENT_INVALID: *const dyn Trait = unsafe { mem::transmute: // Officially blessed way to get the vtable const DYN_METADATA: ptr::DynMetadata = ptr::metadata::(ptr::null::()); - static mut RAW_TRAIT_OBJ_VTABLE_NULL_THROUGH_REF: *const dyn Trait = unsafe { mem::transmute::<_, &dyn Trait>((&92u8, 0usize)) //~^^ ERROR null pointer diff --git a/tests/ui/consts/const-eval/ub-wide-ptr.stderr b/tests/ui/consts/const-eval/ub-wide-ptr.stderr index aa1741eb6a8e9..b442a43c6276f 100644 --- a/tests/ui/consts/const-eval/ub-wide-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-wide-ptr.stderr @@ -1,5 +1,5 @@ error[E0080]: constructing invalid value of type &str: encountered a dangling reference (going beyond the bounds of its allocation) - --> $DIR/ub-wide-ptr.rs:40:1 + --> $DIR/ub-wide-ptr.rs:41:1 | LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -10,7 +10,7 @@ LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; } error[E0080]: constructing invalid value of type (&str,): at .0, encountered invalid reference metadata: slice is bigger than largest supported object - --> $DIR/ub-wide-ptr.rs:42:1 + --> $DIR/ub-wide-ptr.rs:43:1 | LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -21,7 +21,7 @@ LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, us } error[E0080]: unable to turn pointer into integer - --> $DIR/ub-wide-ptr.rs:45:1 + --> $DIR/ub-wide-ptr.rs:46:1 | LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `STR_LENGTH_PTR` failed here @@ -30,7 +30,7 @@ LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) }; = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: unable to turn pointer into integer - --> $DIR/ub-wide-ptr.rs:48:1 + --> $DIR/ub-wide-ptr.rs:49:1 | LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `MY_STR_LENGTH_PTR` failed here @@ -39,7 +39,7 @@ LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) }; = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: constructing invalid value of type &MyStr: encountered invalid reference metadata: slice is bigger than largest supported object - --> $DIR/ub-wide-ptr.rs:50:1 + --> $DIR/ub-wide-ptr.rs:51:1 | LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -50,7 +50,7 @@ LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize: } error[E0080]: constructing invalid value of type &str: at ., encountered uninitialized memory, but expected a string - --> $DIR/ub-wide-ptr.rs:54:1 + --> $DIR/ub-wide-ptr.rs:55:1 | LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -61,7 +61,7 @@ LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit: } error[E0080]: constructing invalid value of type &MyStr: at ..0, encountered uninitialized memory, but expected a string - --> $DIR/ub-wide-ptr.rs:57:1 + --> $DIR/ub-wide-ptr.rs:58:1 | LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -72,7 +72,7 @@ LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUni } error[E0080]: reading memory at ALLOC$ID[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory - --> $DIR/ub-wide-ptr.rs:64:1 + --> $DIR/ub-wide-ptr.rs:65:1 | LL | const SLICE_LENGTH_UNINIT: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SLICE_LENGTH_UNINIT` failed here @@ -82,7 +82,7 @@ LL | const SLICE_LENGTH_UNINIT: &[u8] = unsafe { } error[E0080]: constructing invalid value of type &[u8]: encountered a dangling reference (going beyond the bounds of its allocation) - --> $DIR/ub-wide-ptr.rs:70:1 + --> $DIR/ub-wide-ptr.rs:71:1 | LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -93,7 +93,7 @@ LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; } error[E0080]: constructing invalid value of type &[u32]: encountered invalid reference metadata: slice is bigger than largest supported object - --> $DIR/ub-wide-ptr.rs:73:1 + --> $DIR/ub-wide-ptr.rs:74:1 | LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -104,7 +104,7 @@ LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, is } error[E0080]: unable to turn pointer into integer - --> $DIR/ub-wide-ptr.rs:76:1 + --> $DIR/ub-wide-ptr.rs:77:1 | LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SLICE_LENGTH_PTR` failed here @@ -113,7 +113,7 @@ LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) }; = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: constructing invalid value of type Box<[u8]>: encountered a dangling box (going beyond the bounds of its allocation) - --> $DIR/ub-wide-ptr.rs:79:1 + --> $DIR/ub-wide-ptr.rs:80:1 | LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -124,7 +124,7 @@ LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999us } error[E0080]: unable to turn pointer into integer - --> $DIR/ub-wide-ptr.rs:82:1 + --> $DIR/ub-wide-ptr.rs:83:1 | LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SLICE_LENGTH_PTR_BOX` failed here @@ -133,58 +133,58 @@ LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3) = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: constructing invalid value of type &[bool; 1]: at .[0], encountered 0x03, but expected a boolean - --> $DIR/ub-wide-ptr.rs:86:1 + --> $DIR/ub-wide-ptr.rs:87:1 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾─╼ } note: erroneous constant encountered - --> $DIR/ub-wide-ptr.rs:86:40 + --> $DIR/ub-wide-ptr.rs:87:40 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: constructing invalid value of type &MySlice<[bool; 1]>: at ..0, encountered 0x03, but expected a boolean - --> $DIR/ub-wide-ptr.rs:92:1 + --> $DIR/ub-wide-ptr.rs:93:1 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾─╼ } note: erroneous constant encountered - --> $DIR/ub-wide-ptr.rs:92:42 + --> $DIR/ub-wide-ptr.rs:93:42 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: constructing invalid value of type &MySlice<[bool; 1]>: at ..1[0], encountered 0x03, but expected a boolean - --> $DIR/ub-wide-ptr.rs:95:1 + --> $DIR/ub-wide-ptr.rs:96:1 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾─╼ } note: erroneous constant encountered - --> $DIR/ub-wide-ptr.rs:95:42 + --> $DIR/ub-wide-ptr.rs:96:42 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: reading memory at ALLOC$ID[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory - --> $DIR/ub-wide-ptr.rs:102:1 + --> $DIR/ub-wide-ptr.rs:103:1 | LL | const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `RAW_SLICE_LENGTH_UNINIT` failed here @@ -194,29 +194,29 @@ LL | const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe { } error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID, but expected a vtable pointer - --> $DIR/ub-wide-ptr.rs:110:1 + --> $DIR/ub-wide-ptr.rs:111:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼ } error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID, but expected a vtable pointer - --> $DIR/ub-wide-ptr.rs:113:1 + --> $DIR/ub-wide-ptr.rs:114:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼ } error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered 0x4[noalloc], but expected a vtable pointer - --> $DIR/ub-wide-ptr.rs:116:1 + --> $DIR/ub-wide-ptr.rs:117:1 | LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -227,62 +227,62 @@ LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u } error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC$ID, but expected a vtable pointer - --> $DIR/ub-wide-ptr.rs:118:1 + --> $DIR/ub-wide-ptr.rs:119:1 | LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼ } error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC$ID, but expected a vtable pointer - --> $DIR/ub-wide-ptr.rs:120:1 + --> $DIR/ub-wide-ptr.rs:121:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼ } error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC$ID, but expected a vtable pointer - --> $DIR/ub-wide-ptr.rs:122:1 + --> $DIR/ub-wide-ptr.rs:123:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼ } error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID, but expected a vtable pointer - --> $DIR/ub-wide-ptr.rs:124:1 + --> $DIR/ub-wide-ptr.rs:125:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼ } error[E0080]: constructing invalid value of type &dyn Trait: at .., encountered 0x03, but expected a boolean - --> $DIR/ub-wide-ptr.rs:128:1 + --> $DIR/ub-wide-ptr.rs:129:1 | LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼ } error[E0080]: constructing invalid value of type *const dyn Trait: encountered null pointer, but expected a vtable pointer - --> $DIR/ub-wide-ptr.rs:132:1 + --> $DIR/ub-wide-ptr.rs:133:1 | LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -293,14 +293,14 @@ LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute } error[E0080]: constructing invalid value of type *const dyn Trait: encountered ALLOC$ID, but expected a vtable pointer - --> $DIR/ub-wide-ptr.rs:134:1 + --> $DIR/ub-wide-ptr.rs:135:1 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼ } error[E0080]: constructing invalid value of type *const dyn Trait: encountered null pointer, but expected a vtable pointer @@ -322,7 +322,7 @@ LL | static mut RAW_TRAIT_OBJ_VTABLE_INVALID_THROUGH_REF: *const dyn Trait = uns | = 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) { - ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼ } error: aborting due to 29 previous errors 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 c620c2cf9fb8c..ebf1f88eb8e72 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 @@ -1,6 +1,7 @@ //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" //@ normalize-stderr: "( 0x[0-9a-f][0-9a-f] │)? ([0-9a-f][0-9a-f] |__ |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?()?─*╼ )+ *│.*" -> " HEX_DUMP" //@ normalize-stderr: "HEX_DUMP\s*\n\s*HEX_DUMP" -> "HEX_DUMP" +//@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼" //@ dont-require-annotations: NOTE use std::cell::UnsafeCell; 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 bc9048e78cdb4..ad19f78ef831b 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 @@ -1,5 +1,5 @@ error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed - --> $DIR/mut_ref_in_final.rs:15:21 + --> $DIR/mut_ref_in_final.rs:16:21 | LL | const B: *mut i32 = &mut 4; | ^^^^^^ this mutable borrow refers to such a temporary @@ -9,7 +9,7 @@ LL | const B: *mut i32 = &mut 4; = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed - --> $DIR/mut_ref_in_final.rs:21:35 + --> $DIR/mut_ref_in_final.rs:22:35 | LL | const B3: Option<&mut i32> = Some(&mut 42); | ^^^^^^^ this mutable borrow refers to such a temporary @@ -19,7 +19,7 @@ LL | const B3: Option<&mut i32> = Some(&mut 42); = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:24:42 + --> $DIR/mut_ref_in_final.rs:25:42 | LL | const B4: Option<&mut i32> = helper(&mut 42); | ------------^^- @@ -29,29 +29,29 @@ LL | const B4: Option<&mut i32> = helper(&mut 42); | using this value as a constant requires that borrow lasts for `'static` error[E0080]: constructing invalid value of type &mut u16: encountered mutable reference or box pointing to read-only memory - --> $DIR/mut_ref_in_final.rs:27:1 + --> $DIR/mut_ref_in_final.rs:28:1 | LL | const IMMUT_MUT_REF: &mut u16 = unsafe { mem::transmute(&13) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾─╼ } error[E0080]: constructing invalid value of type &mut u16: encountered mutable reference or box pointing to read-only memory - --> $DIR/mut_ref_in_final.rs:29:1 + --> $DIR/mut_ref_in_final.rs:30:1 | LL | static IMMUT_MUT_REF_STATIC: &mut u16 = unsafe { mem::transmute(&13) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾─╼ } error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:52:65 + --> $DIR/mut_ref_in_final.rs:53:65 | LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- @@ -61,7 +61,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:55:67 + --> $DIR/mut_ref_in_final.rs:56:67 | LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- @@ -71,7 +71,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:58:71 + --> $DIR/mut_ref_in_final.rs:59:71 | LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- @@ -81,7 +81,7 @@ 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 borrows of temporaries that have their lifetime extended until the end of the program are not allowed - --> $DIR/mut_ref_in_final.rs:71:53 + --> $DIR/mut_ref_in_final.rs:72:53 | LL | static RAW_MUT_CAST_S: SyncPtr = SyncPtr { x : &mut 42 as *mut _ as *const _ }; | ^^^^^^^ this mutable borrow refers to such a temporary @@ -91,7 +91,7 @@ LL | static RAW_MUT_CAST_S: SyncPtr = SyncPtr { x : &mut 42 as *mut _ as *c = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed - --> $DIR/mut_ref_in_final.rs:73:54 + --> $DIR/mut_ref_in_final.rs:74:54 | LL | static RAW_MUT_COERCE_S: SyncPtr = SyncPtr { x: &mut 0 }; | ^^^^^^ this mutable borrow refers to such a temporary @@ -101,7 +101,7 @@ LL | static RAW_MUT_COERCE_S: SyncPtr = SyncPtr { x: &mut 0 }; = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed - --> $DIR/mut_ref_in_final.rs:75:52 + --> $DIR/mut_ref_in_final.rs:76:52 | LL | const RAW_MUT_CAST_C: SyncPtr = SyncPtr { x : &mut 42 as *mut _ as *const _ }; | ^^^^^^^ this mutable borrow refers to such a temporary @@ -111,7 +111,7 @@ LL | const RAW_MUT_CAST_C: SyncPtr = SyncPtr { x : &mut 42 as *mut _ as *co = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed - --> $DIR/mut_ref_in_final.rs:77:53 + --> $DIR/mut_ref_in_final.rs:78:53 | LL | const RAW_MUT_COERCE_C: SyncPtr = SyncPtr { x: &mut 0 }; | ^^^^^^ this mutable borrow refers to such a temporary @@ -121,7 +121,7 @@ LL | const RAW_MUT_COERCE_C: SyncPtr = SyncPtr { x: &mut 0 }; = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0080]: constructing invalid value of type Option<&mut i32>: at ..0, encountered a dangling reference (0x2a[noalloc] has no provenance) - --> $DIR/mut_ref_in_final.rs:86:5 + --> $DIR/mut_ref_in_final.rs:87:5 | LL | const INT2PTR: Option<&mut i32> = helper_int2ptr(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -132,7 +132,7 @@ LL | const INT2PTR: Option<&mut i32> = helper_int2ptr(); } error[E0080]: constructing invalid value of type Option<&mut i32>: at ..0, encountered a dangling reference (0x2a[noalloc] has no provenance) - --> $DIR/mut_ref_in_final.rs:87:5 + --> $DIR/mut_ref_in_final.rs:88:5 | LL | static INT2PTR_STATIC: Option<&mut i32> = helper_int2ptr(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -143,25 +143,25 @@ LL | static INT2PTR_STATIC: Option<&mut i32> = helper_int2ptr(); } error[E0080]: constructing invalid value of type Option<&mut i32>: at ..0, encountered a dangling reference (use-after-free) - --> $DIR/mut_ref_in_final.rs:93:5 + --> $DIR/mut_ref_in_final.rs:94:5 | LL | const DANGLING: Option<&mut i32> = helper_dangling(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾─╼ } error[E0080]: constructing invalid value of type Option<&mut i32>: at ..0, encountered a dangling reference (use-after-free) - --> $DIR/mut_ref_in_final.rs:94:5 + --> $DIR/mut_ref_in_final.rs:95:5 | LL | static DANGLING_STATIC: Option<&mut i32> = helper_dangling(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾─╼ } error: aborting due to 16 previous errors diff --git a/tests/ui/consts/miri_unleashed/mutable_references.rs b/tests/ui/consts/miri_unleashed/mutable_references.rs index 78f0cd520cb2b..300da408896e5 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references.rs +++ b/tests/ui/consts/miri_unleashed/mutable_references.rs @@ -1,6 +1,7 @@ //@ compile-flags: -Zunleash-the-miri-inside-of-you //@ 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" +//@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼" //@ dont-require-annotations: NOTE #![allow(static_mut_refs)] diff --git a/tests/ui/consts/miri_unleashed/mutable_references.stderr b/tests/ui/consts/miri_unleashed/mutable_references.stderr index 2f37f7861843c..3750b5354a982 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references.stderr +++ b/tests/ui/consts/miri_unleashed/mutable_references.stderr @@ -1,124 +1,124 @@ error[E0080]: constructing invalid value of type &&mut u32: at ., encountered mutable reference or box pointing to read-only memory - --> $DIR/mutable_references.rs:13:1 + --> $DIR/mutable_references.rs:14:1 | LL | static FOO: &&mut u32 = &&mut 42; | ^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾─╼ } error[E0080]: constructing invalid value of type &mut i32: encountered mutable reference or box pointing to read-only memory - --> $DIR/mutable_references.rs:15:1 + --> $DIR/mutable_references.rs:16:1 | LL | static OH_YES: &mut i32 = &mut 42; | ^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾─╼ } error: encountered mutable pointer in final value of static - --> $DIR/mutable_references.rs:17:1 + --> $DIR/mutable_references.rs:18:1 | LL | static BAR: &mut () = &mut (); | ^^^^^^^^^^^^^^^^^^^ error: encountered mutable pointer in final value of static - --> $DIR/mutable_references.rs:22:1 + --> $DIR/mutable_references.rs:23:1 | LL | static BOO: &mut Foo<()> = &mut Foo(()); | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: constructing invalid value of type &mut i32: encountered mutable reference or box pointing to read-only memory - --> $DIR/mutable_references.rs:25:1 + --> $DIR/mutable_references.rs:26:1 | LL | const BLUNT: &mut i32 = &mut 42; | ^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾─╼ } error[E0080]: constructing invalid value of type Meh: at .x., encountered `UnsafeCell` in read-only memory - --> $DIR/mutable_references.rs:40:1 + --> $DIR/mutable_references.rs:41:1 | LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) }; | ^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾─╼ } error[E0080]: constructing invalid value of type Meh: at .x., encountered `UnsafeCell` in read-only memory - --> $DIR/mutable_references.rs:45:1 + --> $DIR/mutable_references.rs:46:1 | LL | const MUH: Meh = Meh { | ^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾─╼ } error[E0080]: constructing invalid value of type &dyn Sync: at ...x, encountered `UnsafeCell` in read-only memory - --> $DIR/mutable_references.rs:56:1 + --> $DIR/mutable_references.rs:57:1 | LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼ } error[E0080]: constructing invalid value of type &mut i32: encountered mutable reference or box pointing to read-only memory - --> $DIR/mutable_references.rs:62:1 + --> $DIR/mutable_references.rs:63:1 | LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾─╼ } error[E0080]: constant accesses mutable global memory - --> $DIR/mutable_references.rs:73:43 + --> $DIR/mutable_references.rs:74:43 | LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF }; | ^^^^^^^^^^^^^ evaluation of `POINTS_TO_MUTABLE2` failed here error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references.rs:76:1 + --> $DIR/mutable_references.rs:77: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:79:1 + --> $DIR/mutable_references.rs:80: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:99:1 + --> $DIR/mutable_references.rs:100: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:102:1 + --> $DIR/mutable_references.rs:103: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:109:5 + --> $DIR/mutable_references.rs:110:5 | LL | static OH_YES: &mut i32 = &mut 42; | ----------------------- this `static` cannot be written to @@ -129,72 +129,72 @@ LL | *OH_YES = 99; warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:13:26 + --> $DIR/mutable_references.rs:14:26 | LL | static FOO: &&mut u32 = &&mut 42; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:15:27 + --> $DIR/mutable_references.rs:16:27 | LL | static OH_YES: &mut i32 = &mut 42; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:17:23 + --> $DIR/mutable_references.rs:18:23 | LL | static BAR: &mut () = &mut (); | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:22:28 + --> $DIR/mutable_references.rs:23:28 | LL | static BOO: &mut Foo<()> = &mut Foo(()); | ^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:25:25 + --> $DIR/mutable_references.rs:26:25 | LL | const BLUNT: &mut i32 = &mut 42; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:40:28 + --> $DIR/mutable_references.rs:41: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:47:8 + --> $DIR/mutable_references.rs:48:8 | LL | x: &UnsafeCell::new(42), | ^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:56:27 + --> $DIR/mutable_references.rs:57: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:76:45 + --> $DIR/mutable_references.rs:77: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:79:46 + --> $DIR/mutable_references.rs:80: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:84:47 + --> $DIR/mutable_references.rs:85: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:96:51 + --> $DIR/mutable_references.rs:97: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:99:49 + --> $DIR/mutable_references.rs:100: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:102:51 + --> $DIR/mutable_references.rs:103:51 | LL | const RAW_MUT_COERCE: SyncPtr = SyncPtr { x: &mut 0 }; | ^^^^^^ From 5eb0a5a852b514d8de8c089eb2d3cb48cf632bcf Mon Sep 17 00:00:00 2001 From: heinwol Date: Mon, 29 Jun 2026 13:24:39 +0300 Subject: [PATCH 18/21] bless for 32bit --- .../invalid-patterns.32bit.stderr | 4 +- .../const-err-enum-discriminant.32bit.stderr | 2 +- .../heap/alloc_intrinsic_uninit.32bit.stderr | 2 +- .../consts/const-eval/raw-bytes.32bit.stderr | 176 +++++++++--------- .../ub-incorrect-vtable.32bit.stderr | 22 +-- .../consts/const-eval/ub-upvars.32bit.stderr | 2 +- .../consts/const-eval/union-ub.32bit.stderr | 2 +- .../interior-mut-const-via-union.32bit.stderr | 2 +- tests/ui/consts/issue-63952.32bit.stderr | 2 +- .../static-no-inner-mut.32bit.stderr | 8 +- 10 files changed, 111 insertions(+), 111 deletions(-) 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 ec39cc27efb41..31a2accccd7fd 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 @@ -46,7 +46,7 @@ note: expected because of the type of the const parameter LL | fn get_flag() -> Option { | ^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory --> $DIR/invalid-patterns.rs:40:32 | LL | get_flag::(); @@ -78,7 +78,7 @@ LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character 42 │ B } -error[E0080]: reading memory at ALLOC1[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory --> $DIR/invalid-patterns.rs:44:58 | LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); diff --git a/tests/ui/consts/const-err-enum-discriminant.32bit.stderr b/tests/ui/consts/const-err-enum-discriminant.32bit.stderr index cc786108f648b..864364139594a 100644 --- a/tests/ui/consts/const-err-enum-discriminant.32bit.stderr +++ b/tests/ui/consts/const-err-enum-discriminant.32bit.stderr @@ -1,4 +1,4 @@ -error[E0080]: reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory --> $DIR/const-err-enum-discriminant.rs:10:21 | LL | Boo = [unsafe { Foo { b: () }.a }; 4][3], 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 f8d6cc145fca8..2d0e2e5d41839 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 @@ -6,7 +6,7 @@ LL | const BAR: &i32 = unsafe { | = 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╼ │ ╾──╼ + ╾ALLOC$ID╼ │ ╾──╼ } error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr index 4493067e9a8bb..37c715e003e8f 100644 --- a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr @@ -1,5 +1,5 @@ error[E0080]: constructing invalid value of type Enum: at ., encountered 0x00000001, but expected a valid enum tag - --> $DIR/raw-bytes.rs:24:1 + --> $DIR/raw-bytes.rs:23:1 | LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -10,7 +10,7 @@ LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; } error[E0080]: constructing invalid value of type Enum2: at ., encountered 0x00000000, but expected a valid enum tag - --> $DIR/raw-bytes.rs:32:1 + --> $DIR/raw-bytes.rs:31:1 | LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -21,7 +21,7 @@ LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; } error[E0080]: constructing invalid value of type UninhDiscriminant: at ., encountered an uninhabited enum variant - --> $DIR/raw-bytes.rs:46:1 + --> $DIR/raw-bytes.rs:45:1 | LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -32,7 +32,7 @@ LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute } error[E0080]: constructing invalid value of type UninhDiscriminant: at ., encountered 0x03, but expected a valid enum tag - --> $DIR/raw-bytes.rs:48:1 + --> $DIR/raw-bytes.rs:47:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -43,7 +43,7 @@ LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute } error[E0080]: constructing invalid value of type Option<(char, char)>: at ..0.1, encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) - --> $DIR/raw-bytes.rs:54:1 + --> $DIR/raw-bytes.rs:53:1 | LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -54,7 +54,7 @@ LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::tran } error[E0080]: constructing invalid value of type NonNull: at .pointer, encountered 0, but expected something greater or equal to 1 - --> $DIR/raw-bytes.rs:59:1 + --> $DIR/raw-bytes.rs:58:1 | LL | const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -65,7 +65,7 @@ LL | const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; } error[E0080]: constructing invalid value of type NonZero: at .0.0, encountered 0, but expected something greater or equal to 1 - --> $DIR/raw-bytes.rs:62:1 + --> $DIR/raw-bytes.rs:61:1 | LL | const NULL_U8: NonZero = unsafe { mem::transmute(0u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -76,7 +76,7 @@ LL | const NULL_U8: NonZero = unsafe { mem::transmute(0u8) }; } error[E0080]: constructing invalid value of type NonZero: at .0.0, encountered 0, but expected something greater or equal to 1 - --> $DIR/raw-bytes.rs:64:1 + --> $DIR/raw-bytes.rs:63:1 | LL | const NULL_USIZE: NonZero = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -87,7 +87,7 @@ LL | const NULL_USIZE: NonZero = unsafe { mem::transmute(0usize) }; } error[E0080]: constructing invalid value of type RestrictedRange1: at .0, encountered 42, but expected something in the range 10..=30 - --> $DIR/raw-bytes.rs:68:1 + --> $DIR/raw-bytes.rs:67:1 | LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(mem::transmute(42_u32)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -98,7 +98,7 @@ LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(mem::transmu } error[E0080]: constructing invalid value of type RestrictedRange2: at .0, encountered 20, but expected something less or equal to 10, or greater or equal to 30 - --> $DIR/raw-bytes.rs:72:1 + --> $DIR/raw-bytes.rs:71:1 | LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(mem::transmute(20_i32)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -109,40 +109,40 @@ LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(mem::transmu } error[E0080]: constructing invalid value of type NonNull: at .pointer, encountered 0, but expected something greater or equal to 1 - --> $DIR/raw-bytes.rs:75:1 + --> $DIR/raw-bytes.rs:74:1 | LL | const NULL_FAT_PTR: NonNull = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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╼ │ ....╾──╼ + 00 00 00 00 ╾ALLOC$ID╼ │ ....╾──╼ } error[E0080]: constructing invalid value of type &u16: encountered an unaligned reference (required 2 byte alignment but found 1) - --> $DIR/raw-bytes.rs:82:1 + --> $DIR/raw-bytes.rs:81:1 | LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; | ^^^^^^^^^^^^^^^^^^^^^ 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╼ │ ╾──╼ + ╾ALLOC$ID╼ │ ╾──╼ } error[E0080]: constructing invalid value of type Box: encountered an unaligned box (required 2 byte alignment but found 1) - --> $DIR/raw-bytes.rs:85:1 + --> $DIR/raw-bytes.rs:84:1 | LL | const UNALIGNED_BOX: Box = unsafe { mem::transmute(&[0u8; 4]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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╼ │ ╾──╼ + ╾ALLOC$ID╼ │ ╾──╼ } error[E0080]: constructing invalid value of type &u16: encountered a null reference - --> $DIR/raw-bytes.rs:88:1 + --> $DIR/raw-bytes.rs:87:1 | LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -153,7 +153,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; } error[E0080]: constructing invalid value of type Box: encountered a null box - --> $DIR/raw-bytes.rs:91:1 + --> $DIR/raw-bytes.rs:90:1 | LL | const NULL_BOX: Box = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -164,7 +164,7 @@ LL | const NULL_BOX: Box = unsafe { mem::transmute(0usize) }; } error[E0080]: constructing invalid value of type &u8: encountered a dangling reference (0x539[noalloc] has no provenance) - --> $DIR/raw-bytes.rs:94:1 + --> $DIR/raw-bytes.rs:93:1 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -175,7 +175,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; } error[E0080]: constructing invalid value of type Box: encountered a dangling box (0x539[noalloc] has no provenance) - --> $DIR/raw-bytes.rs:97:1 + --> $DIR/raw-bytes.rs:96:1 | LL | const USIZE_AS_BOX: Box = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -186,7 +186,7 @@ LL | const USIZE_AS_BOX: Box = unsafe { mem::transmute(1337usize) }; } error[E0080]: constructing invalid value of type fn(): encountered null pointer, but expected a function pointer - --> $DIR/raw-bytes.rs:100:1 + --> $DIR/raw-bytes.rs:99:1 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -197,7 +197,7 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; } error[E0080]: constructing invalid value of type fn(): encountered 0xd[noalloc], but expected a function pointer - --> $DIR/raw-bytes.rs:102:1 + --> $DIR/raw-bytes.rs:101:1 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -207,19 +207,19 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; 0d 00 00 00 │ .... } -error[E0080]: constructing invalid value of type fn(): encountered ALLOC3, but expected a function pointer - --> $DIR/raw-bytes.rs:104:1 +error[E0080]: constructing invalid value of type fn(): encountered ALLOC$ID, but expected a function pointer + --> $DIR/raw-bytes.rs:103:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; | ^^^^^^^^^^^^^^^^^^^^^^^ 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╼ │ ╾──╼ + ╾ALLOC$ID╼ │ ╾──╼ } error[E0080]: constructing invalid value of type &Bar: encountered a reference pointing to uninhabited type Bar - --> $DIR/raw-bytes.rs:110:1 + --> $DIR/raw-bytes.rs:109:1 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -230,62 +230,62 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; } error[E0080]: constructing invalid value of type &str: encountered a dangling reference (going beyond the bounds of its allocation) - --> $DIR/raw-bytes.rs:134:1 + --> $DIR/raw-bytes.rs:133:1 | LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──╼.... + ╾ALLOC$ID╼ e7 03 00 00 │ ╾──╼.... } error[E0080]: constructing invalid value of type (&str,): at .0, encountered invalid reference metadata: slice is bigger than largest supported object - --> $DIR/raw-bytes.rs:136:1 + --> $DIR/raw-bytes.rs:135:1 | LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──╼.... + ╾ALLOC$ID╼ ff ff ff ff │ ╾──╼.... } error[E0080]: constructing invalid value of type &MyStr: encountered invalid reference metadata: slice is bigger than largest supported object - --> $DIR/raw-bytes.rs:138:1 + --> $DIR/raw-bytes.rs:137:1 | LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──╼.... + ╾ALLOC$ID╼ ff ff ff ff │ ╾──╼.... } error[E0080]: constructing invalid value of type &str: at ., encountered uninitialized memory, but expected a string - --> $DIR/raw-bytes.rs:141:1 + --> $DIR/raw-bytes.rs:140:1 | LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──╼.... + ╾ALLOC$ID╼ 01 00 00 00 │ ╾──╼.... } error[E0080]: constructing invalid value of type &MyStr: at ..0, encountered uninitialized memory, but expected a string - --> $DIR/raw-bytes.rs:143:1 + --> $DIR/raw-bytes.rs:142:1 | LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:: { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──╼.... + ╾ALLOC$ID╼ 01 00 00 00 │ ╾──╼.... } error[E0080]: constructing invalid value of type &MyStr: at ..0, encountered a pointer, but expected a string - --> $DIR/raw-bytes.rs:145:1 + --> $DIR/raw-bytes.rs:144:1 | LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -294,172 +294,172 @@ LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _> = 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 │ ╾──╼.... + ╾ALLOC$ID╼ 01 00 00 00 │ ╾──╼.... } error[E0080]: constructing invalid value of type &[u8]: encountered a dangling reference (going beyond the bounds of its allocation) - --> $DIR/raw-bytes.rs:149:1 + --> $DIR/raw-bytes.rs:148:1 | LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──╼.... + ╾ALLOC$ID╼ e7 03 00 00 │ ╾──╼.... } error[E0080]: constructing invalid value of type &[u32]: encountered invalid reference metadata: slice is bigger than largest supported object - --> $DIR/raw-bytes.rs:151:1 + --> $DIR/raw-bytes.rs:150:1 | LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──╼.... + ╾ALLOC$ID╼ ff ff ff 7f │ ╾──╼.... } error[E0080]: constructing invalid value of type Box<[u8]>: encountered a dangling box (going beyond the bounds of its allocation) - --> $DIR/raw-bytes.rs:154:1 + --> $DIR/raw-bytes.rs:153:1 | LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──╼.... + ╾ALLOC$ID╼ e7 03 00 00 │ ╾──╼.... } error[E0080]: constructing invalid value of type &[bool; 1]: at .[0], encountered 0x03, but expected a boolean - --> $DIR/raw-bytes.rs:157:1 + --> $DIR/raw-bytes.rs:156:1 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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╼ │ ╾──╼ + ╾ALLOC$ID╼ │ ╾──╼ } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:157:40 + --> $DIR/raw-bytes.rs:156:40 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: constructing invalid value of type &MySlice<[bool; 1]>: at ..0, encountered 0x03, but expected a boolean - --> $DIR/raw-bytes.rs:161:1 + --> $DIR/raw-bytes.rs:160:1 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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╼ │ ╾──╼ + ╾ALLOC$ID╼ │ ╾──╼ } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:161:42 + --> $DIR/raw-bytes.rs:160:42 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: constructing invalid value of type &MySlice<[bool; 1]>: at ..1[0], encountered 0x03, but expected a boolean - --> $DIR/raw-bytes.rs:164:1 + --> $DIR/raw-bytes.rs:163:1 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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╼ │ ╾──╼ + ╾ALLOC$ID╼ │ ╾──╼ } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:164:42 + --> $DIR/raw-bytes.rs:163:42 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC17, but expected a vtable pointer - --> $DIR/raw-bytes.rs:168:1 +error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID, but expected a vtable pointer + --> $DIR/raw-bytes.rs:167:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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╼ │ ╾──╼╾──╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼ } -error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC19, but expected a vtable pointer - --> $DIR/raw-bytes.rs:171:1 +error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID, but expected a vtable pointer + --> $DIR/raw-bytes.rs:170:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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╼ │ ╾──╼╾──╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼ } error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered 0x4[noalloc], but expected a vtable pointer - --> $DIR/raw-bytes.rs:174:1 + --> $DIR/raw-bytes.rs:173:1 | LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──╼.... + ╾ALLOC$ID╼ 04 00 00 00 │ ╾──╼.... } -error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC22, but expected a vtable pointer - --> $DIR/raw-bytes.rs:176:1 +error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID, but expected a vtable pointer + --> $DIR/raw-bytes.rs:175:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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╼ │ ╾──╼╾──╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼ } error[E0080]: constructing invalid value of type &dyn Trait: at .., encountered 0x03, but expected a boolean - --> $DIR/raw-bytes.rs:179:1 + --> $DIR/raw-bytes.rs:178:1 | LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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╼ │ ╾──╼╾──╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼ } error[E0080]: constructing invalid value of type *const dyn Trait: encountered null pointer, but expected a vtable pointer - --> $DIR/raw-bytes.rs:182:1 + --> $DIR/raw-bytes.rs:181:1 | LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──╼.... + ╾ALLOC$ID╼ 00 00 00 00 │ ╾──╼.... } -error[E0080]: constructing invalid value of type *const dyn Trait: encountered ALLOC27, but expected a vtable pointer - --> $DIR/raw-bytes.rs:184:1 +error[E0080]: constructing invalid value of type *const dyn Trait: encountered ALLOC$ID, but expected a vtable pointer + --> $DIR/raw-bytes.rs:183:1 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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╼ │ ╾──╼╾──╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼ } error[E0080]: constructing invalid value of type &[!; 1]: encountered a reference pointing to uninhabited type [!; 1] - --> $DIR/raw-bytes.rs:188:1 + --> $DIR/raw-bytes.rs:187:1 | LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -470,7 +470,7 @@ LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; } error[E0080]: constructing invalid value of type &[!]: at .[0], encountered a value of the never type `!` - --> $DIR/raw-bytes.rs:189:1 + --> $DIR/raw-bytes.rs:188:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; | ^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -481,7 +481,7 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; } error[E0080]: constructing invalid value of type &[!]: at .[0], encountered a value of the never type `!` - --> $DIR/raw-bytes.rs:190:1 + --> $DIR/raw-bytes.rs:189:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; | ^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -492,18 +492,18 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; } error[E0080]: constructing invalid value of type &[u8]: at .[0], encountered uninitialized memory, but expected an integer - --> $DIR/raw-bytes.rs:193:1 + --> $DIR/raw-bytes.rs:192:1 | LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 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) { - ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼.... + ╾ALLOC$ID╼ 01 00 00 00 │ ╾──╼.... } error[E0080]: constructing invalid value of type &[u8]: at .[0], encountered a pointer, but expected an integer - --> $DIR/raw-bytes.rs:196:1 + --> $DIR/raw-bytes.rs:195:1 | LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) }; | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -512,44 +512,44 @@ LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem: = 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 │ ╾──╼.... + ╾ALLOC$ID╼ 04 00 00 00 │ ╾──╼.... } error[E0080]: constructing invalid value of type &[bool]: at .[0], encountered 0x11, but expected a boolean - --> $DIR/raw-bytes.rs:199:1 + --> $DIR/raw-bytes.rs:198:1 | LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; | ^^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──╼.... + ╾ALLOC$ID╼ 04 00 00 00 │ ╾──╼.... } error[E0080]: constructing invalid value of type &[u16]: at .[1], encountered uninitialized memory, but expected an integer - --> $DIR/raw-bytes.rs:203:1 + --> $DIR/raw-bytes.rs:202:1 | LL | pub static S7: &[u16] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──╼.... + ╾ALLOC$ID╼ 04 00 00 00 │ ╾──╼.... } error[E0080]: constructing invalid value of type &[u8]: at .[0], encountered uninitialized memory, but expected an integer - --> $DIR/raw-bytes.rs:210:1 + --> $DIR/raw-bytes.rs:209:1 | LL | pub static R4: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──╼.... + ╾ALLOC$ID╼ 01 00 00 00 │ ╾──╼.... } error[E0080]: constructing invalid value of type &[u8]: at .[0], encountered a pointer, but expected an integer - --> $DIR/raw-bytes.rs:215:1 + --> $DIR/raw-bytes.rs:214:1 | LL | pub static R5: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value @@ -558,18 +558,18 @@ LL | pub static R5: &[u8] = unsafe { = 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 │ ╾──╼.... + ╾ALLOC$ID╼ 04 00 00 00 │ ╾──╼.... } error[E0080]: constructing invalid value of type &[bool]: at .[0], encountered 0x11, but expected a boolean - --> $DIR/raw-bytes.rs:220:1 + --> $DIR/raw-bytes.rs:219:1 | LL | pub static R6: &[bool] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^ 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 │ ╾──╼.... + ╾ALLOC$ID╼ 04 00 00 00 │ ╾──╼.... } error: aborting due to 50 previous errors 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 2d2d97da97879..1efd30818b2e5 100644 --- a/tests/ui/consts/const-eval/ub-incorrect-vtable.32bit.stderr +++ b/tests/ui/consts/const-eval/ub-incorrect-vtable.32bit.stderr @@ -1,4 +1,4 @@ -error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC1, but expected a vtable pointer +error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC$ID, but expected a vtable pointer --> $DIR/ub-incorrect-vtable.rs:18:1 | LL | const INVALID_VTABLE_ALIGNMENT: &dyn Trait = @@ -6,10 +6,10 @@ LL | const INVALID_VTABLE_ALIGNMENT: &dyn Trait = | = 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╼ │ ╾──╼╾──╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼ } -error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC3, but expected a vtable pointer +error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC$ID, but expected a vtable pointer --> $DIR/ub-incorrect-vtable.rs:22:1 | LL | const INVALID_VTABLE_SIZE: &dyn Trait = @@ -17,10 +17,10 @@ LL | const INVALID_VTABLE_SIZE: &dyn Trait = | = 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╼ │ ╾──╼╾──╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼ } -error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC5, but expected a vtable pointer +error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID, but expected a vtable pointer --> $DIR/ub-incorrect-vtable.rs:31:1 | LL | const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> = @@ -28,10 +28,10 @@ LL | const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> = | = 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╼ │ ╾──╼╾──╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼ } -error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC7, but expected a vtable pointer +error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID, but expected a vtable pointer --> $DIR/ub-incorrect-vtable.rs:35:1 | LL | const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> = @@ -39,10 +39,10 @@ LL | const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> = | = 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╼ │ ╾──╼╾──╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼ } -error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC9, but expected a vtable pointer +error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID, but expected a vtable pointer --> $DIR/ub-incorrect-vtable.rs:40:1 | LL | const INVALID_VTABLE_UB: W<&dyn Trait> = @@ -50,7 +50,7 @@ LL | const INVALID_VTABLE_UB: W<&dyn Trait> = | = 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╼ │ ╾──╼╾──╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼ } error[E0080]: constructing invalid value of type Wide<'_>: at .1, encountered a dangling reference (going beyond the bounds of its allocation) @@ -61,7 +61,7 @@ LL | const G: Wide = unsafe { Transmute { t: FOO }.u }; | = 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) { - ╾ALLOC10╼ ╾ALLOC11╼ │ ╾──╼╾──╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼ } error: aborting due to 6 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 2e5797c65b35d..e0c3afadd6fca 100644 --- a/tests/ui/consts/const-eval/ub-upvars.32bit.stderr +++ b/tests/ui/consts/const-eval/ub-upvars.32bit.stderr @@ -6,7 +6,7 @@ LL | const BAD_UPVAR: &dyn FnOnce() = &{ | = 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╼ │ ╾──╼╾──╼ + ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼ } error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/union-ub.32bit.stderr b/tests/ui/consts/const-eval/union-ub.32bit.stderr index 95960d1c77dc7..071a6ae99183f 100644 --- a/tests/ui/consts/const-eval/union-ub.32bit.stderr +++ b/tests/ui/consts/const-eval/union-ub.32bit.stderr @@ -9,7 +9,7 @@ LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool }; 2a │ * } -error[E0080]: reading memory at ALLOC0[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory +error[E0080]: reading memory at ALLOC$ID[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory --> $DIR/union-ub.rs:35:36 | LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool }; 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 64a178b6913dc..e43b790fad472 100644 --- a/tests/ui/consts/interior-mut-const-via-union.32bit.stderr +++ b/tests/ui/consts/interior-mut-const-via-union.32bit.stderr @@ -6,7 +6,7 @@ LL | fn main() { | = 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╼ │ ╾──╼ + ╾ALLOC$ID╼ │ ╾──╼ } note: erroneous constant encountered diff --git a/tests/ui/consts/issue-63952.32bit.stderr b/tests/ui/consts/issue-63952.32bit.stderr index eb57a2f2ab5ea..61028b5b426b2 100644 --- a/tests/ui/consts/issue-63952.32bit.stderr +++ b/tests/ui/consts/issue-63952.32bit.stderr @@ -6,7 +6,7 @@ LL | const SLICE_WAY_TOO_LONG: &[u8] = unsafe { | = 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╼ ff ff ff ff │ ╾──╼.... + ╾ALLOC$ID╼ ff ff ff ff │ ╾──╼.... } error: aborting due to 1 previous error 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 ab21696729100..f6061d9f5d794 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 @@ -6,7 +6,7 @@ LL | static REF: &AtomicI32 = &AtomicI32::new(42); | = 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╼ │ ╾──╼ + ╾ALLOC$ID╼ │ ╾──╼ } error[E0080]: constructing invalid value of type &mut i32: encountered mutable reference or box pointing to read-only memory @@ -17,7 +17,7 @@ LL | static REFMUT: &mut i32 = &mut 0; | = 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╼ │ ╾──╼ + ╾ALLOC$ID╼ │ ╾──╼ } error[E0080]: constructing invalid value of type &Atomic: at ..v, encountered `UnsafeCell` in read-only memory @@ -28,7 +28,7 @@ LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}}; | = 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╼ │ ╾──╼ + ╾ALLOC$ID╼ │ ╾──╼ } error[E0080]: constructing invalid value of type &mut i32: encountered mutable reference or box pointing to read-only memory @@ -39,7 +39,7 @@ LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}}; | = 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) { - ╾ALLOC3╼ │ ╾──╼ + ╾ALLOC$ID╼ │ ╾──╼ } error: encountered mutable pointer in final value of static From 8a64598af93f890648208e58559936da107cfd5d Mon Sep 17 00:00:00 2001 From: heinwol Date: Wed, 1 Jul 2026 14:16:59 +0300 Subject: [PATCH 19/21] additional failures normalization --- tests/ui/consts/const_refs_to_static_fail_invalid.rs | 1 + tests/ui/consts/const_transmute_type_id7.rs | 2 ++ tests/ui/consts/dangling-alloc-id-ice.rs | 1 + tests/ui/consts/dangling-zst-ice-issue-126393.rs | 1 + tests/ui/statics/mutable_memory_validation.rs | 1 + 5 files changed, 6 insertions(+) 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 229b9fdcc6027..0db8c059d5392 100644 --- a/tests/ui/consts/const_refs_to_static_fail_invalid.rs +++ b/tests/ui/consts/const_refs_to_static_fail_invalid.rs @@ -1,5 +1,6 @@ //@ 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" +//@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼" //@ dont-require-annotations: NOTE #![allow(static_mut_refs)] diff --git a/tests/ui/consts/const_transmute_type_id7.rs b/tests/ui/consts/const_transmute_type_id7.rs index 6863b88ca2798..1576f00a5af64 100644 --- a/tests/ui/consts/const_transmute_type_id7.rs +++ b/tests/ui/consts/const_transmute_type_id7.rs @@ -5,6 +5,8 @@ //@ normalize-stderr: "\[&\(\); \d\]" -> "ARRAY" //@ 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] |╾─*A(LLOC)?[0-9]+(\+[a-z0-9]+)?()?─*╼ )+ *│.*" -> "HEX_DUMP" +//@ normalize-stderr: "(╾ALLOC\$ID╼ )+" -> "╾ALLOC$$IDs╼" +//@ normalize-stderr: "╾[╼╾─]*╼" -> "╾─╼" #![feature(const_trait_impl, const_cmp)] diff --git a/tests/ui/consts/dangling-alloc-id-ice.rs b/tests/ui/consts/dangling-alloc-id-ice.rs index b77c5971b2bc1..1b10b1d78aa3a 100644 --- a/tests/ui/consts/dangling-alloc-id-ice.rs +++ b/tests/ui/consts/dangling-alloc-id-ice.rs @@ -3,6 +3,7 @@ //@ 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] |╾─*A(LLOC)?[0-9]+(\+[a-z0-9]+)?()?─*╼ )+ *│.*" -> "HEX_DUMP" //@ normalize-stderr: "HEX_DUMP\s*\n\s*HEX_DUMP" -> "HEX_DUMP" +//@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼" union Foo<'a> { y: &'a (), diff --git a/tests/ui/consts/dangling-zst-ice-issue-126393.rs b/tests/ui/consts/dangling-zst-ice-issue-126393.rs index 6b667fdfd35de..52f97e0364b72 100644 --- a/tests/ui/consts/dangling-zst-ice-issue-126393.rs +++ b/tests/ui/consts/dangling-zst-ice-issue-126393.rs @@ -2,6 +2,7 @@ //@ 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] |╾─*A(LLOC)?[0-9]+(\+[a-z0-9]+)?()?─*╼ )+ *│.*" -> "HEX_DUMP" //@ normalize-stderr: "HEX_DUMP\s*\n\s*HEX_DUMP" -> "HEX_DUMP" +//@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼" pub struct Wrapper; pub static MAGIC_FFI_REF: &'static Wrapper = unsafe { diff --git a/tests/ui/statics/mutable_memory_validation.rs b/tests/ui/statics/mutable_memory_validation.rs index bdef949a38bb7..bcc12d34d0994 100644 --- a/tests/ui/statics/mutable_memory_validation.rs +++ b/tests/ui/statics/mutable_memory_validation.rs @@ -3,6 +3,7 @@ // Strip out raw byte dumps to make comparison platform-independent: //@ 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] |╾─*A(LLOC)?[0-9]+(\+[a-z0-9]+)?()?─*╼ )+ *│.*" -> "HEX_DUMP" +//@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼" use std::cell::UnsafeCell; From c7a0991605a2f89e4b96432970ba843dd3c6c494 Mon Sep 17 00:00:00 2001 From: heinwol Date: Wed, 1 Jul 2026 14:23:38 +0300 Subject: [PATCH 20/21] bless from previous --- tests/ui/consts/const_refs_to_static_fail_invalid.stderr | 8 ++++---- tests/ui/consts/const_transmute_type_id7.stderr | 4 ++-- tests/ui/consts/dangling-alloc-id-ice.stderr | 4 ++-- tests/ui/consts/dangling-zst-ice-issue-126393.stderr | 4 ++-- tests/ui/statics/mutable_memory_validation.stderr | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) 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 c355b6efb062f..1bd031f163483 100644 --- a/tests/ui/consts/const_refs_to_static_fail_invalid.stderr +++ b/tests/ui/consts/const_refs_to_static_fail_invalid.stderr @@ -1,16 +1,16 @@ error[E0080]: constructing invalid value of type &bool: at ., encountered 0x0a, but expected a boolean - --> $DIR/const_refs_to_static_fail_invalid.rs:10:5 + --> $DIR/const_refs_to_static_fail_invalid.rs:11:5 | LL | const C: &bool = unsafe { std::mem::transmute(&S) }; | ^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾─╼ } error: constant extern_::C cannot be used as pattern - --> $DIR/const_refs_to_static_fail_invalid.rs:29:9 + --> $DIR/const_refs_to_static_fail_invalid.rs:30:9 | LL | C => {} | ^ @@ -18,7 +18,7 @@ LL | C => {} = note: constants that reference mutable or external memory cannot be used as patterns error: constant mutable::C cannot be used as pattern - --> $DIR/const_refs_to_static_fail_invalid.rs:42:9 + --> $DIR/const_refs_to_static_fail_invalid.rs:43:9 | LL | C => {} | ^ diff --git a/tests/ui/consts/const_transmute_type_id7.stderr b/tests/ui/consts/const_transmute_type_id7.stderr index f4787208f9183..e96dee687afbf 100644 --- a/tests/ui/consts/const_transmute_type_id7.stderr +++ b/tests/ui/consts/const_transmute_type_id7.stderr @@ -1,12 +1,12 @@ error[E0080]: constructing invalid value of type ARRAY: at [0], encountered a maybe-null reference - --> $DIR/const_transmute_type_id7.rs:14:1 + --> $DIR/const_transmute_type_id7.rs:16:1 | LL | const A: [&(); 16 / size_of::<*const ()>()] = unsafe { transmute(TypeId::of::()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ + ╾ALLOC$IDs╼│ ╾─╼ } error: aborting due to 1 previous error diff --git a/tests/ui/consts/dangling-alloc-id-ice.stderr b/tests/ui/consts/dangling-alloc-id-ice.stderr index 729f70092db89..b6166f9b543f2 100644 --- a/tests/ui/consts/dangling-alloc-id-ice.stderr +++ b/tests/ui/consts/dangling-alloc-id-ice.stderr @@ -1,12 +1,12 @@ error[E0080]: constructing invalid value of type &(): encountered a dangling reference (use-after-free) - --> $DIR/dangling-alloc-id-ice.rs:12:1 + --> $DIR/dangling-alloc-id-ice.rs:13:1 | LL | const FOO: &() = { | ^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾─╼ } error: aborting due to 1 previous error diff --git a/tests/ui/consts/dangling-zst-ice-issue-126393.stderr b/tests/ui/consts/dangling-zst-ice-issue-126393.stderr index 0287313415b4c..ba792740bbb89 100644 --- a/tests/ui/consts/dangling-zst-ice-issue-126393.stderr +++ b/tests/ui/consts/dangling-zst-ice-issue-126393.stderr @@ -1,12 +1,12 @@ error[E0080]: constructing invalid value of type &Wrapper: encountered a dangling reference (use-after-free) - --> $DIR/dangling-zst-ice-issue-126393.rs:7:1 + --> $DIR/dangling-zst-ice-issue-126393.rs:8:1 | LL | pub static MAGIC_FFI_REF: &'static Wrapper = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾─╼ } error: aborting due to 1 previous error diff --git a/tests/ui/statics/mutable_memory_validation.stderr b/tests/ui/statics/mutable_memory_validation.stderr index 30aa286808533..de596d04ee522 100644 --- a/tests/ui/statics/mutable_memory_validation.stderr +++ b/tests/ui/statics/mutable_memory_validation.stderr @@ -1,12 +1,12 @@ error[E0080]: constructing invalid value of type Meh: at .x., encountered `UnsafeCell` in read-only memory - --> $DIR/mutable_memory_validation.rs:13:1 + --> $DIR/mutable_memory_validation.rs:14:1 | LL | const MUH: Meh = Meh { x: unsafe { &mut *(&READONLY as *const _ as *mut _) } }; | ^^^^^^^^^^^^^^ 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) { - ╾ALLOC$ID╼ │ ╾──────╼ + ╾ALLOC$ID╼ │ ╾─╼ } error: aborting due to 1 previous error From 92c10f9771fb1f5e05fc3c40a843d62395a53dc2 Mon Sep 17 00:00:00 2001 From: aerooneqq Date: Wed, 1 Jul 2026 15:36:36 +0300 Subject: [PATCH 21/21] Support simplest output `Self` mapping in delegation --- compiler/rustc_ast_lowering/src/delegation.rs | 68 ++- .../src/delegation/generics.rs | 13 +- .../pretty/delegation/self-mapping-output.pp | 44 ++ .../pretty/delegation/self-mapping-output.rs | 33 ++ .../delegation/self-mapping-output-privacy.rs | 28 ++ .../self-mapping-output-privacy.stderr | 15 + tests/ui/delegation/self-mapping-output.rs | 357 +++++++++++++ .../ui/delegation/self-mapping-output.stderr | 468 ++++++++++++++++++ 8 files changed, 1021 insertions(+), 5 deletions(-) create mode 100644 tests/pretty/delegation/self-mapping-output.pp create mode 100644 tests/pretty/delegation/self-mapping-output.rs create mode 100644 tests/ui/delegation/self-mapping-output-privacy.rs create mode 100644 tests/ui/delegation/self-mapping-output-privacy.stderr create mode 100644 tests/ui/delegation/self-mapping-output.rs create mode 100644 tests/ui/delegation/self-mapping-output.stderr diff --git a/compiler/rustc_ast_lowering/src/delegation.rs b/compiler/rustc_ast_lowering/src/delegation.rs index 078ebd6987ae3..2680e7223c1bc 100644 --- a/compiler/rustc_ast_lowering/src/delegation.rs +++ b/compiler/rustc_ast_lowering/src/delegation.rs @@ -53,7 +53,7 @@ use rustc_middle::span_bug; use rustc_middle::ty::{Asyncness, PerOwnerResolverData}; use rustc_span::def_id::{DefId, LocalDefId}; use rustc_span::symbol::kw; -use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol}; +use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol, sym}; use crate::delegation::generics::{GenericsGenerationResult, GenericsGenerationResults}; use crate::diagnostics::{ @@ -661,11 +661,34 @@ impl<'hir> LoweringContext<'_, 'hir> { let callee_path = self.arena.alloc(self.mk_expr(hir::ExprKind::Path(new_path), span)); let args = self.arena.alloc_from_iter(args); - let call = self.arena.alloc(self.mk_expr(hir::ExprKind::Call(callee_path, args), span)); + let call = self.mk_expr(hir::ExprKind::Call(callee_path, args), span); + + let expr = if let Some((parent, of_trait)) = self.should_wrap_return_value(delegation) { + let res = Res::SelfTyAlias { alias_to: parent.to_def_id(), is_trait_impl: of_trait }; + let ident = Ident::new(kw::SelfUpper, span); + let path = self.create_resolved_path(res, ident, span); + + // FIXME(fn_delegation): add default `..` for all other fields. + let initializer = hir::ExprKind::Struct( + self.arena.alloc(path), + self.arena.alloc_slice(&[hir::ExprField { + hir_id: self.next_id(), + is_shorthand: false, + ident: Ident::new(sym::integer(0), span), + expr: self.arena.alloc(call), + span, + }]), + hir::StructTailExpr::None, + ); + + self.arena.alloc(self.mk_expr(initializer, span)) + } else { + self.arena.alloc(call) + }; let block = self.arena.alloc(hir::Block { stmts, - expr: Some(call), + expr: Some(expr), hir_id: self.next_id(), rules: hir::BlockCheckMode::DefaultBlock, span, @@ -675,6 +698,45 @@ impl<'hir> LoweringContext<'_, 'hir> { (self.mk_expr(hir::ExprKind::Block(block, None), span), call.hir_id) } + fn should_wrap_return_value(&self, delegation: &Delegation) -> Option<(LocalDefId, bool)> { + // Heuristic: don't do wrapping if there is no target expression. + if delegation.body.is_none() { + return None; + } + + let tcx = self.tcx; + let parent = tcx.local_parent(self.owner.def_id); + let parent_kind = tcx.def_kind(parent); + + // Apply wrapping for delegations inside + // 1) Trait impls, as the return type of both signature function + // and generated delegation has `Self` generic param returned + // (checked below). + // FIXME(fn_delegation): think of enabling wrapping in more scenarios: + // trait-(impl)-to-free + // trait-(impl)-to-inherent + // inherent-to-free + // 2) Inherent methods when delegating to trait, as we change the type of + // `Self` to type of struct or enum we delegate from. + if !matches!(tcx.def_kind(parent), DefKind::Impl { .. }) { + return None; + } + + let is_trait_impl = parent_kind == DefKind::Impl { of_trait: true }; + + // Check that delegation path resolves to a trait AssocFn, not to a free method. + Some((parent, is_trait_impl)).filter(|_| { + self.get_resolution_id(delegation.id).is_some_and(|id| { + tcx.def_kind(id) == DefKind::AssocFn + // Check that the return type of the callee is `Self` param. + // After previous check we are sure that `sig_id` and `delegation.id` + // point to the same function. + && tcx.def_kind(tcx.parent(id)) == DefKind::Trait + && tcx.fn_sig(id).skip_binder().output().skip_binder().is_param(0) + }) + }) + } + fn process_segment( &mut self, span: Span, diff --git a/compiler/rustc_ast_lowering/src/delegation/generics.rs b/compiler/rustc_ast_lowering/src/delegation/generics.rs index 79a3961c22a53..41e66ddc5e993 100644 --- a/compiler/rustc_ast_lowering/src/delegation/generics.rs +++ b/compiler/rustc_ast_lowering/src/delegation/generics.rs @@ -581,18 +581,27 @@ impl<'hir> LoweringContext<'_, 'hir> { p.def_id.to_def_id(), ); + self.create_resolved_path(res, p.name.ident(), p.span) + } + + pub(super) fn create_resolved_path( + &mut self, + res: Res, + ident: Ident, + span: Span, + ) -> hir::QPath<'hir> { hir::QPath::Resolved( None, self.arena.alloc(hir::Path { segments: self.arena.alloc_slice(&[hir::PathSegment { args: None, hir_id: self.next_id(), - ident: p.name.ident(), + ident, infer_args: false, res, }]), res, - span: p.span, + span, }), ) } diff --git a/tests/pretty/delegation/self-mapping-output.pp b/tests/pretty/delegation/self-mapping-output.pp new file mode 100644 index 0000000000000..84e98d6e97b06 --- /dev/null +++ b/tests/pretty/delegation/self-mapping-output.pp @@ -0,0 +1,44 @@ +#![attr = Feature([fn_delegation#0])] +extern crate std; +#[attr = PreludeImport] +use ::std::prelude::rust_2015::*; +//@ pretty-compare-only +//@ pretty-mode:hir +//@ pp-exact:self-mapping-output.pp + + +trait Trait { + fn method(&self) + -> Self; + fn r#static() + -> Self; + fn raw_S(&self) -> S { S } +} + +struct S; +impl Trait for S { + fn method(&self) -> S { S } + fn r#static() -> S { S } +} + +struct W(S); +impl Trait for W { + #[attr = Inline(Hint)] + fn method(self: _) -> _ { Self { 0: Trait::method(self.0) } } + #[attr = Inline(Hint)] + fn r#static() -> _ { Trait::r#static() } + //~^ WARN: function cannot return without recursing [unconditional_recursion] + #[attr = Inline(Hint)] + fn raw_S(self: _) -> _ { Trait::raw_S(self.0) } +} + +impl W { + #[attr = Inline(Hint)] + fn method(self: _) -> _ { Self { 0: Trait::method(self.0) } } + #[attr = Inline(Hint)] + fn r#static() -> _ { Trait::r#static() } + #[attr = Inline(Hint)] + fn raw_S(self: _) -> _ { Trait::raw_S(self.0) } +} + +fn main() { } diff --git a/tests/pretty/delegation/self-mapping-output.rs b/tests/pretty/delegation/self-mapping-output.rs new file mode 100644 index 0000000000000..11699d710e081 --- /dev/null +++ b/tests/pretty/delegation/self-mapping-output.rs @@ -0,0 +1,33 @@ +//@ pretty-compare-only +//@ pretty-mode:hir +//@ pp-exact:self-mapping-output.pp + +#![feature(fn_delegation)] + +trait Trait { + fn method(&self) -> Self; + fn r#static() -> Self; + fn raw_S(&self) -> S { S } +} + +struct S; +impl Trait for S { + fn method(&self) -> S { S } + fn r#static() -> S { S } +} + +struct W(S); +impl Trait for W { + reuse Trait::method { self.0 } + reuse Trait::r#static; + //~^ WARN: function cannot return without recursing [unconditional_recursion] + reuse Trait::raw_S { self.0 } +} + +impl W { + reuse Trait::method { self.0 } + reuse Trait::r#static; + reuse Trait::raw_S { self.0 } +} + +fn main() {} diff --git a/tests/ui/delegation/self-mapping-output-privacy.rs b/tests/ui/delegation/self-mapping-output-privacy.rs new file mode 100644 index 0000000000000..f072d240608f8 --- /dev/null +++ b/tests/ui/delegation/self-mapping-output-privacy.rs @@ -0,0 +1,28 @@ +#![feature(fn_delegation)] + +trait Trait { + fn method(&self) -> Self; +} + +pub struct S; +impl Trait for S { + fn method(&self) -> S { + S + } +} + +mod private { + pub struct W(super::S); +} + +impl Trait for private::W { + reuse Trait::method { S } + //~^ ERROR: field `0` of struct `W` is private +} + +impl private::W { + reuse Trait::method { S } + //~^ ERROR: field `0` of struct `W` is private +} + +fn main() {} diff --git a/tests/ui/delegation/self-mapping-output-privacy.stderr b/tests/ui/delegation/self-mapping-output-privacy.stderr new file mode 100644 index 0000000000000..38f6b1a4a9ddf --- /dev/null +++ b/tests/ui/delegation/self-mapping-output-privacy.stderr @@ -0,0 +1,15 @@ +error[E0451]: field `0` of struct `W` is private + --> $DIR/self-mapping-output-privacy.rs:19:18 + | +LL | reuse Trait::method { S } + | ^^^^^^ private field + +error[E0451]: field `0` of struct `W` is private + --> $DIR/self-mapping-output-privacy.rs:24:18 + | +LL | reuse Trait::method { S } + | ^^^^^^ private field + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0451`. diff --git a/tests/ui/delegation/self-mapping-output.rs b/tests/ui/delegation/self-mapping-output.rs new file mode 100644 index 0000000000000..47b122b0accda --- /dev/null +++ b/tests/ui/delegation/self-mapping-output.rs @@ -0,0 +1,357 @@ +#![feature(fn_delegation)] + +mod success { + trait Trait { + fn method(&self) -> Self; + fn r#static() -> Self; + fn raw_S(&self) -> S { S } + } + + struct S; + impl Trait for S { + fn method(&self) -> S { S } + fn r#static() -> S { S } + } + + struct W(S); + impl Trait for W { + reuse Trait::method { self.0 } + reuse Trait::r#static; + //~^ WARN: function cannot return without recursing [unconditional_recursion] + reuse Trait::raw_S { self.0 } + } + + impl W { + reuse Trait::method { self.0 } + reuse Trait::r#static; + reuse Trait::raw_S { self.0 } + } +} + +mod success_non_field { + trait Trait { + fn method(&self) -> Self; + fn r#static() -> Self; + fn raw_S(&self) -> S { S } + } + + struct S; + impl Trait for S { + fn method(&self) -> S { S } + fn r#static() -> S { S } + } + + struct W(S); + impl Trait for W { + reuse Trait::method { S } + reuse Trait::r#static; + //~^ WARN: function cannot return without recursing [unconditional_recursion] + reuse Trait::raw_S { S } + } + + impl W { + reuse Trait::method { S } + reuse Trait::r#static; + reuse Trait::raw_S { S } + } +} + +mod success_generics { + trait Trait<'a, T, const N: usize> { + fn method(&self) -> Self; + fn r#static() -> Self; + fn raw_S(&self) -> S<'a, 'static, T, (), N, 123> { + S::<'a, 'static, T, (), N, 123>(std::marker::PhantomData) + } + } + + struct S<'a, 'b, A, B, const N: usize, const M: usize>( + std::marker::PhantomData<&'a &'b (A, B, &'a [(); N], &'b [(); M])> + ); + + impl<'a, T, const N: usize> Trait<'a, T, N> for S<'a, 'static, T, (), N, 123> { + fn method(&self) -> S<'a, 'static, T, (), N, 123> { + S(std::marker::PhantomData) + } + + fn r#static() -> S<'a, 'static, T, (), N, 123> { S(std::marker::PhantomData) } + } + + struct W<'a, 'b, A, B, const N: usize, const M: usize>(S<'a, 'b, A, B, N, M>); + impl<'a, T, const N: usize> Trait<'a, T, N> for W<'a, 'static, T, (), N, 123> { + reuse Trait::<'a, T, N>::method { self.0 } + reuse Trait::<'a, T, N>::r#static; + //~^ WARN: function cannot return without recursing [unconditional_recursion] + reuse Trait::<'a, T, N>::raw_S { self.0 } + } + + impl<'a, T, const N: usize> W<'a, 'static, T, (), N, 123> { + reuse Trait::<'a, T, N>::method { self.0 } + reuse Trait::<'a, T, N>::r#static; + reuse Trait::<'a, T, N>::raw_S { self.0 } + } +} + +mod no_constructor { + trait Trait { + fn method(&self) -> Self; + fn r#static() -> Self; + fn raw_S(&self) -> S { S } + } + + struct S; + impl Trait for S { + fn method(&self) -> S { S } + fn r#static() -> S { S } + } + + struct W { s: S } + impl Trait for W { + reuse Trait::method { self.0 } + //~^ ERROR: no field `0` on type `&no_constructor::W` + //~| ERROR: struct `no_constructor::W` has no field named `0` + reuse Trait::r#static; + //~^ WARN: function cannot return without recursing [unconditional_recursion] + reuse Trait::raw_S { self.0 } + //~^ ERROR: no field `0` on type `&no_constructor::W` + } + + impl W { + reuse Trait::method { self.0 } + //~^ ERROR: no field `0` on type `&no_constructor::W` + //~| ERROR: struct `no_constructor::W` has no field named `0` + reuse Trait::r#static; + reuse Trait::raw_S { self.0 } + //~^ ERROR: no field `0` on type `&no_constructor::W` + } +} + +mod more_than_one_field { + trait Trait { + fn method(&self) -> Self; + fn r#static() -> Self; + fn raw_S(&self) -> S { S } + } + + struct S; + impl Trait for S { + fn method(&self) -> S { S } + fn r#static() -> S { S } + } + + struct W(S, S, S); + impl Trait for W { + reuse Trait::method { self.0 } + //~^ ERROR: missing fields `1` and `2` in initializer of `more_than_one_field::W` + reuse Trait::r#static; + //~^ WARN: function cannot return without recursing [unconditional_recursion] + reuse Trait::raw_S { self.0 } + } + + impl W { + reuse Trait::method { self.0 } + //~^ ERROR: missing fields `1` and `2` in initializer of `more_than_one_field::W` + reuse Trait::r#static; + reuse Trait::raw_S { self.0 } + } +} + +mod non_trait_path_reuse { + trait Trait { + fn method(&self) -> Self; + fn r#static() -> Self; + fn raw_S(&self) -> S { S } + } + + mod to_reuse { + pub fn method(_: impl super::Trait) -> impl super::Trait { + super::S + } + + pub fn r#static() -> impl super::Trait { + super::S + } + } + + pub struct S; + impl Trait for S { + fn method(&self) -> S { S } + fn r#static() -> S { S } + } + + struct W(S); + impl Trait for W { + reuse to_reuse::method { self.0 } + //~^ ERROR: mismatched types + reuse to_reuse::r#static; + //~^ ERROR: mismatched types + } + + impl W { + reuse to_reuse::method { self.0 } + //~^ ERROR: no field `0` on type `impl super::Trait` + reuse to_reuse::r#static; + } +} + +mod non_Self_return_type { + trait Trait { + fn method(&self) -> (); + fn r#static() -> (); + fn raw_S(&self) -> S { S } + } + + struct S; + impl Trait for S { + fn method(&self) -> () { () } + fn r#static() -> () { () } + fn raw_S(&self) -> S { S } + } + + struct W(()); + impl Trait for W { + reuse Trait::method { self.0 } + //~^ ERROR: mismatched types + + reuse Trait::r#static; + //~^ ERROR: type annotations needed + + reuse Trait::raw_S { self.0 } + //~^ ERROR: mismatched types + } + + impl W { + reuse Trait::method { self.0 } + //~^ ERROR: mismatched types + + reuse Trait::r#static; + //~^ ERROR: type annotations needed + + reuse Trait::raw_S { self.0 } + //~^ ERROR: mismatched types + } +} + +mod wrong_return_type { + trait Trait { + fn method(&self) -> Self; + fn r#static() -> Self; + fn raw_S(&self) -> S { S } + } + + struct F; + impl Trait for F { + fn method(&self) -> F { F } + fn r#static() -> F { F } + } + + struct S; + impl Trait for S { + fn method(&self) -> S { S } + fn r#static() -> S { S } + } + + struct W(S); + impl Trait for W { + reuse ::method { self.0 } + //~^ ERROR: mismatched types + //~| ERROR: mismatched types + + reuse ::r#static; + //~^ ERROR: mismatched types + + reuse ::raw_S { self.0 } + //~^ ERROR: mismatched types + } + + impl W { + reuse ::method { self.0 } + //~^ ERROR: mismatched types + //~| ERROR: mismatched types + + reuse ::r#static; + //~^ ERROR: mismatched types + + reuse ::raw_S { self.0 } + //~^ ERROR: mismatched types + } +} + +mod wrong_target_expression { + trait Trait { + fn method(&self) -> Self; + fn r#static() -> Self; + fn raw_S(&self) -> S { S } + } + + struct S; + impl Trait for S { + fn method(&self) -> S { S } + fn r#static() -> S { S } + } + + struct F; + impl Trait for F { + fn method(&self) -> F { F } + fn r#static() -> F { F } + } + + struct W(S); + impl Trait for W { + reuse Trait::method { F } + //~^ ERROR: mismatched types + + reuse Trait::r#static; + //~^ WARN: function cannot return without recursing [unconditional_recursion] + reuse Trait::raw_S { F } + } + + impl W { + reuse Trait::method { F } + //~^ ERROR: mismatched types + + reuse Trait::r#static; + reuse Trait::raw_S { F } + } +} + +mod privacy { + trait Trait { + fn method(&self) -> Self; + fn r#static() -> Self; + fn raw_S(&self) -> S { S } + } + + pub struct S; + impl Trait for S { + fn method(&self) -> S { S } + fn r#static() -> S { S } + } + + mod private { + pub struct W(super::S); + } + + impl Trait for private::W { + reuse Trait::method { self.0 } + //~^ ERROR: field `0` of struct `private::W` is private + + reuse Trait::r#static; + //~^ WARN: function cannot return without recursing [unconditional_recursion] + + reuse Trait::raw_S { self.0 } + //~^ ERROR: field `0` of struct `private::W` is private + } + + impl private::W { + reuse Trait::method { self.0 } + //~^ ERROR: field `0` of struct `private::W` is private + + reuse Trait::r#static; + + reuse Trait::raw_S { self.0 } + //~^ ERROR: field `0` of struct `private::W` is private + } +} + +fn main() {} diff --git a/tests/ui/delegation/self-mapping-output.stderr b/tests/ui/delegation/self-mapping-output.stderr new file mode 100644 index 0000000000000..86ce822a1821c --- /dev/null +++ b/tests/ui/delegation/self-mapping-output.stderr @@ -0,0 +1,468 @@ +error[E0560]: struct `no_constructor::W` has no field named `0` + --> $DIR/self-mapping-output.rs:110:22 + | +LL | reuse Trait::method { self.0 } + | ^^^^^^ unknown field + | +help: a field with a similar name exists + | +LL - reuse Trait::method { self.0 } +LL + reuse Trait::s { self.0 } + | + +error[E0609]: no field `0` on type `&no_constructor::W` + --> $DIR/self-mapping-output.rs:110:36 + | +LL | reuse Trait::method { self.0 } + | ^ unknown field + | +help: a field with a similar name exists + | +LL - reuse Trait::method { self.0 } +LL + reuse Trait::method { self.s } + | + +error[E0609]: no field `0` on type `&no_constructor::W` + --> $DIR/self-mapping-output.rs:115:35 + | +LL | reuse Trait::raw_S { self.0 } + | ^ unknown field + | +help: a field with a similar name exists + | +LL - reuse Trait::raw_S { self.0 } +LL + reuse Trait::raw_S { self.s } + | + +error[E0560]: struct `no_constructor::W` has no field named `0` + --> $DIR/self-mapping-output.rs:120:22 + | +LL | reuse Trait::method { self.0 } + | ^^^^^^ unknown field + | +help: a field with a similar name exists + | +LL - reuse Trait::method { self.0 } +LL + reuse Trait::s { self.0 } + | + +error[E0609]: no field `0` on type `&no_constructor::W` + --> $DIR/self-mapping-output.rs:120:36 + | +LL | reuse Trait::method { self.0 } + | ^ unknown field + | +help: a field with a similar name exists + | +LL - reuse Trait::method { self.0 } +LL + reuse Trait::method { self.s } + | + +error[E0609]: no field `0` on type `&no_constructor::W` + --> $DIR/self-mapping-output.rs:124:35 + | +LL | reuse Trait::raw_S { self.0 } + | ^ unknown field + | +help: a field with a similar name exists + | +LL - reuse Trait::raw_S { self.0 } +LL + reuse Trait::raw_S { self.s } + | + +error[E0063]: missing fields `1` and `2` in initializer of `more_than_one_field::W` + --> $DIR/self-mapping-output.rs:144:22 + | +LL | reuse Trait::method { self.0 } + | ^^^^^^ missing `1` and `2` + +error[E0063]: missing fields `1` and `2` in initializer of `more_than_one_field::W` + --> $DIR/self-mapping-output.rs:152:22 + | +LL | reuse Trait::method { self.0 } + | ^^^^^^ missing `1` and `2` + +error[E0308]: mismatched types + --> $DIR/self-mapping-output.rs:184:25 + | +LL | pub fn method(_: impl super::Trait) -> impl super::Trait { + | ----------------- the found opaque type +... +LL | reuse to_reuse::method { self.0 } + | ^^^^^^ + | | + | expected `W`, found opaque type + | expected `non_trait_path_reuse::W` because of return type + | + = note: expected struct `non_trait_path_reuse::W` + found opaque type `impl non_trait_path_reuse::Trait` + +error[E0308]: mismatched types + --> $DIR/self-mapping-output.rs:186:25 + | +LL | pub fn r#static() -> impl super::Trait { + | ----------------- the found opaque type +... +LL | reuse to_reuse::r#static; + | ^^^^^^^^ + | | + | expected `W`, found opaque type + | expected `non_trait_path_reuse::W` because of return type + | + = note: expected struct `non_trait_path_reuse::W` + found opaque type `impl non_trait_path_reuse::Trait` + +error[E0609]: no field `0` on type `impl super::Trait` + --> $DIR/self-mapping-output.rs:191:39 + | +LL | reuse to_reuse::method { self.0 } + | ^ unknown field + +error[E0308]: mismatched types + --> $DIR/self-mapping-output.rs:213:31 + | +LL | reuse Trait::method { self.0 } + | ------ ^^^^^^ expected `&_`, found `()` + | | + | arguments to this function are incorrect + | + = note: expected reference `&_` + found unit type `()` +note: method defined here + --> $DIR/self-mapping-output.rs:199:12 + | +LL | fn method(&self) -> (); + | ^^^^^^ ---- +help: consider borrowing here + | +LL | reuse Trait::method { &self.0 } + | + + +error[E0283]: type annotations needed + --> $DIR/self-mapping-output.rs:216:22 + | +LL | reuse Trait::r#static; + | ^^^^^^^^ cannot infer type + | + = note: the type must implement `non_Self_return_type::Trait` +help: the following types implement trait `non_Self_return_type::Trait` + --> $DIR/self-mapping-output.rs:205:5 + | +LL | impl Trait for S { + | ^^^^^^^^^^^^^^^^ `non_Self_return_type::S` +... +LL | impl Trait for W { + | ^^^^^^^^^^^^^^^^ `non_Self_return_type::W` + +error[E0308]: mismatched types + --> $DIR/self-mapping-output.rs:219:30 + | +LL | reuse Trait::raw_S { self.0 } + | ----- ^^^^^^ expected `&_`, found `()` + | | + | arguments to this function are incorrect + | + = note: expected reference `&_` + found unit type `()` +note: method defined here + --> $DIR/self-mapping-output.rs:201:12 + | +LL | fn raw_S(&self) -> S { S } + | ^^^^^ ----- +help: consider borrowing here + | +LL | reuse Trait::raw_S { &self.0 } + | + + +error[E0308]: mismatched types + --> $DIR/self-mapping-output.rs:224:31 + | +LL | reuse Trait::method { self.0 } + | ------ ^^^^^^ expected `&_`, found `()` + | | + | arguments to this function are incorrect + | + = note: expected reference `&_` + found unit type `()` +note: method defined here + --> $DIR/self-mapping-output.rs:199:12 + | +LL | fn method(&self) -> (); + | ^^^^^^ ---- +help: consider borrowing here + | +LL | reuse Trait::method { &self.0 } + | + + +error[E0283]: type annotations needed + --> $DIR/self-mapping-output.rs:227:22 + | +LL | reuse Trait::r#static; + | ^^^^^^^^ cannot infer type + | + = note: the type must implement `non_Self_return_type::Trait` +help: the following types implement trait `non_Self_return_type::Trait` + --> $DIR/self-mapping-output.rs:205:5 + | +LL | impl Trait for S { + | ^^^^^^^^^^^^^^^^ `non_Self_return_type::S` +... +LL | impl Trait for W { + | ^^^^^^^^^^^^^^^^ `non_Self_return_type::W` + +error[E0308]: mismatched types + --> $DIR/self-mapping-output.rs:230:30 + | +LL | reuse Trait::raw_S { self.0 } + | ----- ^^^^^^ expected `&_`, found `()` + | | + | arguments to this function are incorrect + | + = note: expected reference `&_` + found unit type `()` +note: method defined here + --> $DIR/self-mapping-output.rs:201:12 + | +LL | fn raw_S(&self) -> S { S } + | ^^^^^ ----- +help: consider borrowing here + | +LL | reuse Trait::raw_S { &self.0 } + | + + +error[E0308]: mismatched types + --> $DIR/self-mapping-output.rs:256:38 + | +LL | reuse ::method { self.0 } + | ------ ^^^^^^ expected `&F`, found `&S` + | | + | arguments to this function are incorrect + | this return type influences the call expression's return type + | + = note: expected reference `&wrong_return_type::F` + found reference `&wrong_return_type::S` +note: method defined here + --> $DIR/self-mapping-output.rs:237:12 + | +LL | fn method(&self) -> Self; + | ^^^^^^ ---- + +error[E0308]: mismatched types + --> $DIR/self-mapping-output.rs:256:29 + | +LL | reuse ::method { self.0 } + | ^^^^^^ expected `S`, found `F` + +error[E0308]: mismatched types + --> $DIR/self-mapping-output.rs:260:29 + | +LL | reuse ::r#static; + | ^^^^^^^^ + | | + | expected `W`, found `F` + | expected `wrong_return_type::W` because of return type + +error[E0308]: mismatched types + --> $DIR/self-mapping-output.rs:263:37 + | +LL | reuse ::raw_S { self.0 } + | ----- ^^^^^^ expected `&F`, found `&S` + | | + | arguments to this function are incorrect + | + = note: expected reference `&wrong_return_type::F` + found reference `&wrong_return_type::S` +note: method defined here + --> $DIR/self-mapping-output.rs:239:12 + | +LL | fn raw_S(&self) -> S { S } + | ^^^^^ ----- + +error[E0308]: mismatched types + --> $DIR/self-mapping-output.rs:268:38 + | +LL | reuse ::method { self.0 } + | ------ ^^^^^^ expected `&F`, found `&S` + | | + | arguments to this function are incorrect + | this return type influences the call expression's return type + | + = note: expected reference `&wrong_return_type::F` + found reference `&wrong_return_type::S` +note: method defined here + --> $DIR/self-mapping-output.rs:237:12 + | +LL | fn method(&self) -> Self; + | ^^^^^^ ---- + +error[E0308]: mismatched types + --> $DIR/self-mapping-output.rs:268:29 + | +LL | reuse ::method { self.0 } + | ^^^^^^ expected `S`, found `F` + +error[E0308]: mismatched types + --> $DIR/self-mapping-output.rs:272:29 + | +LL | reuse ::r#static; + | ^^^^^^^^ + | | + | expected `W`, found `F` + | expected `wrong_return_type::W` because of return type + +error[E0308]: mismatched types + --> $DIR/self-mapping-output.rs:275:37 + | +LL | reuse ::raw_S { self.0 } + | ----- ^^^^^^ expected `&F`, found `&S` + | | + | arguments to this function are incorrect + | + = note: expected reference `&wrong_return_type::F` + found reference `&wrong_return_type::S` +note: method defined here + --> $DIR/self-mapping-output.rs:239:12 + | +LL | fn raw_S(&self) -> S { S } + | ^^^^^ ----- + +error[E0308]: mismatched types + --> $DIR/self-mapping-output.rs:301:31 + | +LL | reuse Trait::method { F } + | ------ ^ expected `&S`, found `&F` + | | + | arguments to this function are incorrect + | this return type influences the call expression's return type + | + = note: expected reference `&wrong_target_expression::S` + found reference `&wrong_target_expression::F` +note: method defined here + --> $DIR/self-mapping-output.rs:282:12 + | +LL | fn method(&self) -> Self; + | ^^^^^^ ---- + +error[E0308]: mismatched types + --> $DIR/self-mapping-output.rs:310:31 + | +LL | reuse Trait::method { F } + | ------ ^ expected `&S`, found `&F` + | | + | arguments to this function are incorrect + | this return type influences the call expression's return type + | + = note: expected reference `&wrong_target_expression::S` + found reference `&wrong_target_expression::F` +note: method defined here + --> $DIR/self-mapping-output.rs:282:12 + | +LL | fn method(&self) -> Self; + | ^^^^^^ ---- + +error[E0616]: field `0` of struct `private::W` is private + --> $DIR/self-mapping-output.rs:336:36 + | +LL | reuse Trait::method { self.0 } + | ^ private field + +error[E0616]: field `0` of struct `private::W` is private + --> $DIR/self-mapping-output.rs:342:35 + | +LL | reuse Trait::raw_S { self.0 } + | ^ private field + +error[E0616]: field `0` of struct `private::W` is private + --> $DIR/self-mapping-output.rs:347:36 + | +LL | reuse Trait::method { self.0 } + | ^ private field + +error[E0616]: field `0` of struct `private::W` is private + --> $DIR/self-mapping-output.rs:352:35 + | +LL | reuse Trait::raw_S { self.0 } + | ^ private field + +warning: function cannot return without recursing + --> $DIR/self-mapping-output.rs:19:22 + | +LL | reuse Trait::r#static; + | ^^^^^^^^ + | | + | cannot return without recursing + | recursive call site + | + = help: a `loop` may express intention better if this is on purpose + = note: `#[warn(unconditional_recursion)]` on by default + +warning: function cannot return without recursing + --> $DIR/self-mapping-output.rs:47:22 + | +LL | reuse Trait::r#static; + | ^^^^^^^^ + | | + | cannot return without recursing + | recursive call site + | + = help: a `loop` may express intention better if this is on purpose + +warning: function cannot return without recursing + --> $DIR/self-mapping-output.rs:83:34 + | +LL | reuse Trait::<'a, T, N>::r#static; + | ^^^^^^^^ + | | + | cannot return without recursing + | recursive call site + | + = help: a `loop` may express intention better if this is on purpose + +warning: function cannot return without recursing + --> $DIR/self-mapping-output.rs:113:22 + | +LL | reuse Trait::r#static; + | ^^^^^^^^ + | | + | cannot return without recursing + | recursive call site + | + = help: a `loop` may express intention better if this is on purpose + +warning: function cannot return without recursing + --> $DIR/self-mapping-output.rs:146:22 + | +LL | reuse Trait::r#static; + | ^^^^^^^^ + | | + | cannot return without recursing + | recursive call site + | + = help: a `loop` may express intention better if this is on purpose + +warning: function cannot return without recursing + --> $DIR/self-mapping-output.rs:304:22 + | +LL | reuse Trait::r#static; + | ^^^^^^^^ + | | + | cannot return without recursing + | recursive call site + | + = help: a `loop` may express intention better if this is on purpose + +warning: function cannot return without recursing + --> $DIR/self-mapping-output.rs:339:22 + | +LL | reuse Trait::r#static; + | ^^^^^^^^ + | | + | cannot return without recursing + | recursive call site + | + = help: a `loop` may express intention better if this is on purpose + +error: aborting due to 31 previous errors; 7 warnings emitted + +Some errors have detailed explanations: E0063, E0283, E0308, E0560, E0609, E0616. +For more information about an error, try `rustc --explain E0063`.