authorbors <bors@rust-lang.org> 2026-07-01 15:45:33 UTC
committerbors <bors@rust-lang.org> 2026-07-01 15:45:33 UTC
log4c9d2bfe4ad7a65669098754964aaebe0ec1ced2
tree64dafb7cf04f533b29d8b938bc2156cdc6469c9e
parente2b71ade2db4ea263ab0d561d889f3e3795a500d
parentddf0d0fd0bc5136f2778b9877e426ef6138cb704

Auto merge of #158663 - JonathanBrouwer:rollup-vypSRyC, r=JonathanBrouwer

Rollup of 8 pull requests Successful merges: - rust-lang/rust#158294 (Use .drectve for MSVC DLL exports) - rust-lang/rust#156716 (tests: fix: parallel frontend test failures: different alloc ids) - rust-lang/rust#158397 (delegation: support simplest output `Self` mapping) - rust-lang/rust#158613 (Fix getrandom fallback test on platforms with `panic=abort`) - rust-lang/rust#158620 (Remove skip_norm_w/i/p().def_id with a helper) - rust-lang/rust#158633 (Remove unnecessary `Clone` derives on resolver types) - rust-lang/rust#158634 (Add missing `needs_drop` check to `DroplessArena`.) - rust-lang/rust#158647 (Document `strip_circumfix` behavior on overlapping prefix and suffix.)

132 files changed, 1818 insertions(+), 678 deletions(-)

compiler/rustc_arena/src/lib.rs+4-2
......@@ -542,11 +542,12 @@ impl DroplessArena {
542542
543543 #[inline]
544544 pub fn alloc_from_iter<T, I: IntoIterator<Item = T>>(&self, iter: I) -> &mut [T] {
545 assert!(!mem::needs_drop::<T>());
546 assert!(size_of::<T>() != 0);
547
545548 // Warning: this function is reentrant: `iter` could hold a reference to `&self` and
546549 // allocate additional elements while we're iterating.
547550 let iter = iter.into_iter();
548 assert!(size_of::<T>() != 0);
549 assert!(!mem::needs_drop::<T>());
550551
551552 let size_hint = iter.size_hint();
552553
......@@ -577,6 +578,7 @@ impl DroplessArena {
577578 ) -> Result<&mut [T], E> {
578579 // Despite the similarity with `alloc_from_iter`, we cannot reuse their fast case, as we
579580 // cannot know the minimum length of the iterator in this case.
581 assert!(!mem::needs_drop::<T>());
580582 assert!(size_of::<T>() != 0);
581583
582584 // Takes care of reentrancy.
compiler/rustc_ast_lowering/src/delegation.rs+65-3
......@@ -53,7 +53,7 @@ use rustc_middle::span_bug;
5353use rustc_middle::ty::{Asyncness, PerOwnerResolverData};
5454use rustc_span::def_id::{DefId, LocalDefId};
5555use rustc_span::symbol::kw;
56use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol};
56use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol, sym};
5757
5858use crate::delegation::generics::{
5959 GenericsGenerationResult, GenericsGenerationResults, GenericsPosition,
......@@ -664,11 +664,34 @@ impl<'hir> LoweringContext<'_, 'hir> {
664664
665665 let callee_path = self.arena.alloc(self.mk_expr(hir::ExprKind::Path(new_path), span));
666666 let args = self.arena.alloc_from_iter(args);
667 let call = self.arena.alloc(self.mk_expr(hir::ExprKind::Call(callee_path, args), span));
667 let call = self.mk_expr(hir::ExprKind::Call(callee_path, args), span);
668
669 let expr = if let Some((parent, of_trait)) = self.should_wrap_return_value(delegation) {
670 let res = Res::SelfTyAlias { alias_to: parent.to_def_id(), is_trait_impl: of_trait };
671 let ident = Ident::new(kw::SelfUpper, span);
672 let path = self.create_resolved_path(res, ident, span);
673
674 // FIXME(fn_delegation): add default `..` for all other fields.
675 let initializer = hir::ExprKind::Struct(
676 self.arena.alloc(path),
677 self.arena.alloc_slice(&[hir::ExprField {
678 hir_id: self.next_id(),
679 is_shorthand: false,
680 ident: Ident::new(sym::integer(0), span),
681 expr: self.arena.alloc(call),
682 span,
683 }]),
684 hir::StructTailExpr::None,
685 );
686
687 self.arena.alloc(self.mk_expr(initializer, span))
688 } else {
689 self.arena.alloc(call)
690 };
668691
669692 let block = self.arena.alloc(hir::Block {
670693 stmts,
671 expr: Some(call),
694 expr: Some(expr),
672695 hir_id: self.next_id(),
673696 rules: hir::BlockCheckMode::DefaultBlock,
674697 span,
......@@ -678,6 +701,45 @@ impl<'hir> LoweringContext<'_, 'hir> {
678701 (self.mk_expr(hir::ExprKind::Block(block, None), span), call.hir_id)
679702 }
680703
704 fn should_wrap_return_value(&self, delegation: &Delegation) -> Option<(LocalDefId, bool)> {
705 // Heuristic: don't do wrapping if there is no target expression.
706 if delegation.body.is_none() {
707 return None;
708 }
709
710 let tcx = self.tcx;
711 let parent = tcx.local_parent(self.owner.def_id);
712 let parent_kind = tcx.def_kind(parent);
713
714 // Apply wrapping for delegations inside
715 // 1) Trait impls, as the return type of both signature function
716 // and generated delegation has `Self` generic param returned
717 // (checked below).
718 // FIXME(fn_delegation): think of enabling wrapping in more scenarios:
719 // trait-(impl)-to-free
720 // trait-(impl)-to-inherent
721 // inherent-to-free
722 // 2) Inherent methods when delegating to trait, as we change the type of
723 // `Self` to type of struct or enum we delegate from.
724 if !matches!(tcx.def_kind(parent), DefKind::Impl { .. }) {
725 return None;
726 }
727
728 let is_trait_impl = parent_kind == DefKind::Impl { of_trait: true };
729
730 // Check that delegation path resolves to a trait AssocFn, not to a free method.
731 Some((parent, is_trait_impl)).filter(|_| {
732 self.get_resolution_id(delegation.id).is_some_and(|id| {
733 tcx.def_kind(id) == DefKind::AssocFn
734 // Check that the return type of the callee is `Self` param.
735 // After previous check we are sure that `sig_id` and `delegation.id`
736 // point to the same function.
737 && tcx.def_kind(tcx.parent(id)) == DefKind::Trait
738 && tcx.fn_sig(id).skip_binder().output().skip_binder().is_param(0)
739 })
740 })
741 }
742
681743 fn process_segment(
682744 &mut self,
683745 span: Span,
compiler/rustc_ast_lowering/src/delegation/generics.rs+11-2
......@@ -588,19 +588,28 @@ impl<'hir> LoweringContext<'_, 'hir> {
588588 p.def_id.to_def_id(),
589589 );
590590
591 self.create_resolved_path(res, p.name.ident(), p.span)
592 }
593
594 pub(super) fn create_resolved_path(
595 &mut self,
596 res: Res,
597 ident: Ident,
598 span: Span,
599 ) -> hir::QPath<'hir> {
591600 hir::QPath::Resolved(
592601 None,
593602 self.arena.alloc(hir::Path {
594603 segments: self.arena.alloc_slice(&[hir::PathSegment {
595604 args: None,
596605 hir_id: self.next_id(),
597 ident: p.name.ident(),
606 ident,
598607 infer_args: false,
599608 res,
600609 delegation_child_segment: false,
601610 }]),
602611 res,
603 span: p.span,
612 span,
604613 }),
605614 )
606615 }
compiler/rustc_codegen_ssa/src/back/link.rs+59-8
......@@ -63,7 +63,10 @@ use super::rmeta_link::RmetaLinkCache;
6363use super::rpath::{self, RPathConfig};
6464use super::{apple, rmeta_link, versioned_llvm_target};
6565use crate::base::needs_allocator_shim_for_linking;
66use crate::{CodegenLintLevelSpecs, CompiledModule, CompiledModules, CrateInfo, NativeLib, errors};
66use crate::{
67 CodegenLintLevelSpecs, CompiledModule, CompiledModules, CrateInfo, NativeLib, SymbolExport,
68 errors,
69};
6770
6871pub fn ensure_removed(dcx: DiagCtxtHandle<'_>, path: &Path) {
6972 if let Err(e) = fs::remove_file(path) {
......@@ -593,7 +596,7 @@ fn link_staticlib(
593596 crate_info
594597 .exported_symbols
595598 .get(&CrateType::StaticLib)
596 .map(|symbols| symbols.iter().map(|(s, _)| s.clone()).collect())
599 .map(|symbols| symbols.iter().map(|symbol| symbol.name.clone()).collect())
597600 }
598601 } else {
599602 None
......@@ -2196,9 +2199,15 @@ fn add_linked_symbol_object(
21962199 cmd: &mut dyn Linker,
21972200 sess: &Session,
21982201 tmpdir: &Path,
2199 symbols: &[(String, SymbolExportKind)],
2202 crate_type: CrateType,
2203 linked_symbols: &[(String, SymbolExportKind)],
2204 exported_symbols: &[SymbolExport],
22002205) {
2201 if symbols.is_empty() {
2206 let should_export_symbols = sess.target.is_like_msvc
2207 && !exported_symbols.is_empty()
2208 && (crate_type != CrateType::Executable
2209 || sess.opts.unstable_opts.export_executable_symbols);
2210 if linked_symbols.is_empty() && !should_export_symbols {
22022211 return;
22032212 }
22042213
......@@ -2235,7 +2244,7 @@ fn add_linked_symbol_object(
22352244 None
22362245 };
22372246
2238 for (sym, kind) in symbols.iter() {
2247 for (sym, kind) in linked_symbols.iter() {
22392248 let symbol = file.add_symbol(object::write::Symbol {
22402249 name: sym.clone().into(),
22412250 value: 0,
......@@ -2293,6 +2302,37 @@ fn add_linked_symbol_object(
22932302 }
22942303 }
22952304
2305 if should_export_symbols {
2306 // Currently the compiler doesn't use `dllexport` (an LLVM attribute) to
2307 // export symbols from a dynamic library. When building a dynamic library,
2308 // however, we're going to want some symbols exported, so this adds a
2309 // `.drectve` section which lists all the symbols using /EXPORT arguments.
2310 //
2311 // The linker will read these arguments from the `.drectve` section and
2312 // export all the symbols from the dynamic library. Note that this is not
2313 // as simple as just exporting all the symbols in the current crate (as
2314 // specified by `codegen.reachable`) but rather we also need to possibly
2315 // export the symbols of upstream crates. Upstream rlibs may be linked
2316 // statically to this dynamic library, in which case they may continue to
2317 // transitively be used and hence need their symbols exported.
2318 fn msvc_drectve_export(symbol: &SymbolExport) -> String {
2319 let data = if symbol.kind == SymbolExportKind::Data { ",DATA" } else { "" };
2320
2321 if let Some(link_name) = symbol.link_name.as_deref() {
2322 // The first name is the decorated symbol used by the import library, while
2323 // EXPORTAS gives the public name written to the DLL export table.
2324 format!(" /EXPORT:\"{link_name}\"{data},EXPORTAS,\"{}\"", symbol.name)
2325 } else {
2326 format!(" /EXPORT:\"{}\"{data}", symbol.name)
2327 }
2328 }
2329
2330 let drectve = exported_symbols.iter().map(msvc_drectve_export).collect::<String>();
2331
2332 let section = file.add_section(vec![], b".drectve".to_vec(), object::SectionKind::Linker);
2333 file.append_section_data(section, drectve.as_bytes(), 1);
2334 }
2335
22962336 let path = tmpdir.join("symbols.o");
22972337 let result = std::fs::write(&path, file.write().unwrap());
22982338 if let Err(error) = result {
......@@ -2486,7 +2526,7 @@ fn undecorate_c_symbol<'a>(
24862526fn add_c_staticlib_symbols(
24872527 sess: &Session,
24882528 lib: &NativeLib,
2489 out: &mut Vec<(String, SymbolExportKind)>,
2529 out: &mut Vec<SymbolExport>,
24902530) -> io::Result<()> {
24912531 let file_path = find_native_static_library(lib.name.as_str(), lib.verbatim, sess);
24922532
......@@ -2549,7 +2589,11 @@ fn add_c_staticlib_symbols(
25492589 let Some(undecorated) = undecorate_c_symbol(name, sess, export_kind) else {
25502590 continue;
25512591 };
2552 out.push((undecorated.to_string(), export_kind));
2592 out.push(SymbolExport::with_link_name(
2593 undecorated.to_string(),
2594 export_kind,
2595 name.to_string(),
2596 ));
25532597 }
25542598 }
25552599
......@@ -2629,7 +2673,14 @@ fn linker_with_args(
26292673 // Pre-link CRT objects.
26302674 add_pre_link_objects(cmd, sess, flavor, link_output_kind, self_contained_crt_objects);
26312675
2632 add_linked_symbol_object(cmd, sess, tmpdir, &crate_info.linked_symbols[&crate_type]);
2676 add_linked_symbol_object(
2677 cmd,
2678 sess,
2679 tmpdir,
2680 crate_type,
2681 &crate_info.linked_symbols[&crate_type],
2682 &export_symbols,
2683 );
26332684
26342685 // Sanitizer libraries.
26352686 add_sanitizer_libraries(sess, flavor, crate_type, cmd);
compiler/rustc_codegen_ssa/src/back/linker.rs+78-110
......@@ -15,7 +15,7 @@ use rustc_middle::middle::dependency_format::Linkage;
1515use rustc_middle::middle::exported_symbols::{
1616 self, ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel,
1717};
18use rustc_middle::ty::TyCtxt;
18use rustc_middle::ty::{SymbolName, TyCtxt};
1919use rustc_session::Session;
2020use rustc_session::config::{self, CrateType, DebugInfo, LinkerPluginLto, Lto, OptLevel, Strip};
2121use rustc_target::spec::{Arch, Cc, CfgAbi, LinkOutputKind, LinkerFlavor, Lld, Os};
......@@ -25,7 +25,7 @@ use super::command::Command;
2525use super::symbol_export;
2626use crate::back::symbol_export::allocator_shim_symbols;
2727use crate::base::needs_allocator_shim_for_linking;
28use crate::errors;
28use crate::{SymbolExport, errors};
2929
3030#[cfg(test)]
3131mod tests;
......@@ -338,12 +338,7 @@ pub(crate) trait Linker {
338338 fn debuginfo(&mut self, strip: Strip, natvis_debugger_visualizers: &[PathBuf]);
339339 fn no_crt_objects(&mut self);
340340 fn no_default_libraries(&mut self);
341 fn export_symbols(
342 &mut self,
343 tmpdir: &Path,
344 crate_type: CrateType,
345 symbols: &[(String, SymbolExportKind)],
346 );
341 fn export_symbols(&mut self, tmpdir: &Path, crate_type: CrateType, symbols: &[SymbolExport]);
347342 fn windows_subsystem(&mut self, subsystem: WindowsSubsystemKind);
348343 fn linker_plugin_lto(&mut self);
349344 fn add_eh_frame_header(&mut self) {}
......@@ -794,12 +789,7 @@ impl<'a> Linker for GccLinker<'a> {
794789 }
795790 }
796791
797 fn export_symbols(
798 &mut self,
799 tmpdir: &Path,
800 crate_type: CrateType,
801 symbols: &[(String, SymbolExportKind)],
802 ) {
792 fn export_symbols(&mut self, tmpdir: &Path, crate_type: CrateType, symbols: &[SymbolExport]) {
803793 // Symbol visibility in object files typically takes care of this.
804794 if crate_type == CrateType::Executable {
805795 let should_export_executable_symbols =
......@@ -826,9 +816,9 @@ impl<'a> Linker for GccLinker<'a> {
826816 // Write a plain, newline-separated list of symbols
827817 let res = try {
828818 let mut f = File::create_buffered(&path)?;
829 for (sym, _) in symbols {
830 debug!(" _{sym}");
831 writeln!(f, "_{sym}")?;
819 for sym in symbols {
820 debug!(" _{}", sym.name);
821 writeln!(f, "_{}", sym.name)?;
832822 }
833823 };
834824 if let Err(error) = res {
......@@ -842,12 +832,13 @@ impl<'a> Linker for GccLinker<'a> {
842832 // .def file similar to MSVC one but without LIBRARY section
843833 // because LD doesn't like when it's empty
844834 writeln!(f, "EXPORTS")?;
845 for (symbol, kind) in symbols {
846 let kind_marker = if *kind == SymbolExportKind::Data { " DATA" } else { "" };
847 debug!(" _{symbol}");
835 for symbol in symbols {
836 let kind_marker =
837 if symbol.kind == SymbolExportKind::Data { " DATA" } else { "" };
838 debug!(" _{}", symbol.name);
848839 // Quote the name in case it's reserved by linker in some way
849840 // (this accounts for names with dots in particular).
850 writeln!(f, " \"{symbol}\"{kind_marker}")?;
841 writeln!(f, " \"{}\"{kind_marker}", symbol.name)?;
851842 }
852843 };
853844 if let Err(error) = res {
......@@ -856,16 +847,16 @@ impl<'a> Linker for GccLinker<'a> {
856847 self.link_arg(path);
857848 } else if self.sess.target.is_like_wasm {
858849 self.link_arg("--no-export-dynamic");
859 for (sym, _) in symbols {
860 self.link_arg("--export").link_arg(sym);
850 for sym in symbols {
851 self.link_arg("--export").link_arg(&sym.name);
861852 }
862853 } else if crate_type == CrateType::Executable && !self.sess.target.is_like_solaris {
863854 let res = try {
864855 let mut f = File::create_buffered(&path)?;
865856 writeln!(f, "{{")?;
866 for (sym, _) in symbols {
867 debug!(sym);
868 writeln!(f, " {sym};")?;
857 for sym in symbols {
858 debug!("{}", sym.name);
859 writeln!(f, " {};", sym.name)?;
869860 }
870861 writeln!(f, "}};")?;
871862 };
......@@ -880,9 +871,9 @@ impl<'a> Linker for GccLinker<'a> {
880871 writeln!(f, "{{")?;
881872 if !symbols.is_empty() {
882873 writeln!(f, " global:")?;
883 for (sym, _) in symbols {
884 debug!(" {sym};");
885 writeln!(f, " {sym};")?;
874 for sym in symbols {
875 debug!(" {};", sym.name);
876 writeln!(f, " {};", sym.name)?;
886877 }
887878 }
888879 writeln!(f, "\n local:\n *;\n}};")?;
......@@ -1126,25 +1117,10 @@ impl<'a> Linker for MsvcLinker<'a> {
11261117 }
11271118 }
11281119
1129 // Currently the compiler doesn't use `dllexport` (an LLVM attribute) to
1130 // export symbols from a dynamic library. When building a dynamic library,
1131 // however, we're going to want some symbols exported, so this function
1132 // generates a DEF file which lists all the symbols.
1133 //
1134 // The linker will read this `*.def` file and export all the symbols from
1135 // the dynamic library. Note that this is not as simple as just exporting
1136 // all the symbols in the current crate (as specified by `codegen.reachable`)
1137 // but rather we also need to possibly export the symbols of upstream
1138 // crates. Upstream rlibs may be linked statically to this dynamic library,
1139 // in which case they may continue to transitively be used and hence need
1140 // their symbols exported.
1141 fn export_symbols(
1142 &mut self,
1143 tmpdir: &Path,
1144 crate_type: CrateType,
1145 symbols: &[(String, SymbolExportKind)],
1146 ) {
1147 // Symbol visibility takes care of this typically
1120 fn export_symbols(&mut self, tmpdir: &Path, crate_type: CrateType, _symbols: &[SymbolExport]) {
1121 // We already add /EXPORT arguments to the .drectve section of symbols.o.
1122 // Keep passing an empty .def file: link.exe otherwise skips the import
1123 // library for DLLs with no exports.
11481124 if crate_type == CrateType::Executable {
11491125 let should_export_executable_symbols =
11501126 self.sess.opts.unstable_opts.export_executable_symbols;
......@@ -1156,16 +1132,8 @@ impl<'a> Linker for MsvcLinker<'a> {
11561132 let path = tmpdir.join("lib.def");
11571133 let res = try {
11581134 let mut f = File::create_buffered(&path)?;
1159
1160 // Start off with the standard module name header and then go
1161 // straight to exports.
11621135 writeln!(f, "LIBRARY")?;
11631136 writeln!(f, "EXPORTS")?;
1164 for (symbol, kind) in symbols {
1165 let kind_marker = if *kind == SymbolExportKind::Data { " DATA" } else { "" };
1166 debug!(" _{symbol}");
1167 writeln!(f, " {symbol}{kind_marker}")?;
1168 }
11691137 };
11701138 if let Err(error) = res {
11711139 self.sess.dcx().emit_fatal(errors::LibDefWriteFailure { error });
......@@ -1313,19 +1281,14 @@ impl<'a> Linker for EmLinker<'a> {
13131281 self.cc_arg("-nodefaultlibs");
13141282 }
13151283
1316 fn export_symbols(
1317 &mut self,
1318 _tmpdir: &Path,
1319 _crate_type: CrateType,
1320 symbols: &[(String, SymbolExportKind)],
1321 ) {
1284 fn export_symbols(&mut self, _tmpdir: &Path, _crate_type: CrateType, symbols: &[SymbolExport]) {
13221285 debug!("EXPORTED SYMBOLS:");
13231286
13241287 self.cc_arg("-s");
13251288
13261289 let mut arg = OsString::from("EXPORTED_FUNCTIONS=");
13271290 let encoded = serde_json::to_string(
1328 &symbols.iter().map(|(sym, _)| "_".to_owned() + sym).collect::<Vec<_>>(),
1291 &symbols.iter().map(|sym| "_".to_owned() + &sym.name).collect::<Vec<_>>(),
13291292 )
13301293 .unwrap();
13311294 debug!("{encoded}");
......@@ -1453,14 +1416,9 @@ impl<'a> Linker for WasmLd<'a> {
14531416
14541417 fn no_default_libraries(&mut self) {}
14551418
1456 fn export_symbols(
1457 &mut self,
1458 _tmpdir: &Path,
1459 _crate_type: CrateType,
1460 symbols: &[(String, SymbolExportKind)],
1461 ) {
1462 for (sym, _) in symbols {
1463 self.link_args(&["--export", sym]);
1419 fn export_symbols(&mut self, _tmpdir: &Path, _crate_type: CrateType, symbols: &[SymbolExport]) {
1420 for sym in symbols {
1421 self.link_args(&["--export", &sym.name]);
14641422 }
14651423 }
14661424
......@@ -1581,7 +1539,7 @@ impl<'a> Linker for L4Bender<'a> {
15811539 self.cc_arg("-nostdlib");
15821540 }
15831541
1584 fn export_symbols(&mut self, _: &Path, _: CrateType, _: &[(String, SymbolExportKind)]) {
1542 fn export_symbols(&mut self, _: &Path, _: CrateType, _: &[SymbolExport]) {
15851543 // ToDo, not implemented, copy from GCC
15861544 self.sess.dcx().emit_warn(errors::L4BenderExportingSymbolsUnimplemented);
15871545 }
......@@ -1735,19 +1693,14 @@ impl<'a> Linker for AixLinker<'a> {
17351693
17361694 fn no_default_libraries(&mut self) {}
17371695
1738 fn export_symbols(
1739 &mut self,
1740 tmpdir: &Path,
1741 _crate_type: CrateType,
1742 symbols: &[(String, SymbolExportKind)],
1743 ) {
1696 fn export_symbols(&mut self, tmpdir: &Path, _crate_type: CrateType, symbols: &[SymbolExport]) {
17441697 let path = tmpdir.join("list.exp");
17451698 let res = try {
17461699 let mut f = File::create_buffered(&path)?;
17471700 // FIXME: use llvm-nm to generate export list.
1748 for (symbol, _) in symbols {
1749 debug!(" _{symbol}");
1750 writeln!(f, " {symbol}")?;
1701 for symbol in symbols {
1702 debug!(" _{}", symbol.name);
1703 writeln!(f, " {}", symbol.name)?;
17511704 }
17521705 };
17531706 if let Err(e) = res {
......@@ -1792,15 +1745,36 @@ fn for_each_exported_symbols_include_dep<'tcx>(
17921745 }
17931746}
17941747
1795pub(crate) fn exported_symbols(
1748fn symbol_export_from_exported_symbol<'tcx>(
1749 tcx: TyCtxt<'tcx>,
1750 symbol: ExportedSymbol<'tcx>,
1751 kind: SymbolExportKind,
1752 cnum: CrateNum,
1753) -> SymbolExport {
1754 let name = symbol_export::exporting_symbol_name_for_instance_in_crate(tcx, symbol, cnum);
1755 let link_name =
1756 symbol_export::linking_symbol_name_for_instance_in_crate(tcx, symbol, kind, cnum);
1757 SymbolExport::with_link_name(name, kind, link_name)
1758}
1759
1760fn symbol_export_from_raw_name(
17961761 tcx: TyCtxt<'_>,
1797 crate_type: CrateType,
1798) -> Vec<(String, SymbolExportKind)> {
1762 name: String,
1763 kind: SymbolExportKind,
1764) -> SymbolExport {
1765 let symbol = ExportedSymbol::NoDefId(SymbolName::new(tcx, &name));
1766 let link_name =
1767 symbol_export::linking_symbol_name_for_instance_in_crate(tcx, symbol, kind, LOCAL_CRATE);
1768 SymbolExport::with_link_name(name, kind, link_name)
1769}
1770
1771pub(crate) fn exported_symbols(tcx: TyCtxt<'_>, crate_type: CrateType) -> Vec<SymbolExport> {
17991772 if let Some(ref exports) = tcx.sess.target.override_export_symbols {
18001773 return exports
18011774 .iter()
18021775 .map(|name| {
1803 (
1776 symbol_export_from_raw_name(
1777 tcx,
18041778 name.to_string(),
18051779 // FIXME use the correct export kind for this symbol. override_export_symbols
18061780 // can't directly specify the SymbolExportKind as it is defined in rustc_middle
......@@ -1825,7 +1799,11 @@ pub(crate) fn exported_symbols(
18251799 && !tcx.sess.target.is_like_wasm
18261800 {
18271801 let metadata_symbol_name = exported_symbols::metadata_symbol_name(tcx);
1828 symbols.push((metadata_symbol_name, SymbolExportKind::Data));
1802 symbols.push(symbol_export_from_raw_name(
1803 tcx,
1804 metadata_symbol_name,
1805 SymbolExportKind::Data,
1806 ));
18291807 }
18301808
18311809 symbols
......@@ -1834,7 +1812,7 @@ pub(crate) fn exported_symbols(
18341812fn exported_symbols_for_non_proc_macro(
18351813 tcx: TyCtxt<'_>,
18361814 crate_type: CrateType,
1837) -> Vec<(String, SymbolExportKind)> {
1815) -> Vec<SymbolExport> {
18381816 let mut symbols = Vec::new();
18391817 let export_threshold = symbol_export::crates_export_threshold(&[crate_type]);
18401818 for_each_exported_symbols_include_dep(tcx, crate_type, |symbol, info, cnum| {
......@@ -1842,10 +1820,7 @@ fn exported_symbols_for_non_proc_macro(
18421820 // from any dylib. The latter doesn't work anyway as we use hidden visibility for
18431821 // compiler-builtins. Most linkers silently ignore it, but ld64 gives a warning.
18441822 if info.level.is_below_threshold(export_threshold) && !tcx.is_compiler_builtins(cnum) {
1845 symbols.push((
1846 symbol_export::exporting_symbol_name_for_instance_in_crate(tcx, symbol, cnum),
1847 info.kind,
1848 ));
1823 symbols.push(symbol_export_from_exported_symbol(tcx, symbol, info.kind, cnum));
18491824 symbol_export::extend_exported_symbols(&mut symbols, tcx, symbol, cnum);
18501825 }
18511826 });
......@@ -1855,13 +1830,16 @@ fn exported_symbols_for_non_proc_macro(
18551830 && needs_allocator_shim_for_linking(tcx.dependency_formats(()), crate_type)
18561831 && let Some(kind) = tcx.allocator_kind(())
18571832 {
1858 symbols.extend(allocator_shim_symbols(tcx, kind));
1833 symbols.extend(
1834 allocator_shim_symbols(tcx, kind)
1835 .map(|(name, kind)| symbol_export_from_raw_name(tcx, name, kind)),
1836 );
18591837 }
18601838
18611839 symbols
18621840}
18631841
1864fn exported_symbols_for_proc_macro_crate(tcx: TyCtxt<'_>) -> Vec<(String, SymbolExportKind)> {
1842fn exported_symbols_for_proc_macro_crate(tcx: TyCtxt<'_>) -> Vec<SymbolExport> {
18651843 // `exported_symbols` will be empty when !should_codegen.
18661844 if !tcx.sess.opts.output_types.should_codegen() {
18671845 return Vec::new();
......@@ -1870,7 +1848,7 @@ fn exported_symbols_for_proc_macro_crate(tcx: TyCtxt<'_>) -> Vec<(String, Symbol
18701848 let stable_crate_id = tcx.stable_crate_id(LOCAL_CRATE);
18711849 let proc_macro_decls_name = rustc_session::generate_proc_macro_decls_symbol(stable_crate_id);
18721850
1873 vec![(proc_macro_decls_name, SymbolExportKind::Data)]
1851 vec![symbol_export_from_raw_name(tcx, proc_macro_decls_name, SymbolExportKind::Data)]
18741852}
18751853
18761854pub(crate) fn linked_symbols(
......@@ -1984,16 +1962,11 @@ impl<'a> Linker for LlbcLinker<'a> {
19841962
19851963 fn ehcont_guard(&mut self) {}
19861964
1987 fn export_symbols(
1988 &mut self,
1989 _tmpdir: &Path,
1990 _crate_type: CrateType,
1991 symbols: &[(String, SymbolExportKind)],
1992 ) {
1965 fn export_symbols(&mut self, _tmpdir: &Path, _crate_type: CrateType, symbols: &[SymbolExport]) {
19931966 match _crate_type {
19941967 CrateType::Cdylib => {
1995 for (sym, _) in symbols {
1996 self.link_args(&["--export-symbol", sym]);
1968 for sym in symbols {
1969 self.link_args(&["--export-symbol", &sym.name]);
19971970 }
19981971 }
19991972 _ => (),
......@@ -2064,17 +2037,12 @@ impl<'a> Linker for BpfLinker<'a> {
20642037
20652038 fn ehcont_guard(&mut self) {}
20662039
2067 fn export_symbols(
2068 &mut self,
2069 tmpdir: &Path,
2070 _crate_type: CrateType,
2071 symbols: &[(String, SymbolExportKind)],
2072 ) {
2040 fn export_symbols(&mut self, tmpdir: &Path, _crate_type: CrateType, symbols: &[SymbolExport]) {
20732041 let path = tmpdir.join("symbols");
20742042 let res = try {
20752043 let mut f = File::create_buffered(&path)?;
2076 for (sym, _) in symbols {
2077 writeln!(f, "{sym}")?;
2044 for sym in symbols {
2045 writeln!(f, "{}", sym.name)?;
20782046 }
20792047 };
20802048 if let Err(error) = res {
compiler/rustc_codegen_ssa/src/back/symbol_export.rs+3-2
......@@ -21,6 +21,7 @@ use rustc_symbol_mangling::mangle_internal_symbol;
2121use rustc_target::spec::{Arch, Os, TlsModel};
2222use tracing::debug;
2323
24use crate::SymbolExport;
2425use crate::back::symbol_export;
2526use crate::base::allocator_shim_contents;
2627
......@@ -721,7 +722,7 @@ pub(crate) fn exporting_symbol_name_for_instance_in_crate<'tcx>(
721722/// Add it to the symbols list for all kernel functions, so that it is exported in the linked
722723/// object.
723724pub(crate) fn extend_exported_symbols<'tcx>(
724 symbols: &mut Vec<(String, SymbolExportKind)>,
725 symbols: &mut Vec<SymbolExport>,
725726 tcx: TyCtxt<'tcx>,
726727 symbol: ExportedSymbol<'tcx>,
727728 instantiating_crate: CrateNum,
......@@ -737,7 +738,7 @@ pub(crate) fn extend_exported_symbols<'tcx>(
737738 // Add the symbol for the kernel descriptor (with .kd suffix)
738739 // Per https://llvm.org/docs/AMDGPUUsage.html#symbols these will always be `STT_OBJECT` so
739740 // export as data.
740 symbols.push((format!("{undecorated}.kd"), SymbolExportKind::Data));
741 symbols.push(SymbolExport::new(format!("{undecorated}.kd"), SymbolExportKind::Data));
741742}
742743
743744fn maybe_emutls_symbol_name<'tcx>(
compiler/rustc_codegen_ssa/src/lib.rs+23-1
......@@ -233,6 +233,28 @@ impl From<&cstore::NativeLib> for NativeLib {
233233 }
234234}
235235
236/// A symbol to make visible from a linked artifact.
237#[derive(Clone, Debug, Encodable, Decodable)]
238pub struct SymbolExport {
239 /// Name to make visible from the linked artifact.
240 pub name: String,
241 /// Kind of symbol, used for target-specific export directives and name decoration.
242 pub kind: SymbolExportKind,
243 /// Name of the symbol as seen by the linker, when it differs from `name`.
244 pub link_name: Option<String>,
245}
246
247impl SymbolExport {
248 pub fn new(name: String, kind: SymbolExportKind) -> SymbolExport {
249 SymbolExport { name, kind, link_name: None }
250 }
251
252 pub fn with_link_name(name: String, kind: SymbolExportKind, link_name: String) -> SymbolExport {
253 let link_name = if link_name == name { None } else { Some(link_name) };
254 SymbolExport { name, kind, link_name }
255 }
256}
257
236258/// Misc info we load from metadata to persist beyond the tcx.
237259///
238260/// Note: though `CrateNum` is only meaningful within the same tcx, information within `CrateInfo`
......@@ -247,7 +269,7 @@ pub struct CrateInfo {
247269 pub target_cpu: String,
248270 pub target_features: Vec<String>,
249271 pub crate_types: Vec<CrateType>,
250 pub exported_symbols: UnordMap<CrateType, Vec<(String, SymbolExportKind)>>,
272 pub exported_symbols: UnordMap<CrateType, Vec<SymbolExport>>,
251273 pub linked_symbols: FxIndexMap<CrateType, Vec<(String, SymbolExportKind)>>,
252274 pub local_crate_name: Symbol,
253275 pub compiler_builtins: Option<CrateNum>,
compiler/rustc_expand/src/base.rs+1-1
......@@ -1199,7 +1199,7 @@ pub trait LintStoreExpand {
11991199
12001200type LintStoreExpandDyn<'a> = Option<&'a (dyn LintStoreExpand + 'a)>;
12011201
1202#[derive(Debug, Clone, Default)]
1202#[derive(Debug, Default)]
12031203pub struct ModuleData {
12041204 /// Path to the module starting from the crate name, like `my_crate::foo::bar`.
12051205 pub mod_path: Vec<Ident>,
compiler/rustc_hir_analysis/src/check/check.rs+2-3
......@@ -839,9 +839,8 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
839839 tcx.ensure_ok().associated_items(def_id);
840840 if of_trait {
841841 let impl_trait_header = tcx.impl_trait_header(def_id);
842 res = res.and(tcx.ensure_result().coherent_trait(
843 impl_trait_header.trait_ref.instantiate_identity().skip_norm_wip().def_id,
844 ));
842 res = res
843 .and(tcx.ensure_result().coherent_trait(impl_trait_header.trait_ref.def_id()));
845844
846845 if res.is_ok() {
847846 // Checking this only makes sense if the all trait impls satisfy basic
compiler/rustc_mir_transform/src/check_call_recursion.rs+1-1
......@@ -45,7 +45,7 @@ impl<'tcx> MirLint<'tcx> for CheckDropRecursion {
4545 if let DefKind::AssocFn = tcx.def_kind(def_id)
4646 && let Some(impl_id) = tcx.trait_impl_of_assoc(def_id.to_def_id())
4747 && let trait_ref = tcx.impl_trait_ref(impl_id)
48 && tcx.is_lang_item(trait_ref.instantiate_identity().skip_norm_wip().def_id, LangItem::Drop)
48 && tcx.is_lang_item(trait_ref.def_id(), LangItem::Drop)
4949 // avoid erroneous `Drop` impls from causing ICEs below
5050 && let sig = tcx.fn_sig(def_id).instantiate_identity().skip_norm_wip()
5151 && sig.inputs().skip_binder().len() == 1
compiler/rustc_resolve/src/error_helper.rs+1-1
......@@ -109,7 +109,7 @@ impl TypoSuggestion {
109109}
110110
111111/// A free importable items suggested in case of resolution failure.
112#[derive(Debug, Clone)]
112#[derive(Debug)]
113113pub(crate) struct ImportSuggestion {
114114 pub did: Option<DefId>,
115115 pub descr: &'static str,
compiler/rustc_resolve/src/imports.rs+4-5
......@@ -69,7 +69,6 @@ impl<'ra> PendingDecl<'ra> {
6969}
7070
7171/// Contains data for specific kinds of imports.
72#[derive(Clone)]
7372pub(crate) enum ImportKind<'ra> {
7473 Single {
7574 /// `source` in `use prefix::source as target`.
......@@ -157,7 +156,7 @@ impl<'ra> std::fmt::Debug for ImportKind<'ra> {
157156}
158157
159158/// One import.
160#[derive(Debug, Clone)]
159#[derive(Debug)]
161160pub(crate) struct ImportData<'ra> {
162161 pub kind: ImportKind<'ra>,
163162
......@@ -280,7 +279,7 @@ impl<'ra> ImportData<'ra> {
280279}
281280
282281/// Records information about the resolution of a name in a namespace of a module.
283#[derive(Clone, Debug)]
282#[derive(Debug)]
284283pub(crate) struct NameResolution<'ra> {
285284 /// Single imports that may define the name in the namespace.
286285 /// Imports are arena-allocated, so it's ok to use pointers as keys.
......@@ -377,7 +376,7 @@ pub(crate) mod cycle_detection {
377376
378377/// An error that may be transformed into a diagnostic later. Used to combine multiple unresolved
379378/// import errors within the same use tree into a single diagnostic.
380#[derive(Debug, Clone)]
379#[derive(Debug)]
381380pub(crate) struct UnresolvedImportError {
382381 pub(crate) span: Span,
383382 pub(crate) label: Option<String>,
......@@ -396,7 +395,7 @@ fn pub_use_of_private_extern_crate_hack(
396395 import: ImportSummary,
397396 decl: Decl<'_>,
398397) -> Option<LocalDefId> {
399 match (import.is_single, decl.kind) {
398 match (import.is_single, &decl.kind) {
400399 (true, DeclKind::Import { import: decl_import, .. })
401400 if let ImportKind::ExternCrate { def_id, .. } = decl_import.kind
402401 && import.vis.is_public() =>
compiler/rustc_resolve/src/late/diagnostics.rs+1-1
......@@ -133,7 +133,7 @@ pub(super) struct MissingLifetime {
133133
134134/// Description of the lifetimes appearing in a function parameter.
135135/// This is used to provide a literal explanation to the elision failure.
136#[derive(Clone, Debug)]
136#[derive(Debug)]
137137pub(super) struct ElisionFnParameter {
138138 /// The index of the argument in the original definition.
139139 pub index: usize,
compiler/rustc_resolve/src/lib.rs+2-2
......@@ -984,7 +984,7 @@ impl<'ra> fmt::Debug for LocalModule<'ra> {
984984}
985985
986986/// Data associated with any name declaration.
987#[derive(Clone, Debug)]
987#[derive(Debug)]
988988struct DeclData<'ra> {
989989 kind: DeclKind<'ra>,
990990 ambiguity: CmCell<Option<(Decl<'ra>, bool /*warning*/)>>,
......@@ -1018,7 +1018,7 @@ impl std::hash::Hash for DeclData<'_> {
10181018}
10191019
10201020/// Name declaration kind.
1021#[derive(Clone, Copy, Debug)]
1021#[derive(Debug)]
10221022enum DeclKind<'ra> {
10231023 /// The name declaration is a definition (possibly without a `DefId`),
10241024 /// can be provided by source code or built into the language.
compiler/rustc_type_ir/src/binder.rs+6
......@@ -448,6 +448,12 @@ impl<I: Interner, T> EarlyBinder<I, T> {
448448 }
449449}
450450
451impl<I: Interner> EarlyBinder<I, ty::TraitRef<I>> {
452 pub fn def_id(&self) -> I::TraitId {
453 self.value.def_id
454 }
455}
456
451457impl<I: Interner, T> EarlyBinder<I, Option<T>> {
452458 pub fn transpose(self) -> Option<EarlyBinder<I, T>> {
453459 self.value.map(|value| EarlyBinder { value, _tcx: PhantomData })
library/core/src/slice/mod.rs+6-3
......@@ -2738,10 +2738,12 @@ impl<T> [T] {
27382738
27392739 /// Returns a subslice with the prefix and suffix removed.
27402740 ///
2741 /// If the slice starts with `prefix` and ends with `suffix`, returns the subslice after the
2742 /// prefix and before the suffix, wrapped in `Some`.
2741 /// If the slice starts with `prefix`, ends with `suffix`, and
2742 /// the prefix and suffix don't overlap, returns the subslice after
2743 /// the prefix and before the suffix, wrapped in `Some`.
27432744 ///
2744 /// If the slice does not start with `prefix` or does not end with `suffix`, returns `None`.
2745 /// If the slice does not start with `prefix`, does not end with `suffix`,
2746 /// or the prefix and suffix overlap in the slice, returns `None`.
27452747 ///
27462748 /// # Examples
27472749 ///
......@@ -2754,6 +2756,7 @@ impl<T> [T] {
27542756 /// assert_eq!(v.strip_circumfix(&[10], &[40]), None);
27552757 /// assert_eq!(v.strip_circumfix(&[], &[40, 30]), Some(&[10, 50][..]));
27562758 /// assert_eq!(v.strip_circumfix(&[10, 50], &[]), Some(&[40, 30][..]));
2759 /// assert_eq!(v.strip_circumfix(&[10, 50, 40], &[50, 40, 30]), None);
27572760 /// ```
27582761 #[must_use = "returns the subslice without modifying the original"]
27592762 #[stable(feature = "strip_circumfix", since = "CURRENT_RUSTC_VERSION")]
library/core/src/str/mod.rs+5-2
......@@ -2492,12 +2492,14 @@ impl str {
24922492
24932493 /// Returns a string slice with the prefix and suffix removed.
24942494 ///
2495 /// If the string starts with the pattern `prefix` and ends with the pattern `suffix`, returns
2495 /// If the string starts with the pattern `prefix` and ends with
2496 /// the pattern `suffix`, and the prefix and suffix don't overlap, returns
24962497 /// the substring after the prefix and before the suffix, wrapped in `Some`.
24972498 /// Unlike [`trim_start_matches`] and [`trim_end_matches`], this method removes both the prefix
24982499 /// and suffix exactly once.
24992500 ///
2500 /// If the string does not start with `prefix` or does not end with `suffix`, returns `None`.
2501 /// If the string does not start with `prefix`, does not end with `suffix`,
2502 /// or the prefix and suffix overlap in the string, returns `None`.
25012503 ///
25022504 /// Each [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a
25032505 /// function or closure that determines if a character matches.
......@@ -2513,6 +2515,7 @@ impl str {
25132515 /// assert_eq!("bar:hello:foo".strip_circumfix("bar:", ":foo"), Some("hello"));
25142516 /// assert_eq!("bar:foo".strip_circumfix("foo", "foo"), None);
25152517 /// assert_eq!("foo:bar;".strip_circumfix("foo:", ';'), Some("bar"));
2518 /// assert_eq!("foo:bar:baz".strip_circumfix("foo:bar:", ":bar:baz"), None);
25162519 /// ```
25172520 #[must_use = "this returns the remaining substring as a new slice, \
25182521 without modifying the original"]
library/std/src/sys/random/linux.rs+3-1
......@@ -123,7 +123,9 @@ fn getrandom(mut bytes: &mut [u8], insecure: bool) {
123123 GETRANDOM_AVAILABLE.store(false, Relaxed);
124124 break;
125125 }
126 _ => panic!("failed to generate random data"),
126 other => {
127 panic!("failed to generate random data: errno={other:?}, flags={flags:?}")
128 }
127129 }
128130 }
129131 }
src/tools/compiletest/src/runtest.rs+45-24
......@@ -2580,31 +2580,52 @@ impl<'test> TestCx<'test> {
25802580 // that actually appear in the output.
25812581 // We use uppercase ALLOC to distinguish from the non-normalized version.
25822582 {
2583 let mut seen_allocs = indexmap::IndexSet::new();
2584
2585 // The alloc-id appears in pretty-printed allocations.
2586 normalized = static_regex!(
2587 r"╾─*a(lloc)?([0-9]+)(\+0x[0-9a-f]+)?(<imm>)?( \([0-9]+ ptr bytes\))?─*╼"
2588 )
2589 .replace_all(&normalized, |caps: &Captures<'_>| {
2590 // Renumber the captured index.
2591 let index = caps.get(2).unwrap().as_str().to_string();
2592 let (index, _) = seen_allocs.insert_full(index);
2593 let offset = caps.get(3).map_or("", |c| c.as_str());
2594 let imm = caps.get(4).map_or("", |c| c.as_str());
2595 // Do not bother keeping it pretty, just make it deterministic.
2596 format!("╾ALLOC{index}{offset}{imm}╼")
2597 })
2598 .into_owned();
2583 match self.config.mode {
2584 // Unfortunately, due to parallel frontend assigning alloc-ids
2585 // nondeterministically we resort to dropping ids altogether for now
2586 // in ui tests
2587 TestMode::Ui => {
2588 // The alloc-id appears in pretty-printed allocations.
2589 normalized = static_regex!(
2590 r"╾─*(a(lloc)?|A(LLOC)?)\d+(\+0x[0-9a-f]+)?(<imm>)?( ?\(\d+ ptr bytes\))?─*╼"
2591 )
2592 .replace_all(&normalized, |_: &Captures<'_>| "╾ALLOC$ID╼".to_string())
2593 .into_owned();
25992594
2600 // The alloc-id appears in a sentence.
2601 normalized = static_regex!(r"\balloc([0-9]+)\b")
2602 .replace_all(&normalized, |caps: &Captures<'_>| {
2603 let index = caps.get(1).unwrap().as_str().to_string();
2604 let (index, _) = seen_allocs.insert_full(index);
2605 format!("ALLOC{index}")
2606 })
2607 .into_owned();
2595 // The alloc-id appears in a sentence.
2596 normalized = static_regex!(r"\b(alloc|ALLOC)\d+\b")
2597 .replace_all(&normalized, |_: &Captures<'_>| "ALLOC$ID".to_string())
2598 .into_owned();
2599 }
2600 // use consistent `AllocId`s in other test modes, where parallel frontend
2601 // should not (theoretically) be an issue
2602 _ => {
2603 let mut seen_allocs = indexmap::IndexSet::new();
2604 // The alloc-id appears in pretty-printed allocations.
2605 normalized = static_regex!(
2606 r"╾─*a(lloc)?([0-9]+)(\+0x[0-9a-f]+)?(<imm>)?( \([0-9]+ ptr bytes\))?─*╼"
2607 )
2608 .replace_all(&normalized, |caps: &Captures<'_>| {
2609 // Renumber the captured index.
2610 let index = caps.get(2).unwrap().as_str().to_string();
2611 let (index, _) = seen_allocs.insert_full(index);
2612 let offset = caps.get(3).map_or("", |c| c.as_str());
2613 let imm = caps.get(4).map_or("", |c| c.as_str());
2614 // Do not bother keeping it pretty, just make it deterministic.
2615 format!("╾ALLOC{index}{offset}{imm}╼")
2616 })
2617 .into_owned();
2618
2619 // The alloc-id appears in a sentence.
2620 normalized = static_regex!(r"\balloc([0-9]+)\b")
2621 .replace_all(&normalized, |caps: &Captures<'_>| {
2622 let index = caps.get(1).unwrap().as_str().to_string();
2623 let (index, _) = seen_allocs.insert_full(index);
2624 format!("ALLOC{index}")
2625 })
2626 .into_owned();
2627 }
2628 }
26082629 }
26092630
26102631 // Custom normalization rules
tests/pretty/delegation/self-mapping-output.pp created+44
......@@ -0,0 +1,44 @@
1#![attr = Feature([fn_delegation#0])]
2extern crate std;
3#[attr = PreludeImport]
4use ::std::prelude::rust_2015::*;
5//@ pretty-compare-only
6//@ pretty-mode:hir
7//@ pp-exact:self-mapping-output.pp
8
9
10trait Trait {
11 fn method(&self)
12 -> Self;
13 fn r#static()
14 -> Self;
15 fn raw_S(&self) -> S { S }
16}
17
18struct S;
19impl Trait for S {
20 fn method(&self) -> S { S }
21 fn r#static() -> S { S }
22}
23
24struct W(S);
25impl Trait for W {
26 #[attr = Inline(Hint)]
27 fn method(self: _) -> _ { Self { 0: Trait::method(self.0) } }
28 #[attr = Inline(Hint)]
29 fn r#static() -> _ { Trait::r#static() }
30 //~^ WARN: function cannot return without recursing [unconditional_recursion]
31 #[attr = Inline(Hint)]
32 fn raw_S(self: _) -> _ { Trait::raw_S(self.0) }
33}
34
35impl W {
36 #[attr = Inline(Hint)]
37 fn method(self: _) -> _ { Self { 0: Trait::method(self.0) } }
38 #[attr = Inline(Hint)]
39 fn r#static() -> _ { Trait::r#static() }
40 #[attr = Inline(Hint)]
41 fn raw_S(self: _) -> _ { Trait::raw_S(self.0) }
42}
43
44fn main() { }
tests/pretty/delegation/self-mapping-output.rs created+33
......@@ -0,0 +1,33 @@
1//@ pretty-compare-only
2//@ pretty-mode:hir
3//@ pp-exact:self-mapping-output.pp
4
5#![feature(fn_delegation)]
6
7trait Trait {
8 fn method(&self) -> Self;
9 fn r#static() -> Self;
10 fn raw_S(&self) -> S { S }
11}
12
13struct S;
14impl Trait for S {
15 fn method(&self) -> S { S }
16 fn r#static() -> S { S }
17}
18
19struct W(S);
20impl Trait for W {
21 reuse Trait::method { self.0 }
22 reuse Trait::r#static;
23 //~^ WARN: function cannot return without recursing [unconditional_recursion]
24 reuse Trait::raw_S { self.0 }
25}
26
27impl W {
28 reuse Trait::method { self.0 }
29 reuse Trait::r#static;
30 reuse Trait::raw_S { self.0 }
31}
32
33fn main() {}
tests/run-make/dll-weak-definition/rmake.rs created+23
......@@ -0,0 +1,23 @@
1// Regression test for MSVC link.exe failing to export weak definitions from dlls.
2// See https://github.com/rust-lang/rust/pull/158294
3
4//@ only-msvc
5//@ needs-rust-lld
6
7use run_make_support::{dynamic_lib_name, llvm_readobj, rustc};
8
9fn test_with_linker(linker: &str) {
10 rustc().input("weak.rs").linker(linker).run();
11
12 llvm_readobj()
13 .arg("--coff-exports")
14 .input(dynamic_lib_name("weak"))
15 .run()
16 .assert_stdout_contains("Name: weak_function")
17 .assert_stdout_contains("Name: WEAK_STATIC");
18}
19
20fn main() {
21 test_with_linker("link");
22 test_with_linker("rust-lld");
23}
tests/run-make/dll-weak-definition/weak.rs created+10
......@@ -0,0 +1,10 @@
1#![feature(linkage)]
2#![crate_type = "cdylib"]
3
4#[linkage = "weak"]
5#[no_mangle]
6pub fn weak_function() {}
7
8#[linkage = "weak"]
9#[no_mangle]
10pub static WEAK_STATIC: u8 = 42;
tests/ui/const-generics/issues/issue-100313.rs+2-2
......@@ -1,5 +1,5 @@
11//@ dont-require-annotations: NOTE
2//@ ignore-parallel-frontend different alloc ids
2
33#![allow(incomplete_features)]
44#![feature(adt_const_params, unsized_const_params)]
55
......@@ -15,7 +15,7 @@ impl<const B: &'static bool> T<B> {
1515
1616const _: () = {
1717 let x = T::<{ &true }>;
18 x.set_false(); //~ ERROR writing to ALLOC0 which is read-only
18 x.set_false(); //~ ERROR writing to ALLOC$ID which is read-only
1919};
2020
2121fn main() {}
tests/ui/const-generics/issues/issue-100313.stderr+1-1
......@@ -1,4 +1,4 @@
1error[E0080]: writing to ALLOC0 which is read-only
1error[E0080]: writing to ALLOC$ID which is read-only
22 --> $DIR/issue-100313.rs:18:5
33 |
44LL | x.set_false();
tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr+2-2
......@@ -46,7 +46,7 @@ note: expected because of the type of the const parameter
4646LL | fn get_flag<const FlagSet: bool, const ShortName: char>() -> Option<char> {
4747 | ^^^^^^^^^^^^^^^^^^^^^
4848
49error[E0080]: reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory
49error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory
5050 --> $DIR/invalid-patterns.rs:40:32
5151 |
5252LL | get_flag::<false, { unsafe { char_raw.character } }>();
......@@ -78,7 +78,7 @@ LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character
7878 42 │ B
7979 }
8080
81error[E0080]: reading memory at ALLOC1[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory
81error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory
8282 --> $DIR/invalid-patterns.rs:44:58
8383 |
8484LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>();
tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr+2-2
......@@ -46,7 +46,7 @@ note: expected because of the type of the const parameter
4646LL | fn get_flag<const FlagSet: bool, const ShortName: char>() -> Option<char> {
4747 | ^^^^^^^^^^^^^^^^^^^^^
4848
49error[E0080]: reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory
49error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory
5050 --> $DIR/invalid-patterns.rs:40:32
5151 |
5252LL | get_flag::<false, { unsafe { char_raw.character } }>();
......@@ -78,7 +78,7 @@ LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character
7878 42 │ B
7979 }
8080
81error[E0080]: reading memory at ALLOC1[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory
81error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory
8282 --> $DIR/invalid-patterns.rs:44:58
8383 |
8484LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>();
tests/ui/const-generics/min_const_generics/invalid-patterns.rs+1-1
......@@ -1,6 +1,6 @@
11//@ stderr-per-bitwidth
22//@ dont-require-annotations: NOTE
3//@ ignore-parallel-frontend different alloc ids
3
44use std::mem::transmute;
55
66fn get_flag<const FlagSet: bool, const ShortName: char>() -> Option<char> {
tests/ui/const-ptr/forbidden_slices.rs+1-1
......@@ -1,7 +1,7 @@
11// Strip out raw byte dumps to make comparison platform-independent:
22//@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
33//@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*A(LLOC)?[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP"
4//@ ignore-parallel-frontend different alloc ids
4
55#![feature(
66 slice_from_ptr_range,
77 const_slice_from_ptr_range,
tests/ui/const-ptr/forbidden_slices.stderr+12-12
......@@ -28,7 +28,7 @@ LL | pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) };
2828 |
2929 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
3030 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
31 HEX_DUMP
31 ╾ALLOC$ID╼ HEX_DUMP
3232 }
3333
3434error[E0080]: constructing invalid value of type &[u8]: at .<deref>[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) }
3939 |
4040 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
4141 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
42 HEX_DUMP
42 ╾ALLOC$ID╼ HEX_DUMP
4343 }
4444
4545error[E0080]: constructing invalid value of type &[u8]: at .<deref>[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
5252 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
5353 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
5454 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
55 HEX_DUMP
55 ╾ALLOC$ID╼ HEX_DUMP
5656 }
5757
5858error[E0080]: constructing invalid value of type &[bool]: at .<deref>[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)
6363 |
6464 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
6565 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
66 HEX_DUMP
66 ╾ALLOC$ID╼ HEX_DUMP
6767 }
6868
6969error[E0080]: constructing invalid value of type &[u16]: at .<deref>[1], encountered uninitialized memory, but expected an integer
......@@ -74,7 +74,7 @@ LL | pub static S7: &[u16] = unsafe {
7474 |
7575 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
7676 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
77 HEX_DUMP
77 ╾ALLOC$ID╼ HEX_DUMP
7878 }
7979
8080error[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 {
8585 |
8686 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
8787 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
88 HEX_DUMP
88 ╾ALLOC$ID╼ HEX_DUMP
8989 }
9090
9191error[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
105105LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; // errors inside libcore
106106 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `R1` failed here
107107
108error[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
108error[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
109109 --> $DIR/forbidden_slices.rs:54:25
110110 |
111111LL | from_ptr_range(ptr..ptr.add(2)) // errors inside libcore
......@@ -119,7 +119,7 @@ LL | pub static R4: &[u8] = unsafe {
119119 |
120120 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
121121 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
122 HEX_DUMP
122 ╾ALLOC$ID╼ HEX_DUMP
123123 }
124124
125125error[E0080]: constructing invalid value of type &[u8]: at .<deref>[0], encountered a pointer, but expected an integer
......@@ -132,7 +132,7 @@ LL | pub static R5: &[u8] = unsafe {
132132 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
133133 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
134134 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
135 HEX_DUMP
135 ╾ALLOC$ID╼ HEX_DUMP
136136 }
137137
138138error[E0080]: constructing invalid value of type &[bool]: at .<deref>[0], encountered 0x11, but expected a boolean
......@@ -143,7 +143,7 @@ LL | pub static R6: &[bool] = unsafe {
143143 |
144144 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
145145 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
146 HEX_DUMP
146 ╾ALLOC$ID╼ HEX_DUMP
147147 }
148148
149149error[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 {
154154 |
155155 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
156156 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
157 HEX_DUMP
157 ╾ALLOC$ID╼ HEX_DUMP
158158 }
159159
160error[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
160error[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
161161 --> $DIR/forbidden_slices.rs:79:25
162162 |
163163LL | from_ptr_range(ptr..ptr.add(1))
tests/ui/const-ptr/out_of_bounds_read.rs+1-1
......@@ -1,6 +1,6 @@
11fn main() {
22 use std::ptr;
3//@ ignore-parallel-frontend different alloc ids
3
44 const DATA: [u32; 1] = [42];
55
66 const PAST_END_PTR: *const u32 = unsafe { DATA.as_ptr().add(1) };
tests/ui/const-ptr/out_of_bounds_read.stderr+3-3
......@@ -1,16 +1,16 @@
1error[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
1error[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
22 --> $DIR/out_of_bounds_read.rs:8:33
33 |
44LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) };
55 | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_READ` failed here
66
7error[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
7error[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
88 --> $DIR/out_of_bounds_read.rs:10:39
99 |
1010LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() };
1111 | ^^^^^^^^^^^^^^^^^^^ evaluation of `main::_CONST_READ` failed here
1212
13error[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
13error[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
1414 --> $DIR/out_of_bounds_read.rs:12:37
1515 |
1616LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() };
tests/ui/consts/const-compare-bytes-ub.rs+1-1
......@@ -1,5 +1,5 @@
11//@ check-fail
2//@ ignore-parallel-frontend different alloc ids
2
33#![feature(core_intrinsics, const_cmp)]
44use std::intrinsics::compare_bytes;
55use std::mem::MaybeUninit;
tests/ui/consts/const-compare-bytes-ub.stderr+4-4
......@@ -16,19 +16,19 @@ error[E0080]: memory access failed: attempting to access 1 byte, but got 0x1[noa
1616LL | compare_bytes(1 as *const u8, 2 as *const u8, 1)
1717 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::DANGLING_PTR_NON_ZERO_LENGTH` failed here
1818
19error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0 which is only 3 bytes from the end of the allocation
19error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID which is only 3 bytes from the end of the allocation
2020 --> $DIR/const-compare-bytes-ub.rs:21:9
2121 |
2222LL | compare_bytes([1, 2, 3].as_ptr(), [1, 2, 3, 4].as_ptr(), 4)
2323 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::LHS_OUT_OF_BOUNDS` failed here
2424
25error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC1 which is only 3 bytes from the end of the allocation
25error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID which is only 3 bytes from the end of the allocation
2626 --> $DIR/const-compare-bytes-ub.rs:25:9
2727 |
2828LL | compare_bytes([1, 2, 3, 4].as_ptr(), [1, 2, 3].as_ptr(), 4)
2929 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::RHS_OUT_OF_BOUNDS` failed here
3030
31error[E0080]: reading memory at ALLOC2[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory
31error[E0080]: reading memory at ALLOC$ID[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory
3232 --> $DIR/const-compare-bytes-ub.rs:29:9
3333 |
3434LL | 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)
3838 __ │ ░
3939 }
4040
41error[E0080]: reading memory at ALLOC3[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory
41error[E0080]: reading memory at ALLOC$ID[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory
4242 --> $DIR/const-compare-bytes-ub.rs:33:9
4343 |
4444LL | compare_bytes([1].as_ptr(), MaybeUninit::uninit().as_ptr(), 1)
tests/ui/consts/const-err-enum-discriminant.32bit.stderr+1-1
......@@ -1,4 +1,4 @@
1error[E0080]: reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
1error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
22 --> $DIR/const-err-enum-discriminant.rs:10:21
33 |
44LL | Boo = [unsafe { Foo { b: () }.a }; 4][3],
tests/ui/consts/const-err-enum-discriminant.64bit.stderr+1-1
......@@ -1,4 +1,4 @@
1error[E0080]: reading memory at ALLOC0[0x0..0x8], but memory is uninitialized at [0x0..0x8], and this operation requires initialized memory
1error[E0080]: reading memory at ALLOC$ID[0x0..0x8], but memory is uninitialized at [0x0..0x8], and this operation requires initialized memory
22 --> $DIR/const-err-enum-discriminant.rs:10:21
33 |
44LL | Boo = [unsafe { Foo { b: () }.a }; 4][3],
tests/ui/consts/const-err-enum-discriminant.rs+1-1
......@@ -1,5 +1,5 @@
11//@ stderr-per-bitwidth
2//@ ignore-parallel-frontend different alloc ids
2
33#[derive(Copy, Clone)]
44union Foo {
55 a: isize,
tests/ui/consts/const-eval/c-variadic-fail.rs+5-5
......@@ -1,5 +1,5 @@
11//@ build-fail
2//@ ignore-parallel-frontend different alloc ids
2
33#![feature(c_variadic)]
44#![feature(const_c_variadic)]
55#![feature(const_trait_impl)]
......@@ -138,7 +138,7 @@ fn use_after_free() {
138138 let ap = helper(1, 2, 3);
139139 let mut ap = std::mem::transmute::<_, VaList>(ap);
140140 ap.next_arg::<i32>();
141 //~^ ERROR memory access failed: ALLOC0 has been freed, so this pointer is dangling [E0080]
141 //~^ ERROR memory access failed: ALLOC$ID has been freed, so this pointer is dangling [E0080]
142142 }
143143 };
144144}
......@@ -160,7 +160,7 @@ fn manual_copy_drop() {
160160 }
161161
162162 const { unsafe { helper(1, 2, 3) } };
163 //~^ ERROR using ALLOC0 as variable argument list pointer but it does not point to a variable argument list [E0080]
163 //~^ ERROR using ALLOC$ID as variable argument list pointer but it does not point to a variable argument list [E0080]
164164}
165165
166166fn manual_copy_forget() {
......@@ -176,7 +176,7 @@ fn manual_copy_forget() {
176176 }
177177
178178 const { unsafe { helper(1, 2, 3) } };
179 //~^ ERROR using ALLOC0 as variable argument list pointer but it does not point to a variable argument list [E0080]
179 //~^ ERROR using ALLOC$ID as variable argument list pointer but it does not point to a variable argument list [E0080]
180180}
181181
182182fn manual_copy_read() {
......@@ -189,7 +189,7 @@ fn manual_copy_read() {
189189 }
190190
191191 const { unsafe { helper(1, 2, 3) } };
192 //~^ ERROR using ALLOC0 as variable argument list pointer but it does not point to a variable argument list [E0080]
192 //~^ ERROR using ALLOC$ID as variable argument list pointer but it does not point to a variable argument list [E0080]
193193}
194194
195195fn drop_of_invalid() {
tests/ui/consts/const-eval/c-variadic-fail.stderr+4-4
......@@ -418,7 +418,7 @@ LL | const { read_as::<*const fn(&'static ())>(std::ptr::dangling::<for<'a>
418418 |
419419 = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
420420
421error[E0080]: memory access failed: ALLOC0 has been freed, so this pointer is dangling
421error[E0080]: memory access failed: ALLOC$ID has been freed, so this pointer is dangling
422422 --> $DIR/c-variadic-fail.rs:140:13
423423 |
424424LL | ap.next_arg::<i32>();
......@@ -451,7 +451,7 @@ LL | | };
451451 |
452452 = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
453453
454error[E0080]: using ALLOC1 as variable argument list pointer but it does not point to a variable argument list
454error[E0080]: using ALLOC$ID as variable argument list pointer but it does not point to a variable argument list
455455 --> $DIR/c-variadic-fail.rs:162:22
456456 |
457457LL | const { unsafe { helper(1, 2, 3) } };
......@@ -483,7 +483,7 @@ LL | const { unsafe { helper(1, 2, 3) } };
483483 |
484484 = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
485485
486error[E0080]: using ALLOC2 as variable argument list pointer but it does not point to a variable argument list
486error[E0080]: using ALLOC$ID as variable argument list pointer but it does not point to a variable argument list
487487 --> $DIR/c-variadic-fail.rs:178:22
488488 |
489489LL | const { unsafe { helper(1, 2, 3) } };
......@@ -515,7 +515,7 @@ LL | const { unsafe { helper(1, 2, 3) } };
515515 |
516516 = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
517517
518error[E0080]: using ALLOC3 as variable argument list pointer but it does not point to a variable argument list
518error[E0080]: using ALLOC$ID as variable argument list pointer but it does not point to a variable argument list
519519 --> $DIR/c-variadic-fail.rs:191:22
520520 |
521521LL | const { unsafe { helper(1, 2, 3) } };
tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr+4-4
......@@ -43,14 +43,14 @@ LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uin
4343 = help: this code performed an operation that depends on the underlying bytes representing a pointer
4444 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
4545
46error[E0080]: reading memory at ALLOC2[0x0..0x10], but memory is uninitialized at [0x8..0x10], and this operation requires initialized memory
46error[E0080]: reading memory at ALLOC$ID[0x0..0x10], but memory is uninitialized at [0x8..0x10], and this operation requires initialized memory
4747 --> $DIR/const-pointer-values-in-various-types.rs:42:47
4848 |
4949LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 };
5050 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_U128_UNION` failed here
5151 |
5252 = note: the raw bytes of the constant (size: 16, align: 16) {
53 ╾ALLOC0<imm>╼ __ __ __ __ __ __ __ __ │ ╾──────╼░░░░░░░░
53 ╾ALLOC$ID╼ __ __ __ __ __ __ __ __ │ ╾──────╼░░░░░░░░
5454 }
5555
5656error[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
8989 = help: this code performed an operation that depends on the underlying bytes representing a pointer
9090 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
9191
92error[E0080]: reading memory at ALLOC3[0x0..0x10], but memory is uninitialized at [0x8..0x10], and this operation requires initialized memory
92error[E0080]: reading memory at ALLOC$ID[0x0..0x10], but memory is uninitialized at [0x8..0x10], and this operation requires initialized memory
9393 --> $DIR/const-pointer-values-in-various-types.rs:57:47
9494 |
9595LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 };
9696 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_I128_UNION` failed here
9797 |
9898 = note: the raw bytes of the constant (size: 16, align: 16) {
99 ╾ALLOC1<imm>╼ __ __ __ __ __ __ __ __ │ ╾──────╼░░░░░░░░
99 ╾ALLOC$ID╼ __ __ __ __ __ __ __ __ │ ╾──────╼░░░░░░░░
100100 }
101101
102102error[E0080]: unable to turn pointer into integer
tests/ui/consts/const-eval/const-pointer-values-in-various-types.rs+1-1
......@@ -1,7 +1,7 @@
11//@ only-x86_64
22//@ stderr-per-bitwidth
33//@ dont-require-annotations: NOTE
4//@ ignore-parallel-frontend different alloc ids
4
55#[repr(C)]
66union Nonsense {
77 u: usize,
tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr+1-1
......@@ -6,7 +6,7 @@ LL | const BAR: &i32 = unsafe {
66 |
77 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88 = note: the raw bytes of the constant (size: 4, align: 4) {
9 ╾ALLOC0<imm>╼ │ ╾──╼
9 ╾ALLOC$ID╼ │ ╾──╼
1010 }
1111
1212error: aborting due to 1 previous error
tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr+1-1
......@@ -6,7 +6,7 @@ LL | const BAR: &i32 = unsafe {
66 |
77 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88 = note: the raw bytes of the constant (size: 8, align: 8) {
9 ╾ALLOC0<imm>╼ │ ╾──────╼
9 ╾ALLOC$ID╼ │ ╾──────╼
1010 }
1111
1212error: aborting due to 1 previous error
tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs+1-1
......@@ -3,7 +3,7 @@
33#![feature(core_intrinsics)]
44#![feature(const_heap)]
55use std::intrinsics;
6//@ ignore-parallel-frontend different alloc ids
6
77const BAR: &i32 = unsafe { //~ ERROR: uninitialized memory
88 // Make the pointer immutable to avoid errors related to mutable pointers in constants.
99 &*(intrinsics::const_make_global(intrinsics::const_allocate(4, 4)) as *const i32)
tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs+2-1
......@@ -1,10 +1,11 @@
11#![feature(core_intrinsics)]
22#![feature(const_heap)]
3//@ ignore-parallel-frontend different alloc ids
3
44// Strip out raw byte dumps to make comparison platform-independent:
55//@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
66//@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*A(LLOC)?[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP"
77//@ normalize-stderr: "HEX_DUMP\s*\n\s*HEX_DUMP" -> "HEX_DUMP"
8//@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼"
89
910use std::intrinsics;
1011
tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr+4-4
......@@ -1,16 +1,16 @@
11error[E0080]: constructing invalid value of type &u8: encountered a dangling reference (use-after-free)
2 --> $DIR/dealloc_intrinsic_dangling.rs:11:1
2 --> $DIR/dealloc_intrinsic_dangling.rs:12:1
33 |
44LL | const _X: &'static u8 = unsafe {
55 | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
66 |
77 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
9 HEX_DUMP
9 ╾ALLOC$ID╼ │ ╾─╼
1010 }
1111
12error[E0080]: memory access failed: ALLOC1 has been freed, so this pointer is dangling
13 --> $DIR/dealloc_intrinsic_dangling.rs:22:5
12error[E0080]: memory access failed: ALLOC$ID has been freed, so this pointer is dangling
13 --> $DIR/dealloc_intrinsic_dangling.rs:23:5
1414 |
1515LL | *reference
1616 | ^^^^^^^^^^ evaluation of `_Y` failed here
tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.rs+1-1
......@@ -1,6 +1,6 @@
11#![feature(core_intrinsics)]
22#![feature(const_heap)]
3//@ ignore-parallel-frontend different alloc ids
3
44use std::intrinsics;
55
66const _X: () = unsafe {
tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr+1-1
......@@ -1,4 +1,4 @@
1error[E0080]: memory access failed: ALLOC0 has been freed, so this pointer is dangling
1error[E0080]: memory access failed: ALLOC$ID has been freed, so this pointer is dangling
22 --> $DIR/dealloc_intrinsic_duplicate.rs:9:5
33 |
44LL | intrinsics::const_deallocate(ptr, 4, 4);
tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.rs+1-1
......@@ -1,6 +1,6 @@
11#![feature(core_intrinsics)]
22#![feature(const_heap)]
3//@ ignore-parallel-frontend different alloc ids
3
44use std::intrinsics;
55
66const _X: () = unsafe {
tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr+3-3
......@@ -1,16 +1,16 @@
1error[E0080]: incorrect layout on deallocation: ALLOC0 has size 4 and alignment 4, but gave size 4 and alignment 2
1error[E0080]: incorrect layout on deallocation: ALLOC$ID has size 4 and alignment 4, but gave size 4 and alignment 2
22 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:8:5
33 |
44LL | intrinsics::const_deallocate(ptr, 4, 2);
55 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_X` failed here
66
7error[E0080]: incorrect layout on deallocation: ALLOC1 has size 4 and alignment 4, but gave size 2 and alignment 4
7error[E0080]: incorrect layout on deallocation: ALLOC$ID has size 4 and alignment 4, but gave size 2 and alignment 4
88 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:13:5
99 |
1010LL | intrinsics::const_deallocate(ptr, 2, 4);
1111 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_Y` failed here
1212
13error[E0080]: incorrect layout on deallocation: ALLOC2 has size 4 and alignment 4, but gave size 3 and alignment 4
13error[E0080]: incorrect layout on deallocation: ALLOC$ID has size 4 and alignment 4, but gave size 3 and alignment 4
1414 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:19:5
1515 |
1616LL | intrinsics::const_deallocate(ptr, 3, 4);
tests/ui/consts/const-eval/heap/make-global-dangling.rs+1-1
......@@ -1,5 +1,5 @@
11// Ensure that we can't call `const_make_global` on dangling pointers.
2//@ ignore-parallel-frontend different alloc ids
2
33#![feature(core_intrinsics)]
44#![feature(const_heap)]
55
tests/ui/consts/const-eval/heap/make-global-other.rs+2-2
......@@ -1,5 +1,5 @@
11// Ensure that we can't call `const_make_global` on pointers not in the current interpreter.
2//@ ignore-parallel-frontend different alloc ids
2
33#![feature(core_intrinsics)]
44#![feature(const_heap)]
55
......@@ -9,7 +9,7 @@ const X: &i32 = &0;
99
1010const Y: &i32 = unsafe {
1111 &*(intrinsics::const_make_global(X as *const i32 as *mut u8) as *const i32)
12 //~^ error: pointer passed to `const_make_global` does not point to a heap allocation: ALLOC0<imm>
12 //~^ error: pointer passed to `const_make_global` does not point to a heap allocation: ALLOC$ID
1313};
1414
1515fn main() {}
tests/ui/consts/const-eval/heap/make-global-other.stderr+1-1
......@@ -1,4 +1,4 @@
1error[E0080]: pointer passed to `const_make_global` does not point to a heap allocation: ALLOC0<imm>
1error[E0080]: pointer passed to `const_make_global` does not point to a heap allocation: ALLOC$ID<imm>
22 --> $DIR/make-global-other.rs:11:8
33 |
44LL | &*(intrinsics::const_make_global(X as *const i32 as *mut u8) as *const i32)
tests/ui/consts/const-eval/heap/make-global-twice.rs+2-2
......@@ -1,5 +1,5 @@
11// Ensure that we can't call `const_make_global` twice.
2//@ ignore-parallel-frontend different alloc ids
2
33#![feature(core_intrinsics)]
44#![feature(const_heap)]
55
......@@ -11,7 +11,7 @@ const Y: &i32 = unsafe {
1111 *i = 20;
1212 intrinsics::const_make_global(ptr);
1313 intrinsics::const_make_global(ptr);
14 //~^ error: attempting to call `const_make_global` twice on the same allocation ALLOC0
14 //~^ error: attempting to call `const_make_global` twice on the same allocation ALLOC$ID
1515 &*i
1616};
1717
tests/ui/consts/const-eval/heap/make-global-twice.stderr+1-1
......@@ -1,4 +1,4 @@
1error[E0080]: attempting to call `const_make_global` twice on the same allocation ALLOC0
1error[E0080]: attempting to call `const_make_global` twice on the same allocation ALLOC$ID
22 --> $DIR/make-global-twice.rs:13:5
33 |
44LL | intrinsics::const_make_global(ptr);
tests/ui/consts/const-eval/heap/ptr_made_global_mutated.rs+2-2
......@@ -2,13 +2,13 @@
22#![feature(core_intrinsics)]
33#![feature(const_heap)]
44use std::intrinsics;
5//@ ignore-parallel-frontend different alloc ids
5
66const A: &u8 = unsafe {
77 let ptr = intrinsics::const_allocate(1, 1);
88 *ptr = 1;
99 let ptr: *const u8 = intrinsics::const_make_global(ptr);
1010 *(ptr as *mut u8) = 2;
11 //~^ error: writing to ALLOC0 which is read-only
11 //~^ error: writing to ALLOC$ID which is read-only
1212 &*ptr
1313};
1414
tests/ui/consts/const-eval/heap/ptr_made_global_mutated.stderr+1-1
......@@ -1,4 +1,4 @@
1error[E0080]: writing to ALLOC0 which is read-only
1error[E0080]: writing to ALLOC$ID which is read-only
22 --> $DIR/ptr_made_global_mutated.rs:10:5
33 |
44LL | *(ptr as *mut u8) = 2;
tests/ui/consts/const-eval/issue-49296.rs+1-1
......@@ -1,5 +1,5 @@
11// issue-49296: Unsafe shenigans in constants can result in missing errors
2//@ ignore-parallel-frontend different alloc ids
2
33use std::mem::transmute;
44
55const fn wat(x: u64) -> &'static u64 {
tests/ui/consts/const-eval/issue-49296.stderr+1-1
......@@ -1,4 +1,4 @@
1error[E0080]: memory access failed: ALLOC0 has been freed, so this pointer is dangling
1error[E0080]: memory access failed: ALLOC$ID has been freed, so this pointer is dangling
22 --> $DIR/issue-49296.rs:9:16
33 |
44LL | const X: u64 = *wat(42);
tests/ui/consts/const-eval/ptr_fragments_mixed.rs+1-1
......@@ -1,6 +1,6 @@
11//! This mixes fragments from different pointers, in a way that we should not accept.
22//! See <https://github.com/rust-lang/rust/issues/146291>.
3//@ ignore-parallel-frontend different alloc ids
3
44static A: u8 = 123;
55static B: u8 = 123;
66
tests/ui/consts/const-eval/ptr_fragments_mixed.stderr+2-2
......@@ -1,4 +1,4 @@
1error[E0080]: unable to read parts of a pointer from memory at ALLOC0
1error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID
22 --> $DIR/ptr_fragments_mixed.rs:19:9
33 |
44LL | y
......@@ -7,7 +7,7 @@ LL | y
77 = help: this code performed an operation that depends on the underlying bytes representing a pointer
88 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
99
10error[E0080]: unable to read parts of a pointer from memory at ALLOC1
10error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID
1111 --> $DIR/ptr_fragments_mixed.rs:33:9
1212 |
1313LL | y
tests/ui/consts/const-eval/raw-bytes.32bit.stderr+88-88
......@@ -1,5 +1,5 @@
11error[E0080]: constructing invalid value of type Enum: at .<enum-tag>, encountered 0x00000001, but expected a valid enum tag
2 --> $DIR/raw-bytes.rs:24:1
2 --> $DIR/raw-bytes.rs:23:1
33 |
44LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) };
55 | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -10,7 +10,7 @@ LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) };
1010 }
1111
1212error[E0080]: constructing invalid value of type Enum2: at .<enum-tag>, encountered 0x00000000, but expected a valid enum tag
13 --> $DIR/raw-bytes.rs:32:1
13 --> $DIR/raw-bytes.rs:31:1
1414 |
1515LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) };
1616 | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -21,7 +21,7 @@ LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) };
2121 }
2222
2323error[E0080]: constructing invalid value of type UninhDiscriminant: at .<enum-tag>, encountered an uninhabited enum variant
24 --> $DIR/raw-bytes.rs:46:1
24 --> $DIR/raw-bytes.rs:45:1
2525 |
2626LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) };
2727 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -32,7 +32,7 @@ LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute
3232 }
3333
3434error[E0080]: constructing invalid value of type UninhDiscriminant: at .<enum-tag>, encountered 0x03, but expected a valid enum tag
35 --> $DIR/raw-bytes.rs:48:1
35 --> $DIR/raw-bytes.rs:47:1
3636 |
3737LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) };
3838 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -43,7 +43,7 @@ LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute
4343 }
4444
4545error[E0080]: constructing invalid value of type Option<(char, char)>: at .<enum-variant(Some)>.0.1, encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`)
46 --> $DIR/raw-bytes.rs:54:1
46 --> $DIR/raw-bytes.rs:53:1
4747 |
4848LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) }));
4949 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
5454 }
5555
5656error[E0080]: constructing invalid value of type NonNull<u8>: at .pointer, encountered 0, but expected something greater or equal to 1
57 --> $DIR/raw-bytes.rs:59:1
57 --> $DIR/raw-bytes.rs:58:1
5858 |
5959LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
6060 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -65,7 +65,7 @@ LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
6565 }
6666
6767error[E0080]: constructing invalid value of type NonZero<u8>: at .0.0, encountered 0, but expected something greater or equal to 1
68 --> $DIR/raw-bytes.rs:62:1
68 --> $DIR/raw-bytes.rs:61:1
6969 |
7070LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) };
7171 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -76,7 +76,7 @@ LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) };
7676 }
7777
7878error[E0080]: constructing invalid value of type NonZero<usize>: at .0.0, encountered 0, but expected something greater or equal to 1
79 --> $DIR/raw-bytes.rs:64:1
79 --> $DIR/raw-bytes.rs:63:1
8080 |
8181LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) };
8282 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -87,7 +87,7 @@ LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) };
8787 }
8888
8989error[E0080]: constructing invalid value of type RestrictedRange1: at .0, encountered 42, but expected something in the range 10..=30
90 --> $DIR/raw-bytes.rs:68:1
90 --> $DIR/raw-bytes.rs:67:1
9191 |
9292LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(mem::transmute(42_u32)) };
9393 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -98,7 +98,7 @@ LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(mem::transmu
9898 }
9999
100100error[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
101 --> $DIR/raw-bytes.rs:72:1
101 --> $DIR/raw-bytes.rs:71:1
102102 |
103103LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(mem::transmute(20_i32)) };
104104 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -109,40 +109,40 @@ LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(mem::transmu
109109 }
110110
111111error[E0080]: constructing invalid value of type NonNull<dyn Send>: at .pointer, encountered 0, but expected something greater or equal to 1
112 --> $DIR/raw-bytes.rs:75:1
112 --> $DIR/raw-bytes.rs:74:1
113113 |
114114LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe {
115115 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
116116 |
117117 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
118118 = note: the raw bytes of the constant (size: 8, align: 4) {
119 00 00 00 00 ╾ALLOC_ID╼ │ ....╾──╼
119 00 00 00 00 ╾ALLOC$ID╼ │ ....╾──╼
120120 }
121121
122122error[E0080]: constructing invalid value of type &u16: encountered an unaligned reference (required 2 byte alignment but found 1)
123 --> $DIR/raw-bytes.rs:82:1
123 --> $DIR/raw-bytes.rs:81:1
124124 |
125125LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
126126 | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
127127 |
128128 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
129129 = note: the raw bytes of the constant (size: 4, align: 4) {
130 ╾ALLOC_ID╼ │ ╾──╼
130 ╾ALLOC$ID╼ │ ╾──╼
131131 }
132132
133133error[E0080]: constructing invalid value of type Box<u16>: encountered an unaligned box (required 2 byte alignment but found 1)
134 --> $DIR/raw-bytes.rs:85:1
134 --> $DIR/raw-bytes.rs:84:1
135135 |
136136LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
137137 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
138138 |
139139 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
140140 = note: the raw bytes of the constant (size: 4, align: 4) {
141 ╾ALLOC_ID╼ │ ╾──╼
141 ╾ALLOC$ID╼ │ ╾──╼
142142 }
143143
144144error[E0080]: constructing invalid value of type &u16: encountered a null reference
145 --> $DIR/raw-bytes.rs:88:1
145 --> $DIR/raw-bytes.rs:87:1
146146 |
147147LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
148148 | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -153,7 +153,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
153153 }
154154
155155error[E0080]: constructing invalid value of type Box<u16>: encountered a null box
156 --> $DIR/raw-bytes.rs:91:1
156 --> $DIR/raw-bytes.rs:90:1
157157 |
158158LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
159159 | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -164,7 +164,7 @@ LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
164164 }
165165
166166error[E0080]: constructing invalid value of type &u8: encountered a dangling reference (0x539[noalloc] has no provenance)
167 --> $DIR/raw-bytes.rs:94:1
167 --> $DIR/raw-bytes.rs:93:1
168168 |
169169LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
170170 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -175,7 +175,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
175175 }
176176
177177error[E0080]: constructing invalid value of type Box<u8>: encountered a dangling box (0x539[noalloc] has no provenance)
178 --> $DIR/raw-bytes.rs:97:1
178 --> $DIR/raw-bytes.rs:96:1
179179 |
180180LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
181181 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -186,7 +186,7 @@ LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
186186 }
187187
188188error[E0080]: constructing invalid value of type fn(): encountered null pointer, but expected a function pointer
189 --> $DIR/raw-bytes.rs:100:1
189 --> $DIR/raw-bytes.rs:99:1
190190 |
191191LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
192192 | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -197,7 +197,7 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
197197 }
198198
199199error[E0080]: constructing invalid value of type fn(): encountered 0xd[noalloc], but expected a function pointer
200 --> $DIR/raw-bytes.rs:102:1
200 --> $DIR/raw-bytes.rs:101:1
201201 |
202202LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
203203 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -207,19 +207,19 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
207207 0d 00 00 00 │ ....
208208 }
209209
210error[E0080]: constructing invalid value of type fn(): encountered ALLOC3<imm>, but expected a function pointer
211 --> $DIR/raw-bytes.rs:104:1
210error[E0080]: constructing invalid value of type fn(): encountered ALLOC$ID<imm>, but expected a function pointer
211 --> $DIR/raw-bytes.rs:103:1
212212 |
213213LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
214214 | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
215215 |
216216 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
217217 = note: the raw bytes of the constant (size: 4, align: 4) {
218 ╾ALLOC_ID╼ │ ╾──╼
218 ╾ALLOC$ID╼ │ ╾──╼
219219 }
220220
221221error[E0080]: constructing invalid value of type &Bar: encountered a reference pointing to uninhabited type Bar
222 --> $DIR/raw-bytes.rs:110:1
222 --> $DIR/raw-bytes.rs:109:1
223223 |
224224LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) };
225225 | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -230,62 +230,62 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) };
230230 }
231231
232232error[E0080]: constructing invalid value of type &str: encountered a dangling reference (going beyond the bounds of its allocation)
233 --> $DIR/raw-bytes.rs:134:1
233 --> $DIR/raw-bytes.rs:133:1
234234 |
235235LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) };
236236 | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
237237 |
238238 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
239239 = note: the raw bytes of the constant (size: 8, align: 4) {
240 ╾ALLOC_ID╼ e7 03 00 00 │ ╾──╼....
240 ╾ALLOC$ID╼ e7 03 00 00 │ ╾──╼....
241241 }
242242
243243error[E0080]: constructing invalid value of type (&str,): at .0, encountered invalid reference metadata: slice is bigger than largest supported object
244 --> $DIR/raw-bytes.rs:136:1
244 --> $DIR/raw-bytes.rs:135:1
245245 |
246246LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },);
247247 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
248248 |
249249 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
250250 = note: the raw bytes of the constant (size: 8, align: 4) {
251 ╾ALLOC_ID╼ ff ff ff ff │ ╾──╼....
251 ╾ALLOC$ID╼ ff ff ff ff │ ╾──╼....
252252 }
253253
254254error[E0080]: constructing invalid value of type &MyStr: encountered invalid reference metadata: slice is bigger than largest supported object
255 --> $DIR/raw-bytes.rs:138:1
255 --> $DIR/raw-bytes.rs:137:1
256256 |
257257LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) };
258258 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
259259 |
260260 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
261261 = note: the raw bytes of the constant (size: 8, align: 4) {
262 ╾ALLOC_ID╼ ff ff ff ff │ ╾──╼....
262 ╾ALLOC$ID╼ ff ff ff ff │ ╾──╼....
263263 }
264264
265265error[E0080]: constructing invalid value of type &str: at .<deref>, encountered uninitialized memory, but expected a string
266 --> $DIR/raw-bytes.rs:141:1
266 --> $DIR/raw-bytes.rs:140:1
267267 |
268268LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
269269 | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
270270 |
271271 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
272272 = note: the raw bytes of the constant (size: 8, align: 4) {
273 ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼....
273 ╾ALLOC$ID╼ 01 00 00 00 │ ╾──╼....
274274 }
275275
276276error[E0080]: constructing invalid value of type &MyStr: at .<deref>.0, encountered uninitialized memory, but expected a string
277 --> $DIR/raw-bytes.rs:143:1
277 --> $DIR/raw-bytes.rs:142:1
278278 |
279279LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
280280 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
281281 |
282282 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
283283 = note: the raw bytes of the constant (size: 8, align: 4) {
284 ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼....
284 ╾ALLOC$ID╼ 01 00 00 00 │ ╾──╼....
285285 }
286286
287287error[E0080]: constructing invalid value of type &MyStr: at .<deref>.0, encountered a pointer, but expected a string
288 --> $DIR/raw-bytes.rs:145:1
288 --> $DIR/raw-bytes.rs:144:1
289289 |
290290LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) };
291291 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -294,172 +294,172 @@ LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>
294294 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
295295 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
296296 = note: the raw bytes of the constant (size: 8, align: 4) {
297 ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼....
297 ╾ALLOC$ID╼ 01 00 00 00 │ ╾──╼....
298298 }
299299
300300error[E0080]: constructing invalid value of type &[u8]: encountered a dangling reference (going beyond the bounds of its allocation)
301 --> $DIR/raw-bytes.rs:149:1
301 --> $DIR/raw-bytes.rs:148:1
302302 |
303303LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) };
304304 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
305305 |
306306 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
307307 = note: the raw bytes of the constant (size: 8, align: 4) {
308 ╾ALLOC_ID╼ e7 03 00 00 │ ╾──╼....
308 ╾ALLOC$ID╼ e7 03 00 00 │ ╾──╼....
309309 }
310310
311311error[E0080]: constructing invalid value of type &[u32]: encountered invalid reference metadata: slice is bigger than largest supported object
312 --> $DIR/raw-bytes.rs:151:1
312 --> $DIR/raw-bytes.rs:150:1
313313 |
314314LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) };
315315 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
316316 |
317317 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
318318 = note: the raw bytes of the constant (size: 8, align: 4) {
319 ╾ALLOC_ID╼ ff ff ff 7f │ ╾──╼....
319 ╾ALLOC$ID╼ ff ff ff 7f │ ╾──╼....
320320 }
321321
322322error[E0080]: constructing invalid value of type Box<[u8]>: encountered a dangling box (going beyond the bounds of its allocation)
323 --> $DIR/raw-bytes.rs:154:1
323 --> $DIR/raw-bytes.rs:153:1
324324 |
325325LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) };
326326 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
327327 |
328328 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
329329 = note: the raw bytes of the constant (size: 8, align: 4) {
330 ╾ALLOC_ID╼ e7 03 00 00 │ ╾──╼....
330 ╾ALLOC$ID╼ e7 03 00 00 │ ╾──╼....
331331 }
332332
333333error[E0080]: constructing invalid value of type &[bool; 1]: at .<deref>[0], encountered 0x03, but expected a boolean
334 --> $DIR/raw-bytes.rs:157:1
334 --> $DIR/raw-bytes.rs:156:1
335335 |
336336LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
337337 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
338338 |
339339 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
340340 = note: the raw bytes of the constant (size: 4, align: 4) {
341 ╾ALLOC_ID╼ │ ╾──╼
341 ╾ALLOC$ID╼ │ ╾──╼
342342 }
343343
344344note: erroneous constant encountered
345 --> $DIR/raw-bytes.rs:157:40
345 --> $DIR/raw-bytes.rs:156:40
346346 |
347347LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
348348 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
349349
350350error[E0080]: constructing invalid value of type &MySlice<[bool; 1]>: at .<deref>.0, encountered 0x03, but expected a boolean
351 --> $DIR/raw-bytes.rs:161:1
351 --> $DIR/raw-bytes.rs:160:1
352352 |
353353LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
354354 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
355355 |
356356 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
357357 = note: the raw bytes of the constant (size: 4, align: 4) {
358 ╾ALLOC_ID╼ │ ╾──╼
358 ╾ALLOC$ID╼ │ ╾──╼
359359 }
360360
361361note: erroneous constant encountered
362 --> $DIR/raw-bytes.rs:161:42
362 --> $DIR/raw-bytes.rs:160:42
363363 |
364364LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
365365 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
366366
367367error[E0080]: constructing invalid value of type &MySlice<[bool; 1]>: at .<deref>.1[0], encountered 0x03, but expected a boolean
368 --> $DIR/raw-bytes.rs:164:1
368 --> $DIR/raw-bytes.rs:163:1
369369 |
370370LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
371371 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
372372 |
373373 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
374374 = note: the raw bytes of the constant (size: 4, align: 4) {
375 ╾ALLOC_ID╼ │ ╾──╼
375 ╾ALLOC$ID╼ │ ╾──╼
376376 }
377377
378378note: erroneous constant encountered
379 --> $DIR/raw-bytes.rs:164:42
379 --> $DIR/raw-bytes.rs:163:42
380380 |
381381LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
382382 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
383383
384error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC17<imm>, but expected a vtable pointer
385 --> $DIR/raw-bytes.rs:168:1
384error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID<imm>, but expected a vtable pointer
385 --> $DIR/raw-bytes.rs:167:1
386386 |
387387LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) };
388388 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
389389 |
390390 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
391391 = note: the raw bytes of the constant (size: 8, align: 4) {
392 ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼
392 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼
393393 }
394394
395error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC19<imm>, but expected a vtable pointer
396 --> $DIR/raw-bytes.rs:171:1
395error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID<imm>, but expected a vtable pointer
396 --> $DIR/raw-bytes.rs:170:1
397397 |
398398LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) };
399399 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
400400 |
401401 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
402402 = note: the raw bytes of the constant (size: 8, align: 4) {
403 ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼
403 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼
404404 }
405405
406406error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered 0x4[noalloc], but expected a vtable pointer
407 --> $DIR/raw-bytes.rs:174:1
407 --> $DIR/raw-bytes.rs:173:1
408408 |
409409LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) };
410410 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
411411 |
412412 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
413413 = note: the raw bytes of the constant (size: 8, align: 4) {
414 ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼....
414 ╾ALLOC$ID╼ 04 00 00 00 │ ╾──╼....
415415 }
416416
417error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC22<imm>, but expected a vtable pointer
418 --> $DIR/raw-bytes.rs:176:1
417error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID<imm>, but expected a vtable pointer
418 --> $DIR/raw-bytes.rs:175:1
419419 |
420420LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) };
421421 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
422422 |
423423 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
424424 = note: the raw bytes of the constant (size: 8, align: 4) {
425 ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼
425 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼
426426 }
427427
428428error[E0080]: constructing invalid value of type &dyn Trait: at .<deref>.<dyn-downcast(bool)>, encountered 0x03, but expected a boolean
429 --> $DIR/raw-bytes.rs:179:1
429 --> $DIR/raw-bytes.rs:178:1
430430 |
431431LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) };
432432 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
433433 |
434434 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
435435 = note: the raw bytes of the constant (size: 8, align: 4) {
436 ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼
436 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼
437437 }
438438
439439error[E0080]: constructing invalid value of type *const dyn Trait: encountered null pointer, but expected a vtable pointer
440 --> $DIR/raw-bytes.rs:182:1
440 --> $DIR/raw-bytes.rs:181:1
441441 |
442442LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) };
443443 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
444444 |
445445 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
446446 = note: the raw bytes of the constant (size: 8, align: 4) {
447 ╾ALLOC_ID╼ 00 00 00 00 │ ╾──╼....
447 ╾ALLOC$ID╼ 00 00 00 00 │ ╾──╼....
448448 }
449449
450error[E0080]: constructing invalid value of type *const dyn Trait: encountered ALLOC27<imm>, but expected a vtable pointer
451 --> $DIR/raw-bytes.rs:184:1
450error[E0080]: constructing invalid value of type *const dyn Trait: encountered ALLOC$ID<imm>, but expected a vtable pointer
451 --> $DIR/raw-bytes.rs:183:1
452452 |
453453LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
454454 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
455455 |
456456 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
457457 = note: the raw bytes of the constant (size: 8, align: 4) {
458 ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼
458 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼
459459 }
460460
461461error[E0080]: constructing invalid value of type &[!; 1]: encountered a reference pointing to uninhabited type [!; 1]
462 --> $DIR/raw-bytes.rs:188:1
462 --> $DIR/raw-bytes.rs:187:1
463463 |
464464LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) };
465465 | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -470,7 +470,7 @@ LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) };
470470 }
471471
472472error[E0080]: constructing invalid value of type &[!]: at .<deref>[0], encountered a value of the never type `!`
473 --> $DIR/raw-bytes.rs:189:1
473 --> $DIR/raw-bytes.rs:188:1
474474 |
475475LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) };
476476 | ^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -481,7 +481,7 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) };
481481 }
482482
483483error[E0080]: constructing invalid value of type &[!]: at .<deref>[0], encountered a value of the never type `!`
484 --> $DIR/raw-bytes.rs:190:1
484 --> $DIR/raw-bytes.rs:189:1
485485 |
486486LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) };
487487 | ^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -492,18 +492,18 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) };
492492 }
493493
494494error[E0080]: constructing invalid value of type &[u8]: at .<deref>[0], encountered uninitialized memory, but expected an integer
495 --> $DIR/raw-bytes.rs:193:1
495 --> $DIR/raw-bytes.rs:192:1
496496 |
497497LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) };
498498 | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
499499 |
500500 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
501501 = note: the raw bytes of the constant (size: 8, align: 4) {
502 ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼....
502 ╾ALLOC$ID╼ 01 00 00 00 │ ╾──╼....
503503 }
504504
505505error[E0080]: constructing invalid value of type &[u8]: at .<deref>[0], encountered a pointer, but expected an integer
506 --> $DIR/raw-bytes.rs:196:1
506 --> $DIR/raw-bytes.rs:195:1
507507 |
508508LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) };
509509 | ^^^^^^^^^^^^^^^^^^^^ 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:
512512 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
513513 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
514514 = note: the raw bytes of the constant (size: 8, align: 4) {
515 ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼....
515 ╾ALLOC$ID╼ 04 00 00 00 │ ╾──╼....
516516 }
517517
518518error[E0080]: constructing invalid value of type &[bool]: at .<deref>[0], encountered 0x11, but expected a boolean
519 --> $DIR/raw-bytes.rs:199:1
519 --> $DIR/raw-bytes.rs:198:1
520520 |
521521LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) };
522522 | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
523523 |
524524 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
525525 = note: the raw bytes of the constant (size: 8, align: 4) {
526 ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼....
526 ╾ALLOC$ID╼ 04 00 00 00 │ ╾──╼....
527527 }
528528
529529error[E0080]: constructing invalid value of type &[u16]: at .<deref>[1], encountered uninitialized memory, but expected an integer
530 --> $DIR/raw-bytes.rs:203:1
530 --> $DIR/raw-bytes.rs:202:1
531531 |
532532LL | pub static S7: &[u16] = unsafe {
533533 | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
534534 |
535535 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
536536 = note: the raw bytes of the constant (size: 8, align: 4) {
537 ╾ALLOC_ID+0x2╼ 04 00 00 00 │ ╾──╼....
537 ╾ALLOC$ID╼ 04 00 00 00 │ ╾──╼....
538538 }
539539
540540error[E0080]: constructing invalid value of type &[u8]: at .<deref>[0], encountered uninitialized memory, but expected an integer
541 --> $DIR/raw-bytes.rs:210:1
541 --> $DIR/raw-bytes.rs:209:1
542542 |
543543LL | pub static R4: &[u8] = unsafe {
544544 | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
545545 |
546546 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
547547 = note: the raw bytes of the constant (size: 8, align: 4) {
548 ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼....
548 ╾ALLOC$ID╼ 01 00 00 00 │ ╾──╼....
549549 }
550550
551551error[E0080]: constructing invalid value of type &[u8]: at .<deref>[0], encountered a pointer, but expected an integer
552 --> $DIR/raw-bytes.rs:215:1
552 --> $DIR/raw-bytes.rs:214:1
553553 |
554554LL | pub static R5: &[u8] = unsafe {
555555 | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -558,18 +558,18 @@ LL | pub static R5: &[u8] = unsafe {
558558 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
559559 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
560560 = note: the raw bytes of the constant (size: 8, align: 4) {
561 ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼....
561 ╾ALLOC$ID╼ 04 00 00 00 │ ╾──╼....
562562 }
563563
564564error[E0080]: constructing invalid value of type &[bool]: at .<deref>[0], encountered 0x11, but expected a boolean
565 --> $DIR/raw-bytes.rs:220:1
565 --> $DIR/raw-bytes.rs:219:1
566566 |
567567LL | pub static R6: &[bool] = unsafe {
568568 | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
569569 |
570570 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
571571 = note: the raw bytes of the constant (size: 8, align: 4) {
572 ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼....
572 ╾ALLOC$ID╼ 04 00 00 00 │ ╾──╼....
573573 }
574574
575575error: aborting due to 50 previous errors
tests/ui/consts/const-eval/raw-bytes.64bit.stderr+88-88
......@@ -1,5 +1,5 @@
11error[E0080]: constructing invalid value of type Enum: at .<enum-tag>, encountered 0x0000000000000001, but expected a valid enum tag
2 --> $DIR/raw-bytes.rs:24:1
2 --> $DIR/raw-bytes.rs:23:1
33 |
44LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) };
55 | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -10,7 +10,7 @@ LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) };
1010 }
1111
1212error[E0080]: constructing invalid value of type Enum2: at .<enum-tag>, encountered 0x0000000000000000, but expected a valid enum tag
13 --> $DIR/raw-bytes.rs:32:1
13 --> $DIR/raw-bytes.rs:31:1
1414 |
1515LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) };
1616 | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -21,7 +21,7 @@ LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) };
2121 }
2222
2323error[E0080]: constructing invalid value of type UninhDiscriminant: at .<enum-tag>, encountered an uninhabited enum variant
24 --> $DIR/raw-bytes.rs:46:1
24 --> $DIR/raw-bytes.rs:45:1
2525 |
2626LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) };
2727 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -32,7 +32,7 @@ LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute
3232 }
3333
3434error[E0080]: constructing invalid value of type UninhDiscriminant: at .<enum-tag>, encountered 0x03, but expected a valid enum tag
35 --> $DIR/raw-bytes.rs:48:1
35 --> $DIR/raw-bytes.rs:47:1
3636 |
3737LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) };
3838 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -43,7 +43,7 @@ LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute
4343 }
4444
4545error[E0080]: constructing invalid value of type Option<(char, char)>: at .<enum-variant(Some)>.0.1, encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`)
46 --> $DIR/raw-bytes.rs:54:1
46 --> $DIR/raw-bytes.rs:53:1
4747 |
4848LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) }));
4949 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
5454 }
5555
5656error[E0080]: constructing invalid value of type NonNull<u8>: at .pointer, encountered 0, but expected something greater or equal to 1
57 --> $DIR/raw-bytes.rs:59:1
57 --> $DIR/raw-bytes.rs:58:1
5858 |
5959LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
6060 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -65,7 +65,7 @@ LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
6565 }
6666
6767error[E0080]: constructing invalid value of type NonZero<u8>: at .0.0, encountered 0, but expected something greater or equal to 1
68 --> $DIR/raw-bytes.rs:62:1
68 --> $DIR/raw-bytes.rs:61:1
6969 |
7070LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) };
7171 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -76,7 +76,7 @@ LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) };
7676 }
7777
7878error[E0080]: constructing invalid value of type NonZero<usize>: at .0.0, encountered 0, but expected something greater or equal to 1
79 --> $DIR/raw-bytes.rs:64:1
79 --> $DIR/raw-bytes.rs:63:1
8080 |
8181LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) };
8282 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -87,7 +87,7 @@ LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) };
8787 }
8888
8989error[E0080]: constructing invalid value of type RestrictedRange1: at .0, encountered 42, but expected something in the range 10..=30
90 --> $DIR/raw-bytes.rs:68:1
90 --> $DIR/raw-bytes.rs:67:1
9191 |
9292LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(mem::transmute(42_u32)) };
9393 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -98,7 +98,7 @@ LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(mem::transmu
9898 }
9999
100100error[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
101 --> $DIR/raw-bytes.rs:72:1
101 --> $DIR/raw-bytes.rs:71:1
102102 |
103103LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(mem::transmute(20_i32)) };
104104 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -109,40 +109,40 @@ LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(mem::transmu
109109 }
110110
111111error[E0080]: constructing invalid value of type NonNull<dyn Send>: at .pointer, encountered 0, but expected something greater or equal to 1
112 --> $DIR/raw-bytes.rs:75:1
112 --> $DIR/raw-bytes.rs:74:1
113113 |
114114LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe {
115115 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
116116 |
117117 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
118118 = note: the raw bytes of the constant (size: 16, align: 8) {
119 00 00 00 00 00 00 00 00 ╾ALLOC_ID╼ │ ........╾──────╼
119 00 00 00 00 00 00 00 00 ╾ALLOC$ID╼ │ ........╾──────╼
120120 }
121121
122122error[E0080]: constructing invalid value of type &u16: encountered an unaligned reference (required 2 byte alignment but found 1)
123 --> $DIR/raw-bytes.rs:82:1
123 --> $DIR/raw-bytes.rs:81:1
124124 |
125125LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
126126 | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
127127 |
128128 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
129129 = note: the raw bytes of the constant (size: 8, align: 8) {
130 ╾ALLOC_ID╼ │ ╾──────╼
130 ╾ALLOC$ID╼ │ ╾──────╼
131131 }
132132
133133error[E0080]: constructing invalid value of type Box<u16>: encountered an unaligned box (required 2 byte alignment but found 1)
134 --> $DIR/raw-bytes.rs:85:1
134 --> $DIR/raw-bytes.rs:84:1
135135 |
136136LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
137137 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
138138 |
139139 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
140140 = note: the raw bytes of the constant (size: 8, align: 8) {
141 ╾ALLOC_ID╼ │ ╾──────╼
141 ╾ALLOC$ID╼ │ ╾──────╼
142142 }
143143
144144error[E0080]: constructing invalid value of type &u16: encountered a null reference
145 --> $DIR/raw-bytes.rs:88:1
145 --> $DIR/raw-bytes.rs:87:1
146146 |
147147LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
148148 | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -153,7 +153,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
153153 }
154154
155155error[E0080]: constructing invalid value of type Box<u16>: encountered a null box
156 --> $DIR/raw-bytes.rs:91:1
156 --> $DIR/raw-bytes.rs:90:1
157157 |
158158LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
159159 | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -164,7 +164,7 @@ LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
164164 }
165165
166166error[E0080]: constructing invalid value of type &u8: encountered a dangling reference (0x539[noalloc] has no provenance)
167 --> $DIR/raw-bytes.rs:94:1
167 --> $DIR/raw-bytes.rs:93:1
168168 |
169169LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
170170 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -175,7 +175,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
175175 }
176176
177177error[E0080]: constructing invalid value of type Box<u8>: encountered a dangling box (0x539[noalloc] has no provenance)
178 --> $DIR/raw-bytes.rs:97:1
178 --> $DIR/raw-bytes.rs:96:1
179179 |
180180LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
181181 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -186,7 +186,7 @@ LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
186186 }
187187
188188error[E0080]: constructing invalid value of type fn(): encountered null pointer, but expected a function pointer
189 --> $DIR/raw-bytes.rs:100:1
189 --> $DIR/raw-bytes.rs:99:1
190190 |
191191LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
192192 | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -197,7 +197,7 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
197197 }
198198
199199error[E0080]: constructing invalid value of type fn(): encountered 0xd[noalloc], but expected a function pointer
200 --> $DIR/raw-bytes.rs:102:1
200 --> $DIR/raw-bytes.rs:101:1
201201 |
202202LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
203203 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -207,19 +207,19 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
207207 0d 00 00 00 00 00 00 00 │ ........
208208 }
209209
210error[E0080]: constructing invalid value of type fn(): encountered ALLOC3<imm>, but expected a function pointer
211 --> $DIR/raw-bytes.rs:104:1
210error[E0080]: constructing invalid value of type fn(): encountered ALLOC$ID<imm>, but expected a function pointer
211 --> $DIR/raw-bytes.rs:103:1
212212 |
213213LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
214214 | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
215215 |
216216 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
217217 = note: the raw bytes of the constant (size: 8, align: 8) {
218 ╾ALLOC_ID╼ │ ╾──────╼
218 ╾ALLOC$ID╼ │ ╾──────╼
219219 }
220220
221221error[E0080]: constructing invalid value of type &Bar: encountered a reference pointing to uninhabited type Bar
222 --> $DIR/raw-bytes.rs:110:1
222 --> $DIR/raw-bytes.rs:109:1
223223 |
224224LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) };
225225 | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -230,62 +230,62 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) };
230230 }
231231
232232error[E0080]: constructing invalid value of type &str: encountered a dangling reference (going beyond the bounds of its allocation)
233 --> $DIR/raw-bytes.rs:134:1
233 --> $DIR/raw-bytes.rs:133:1
234234 |
235235LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) };
236236 | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
237237 |
238238 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
239239 = note: the raw bytes of the constant (size: 16, align: 8) {
240 ╾ALLOC_ID╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........
240 ╾ALLOC$ID╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........
241241 }
242242
243243error[E0080]: constructing invalid value of type (&str,): at .0, encountered invalid reference metadata: slice is bigger than largest supported object
244 --> $DIR/raw-bytes.rs:136:1
244 --> $DIR/raw-bytes.rs:135:1
245245 |
246246LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },);
247247 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
248248 |
249249 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
250250 = note: the raw bytes of the constant (size: 16, align: 8) {
251 ╾ALLOC_ID╼ ff ff ff ff ff ff ff ff │ ╾──────╼........
251 ╾ALLOC$ID╼ ff ff ff ff ff ff ff ff │ ╾──────╼........
252252 }
253253
254254error[E0080]: constructing invalid value of type &MyStr: encountered invalid reference metadata: slice is bigger than largest supported object
255 --> $DIR/raw-bytes.rs:138:1
255 --> $DIR/raw-bytes.rs:137:1
256256 |
257257LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) };
258258 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
259259 |
260260 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
261261 = note: the raw bytes of the constant (size: 16, align: 8) {
262 ╾ALLOC_ID╼ ff ff ff ff ff ff ff ff │ ╾──────╼........
262 ╾ALLOC$ID╼ ff ff ff ff ff ff ff ff │ ╾──────╼........
263263 }
264264
265265error[E0080]: constructing invalid value of type &str: at .<deref>, encountered uninitialized memory, but expected a string
266 --> $DIR/raw-bytes.rs:141:1
266 --> $DIR/raw-bytes.rs:140:1
267267 |
268268LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
269269 | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
270270 |
271271 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
272272 = note: the raw bytes of the constant (size: 16, align: 8) {
273 ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........
273 ╾ALLOC$ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........
274274 }
275275
276276error[E0080]: constructing invalid value of type &MyStr: at .<deref>.0, encountered uninitialized memory, but expected a string
277 --> $DIR/raw-bytes.rs:143:1
277 --> $DIR/raw-bytes.rs:142:1
278278 |
279279LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
280280 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
281281 |
282282 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
283283 = note: the raw bytes of the constant (size: 16, align: 8) {
284 ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........
284 ╾ALLOC$ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........
285285 }
286286
287287error[E0080]: constructing invalid value of type &MyStr: at .<deref>.0, encountered a pointer, but expected a string
288 --> $DIR/raw-bytes.rs:145:1
288 --> $DIR/raw-bytes.rs:144:1
289289 |
290290LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) };
291291 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -294,172 +294,172 @@ LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>
294294 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
295295 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
296296 = note: the raw bytes of the constant (size: 16, align: 8) {
297 ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........
297 ╾ALLOC$ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........
298298 }
299299
300300error[E0080]: constructing invalid value of type &[u8]: encountered a dangling reference (going beyond the bounds of its allocation)
301 --> $DIR/raw-bytes.rs:149:1
301 --> $DIR/raw-bytes.rs:148:1
302302 |
303303LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) };
304304 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
305305 |
306306 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
307307 = note: the raw bytes of the constant (size: 16, align: 8) {
308 ╾ALLOC_ID╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........
308 ╾ALLOC$ID╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........
309309 }
310310
311311error[E0080]: constructing invalid value of type &[u32]: encountered invalid reference metadata: slice is bigger than largest supported object
312 --> $DIR/raw-bytes.rs:151:1
312 --> $DIR/raw-bytes.rs:150:1
313313 |
314314LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) };
315315 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
316316 |
317317 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
318318 = note: the raw bytes of the constant (size: 16, align: 8) {
319 ╾ALLOC_ID╼ ff ff ff ff ff ff ff 7f │ ╾──────╼........
319 ╾ALLOC$ID╼ ff ff ff ff ff ff ff 7f │ ╾──────╼........
320320 }
321321
322322error[E0080]: constructing invalid value of type Box<[u8]>: encountered a dangling box (going beyond the bounds of its allocation)
323 --> $DIR/raw-bytes.rs:154:1
323 --> $DIR/raw-bytes.rs:153:1
324324 |
325325LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) };
326326 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
327327 |
328328 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
329329 = note: the raw bytes of the constant (size: 16, align: 8) {
330 ╾ALLOC_ID╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........
330 ╾ALLOC$ID╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........
331331 }
332332
333333error[E0080]: constructing invalid value of type &[bool; 1]: at .<deref>[0], encountered 0x03, but expected a boolean
334 --> $DIR/raw-bytes.rs:157:1
334 --> $DIR/raw-bytes.rs:156:1
335335 |
336336LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
337337 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
338338 |
339339 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
340340 = note: the raw bytes of the constant (size: 8, align: 8) {
341 ╾ALLOC_ID╼ │ ╾──────╼
341 ╾ALLOC$ID╼ │ ╾──────╼
342342 }
343343
344344note: erroneous constant encountered
345 --> $DIR/raw-bytes.rs:157:40
345 --> $DIR/raw-bytes.rs:156:40
346346 |
347347LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
348348 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
349349
350350error[E0080]: constructing invalid value of type &MySlice<[bool; 1]>: at .<deref>.0, encountered 0x03, but expected a boolean
351 --> $DIR/raw-bytes.rs:161:1
351 --> $DIR/raw-bytes.rs:160:1
352352 |
353353LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
354354 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
355355 |
356356 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
357357 = note: the raw bytes of the constant (size: 8, align: 8) {
358 ╾ALLOC_ID╼ │ ╾──────╼
358 ╾ALLOC$ID╼ │ ╾──────╼
359359 }
360360
361361note: erroneous constant encountered
362 --> $DIR/raw-bytes.rs:161:42
362 --> $DIR/raw-bytes.rs:160:42
363363 |
364364LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
365365 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
366366
367367error[E0080]: constructing invalid value of type &MySlice<[bool; 1]>: at .<deref>.1[0], encountered 0x03, but expected a boolean
368 --> $DIR/raw-bytes.rs:164:1
368 --> $DIR/raw-bytes.rs:163:1
369369 |
370370LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
371371 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
372372 |
373373 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
374374 = note: the raw bytes of the constant (size: 8, align: 8) {
375 ╾ALLOC_ID╼ │ ╾──────╼
375 ╾ALLOC$ID╼ │ ╾──────╼
376376 }
377377
378378note: erroneous constant encountered
379 --> $DIR/raw-bytes.rs:164:42
379 --> $DIR/raw-bytes.rs:163:42
380380 |
381381LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
382382 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
383383
384error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC17<imm>, but expected a vtable pointer
385 --> $DIR/raw-bytes.rs:168:1
384error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID<imm>, but expected a vtable pointer
385 --> $DIR/raw-bytes.rs:167:1
386386 |
387387LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) };
388388 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
389389 |
390390 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
391391 = note: the raw bytes of the constant (size: 16, align: 8) {
392 ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼
392 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼
393393 }
394394
395error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC19<imm>, but expected a vtable pointer
396 --> $DIR/raw-bytes.rs:171:1
395error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID<imm>, but expected a vtable pointer
396 --> $DIR/raw-bytes.rs:170:1
397397 |
398398LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) };
399399 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
400400 |
401401 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
402402 = note: the raw bytes of the constant (size: 16, align: 8) {
403 ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼
403 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼
404404 }
405405
406406error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered 0x4[noalloc], but expected a vtable pointer
407 --> $DIR/raw-bytes.rs:174:1
407 --> $DIR/raw-bytes.rs:173:1
408408 |
409409LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) };
410410 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
411411 |
412412 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
413413 = note: the raw bytes of the constant (size: 16, align: 8) {
414 ╾ALLOC_ID╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........
414 ╾ALLOC$ID╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........
415415 }
416416
417error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC22<imm>, but expected a vtable pointer
418 --> $DIR/raw-bytes.rs:176:1
417error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID<imm>, but expected a vtable pointer
418 --> $DIR/raw-bytes.rs:175:1
419419 |
420420LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) };
421421 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
422422 |
423423 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
424424 = note: the raw bytes of the constant (size: 16, align: 8) {
425 ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼
425 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼
426426 }
427427
428428error[E0080]: constructing invalid value of type &dyn Trait: at .<deref>.<dyn-downcast(bool)>, encountered 0x03, but expected a boolean
429 --> $DIR/raw-bytes.rs:179:1
429 --> $DIR/raw-bytes.rs:178:1
430430 |
431431LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) };
432432 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
433433 |
434434 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
435435 = note: the raw bytes of the constant (size: 16, align: 8) {
436 ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼
436 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼
437437 }
438438
439439error[E0080]: constructing invalid value of type *const dyn Trait: encountered null pointer, but expected a vtable pointer
440 --> $DIR/raw-bytes.rs:182:1
440 --> $DIR/raw-bytes.rs:181:1
441441 |
442442LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) };
443443 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
444444 |
445445 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
446446 = note: the raw bytes of the constant (size: 16, align: 8) {
447 ╾ALLOC_ID╼ 00 00 00 00 00 00 00 00 │ ╾──────╼........
447 ╾ALLOC$ID╼ 00 00 00 00 00 00 00 00 │ ╾──────╼........
448448 }
449449
450error[E0080]: constructing invalid value of type *const dyn Trait: encountered ALLOC27<imm>, but expected a vtable pointer
451 --> $DIR/raw-bytes.rs:184:1
450error[E0080]: constructing invalid value of type *const dyn Trait: encountered ALLOC$ID<imm>, but expected a vtable pointer
451 --> $DIR/raw-bytes.rs:183:1
452452 |
453453LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
454454 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
455455 |
456456 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
457457 = note: the raw bytes of the constant (size: 16, align: 8) {
458 ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼
458 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼
459459 }
460460
461461error[E0080]: constructing invalid value of type &[!; 1]: encountered a reference pointing to uninhabited type [!; 1]
462 --> $DIR/raw-bytes.rs:188:1
462 --> $DIR/raw-bytes.rs:187:1
463463 |
464464LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) };
465465 | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -470,7 +470,7 @@ LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) };
470470 }
471471
472472error[E0080]: constructing invalid value of type &[!]: at .<deref>[0], encountered a value of the never type `!`
473 --> $DIR/raw-bytes.rs:189:1
473 --> $DIR/raw-bytes.rs:188:1
474474 |
475475LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) };
476476 | ^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -481,7 +481,7 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) };
481481 }
482482
483483error[E0080]: constructing invalid value of type &[!]: at .<deref>[0], encountered a value of the never type `!`
484 --> $DIR/raw-bytes.rs:190:1
484 --> $DIR/raw-bytes.rs:189:1
485485 |
486486LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) };
487487 | ^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -492,18 +492,18 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) };
492492 }
493493
494494error[E0080]: constructing invalid value of type &[u8]: at .<deref>[0], encountered uninitialized memory, but expected an integer
495 --> $DIR/raw-bytes.rs:193:1
495 --> $DIR/raw-bytes.rs:192:1
496496 |
497497LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) };
498498 | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
499499 |
500500 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
501501 = note: the raw bytes of the constant (size: 16, align: 8) {
502 ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........
502 ╾ALLOC$ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........
503503 }
504504
505505error[E0080]: constructing invalid value of type &[u8]: at .<deref>[0], encountered a pointer, but expected an integer
506 --> $DIR/raw-bytes.rs:196:1
506 --> $DIR/raw-bytes.rs:195:1
507507 |
508508LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) };
509509 | ^^^^^^^^^^^^^^^^^^^^ 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:
512512 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
513513 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
514514 = note: the raw bytes of the constant (size: 16, align: 8) {
515 ╾ALLOC_ID╼ 08 00 00 00 00 00 00 00 │ ╾──────╼........
515 ╾ALLOC$ID╼ 08 00 00 00 00 00 00 00 │ ╾──────╼........
516516 }
517517
518518error[E0080]: constructing invalid value of type &[bool]: at .<deref>[0], encountered 0x11, but expected a boolean
519 --> $DIR/raw-bytes.rs:199:1
519 --> $DIR/raw-bytes.rs:198:1
520520 |
521521LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) };
522522 | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
523523 |
524524 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
525525 = note: the raw bytes of the constant (size: 16, align: 8) {
526 ╾ALLOC_ID╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........
526 ╾ALLOC$ID╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........
527527 }
528528
529529error[E0080]: constructing invalid value of type &[u16]: at .<deref>[1], encountered uninitialized memory, but expected an integer
530 --> $DIR/raw-bytes.rs:203:1
530 --> $DIR/raw-bytes.rs:202:1
531531 |
532532LL | pub static S7: &[u16] = unsafe {
533533 | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
534534 |
535535 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
536536 = note: the raw bytes of the constant (size: 16, align: 8) {
537 ╾ALLOC_ID+0x2╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........
537 ╾ALLOC$ID╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........
538538 }
539539
540540error[E0080]: constructing invalid value of type &[u8]: at .<deref>[0], encountered uninitialized memory, but expected an integer
541 --> $DIR/raw-bytes.rs:210:1
541 --> $DIR/raw-bytes.rs:209:1
542542 |
543543LL | pub static R4: &[u8] = unsafe {
544544 | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
545545 |
546546 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
547547 = note: the raw bytes of the constant (size: 16, align: 8) {
548 ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........
548 ╾ALLOC$ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........
549549 }
550550
551551error[E0080]: constructing invalid value of type &[u8]: at .<deref>[0], encountered a pointer, but expected an integer
552 --> $DIR/raw-bytes.rs:215:1
552 --> $DIR/raw-bytes.rs:214:1
553553 |
554554LL | pub static R5: &[u8] = unsafe {
555555 | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -558,18 +558,18 @@ LL | pub static R5: &[u8] = unsafe {
558558 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
559559 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
560560 = note: the raw bytes of the constant (size: 16, align: 8) {
561 ╾ALLOC_ID╼ 08 00 00 00 00 00 00 00 │ ╾──────╼........
561 ╾ALLOC$ID╼ 08 00 00 00 00 00 00 00 │ ╾──────╼........
562562 }
563563
564564error[E0080]: constructing invalid value of type &[bool]: at .<deref>[0], encountered 0x11, but expected a boolean
565 --> $DIR/raw-bytes.rs:220:1
565 --> $DIR/raw-bytes.rs:219:1
566566 |
567567LL | pub static R6: &[bool] = unsafe {
568568 | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
569569 |
570570 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
571571 = note: the raw bytes of the constant (size: 16, align: 8) {
572 ╾ALLOC_ID╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........
572 ╾ALLOC$ID╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........
573573 }
574574
575575error: aborting due to 50 previous errors
tests/ui/consts/const-eval/raw-bytes.rs+1-2
......@@ -1,9 +1,8 @@
11//@ stderr-per-bitwidth
22//@ ignore-endian-big
33// ignore-tidy-linelength
4//@ normalize-stderr: "╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼" -> "╾ALLOC_ID$1╼"
54//@ dont-require-annotations: NOTE
6//@ ignore-parallel-frontend different alloc ids
5
76#![allow(invalid_value, unnecessary_transmutes)]
87#![feature(never_type, rustc_attrs, ptr_metadata, slice_from_ptr_range, const_slice_from_ptr_range)]
98#![feature(pattern_types, pattern_type_macro)]
tests/ui/consts/const-eval/raw-pointer-ub.rs+1-1
......@@ -4,7 +4,7 @@ const MISALIGNED_LOAD: () = unsafe {
44 let _val = *ptr; //~NOTE: failed here
55 //~^ERROR: based on pointer with alignment 1, but alignment 4 is required
66};
7//@ ignore-parallel-frontend different alloc ids
7
88const MISALIGNED_STORE: () = unsafe {
99 let mut mem = [0u32; 8];
1010 let ptr = mem.as_mut_ptr().byte_add(1);
tests/ui/consts/const-eval/raw-pointer-ub.stderr+1-1
......@@ -25,7 +25,7 @@ error[E0080]: accessing memory based on pointer with alignment 4, but alignment
2525LL | let _val = (*ptr).0;
2626 | ^^^^^^^^ evaluation of `MISALIGNED_FIELD` failed here
2727
28error[E0080]: memory access failed: attempting to access 8 bytes, but got ALLOC0 which is only 4 bytes from the end of the allocation
28error[E0080]: memory access failed: attempting to access 8 bytes, but got ALLOC$ID which is only 4 bytes from the end of the allocation
2929 --> $DIR/raw-pointer-ub.rs:40:16
3030 |
3131LL | let _val = *ptr;
tests/ui/consts/const-eval/read_partial_ptr.rs+1-1
......@@ -1,5 +1,5 @@
11//! Ensure we error when trying to load from a pointer whose provenance has been messed with.
2//@ ignore-parallel-frontend different alloc ids
2
33const PARTIAL_OVERWRITE: () = {
44 let mut p = &42;
55 // Overwrite one byte with a no-provenance value.
tests/ui/consts/const-eval/read_partial_ptr.stderr+4-4
......@@ -1,4 +1,4 @@
1error[E0080]: unable to read parts of a pointer from memory at ALLOC0
1error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID
22 --> $DIR/read_partial_ptr.rs:10:13
33 |
44LL | let x = *p;
......@@ -7,7 +7,7 @@ LL | let x = *p;
77 = help: this code performed an operation that depends on the underlying bytes representing a pointer
88 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
99
10error[E0080]: unable to read parts of a pointer from memory at ALLOC1
10error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID
1111 --> $DIR/read_partial_ptr.rs:23:13
1212 |
1313LL | let x = *p;
......@@ -16,7 +16,7 @@ LL | let x = *p;
1616 = help: this code performed an operation that depends on the underlying bytes representing a pointer
1717 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
1818
19error[E0080]: unable to read parts of a pointer from memory at ALLOC2
19error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID
2020 --> $DIR/read_partial_ptr.rs:34:13
2121 |
2222LL | let x = *p;
......@@ -25,7 +25,7 @@ LL | let x = *p;
2525 = help: this code performed an operation that depends on the underlying bytes representing a pointer
2626 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
2727
28error[E0080]: unable to read parts of a pointer from memory at ALLOC3
28error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID
2929 --> $DIR/read_partial_ptr.rs:46:13
3030 |
3131LL | let x = *p;
tests/ui/consts/const-eval/ub-enum-overwrite.rs+1-1
......@@ -2,7 +2,7 @@ enum E {
22 A(u8),
33 B,
44}
5//@ ignore-parallel-frontend different alloc ids
5
66const _: u8 = {
77 let mut e = E::A(1);
88 let p = if let E::A(x) = &mut e { x as *mut u8 } else { unreachable!() };
tests/ui/consts/const-eval/ub-enum-overwrite.stderr+1-1
......@@ -1,4 +1,4 @@
1error[E0080]: reading memory at ALLOC0[0x1..0x2], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory
1error[E0080]: reading memory at ALLOC$ID[0x1..0x2], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory
22 --> $DIR/ub-enum-overwrite.rs:11:14
33 |
44LL | unsafe { *p }
tests/ui/consts/const-eval/ub-enum.rs+1-1
......@@ -4,7 +4,7 @@
44//@ normalize-stderr: "0x0+" -> "0x0"
55//@ normalize-stderr: "0x[0-9](\.\.|\])" -> "0x%$1"
66//@ dont-require-annotations: NOTE
7//@ ignore-parallel-frontend different alloc ids
7
88#![feature(never_type)]
99#![allow(invalid_value, unnecessary_transmutes)]
1010
tests/ui/consts/const-eval/ub-enum.stderr+1-1
......@@ -56,7 +56,7 @@ LL | const BAD_ENUM2_WRAPPED: Wrap<Enum2> = unsafe { mem::transmute(&0) };
5656 = help: this code performed an operation that depends on the underlying bytes representing a pointer
5757 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
5858
59error[E0080]: reading memory at ALLOC0[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory
59error[E0080]: reading memory at ALLOC$ID[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory
6060 --> $DIR/ub-enum.rs:62:41
6161 |
6262LL | const BAD_ENUM2_UNDEF: Enum2 = unsafe { MaybeUninit { uninit: () }.init };
tests/ui/consts/const-eval/ub-incorrect-vtable.32bit.stderr+11-11
......@@ -1,4 +1,4 @@
1error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC1<imm>, but expected a vtable pointer
1error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC$ID<imm>, but expected a vtable pointer
22 --> $DIR/ub-incorrect-vtable.rs:18:1
33 |
44LL | const INVALID_VTABLE_ALIGNMENT: &dyn Trait =
......@@ -6,10 +6,10 @@ LL | const INVALID_VTABLE_ALIGNMENT: &dyn Trait =
66 |
77 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88 = note: the raw bytes of the constant (size: 8, align: 4) {
9 ╾ALLOC0<imm>╼ ╾ALLOC1<imm>╼ │ ╾──╼╾──╼
9 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼
1010 }
1111
12error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC3<imm>, but expected a vtable pointer
12error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC$ID<imm>, but expected a vtable pointer
1313 --> $DIR/ub-incorrect-vtable.rs:22:1
1414 |
1515LL | const INVALID_VTABLE_SIZE: &dyn Trait =
......@@ -17,10 +17,10 @@ LL | const INVALID_VTABLE_SIZE: &dyn Trait =
1717 |
1818 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
1919 = note: the raw bytes of the constant (size: 8, align: 4) {
20 ╾ALLOC2<imm>╼ ╾ALLOC3<imm>╼ │ ╾──╼╾──╼
20 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼
2121 }
2222
23error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC5<imm>, but expected a vtable pointer
23error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID<imm>, but expected a vtable pointer
2424 --> $DIR/ub-incorrect-vtable.rs:31:1
2525 |
2626LL | const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> =
......@@ -28,10 +28,10 @@ LL | const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> =
2828 |
2929 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
3030 = note: the raw bytes of the constant (size: 8, align: 4) {
31 ╾ALLOC4<imm>╼ ╾ALLOC5<imm>╼ │ ╾──╼╾──╼
31 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼
3232 }
3333
34error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC7<imm>, but expected a vtable pointer
34error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID<imm>, but expected a vtable pointer
3535 --> $DIR/ub-incorrect-vtable.rs:35:1
3636 |
3737LL | const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> =
......@@ -39,10 +39,10 @@ LL | const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> =
3939 |
4040 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
4141 = note: the raw bytes of the constant (size: 8, align: 4) {
42 ╾ALLOC6<imm>╼ ╾ALLOC7<imm>╼ │ ╾──╼╾──╼
42 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼
4343 }
4444
45error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC9<imm>, but expected a vtable pointer
45error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID<imm>, but expected a vtable pointer
4646 --> $DIR/ub-incorrect-vtable.rs:40:1
4747 |
4848LL | const INVALID_VTABLE_UB: W<&dyn Trait> =
......@@ -50,7 +50,7 @@ LL | const INVALID_VTABLE_UB: W<&dyn Trait> =
5050 |
5151 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
5252 = note: the raw bytes of the constant (size: 8, align: 4) {
53 ╾ALLOC8<imm>╼ ╾ALLOC9<imm>╼ │ ╾──╼╾──╼
53 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼
5454 }
5555
5656error[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 };
6161 |
6262 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
6363 = note: the raw bytes of the constant (size: 8, align: 4) {
64 ╾ALLOC10<imm>╼ ╾ALLOC11╼ │ ╾──╼╾──╼
64 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼
6565 }
6666
6767error: aborting due to 6 previous errors
tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr+11-11
......@@ -1,4 +1,4 @@
1error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC1<imm>, but expected a vtable pointer
1error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC$ID<imm>, but expected a vtable pointer
22 --> $DIR/ub-incorrect-vtable.rs:18:1
33 |
44LL | const INVALID_VTABLE_ALIGNMENT: &dyn Trait =
......@@ -6,10 +6,10 @@ LL | const INVALID_VTABLE_ALIGNMENT: &dyn Trait =
66 |
77 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88 = note: the raw bytes of the constant (size: 16, align: 8) {
9 ╾ALLOC0<imm>╼ ╾ALLOC1<imm>╼ │ ╾──────╼╾──────╼
9 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼
1010 }
1111
12error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC3<imm>, but expected a vtable pointer
12error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC$ID<imm>, but expected a vtable pointer
1313 --> $DIR/ub-incorrect-vtable.rs:22:1
1414 |
1515LL | const INVALID_VTABLE_SIZE: &dyn Trait =
......@@ -17,10 +17,10 @@ LL | const INVALID_VTABLE_SIZE: &dyn Trait =
1717 |
1818 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
1919 = note: the raw bytes of the constant (size: 16, align: 8) {
20 ╾ALLOC2<imm>╼ ╾ALLOC3<imm>╼ │ ╾──────╼╾──────╼
20 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼
2121 }
2222
23error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC5<imm>, but expected a vtable pointer
23error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID<imm>, but expected a vtable pointer
2424 --> $DIR/ub-incorrect-vtable.rs:31:1
2525 |
2626LL | const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> =
......@@ -28,10 +28,10 @@ LL | const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> =
2828 |
2929 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
3030 = note: the raw bytes of the constant (size: 16, align: 8) {
31 ╾ALLOC4<imm>╼ ╾ALLOC5<imm>╼ │ ╾──────╼╾──────╼
31 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼
3232 }
3333
34error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC7<imm>, but expected a vtable pointer
34error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID<imm>, but expected a vtable pointer
3535 --> $DIR/ub-incorrect-vtable.rs:35:1
3636 |
3737LL | const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> =
......@@ -39,10 +39,10 @@ LL | const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> =
3939 |
4040 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
4141 = note: the raw bytes of the constant (size: 16, align: 8) {
42 ╾ALLOC6<imm>╼ ╾ALLOC7<imm>╼ │ ╾──────╼╾──────╼
42 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼
4343 }
4444
45error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC9<imm>, but expected a vtable pointer
45error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID<imm>, but expected a vtable pointer
4646 --> $DIR/ub-incorrect-vtable.rs:40:1
4747 |
4848LL | const INVALID_VTABLE_UB: W<&dyn Trait> =
......@@ -50,7 +50,7 @@ LL | const INVALID_VTABLE_UB: W<&dyn Trait> =
5050 |
5151 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
5252 = note: the raw bytes of the constant (size: 16, align: 8) {
53 ╾ALLOC8<imm>╼ ╾ALLOC9<imm>╼ │ ╾──────╼╾──────╼
53 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼
5454 }
5555
5656error[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 };
6161 |
6262 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
6363 = note: the raw bytes of the constant (size: 16, align: 8) {
64 ╾ALLOC10<imm>╼ ╾ALLOC11╼ │ ╾──────╼╾──────╼
64 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼
6565 }
6666
6767error: aborting due to 6 previous errors
tests/ui/consts/const-eval/ub-incorrect-vtable.rs+1-1
......@@ -12,7 +12,7 @@
1212
1313//@ stderr-per-bitwidth
1414//@ dont-require-annotations: NOTE
15//@ ignore-parallel-frontend different alloc ids
15
1616trait Trait {}
1717
1818const INVALID_VTABLE_ALIGNMENT: &dyn Trait =
tests/ui/consts/const-eval/ub-nonnull.rs+3-1
......@@ -1,8 +1,10 @@
11// Strip out raw byte dumps to make comparison platform-independent:
22//@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
33//@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP"
4//@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼"
5//@ normalize-stderr: "[0-9a-f][0-9a-f]( [0-9a-f][0-9a-f]){3,7} ╾ALLOC\$ID╼" -> "HEX_DUMP ╾ALLOC$$ID╼ │ ╾─╼"
46//@ dont-require-annotations: NOTE
5//@ ignore-parallel-frontend different alloc ids
7
68#![allow(invalid_value)] // make sure we cannot allow away the errors tested here
79#![feature(rustc_attrs, ptr_metadata)]
810
tests/ui/consts/const-eval/ub-nonnull.stderr+11-11
......@@ -1,5 +1,5 @@
11error[E0080]: constructing invalid value of type NonNull<u8>: at .pointer, encountered 0, but expected something greater or equal to 1
2 --> $DIR/ub-nonnull.rs:16:1
2 --> $DIR/ub-nonnull.rs:18:1
33 |
44LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
55 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -9,14 +9,14 @@ LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
99 HEX_DUMP
1010 }
1111
12error[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
13 --> $DIR/ub-nonnull.rs:22:29
12error[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
13 --> $DIR/ub-nonnull.rs:24:29
1414 |
1515LL | let out_of_bounds_ptr = &ptr[255];
1616 | ^^^^^^^^^ evaluation of `OUT_OF_BOUNDS_PTR` failed here
1717
1818error[E0080]: constructing invalid value of type NonZero<u8>: at .0.0, encountered 0, but expected something greater or equal to 1
19 --> $DIR/ub-nonnull.rs:26:1
19 --> $DIR/ub-nonnull.rs:28:1
2020 |
2121LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) };
2222 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -27,7 +27,7 @@ LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) };
2727 }
2828
2929error[E0080]: constructing invalid value of type NonZero<usize>: at .0.0, encountered 0, but expected something greater or equal to 1
30 --> $DIR/ub-nonnull.rs:28:1
30 --> $DIR/ub-nonnull.rs:30:1
3131 |
3232LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) };
3333 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -37,8 +37,8 @@ LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) };
3737 HEX_DUMP
3838 }
3939
40error[E0080]: reading memory at ALLOC3[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory
41 --> $DIR/ub-nonnull.rs:36:38
40error[E0080]: reading memory at ALLOC$ID[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory
41 --> $DIR/ub-nonnull.rs:38:38
4242 |
4343LL | const UNINIT: NonZero<u8> = unsafe { MaybeUninit { uninit: () }.init };
4444 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNINIT` failed here
......@@ -48,25 +48,25 @@ LL | const UNINIT: NonZero<u8> = unsafe { MaybeUninit { uninit: () }.init };
4848 }
4949
5050error[E0080]: constructing invalid value of type NonNull<dyn Send>: at .pointer, encountered 0, but expected something greater or equal to 1
51 --> $DIR/ub-nonnull.rs:39:1
51 --> $DIR/ub-nonnull.rs:41:1
5252 |
5353LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe {
5454 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
5555 |
5656 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
5757 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
58 HEX_DUMP
58 HEX_DUMP ╾ALLOC$ID╼ │ ╾─╼ │ ╾─╼
5959 }
6060
6161error[E0080]: constructing invalid value of type NonNull<()>: at .pointer, encountered a maybe-null pointer, but expected something that is definitely non-zero
62 --> $DIR/ub-nonnull.rs:47:1
62 --> $DIR/ub-nonnull.rs:49:1
6363 |
6464LL | const MAYBE_NULL_PTR: NonNull<()> = unsafe { mem::transmute((&raw const S).wrapping_add(4)) };
6565 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
6666 |
6767 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
6868 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
69 HEX_DUMP
69 ╾ALLOC$ID╼ │ ╾─╼
7070 }
7171
7272error: aborting due to 7 previous errors
tests/ui/consts/const-eval/ub-ref-ptr.rs+3-1
......@@ -4,9 +4,11 @@
44//@ normalize-stderr: "([0-9a-f][0-9a-f] |__ |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP"
55//@ dont-require-annotations: NOTE
66//@ normalize-stderr: "0x[0-9](\.\.|\])" -> "0x%$1"
7//@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼"
8
79#![feature(pattern_types, pattern_type_macro)]
810#![allow(invalid_value)]
9//@ ignore-parallel-frontend different alloc ids
11
1012use std::{mem, pat::pattern_type};
1113
1214#[repr(C)]
tests/ui/consts/const-eval/ub-ref-ptr.stderr+28-28
......@@ -1,27 +1,27 @@
11error[E0080]: constructing invalid value of type &u16: encountered an unaligned reference (required 2 byte alignment but found 1)
2 --> $DIR/ub-ref-ptr.rs:18:1
2 --> $DIR/ub-ref-ptr.rs:20:1
33 |
44LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
55 | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
66 |
77 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
9 HEX_DUMP
9 ╾ALLOC$ID╼ │ ╾─╼
1010 }
1111
1212error[E0080]: constructing invalid value of type Box<u16>: encountered an unaligned box (required 2 byte alignment but found 1)
13 --> $DIR/ub-ref-ptr.rs:21:1
13 --> $DIR/ub-ref-ptr.rs:23:1
1414 |
1515LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
1616 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
1717 |
1818 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
1919 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
20 HEX_DUMP
20 ╾ALLOC$ID╼ │ ╾─╼
2121 }
2222
2323error[E0080]: constructing invalid value of type &u16: encountered a null reference
24 --> $DIR/ub-ref-ptr.rs:24:1
24 --> $DIR/ub-ref-ptr.rs:26:1
2525 |
2626LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
2727 | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -32,7 +32,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
3232 }
3333
3434error[E0080]: constructing invalid value of type Box<u16>: encountered a null box
35 --> $DIR/ub-ref-ptr.rs:27:1
35 --> $DIR/ub-ref-ptr.rs:29:1
3636 |
3737LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
3838 | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -43,18 +43,18 @@ LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
4343 }
4444
4545error[E0080]: constructing invalid value of type Box<()>: encountered a maybe-null box
46 --> $DIR/ub-ref-ptr.rs:30:1
46 --> $DIR/ub-ref-ptr.rs:32:1
4747 |
4848LL | const MAYBE_NULL_BOX: Box<()> = unsafe { mem::transmute({
4949 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
5050 |
5151 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
5252 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
53 HEX_DUMP
53 ╾ALLOC$ID╼ │ ╾─╼
5454 }
5555
5656error[E0080]: unable to turn pointer into integer
57 --> $DIR/ub-ref-ptr.rs:39:1
57 --> $DIR/ub-ref-ptr.rs:41:1
5858 |
5959LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
6060 | ^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `REF_AS_USIZE` failed here
......@@ -63,7 +63,7 @@ LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
6363 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
6464
6565error[E0080]: unable to turn pointer into integer
66 --> $DIR/ub-ref-ptr.rs:42:39
66 --> $DIR/ub-ref-ptr.rs:44:39
6767 |
6868LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
6969 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `REF_AS_USIZE_SLICE` failed here
......@@ -72,13 +72,13 @@ LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
7272 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
7373
7474note: erroneous constant encountered
75 --> $DIR/ub-ref-ptr.rs:42:38
75 --> $DIR/ub-ref-ptr.rs:44:38
7676 |
7777LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
7878 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7979
8080error[E0080]: unable to turn pointer into integer
81 --> $DIR/ub-ref-ptr.rs:45:86
81 --> $DIR/ub-ref-ptr.rs:47:86
8282 |
8383LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
8484 | ^^^^^^^^^^^^^^^^^^^^ 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
8787 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
8888
8989note: erroneous constant encountered
90 --> $DIR/ub-ref-ptr.rs:45:85
90 --> $DIR/ub-ref-ptr.rs:47:85
9191 |
9292LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
9393 | ^^^^^^^^^^^^^^^^^^^^^
9494
9595error[E0080]: constructing invalid value of type &u8: encountered a dangling reference (0x539[noalloc] has no provenance)
96 --> $DIR/ub-ref-ptr.rs:48:1
96 --> $DIR/ub-ref-ptr.rs:50:1
9797 |
9898LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
9999 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -104,7 +104,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
104104 }
105105
106106error[E0080]: constructing invalid value of type Box<u8>: encountered a dangling box (0x539[noalloc] has no provenance)
107 --> $DIR/ub-ref-ptr.rs:51:1
107 --> $DIR/ub-ref-ptr.rs:53:1
108108 |
109109LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
110110 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -114,8 +114,8 @@ LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
114114 HEX_DUMP
115115 }
116116
117error[E0080]: reading memory at ALLOC5[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory
118 --> $DIR/ub-ref-ptr.rs:54:41
117error[E0080]: reading memory at ALLOC$ID[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory
118 --> $DIR/ub-ref-ptr.rs:56:41
119119 |
120120LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init };
121121 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNINIT_PTR` failed here
......@@ -125,7 +125,7 @@ LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init };
125125 }
126126
127127error[E0080]: constructing invalid value of type fn(): encountered null pointer, but expected a function pointer
128 --> $DIR/ub-ref-ptr.rs:57:1
128 --> $DIR/ub-ref-ptr.rs:59:1
129129 |
130130LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
131131 | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -135,8 +135,8 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
135135 HEX_DUMP
136136 }
137137
138error[E0080]: reading memory at ALLOC6[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory
139 --> $DIR/ub-ref-ptr.rs:59:38
138error[E0080]: reading memory at ALLOC$ID[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory
139 --> $DIR/ub-ref-ptr.rs:61:38
140140 |
141141LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init };
142142 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNINIT_FN_PTR` failed here
......@@ -146,7 +146,7 @@ LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init };
146146 }
147147
148148error[E0080]: constructing invalid value of type fn(): encountered 0xd[noalloc], but expected a function pointer
149 --> $DIR/ub-ref-ptr.rs:61:1
149 --> $DIR/ub-ref-ptr.rs:63:1
150150 |
151151LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
152152 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -156,30 +156,30 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
156156 HEX_DUMP
157157 }
158158
159error[E0080]: constructing invalid value of type fn(): encountered ALLOC3<imm>, but expected a function pointer
160 --> $DIR/ub-ref-ptr.rs:63:1
159error[E0080]: constructing invalid value of type fn(): encountered ALLOC$ID<imm>, but expected a function pointer
160 --> $DIR/ub-ref-ptr.rs:65:1
161161 |
162162LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
163163 | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
164164 |
165165 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
166166 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
167 HEX_DUMP
167 ╾ALLOC$ID╼ │ ╾─╼
168168 }
169169
170error[E0080]: constructing invalid value of type fn(): encountered ALLOC4+0xa, but expected a function pointer
171 --> $DIR/ub-ref-ptr.rs:65:1
170error[E0080]: constructing invalid value of type fn(): encountered ALLOC$ID+0xa, but expected a function pointer
171 --> $DIR/ub-ref-ptr.rs:67:1
172172 |
173173LL | const MAYBE_NULL_FN_PTR: fn() = unsafe { mem::transmute({
174174 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
175175 |
176176 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
177177 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
178 HEX_DUMP
178 ╾ALLOC$ID╼ │ ╾─╼
179179 }
180180
181181error[E0080]: accessing memory based on pointer with alignment 1, but alignment 4 is required
182 --> $DIR/ub-ref-ptr.rs:75:5
182 --> $DIR/ub-ref-ptr.rs:77:5
183183 |
184184LL | ptr.read();
185185 | ^^^^^^^^^^ evaluation of `UNALIGNED_READ` failed here
tests/ui/consts/const-eval/ub-upvars.32bit.stderr+1-1
......@@ -6,7 +6,7 @@ LL | const BAD_UPVAR: &dyn FnOnce() = &{
66 |
77 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88 = note: the raw bytes of the constant (size: 8, align: 4) {
9 ╾ALLOC0<imm>╼ ╾ALLOC1╼ │ ╾──╼╾──╼
9 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼
1010 }
1111
1212error: aborting due to 1 previous error
tests/ui/consts/const-eval/ub-upvars.64bit.stderr+1-1
......@@ -6,7 +6,7 @@ LL | const BAD_UPVAR: &dyn FnOnce() = &{
66 |
77 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88 = note: the raw bytes of the constant (size: 16, align: 8) {
9 ╾ALLOC0<imm>╼ ╾ALLOC1╼ │ ╾──────╼╾──────╼
9 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼
1010 }
1111
1212error: aborting due to 1 previous error
tests/ui/consts/const-eval/ub-upvars.rs+1-1
......@@ -1,7 +1,7 @@
11//@ edition:2015..2021
22//@ stderr-per-bitwidth
33#![allow(invalid_value)] // make sure we cannot allow away the errors tested here
4//@ ignore-parallel-frontend different alloc ids
4
55use std::mem;
66
77const BAD_UPVAR: &dyn FnOnce() = &{ //~ ERROR null reference
tests/ui/consts/const-eval/ub-wide-ptr.rs+2-2
......@@ -3,13 +3,14 @@
33#![feature(ptr_metadata)]
44
55use std::{ptr, mem};
6//@ ignore-parallel-frontend different alloc ids
6
77// Strip out raw byte dumps to make comparison platform-independent:
88//@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
99//@ normalize-stderr: "([0-9a-f][0-9a-f] |__ |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP"
1010//@ normalize-stderr: "offset \d+" -> "offset N"
1111//@ normalize-stderr: "size \d+" -> "size N"
1212//@ normalize-stderr: "0x[0-9](\.\.|\])" -> "0x%$1"
13//@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼"
1314//@ dont-require-annotations: NOTE
1415
1516/// 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:
137138// Officially blessed way to get the vtable
138139const DYN_METADATA: ptr::DynMetadata<dyn Send> = ptr::metadata::<dyn Send>(ptr::null::<i32>());
139140
140
141141static mut RAW_TRAIT_OBJ_VTABLE_NULL_THROUGH_REF: *const dyn Trait = unsafe {
142142 mem::transmute::<_, &dyn Trait>((&92u8, 0usize))
143143 //~^^ ERROR null pointer
tests/ui/consts/const-eval/ub-wide-ptr.stderr+63-63
......@@ -1,27 +1,27 @@
11error[E0080]: constructing invalid value of type &str: encountered a dangling reference (going beyond the bounds of its allocation)
2 --> $DIR/ub-wide-ptr.rs:40:1
2 --> $DIR/ub-wide-ptr.rs:41:1
33 |
44LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) };
55 | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
66 |
77 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
9 HEX_DUMP
9 ╾ALLOC$ID╼ HEX_DUMP
1010 }
1111
1212error[E0080]: constructing invalid value of type (&str,): at .0, encountered invalid reference metadata: slice is bigger than largest supported object
13 --> $DIR/ub-wide-ptr.rs:42:1
13 --> $DIR/ub-wide-ptr.rs:43:1
1414 |
1515LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },);
1616 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
1717 |
1818 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
1919 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
20 HEX_DUMP
20 ╾ALLOC$ID╼ HEX_DUMP
2121 }
2222
2323error[E0080]: unable to turn pointer into integer
24 --> $DIR/ub-wide-ptr.rs:45:1
24 --> $DIR/ub-wide-ptr.rs:46:1
2525 |
2626LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) };
2727 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `STR_LENGTH_PTR` failed here
......@@ -30,7 +30,7 @@ LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) };
3030 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
3131
3232error[E0080]: unable to turn pointer into integer
33 --> $DIR/ub-wide-ptr.rs:48:1
33 --> $DIR/ub-wide-ptr.rs:49:1
3434 |
3535LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) };
3636 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `MY_STR_LENGTH_PTR` failed here
......@@ -39,40 +39,40 @@ LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) };
3939 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
4040
4141error[E0080]: constructing invalid value of type &MyStr: encountered invalid reference metadata: slice is bigger than largest supported object
42 --> $DIR/ub-wide-ptr.rs:50:1
42 --> $DIR/ub-wide-ptr.rs:51:1
4343 |
4444LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) };
4545 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
4646 |
4747 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
4848 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
49 HEX_DUMP
49 ╾ALLOC$ID╼ HEX_DUMP
5050 }
5151
5252error[E0080]: constructing invalid value of type &str: at .<deref>, encountered uninitialized memory, but expected a string
53 --> $DIR/ub-wide-ptr.rs:54:1
53 --> $DIR/ub-wide-ptr.rs:55:1
5454 |
5555LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
5656 | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
5757 |
5858 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
5959 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
60 HEX_DUMP
60 ╾ALLOC$ID╼ HEX_DUMP
6161 }
6262
6363error[E0080]: constructing invalid value of type &MyStr: at .<deref>.0, encountered uninitialized memory, but expected a string
64 --> $DIR/ub-wide-ptr.rs:57:1
64 --> $DIR/ub-wide-ptr.rs:58:1
6565 |
6666LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
6767 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
6868 |
6969 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
7070 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
71 HEX_DUMP
71 ╾ALLOC$ID╼ HEX_DUMP
7272 }
7373
74error[E0080]: reading memory at ALLOC32[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory
75 --> $DIR/ub-wide-ptr.rs:64:1
74error[E0080]: reading memory at ALLOC$ID[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory
75 --> $DIR/ub-wide-ptr.rs:65:1
7676 |
7777LL | const SLICE_LENGTH_UNINIT: &[u8] = unsafe {
7878 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SLICE_LENGTH_UNINIT` failed here
......@@ -82,29 +82,29 @@ LL | const SLICE_LENGTH_UNINIT: &[u8] = unsafe {
8282 }
8383
8484error[E0080]: constructing invalid value of type &[u8]: encountered a dangling reference (going beyond the bounds of its allocation)
85 --> $DIR/ub-wide-ptr.rs:70:1
85 --> $DIR/ub-wide-ptr.rs:71:1
8686 |
8787LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) };
8888 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
8989 |
9090 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
9191 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
92 HEX_DUMP
92 ╾ALLOC$ID╼ HEX_DUMP
9393 }
9494
9595error[E0080]: constructing invalid value of type &[u32]: encountered invalid reference metadata: slice is bigger than largest supported object
96 --> $DIR/ub-wide-ptr.rs:73:1
96 --> $DIR/ub-wide-ptr.rs:74:1
9797 |
9898LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) };
9999 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
100100 |
101101 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
102102 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
103 HEX_DUMP
103 ╾ALLOC$ID╼ HEX_DUMP
104104 }
105105
106106error[E0080]: unable to turn pointer into integer
107 --> $DIR/ub-wide-ptr.rs:76:1
107 --> $DIR/ub-wide-ptr.rs:77:1
108108 |
109109LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) };
110110 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SLICE_LENGTH_PTR` failed here
......@@ -113,18 +113,18 @@ LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) };
113113 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
114114
115115error[E0080]: constructing invalid value of type Box<[u8]>: encountered a dangling box (going beyond the bounds of its allocation)
116 --> $DIR/ub-wide-ptr.rs:79:1
116 --> $DIR/ub-wide-ptr.rs:80:1
117117 |
118118LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) };
119119 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
120120 |
121121 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
122122 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
123 HEX_DUMP
123 ╾ALLOC$ID╼ HEX_DUMP
124124 }
125125
126126error[E0080]: unable to turn pointer into integer
127 --> $DIR/ub-wide-ptr.rs:82:1
127 --> $DIR/ub-wide-ptr.rs:83:1
128128 |
129129LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) };
130130 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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)
133133 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
134134
135135error[E0080]: constructing invalid value of type &[bool; 1]: at .<deref>[0], encountered 0x03, but expected a boolean
136 --> $DIR/ub-wide-ptr.rs:86:1
136 --> $DIR/ub-wide-ptr.rs:87:1
137137 |
138138LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
139139 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
140140 |
141141 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
142142 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
143 HEX_DUMP
143 ╾ALLOC$ID╼ │ ╾─╼
144144 }
145145
146146note: erroneous constant encountered
147 --> $DIR/ub-wide-ptr.rs:86:40
147 --> $DIR/ub-wide-ptr.rs:87:40
148148 |
149149LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
150150 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
151151
152152error[E0080]: constructing invalid value of type &MySlice<[bool; 1]>: at .<deref>.0, encountered 0x03, but expected a boolean
153 --> $DIR/ub-wide-ptr.rs:92:1
153 --> $DIR/ub-wide-ptr.rs:93:1
154154 |
155155LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
156156 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
157157 |
158158 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
159159 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
160 HEX_DUMP
160 ╾ALLOC$ID╼ │ ╾─╼
161161 }
162162
163163note: erroneous constant encountered
164 --> $DIR/ub-wide-ptr.rs:92:42
164 --> $DIR/ub-wide-ptr.rs:93:42
165165 |
166166LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
167167 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
168168
169169error[E0080]: constructing invalid value of type &MySlice<[bool; 1]>: at .<deref>.1[0], encountered 0x03, but expected a boolean
170 --> $DIR/ub-wide-ptr.rs:95:1
170 --> $DIR/ub-wide-ptr.rs:96:1
171171 |
172172LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
173173 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
174174 |
175175 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
176176 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
177 HEX_DUMP
177 ╾ALLOC$ID╼ │ ╾─╼
178178 }
179179
180180note: erroneous constant encountered
181 --> $DIR/ub-wide-ptr.rs:95:42
181 --> $DIR/ub-wide-ptr.rs:96:42
182182 |
183183LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
184184 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
185185
186error[E0080]: reading memory at ALLOC33[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory
187 --> $DIR/ub-wide-ptr.rs:102:1
186error[E0080]: reading memory at ALLOC$ID[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory
187 --> $DIR/ub-wide-ptr.rs:103:1
188188 |
189189LL | const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe {
190190 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `RAW_SLICE_LENGTH_UNINIT` failed here
......@@ -193,114 +193,114 @@ LL | const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe {
193193 HEX_DUMP
194194 }
195195
196error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC12<imm>, but expected a vtable pointer
197 --> $DIR/ub-wide-ptr.rs:110:1
196error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID<imm>, but expected a vtable pointer
197 --> $DIR/ub-wide-ptr.rs:111:1
198198 |
199199LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) };
200200 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
201201 |
202202 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
203203 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
204 HEX_DUMP
204 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼
205205 }
206206
207error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC14<imm>, but expected a vtable pointer
208 --> $DIR/ub-wide-ptr.rs:113:1
207error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID<imm>, but expected a vtable pointer
208 --> $DIR/ub-wide-ptr.rs:114:1
209209 |
210210LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) };
211211 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
212212 |
213213 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
214214 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
215 HEX_DUMP
215 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼
216216 }
217217
218218error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered 0x4[noalloc], but expected a vtable pointer
219 --> $DIR/ub-wide-ptr.rs:116:1
219 --> $DIR/ub-wide-ptr.rs:117:1
220220 |
221221LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) };
222222 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
223223 |
224224 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
225225 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
226 HEX_DUMP
226 ╾ALLOC$ID╼ HEX_DUMP
227227 }
228228
229error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC17<imm>, but expected a vtable pointer
230 --> $DIR/ub-wide-ptr.rs:118:1
229error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC$ID<imm>, but expected a vtable pointer
230 --> $DIR/ub-wide-ptr.rs:119:1
231231 |
232232LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) };
233233 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
234234 |
235235 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
236236 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
237 HEX_DUMP
237 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼
238238 }
239239
240error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC19<imm>, but expected a vtable pointer
241 --> $DIR/ub-wide-ptr.rs:120:1
240error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC$ID<imm>, but expected a vtable pointer
241 --> $DIR/ub-wide-ptr.rs:121:1
242242 |
243243LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) };
244244 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
245245 |
246246 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
247247 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
248 HEX_DUMP
248 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼
249249 }
250250
251error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC21<imm>, but expected a vtable pointer
252 --> $DIR/ub-wide-ptr.rs:122:1
251error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC$ID<imm>, but expected a vtable pointer
252 --> $DIR/ub-wide-ptr.rs:123:1
253253 |
254254LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) };
255255 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
256256 |
257257 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
258258 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
259 HEX_DUMP
259 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼
260260 }
261261
262error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC23<imm>, but expected a vtable pointer
263 --> $DIR/ub-wide-ptr.rs:124:1
262error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID<imm>, but expected a vtable pointer
263 --> $DIR/ub-wide-ptr.rs:125:1
264264 |
265265LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) };
266266 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
267267 |
268268 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
269269 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
270 HEX_DUMP
270 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼
271271 }
272272
273273error[E0080]: constructing invalid value of type &dyn Trait: at .<deref>.<dyn-downcast(bool)>, encountered 0x03, but expected a boolean
274 --> $DIR/ub-wide-ptr.rs:128:1
274 --> $DIR/ub-wide-ptr.rs:129:1
275275 |
276276LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) };
277277 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
278278 |
279279 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
280280 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
281 HEX_DUMP
281 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼
282282 }
283283
284284error[E0080]: constructing invalid value of type *const dyn Trait: encountered null pointer, but expected a vtable pointer
285 --> $DIR/ub-wide-ptr.rs:132:1
285 --> $DIR/ub-wide-ptr.rs:133:1
286286 |
287287LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) };
288288 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
289289 |
290290 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
291291 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
292 HEX_DUMP
292 ╾ALLOC$ID╼ HEX_DUMP
293293 }
294294
295error[E0080]: constructing invalid value of type *const dyn Trait: encountered ALLOC28<imm>, but expected a vtable pointer
296 --> $DIR/ub-wide-ptr.rs:134:1
295error[E0080]: constructing invalid value of type *const dyn Trait: encountered ALLOC$ID<imm>, but expected a vtable pointer
296 --> $DIR/ub-wide-ptr.rs:135:1
297297 |
298298LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
299299 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
300300 |
301301 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
302302 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
303 HEX_DUMP
303 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼
304304 }
305305
306306error[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
311311 |
312312 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
313313 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
314 HEX_DUMP
314 ╾ALLOC$ID╼ HEX_DUMP
315315 }
316316
317error[E0080]: constructing invalid value of type *const dyn Trait: encountered ALLOC31<imm>, but expected a vtable pointer
317error[E0080]: constructing invalid value of type *const dyn Trait: encountered ALLOC$ID<imm>, but expected a vtable pointer
318318 --> $DIR/ub-wide-ptr.rs:145:1
319319 |
320320LL | 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
322322 |
323323 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
324324 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
325 HEX_DUMP
325 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼
326326 }
327327
328328error: aborting due to 29 previous errors
tests/ui/consts/const-eval/union-const-eval-field.rs+1-1
......@@ -1,7 +1,7 @@
11//@ dont-require-annotations: NOTE
22//@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
33//@ normalize-stderr: "([[:xdigit:]]{2}\s){4}(__\s){4}\s+│\s+([?|\.]){4}\W{4}" -> "HEX_DUMP"
4//@ ignore-parallel-frontend different alloc ids
4
55type Field1 = i32;
66type Field2 = f32;
77type Field3 = i64;
tests/ui/consts/const-eval/union-const-eval-field.stderr+1-1
......@@ -1,4 +1,4 @@
1error[E0080]: reading memory at ALLOC0[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory
1error[E0080]: reading memory at ALLOC$ID[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory
22 --> $DIR/union-const-eval-field.rs:30:37
33 |
44LL | const FIELD3: Field3 = unsafe { UNION.field3 };
tests/ui/consts/const-eval/union-ice.rs+1-1
......@@ -1,5 +1,5 @@
11//@ only-x86_64
2//@ ignore-parallel-frontend different alloc ids
2
33type Field1 = i32;
44type Field3 = i64;
55
tests/ui/consts/const-eval/union-ice.stderr+3-3
......@@ -1,4 +1,4 @@
1error[E0080]: reading memory at ALLOC0[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory
1error[E0080]: reading memory at ALLOC$ID[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory
22 --> $DIR/union-ice.rs:14:33
33 |
44LL | const FIELD3: Field3 = unsafe { UNION.field3 };
......@@ -8,7 +8,7 @@ LL | const FIELD3: Field3 = unsafe { UNION.field3 };
88 00 00 80 3f __ __ __ __ │ ...?░░░░
99 }
1010
11error[E0080]: reading memory at ALLOC1[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory
11error[E0080]: reading memory at ALLOC$ID[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory
1212 --> $DIR/union-ice.rs:19:17
1313 |
1414LL | b: unsafe { UNION.field3 },
......@@ -18,7 +18,7 @@ LL | b: unsafe { UNION.field3 },
1818 00 00 80 3f __ __ __ __ │ ...?░░░░
1919 }
2020
21error[E0080]: reading memory at ALLOC2[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory
21error[E0080]: reading memory at ALLOC$ID[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory
2222 --> $DIR/union-ice.rs:31:18
2323 |
2424LL | unsafe { UNION.field3 },
tests/ui/consts/const-eval/union-ub.32bit.stderr+1-1
......@@ -9,7 +9,7 @@ LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool };
99 2a │ *
1010 }
1111
12error[E0080]: reading memory at ALLOC0[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory
12error[E0080]: reading memory at ALLOC$ID[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory
1313 --> $DIR/union-ub.rs:35:36
1414 |
1515LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool };
tests/ui/consts/const-eval/union-ub.64bit.stderr+1-1
......@@ -9,7 +9,7 @@ LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool };
99 2a │ *
1010 }
1111
12error[E0080]: reading memory at ALLOC0[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory
12error[E0080]: reading memory at ALLOC$ID[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory
1313 --> $DIR/union-ub.rs:35:36
1414 |
1515LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool };
tests/ui/consts/const-eval/union-ub.rs+1-1
......@@ -1,6 +1,6 @@
11//@ stderr-per-bitwidth
22//@ dont-require-annotations: NOTE
3//@ ignore-parallel-frontend different alloc ids
3
44#[repr(C)]
55union DummyUnion {
66 unit: (),
tests/ui/consts/const-mut-refs/mut_ref_in_final.rs+1
......@@ -1,6 +1,7 @@
11//@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
22//@ normalize-stderr: "( 0x[0-9a-f][0-9a-f] │)? ([0-9a-f][0-9a-f] |__ |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> " HEX_DUMP"
33//@ normalize-stderr: "HEX_DUMP\s*\n\s*HEX_DUMP" -> "HEX_DUMP"
4//@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼"
45//@ dont-require-annotations: NOTE
56
67use std::cell::UnsafeCell;
tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr+20-20
......@@ -1,5 +1,5 @@
11error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed
2 --> $DIR/mut_ref_in_final.rs:15:21
2 --> $DIR/mut_ref_in_final.rs:16:21
33 |
44LL | const B: *mut i32 = &mut 4;
55 | ^^^^^^ this mutable borrow refers to such a temporary
......@@ -9,7 +9,7 @@ LL | const B: *mut i32 = &mut 4;
99 = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut`
1010
1111error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed
12 --> $DIR/mut_ref_in_final.rs:21:35
12 --> $DIR/mut_ref_in_final.rs:22:35
1313 |
1414LL | const B3: Option<&mut i32> = Some(&mut 42);
1515 | ^^^^^^^ this mutable borrow refers to such a temporary
......@@ -19,7 +19,7 @@ LL | const B3: Option<&mut i32> = Some(&mut 42);
1919 = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut`
2020
2121error[E0716]: temporary value dropped while borrowed
22 --> $DIR/mut_ref_in_final.rs:24:42
22 --> $DIR/mut_ref_in_final.rs:25:42
2323 |
2424LL | const B4: Option<&mut i32> = helper(&mut 42);
2525 | ------------^^-
......@@ -29,29 +29,29 @@ LL | const B4: Option<&mut i32> = helper(&mut 42);
2929 | using this value as a constant requires that borrow lasts for `'static`
3030
3131error[E0080]: constructing invalid value of type &mut u16: encountered mutable reference or box pointing to read-only memory
32 --> $DIR/mut_ref_in_final.rs:27:1
32 --> $DIR/mut_ref_in_final.rs:28:1
3333 |
3434LL | const IMMUT_MUT_REF: &mut u16 = unsafe { mem::transmute(&13) };
3535 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
3636 |
3737 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
3838 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
39 HEX_DUMP
39 ╾ALLOC$ID╼ │ ╾─╼
4040 }
4141
4242error[E0080]: constructing invalid value of type &mut u16: encountered mutable reference or box pointing to read-only memory
43 --> $DIR/mut_ref_in_final.rs:29:1
43 --> $DIR/mut_ref_in_final.rs:30:1
4444 |
4545LL | static IMMUT_MUT_REF_STATIC: &mut u16 = unsafe { mem::transmute(&13) };
4646 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
4747 |
4848 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
4949 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
50 HEX_DUMP
50 ╾ALLOC$ID╼ │ ╾─╼
5151 }
5252
5353error[E0716]: temporary value dropped while borrowed
54 --> $DIR/mut_ref_in_final.rs:52:65
54 --> $DIR/mut_ref_in_final.rs:53:65
5555 |
5656LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
5757 | -------------------------------^^--
......@@ -61,7 +61,7 @@ LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
6161 | using this value as a constant requires that borrow lasts for `'static`
6262
6363error[E0716]: temporary value dropped while borrowed
64 --> $DIR/mut_ref_in_final.rs:55:67
64 --> $DIR/mut_ref_in_final.rs:56:67
6565 |
6666LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
6767 | -------------------------------^^--
......@@ -71,7 +71,7 @@ LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
7171 | using this value as a static requires that borrow lasts for `'static`
7272
7373error[E0716]: temporary value dropped while borrowed
74 --> $DIR/mut_ref_in_final.rs:58:71
74 --> $DIR/mut_ref_in_final.rs:59:71
7575 |
7676LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
7777 | -------------------------------^^--
......@@ -81,7 +81,7 @@ LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
8181 | using this value as a static requires that borrow lasts for `'static`
8282
8383error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed
84 --> $DIR/mut_ref_in_final.rs:71:53
84 --> $DIR/mut_ref_in_final.rs:72:53
8585 |
8686LL | static RAW_MUT_CAST_S: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
8787 | ^^^^^^^ this mutable borrow refers to such a temporary
......@@ -91,7 +91,7 @@ LL | static RAW_MUT_CAST_S: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *c
9191 = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut`
9292
9393error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed
94 --> $DIR/mut_ref_in_final.rs:73:54
94 --> $DIR/mut_ref_in_final.rs:74:54
9595 |
9696LL | static RAW_MUT_COERCE_S: SyncPtr<i32> = SyncPtr { x: &mut 0 };
9797 | ^^^^^^ this mutable borrow refers to such a temporary
......@@ -101,7 +101,7 @@ LL | static RAW_MUT_COERCE_S: SyncPtr<i32> = SyncPtr { x: &mut 0 };
101101 = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut`
102102
103103error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed
104 --> $DIR/mut_ref_in_final.rs:75:52
104 --> $DIR/mut_ref_in_final.rs:76:52
105105 |
106106LL | const RAW_MUT_CAST_C: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
107107 | ^^^^^^^ this mutable borrow refers to such a temporary
......@@ -111,7 +111,7 @@ LL | const RAW_MUT_CAST_C: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *co
111111 = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut`
112112
113113error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed
114 --> $DIR/mut_ref_in_final.rs:77:53
114 --> $DIR/mut_ref_in_final.rs:78:53
115115 |
116116LL | const RAW_MUT_COERCE_C: SyncPtr<i32> = SyncPtr { x: &mut 0 };
117117 | ^^^^^^ this mutable borrow refers to such a temporary
......@@ -121,7 +121,7 @@ LL | const RAW_MUT_COERCE_C: SyncPtr<i32> = SyncPtr { x: &mut 0 };
121121 = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut`
122122
123123error[E0080]: constructing invalid value of type Option<&mut i32>: at .<enum-variant(Some)>.0, encountered a dangling reference (0x2a[noalloc] has no provenance)
124 --> $DIR/mut_ref_in_final.rs:86:5
124 --> $DIR/mut_ref_in_final.rs:87:5
125125 |
126126LL | const INT2PTR: Option<&mut i32> = helper_int2ptr();
127127 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -132,7 +132,7 @@ LL | const INT2PTR: Option<&mut i32> = helper_int2ptr();
132132 }
133133
134134error[E0080]: constructing invalid value of type Option<&mut i32>: at .<enum-variant(Some)>.0, encountered a dangling reference (0x2a[noalloc] has no provenance)
135 --> $DIR/mut_ref_in_final.rs:87:5
135 --> $DIR/mut_ref_in_final.rs:88:5
136136 |
137137LL | static INT2PTR_STATIC: Option<&mut i32> = helper_int2ptr();
138138 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
......@@ -143,25 +143,25 @@ LL | static INT2PTR_STATIC: Option<&mut i32> = helper_int2ptr();
143143 }
144144
145145error[E0080]: constructing invalid value of type Option<&mut i32>: at .<enum-variant(Some)>.0, encountered a dangling reference (use-after-free)
146 --> $DIR/mut_ref_in_final.rs:93:5
146 --> $DIR/mut_ref_in_final.rs:94:5
147147 |
148148LL | const DANGLING: Option<&mut i32> = helper_dangling();
149149 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
150150 |
151151 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
152152 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
153 HEX_DUMP
153 ╾ALLOC$ID╼ │ ╾─╼
154154 }
155155
156156error[E0080]: constructing invalid value of type Option<&mut i32>: at .<enum-variant(Some)>.0, encountered a dangling reference (use-after-free)
157 --> $DIR/mut_ref_in_final.rs:94:5
157 --> $DIR/mut_ref_in_final.rs:95:5
158158 |
159159LL | static DANGLING_STATIC: Option<&mut i32> = helper_dangling();
160160 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
161161 |
162162 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
163163 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
164 HEX_DUMP
164 ╾ALLOC$ID╼ │ ╾─╼
165165 }
166166
167167error: aborting due to 16 previous errors
tests/ui/consts/const_refs_to_static_fail_invalid.rs+1
......@@ -1,5 +1,6 @@
11//@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
22//@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP"
3//@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼"
34//@ dont-require-annotations: NOTE
45
56#![allow(static_mut_refs)]
tests/ui/consts/const_refs_to_static_fail_invalid.stderr+4-4
......@@ -1,16 +1,16 @@
11error[E0080]: constructing invalid value of type &bool: at .<deref>, encountered 0x0a, but expected a boolean
2 --> $DIR/const_refs_to_static_fail_invalid.rs:10:5
2 --> $DIR/const_refs_to_static_fail_invalid.rs:11:5
33 |
44LL | const C: &bool = unsafe { std::mem::transmute(&S) };
55 | ^^^^^^^^^^^^^^ it is undefined behavior to use this value
66 |
77 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
9 HEX_DUMP
9 ╾ALLOC$ID╼ │ ╾─╼
1010 }
1111
1212error: constant extern_::C cannot be used as pattern
13 --> $DIR/const_refs_to_static_fail_invalid.rs:29:9
13 --> $DIR/const_refs_to_static_fail_invalid.rs:30:9
1414 |
1515LL | C => {}
1616 | ^
......@@ -18,7 +18,7 @@ LL | C => {}
1818 = note: constants that reference mutable or external memory cannot be used as patterns
1919
2020error: constant mutable::C cannot be used as pattern
21 --> $DIR/const_refs_to_static_fail_invalid.rs:42:9
21 --> $DIR/const_refs_to_static_fail_invalid.rs:43:9
2222 |
2323LL | C => {}
2424 | ^
tests/ui/consts/const_transmute_type_id7.rs+2
......@@ -5,6 +5,8 @@
55//@ normalize-stderr: "\[&\(\); \d\]" -> "ARRAY"
66//@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
77//@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*A(LLOC)?[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP"
8//@ normalize-stderr: "(╾ALLOC\$ID╼ )+" -> "╾ALLOC$$IDs╼"
9//@ normalize-stderr: "╾[╼╾─]*╼" -> "╾─╼"
810
911#![feature(const_trait_impl, const_cmp)]
1012
tests/ui/consts/const_transmute_type_id7.stderr+2-2
......@@ -1,12 +1,12 @@
11error[E0080]: constructing invalid value of type ARRAY: at [0], encountered a maybe-null reference
2 --> $DIR/const_transmute_type_id7.rs:14:1
2 --> $DIR/const_transmute_type_id7.rs:16:1
33 |
44LL | const A: [&(); 16 / size_of::<*const ()>()] = unsafe { transmute(TypeId::of::<i32>()) };
55 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
66 |
77 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
9 HEX_DUMP
9 ╾ALLOC$IDs╼│ ╾─╼
1010 }
1111
1212error: aborting due to 1 previous error
tests/ui/consts/copy-intrinsic.rs+1-1
......@@ -1,6 +1,6 @@
11// ignore-tidy-linelength
22#![feature(core_intrinsics)]
3//@ ignore-parallel-frontend different alloc ids
3
44use std::intrinsics::{copy, copy_nonoverlapping};
55use std::mem;
66
tests/ui/consts/copy-intrinsic.stderr+1-1
......@@ -4,7 +4,7 @@ error[E0080]: memory access failed: attempting to access 4 bytes, but got 0x100[
44LL | copy_nonoverlapping(0x100 as *const i32, dangle, 1);
55 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `COPY_OOB_1` failed here
66
7error[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
7error[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
88 --> $DIR/copy-intrinsic.rs:28:5
99 |
1010LL | copy_nonoverlapping(dangle, 0x100 as *mut i32, 1);
tests/ui/consts/dangling-alloc-id-ice.rs+1
......@@ -3,6 +3,7 @@
33//@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
44//@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*A(LLOC)?[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP"
55//@ normalize-stderr: "HEX_DUMP\s*\n\s*HEX_DUMP" -> "HEX_DUMP"
6//@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼"
67
78union Foo<'a> {
89 y: &'a (),
tests/ui/consts/dangling-alloc-id-ice.stderr+2-2
......@@ -1,12 +1,12 @@
11error[E0080]: constructing invalid value of type &(): encountered a dangling reference (use-after-free)
2 --> $DIR/dangling-alloc-id-ice.rs:12:1
2 --> $DIR/dangling-alloc-id-ice.rs:13:1
33 |
44LL | const FOO: &() = {
55 | ^^^^^^^^^^^^^^ it is undefined behavior to use this value
66 |
77 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
9 HEX_DUMP
9 ╾ALLOC$ID╼ │ ╾─╼
1010 }
1111
1212error: aborting due to 1 previous error
tests/ui/consts/dangling-zst-ice-issue-126393.rs+1
......@@ -2,6 +2,7 @@
22//@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
33//@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*A(LLOC)?[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP"
44//@ normalize-stderr: "HEX_DUMP\s*\n\s*HEX_DUMP" -> "HEX_DUMP"
5//@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼"
56
67pub struct Wrapper;
78pub static MAGIC_FFI_REF: &'static Wrapper = unsafe {
tests/ui/consts/dangling-zst-ice-issue-126393.stderr+2-2
......@@ -1,12 +1,12 @@
11error[E0080]: constructing invalid value of type &Wrapper: encountered a dangling reference (use-after-free)
2 --> $DIR/dangling-zst-ice-issue-126393.rs:7:1
2 --> $DIR/dangling-zst-ice-issue-126393.rs:8:1
33 |
44LL | pub static MAGIC_FFI_REF: &'static Wrapper = unsafe {
55 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
66 |
77 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
9 HEX_DUMP
9 ╾ALLOC$ID╼ │ ╾─╼
1010 }
1111
1212error: aborting due to 1 previous error
tests/ui/consts/interior-mut-const-via-union.32bit.stderr+1-1
......@@ -6,7 +6,7 @@ LL | fn main() {
66 |
77 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88 = note: the raw bytes of the constant (size: 4, align: 4) {
9 ╾ALLOC0╼ │ ╾──╼
9 ╾ALLOC$ID╼ │ ╾──╼
1010 }
1111
1212note: erroneous constant encountered
tests/ui/consts/interior-mut-const-via-union.64bit.stderr+1-1
......@@ -6,7 +6,7 @@ LL | fn main() {
66 |
77 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88 = note: the raw bytes of the constant (size: 8, align: 8) {
9 ╾ALLOC0╼ │ ╾──────╼
9 ╾ALLOC$ID╼ │ ╾──────╼
1010 }
1111
1212note: erroneous constant encountered
tests/ui/consts/interior-mut-const-via-union.rs+1-1
......@@ -3,7 +3,7 @@
33//
44//@ build-fail
55//@ stderr-per-bitwidth
6//@ ignore-parallel-frontend different alloc ids
6
77use std::cell::Cell;
88use std::mem::ManuallyDrop;
99
tests/ui/consts/issue-63952.32bit.stderr+1-1
......@@ -6,7 +6,7 @@ LL | const SLICE_WAY_TOO_LONG: &[u8] = unsafe {
66 |
77 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88 = note: the raw bytes of the constant (size: 8, align: 4) {
9 ╾ALLOC0<imm>╼ ff ff ff ff │ ╾──╼....
9 ╾ALLOC$ID╼ ff ff ff ff │ ╾──╼....
1010 }
1111
1212error: aborting due to 1 previous error
tests/ui/consts/issue-63952.64bit.stderr+1-1
......@@ -6,7 +6,7 @@ LL | const SLICE_WAY_TOO_LONG: &[u8] = unsafe {
66 |
77 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88 = note: the raw bytes of the constant (size: 16, align: 8) {
9 ╾ALLOC0<imm>╼ ff ff ff ff ff ff ff ff │ ╾──────╼........
9 ╾ALLOC$ID╼ ff ff ff ff ff ff ff ff │ ╾──────╼........
1010 }
1111
1212error: aborting due to 1 previous error
tests/ui/consts/issue-63952.rs+1-1
......@@ -1,6 +1,6 @@
11// Regression test for #63952, shouldn't hang.
22//@ stderr-per-bitwidth
3//@ ignore-parallel-frontend different alloc ids
3
44#[repr(C)]
55#[derive(Copy, Clone)]
66struct SliceRepr {
tests/ui/consts/issue-79690.64bit.stderr+1-1
......@@ -6,7 +6,7 @@ LL | const G: Fat = unsafe { Transmute { t: FOO }.u };
66 |
77 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88 = note: the raw bytes of the constant (size: 16, align: 8) {
9 ╾ALLOC0<imm>╼ ╾ALLOC1╼ │ ╾──────╼╾──────╼
9 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼
1010 }
1111
1212error: aborting due to 1 previous error
tests/ui/consts/issue-79690.rs+1-1
......@@ -1,7 +1,7 @@
11//@ ignore-32bit
22// This test gives a different error on 32-bit architectures.
33//@ stderr-per-bitwidth
4//@ ignore-parallel-frontend different alloc ids
4
55union Transmute<T: Copy, U: Copy> {
66 t: T,
77 u: U,
tests/ui/consts/miri_unleashed/mutable_references.rs+1
......@@ -1,6 +1,7 @@
11//@ compile-flags: -Zunleash-the-miri-inside-of-you
22//@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
33//@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP"
4//@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼"
45//@ dont-require-annotations: NOTE
56
67#![allow(static_mut_refs)]
tests/ui/consts/miri_unleashed/mutable_references.stderr+36-36
......@@ -1,124 +1,124 @@
11error[E0080]: constructing invalid value of type &&mut u32: at .<deref>, encountered mutable reference or box pointing to read-only memory
2 --> $DIR/mutable_references.rs:13:1
2 --> $DIR/mutable_references.rs:14:1
33 |
44LL | static FOO: &&mut u32 = &&mut 42;
55 | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
66 |
77 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
9 HEX_DUMP
9 ╾ALLOC$ID╼ │ ╾─╼
1010 }
1111
1212error[E0080]: constructing invalid value of type &mut i32: encountered mutable reference or box pointing to read-only memory
13 --> $DIR/mutable_references.rs:15:1
13 --> $DIR/mutable_references.rs:16:1
1414 |
1515LL | static OH_YES: &mut i32 = &mut 42;
1616 | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
1717 |
1818 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
1919 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
20 HEX_DUMP
20 ╾ALLOC$ID╼ │ ╾─╼
2121 }
2222
2323error: encountered mutable pointer in final value of static
24 --> $DIR/mutable_references.rs:17:1
24 --> $DIR/mutable_references.rs:18:1
2525 |
2626LL | static BAR: &mut () = &mut ();
2727 | ^^^^^^^^^^^^^^^^^^^
2828
2929error: encountered mutable pointer in final value of static
30 --> $DIR/mutable_references.rs:22:1
30 --> $DIR/mutable_references.rs:23:1
3131 |
3232LL | static BOO: &mut Foo<()> = &mut Foo(());
3333 | ^^^^^^^^^^^^^^^^^^^^^^^^
3434
3535error[E0080]: constructing invalid value of type &mut i32: encountered mutable reference or box pointing to read-only memory
36 --> $DIR/mutable_references.rs:25:1
36 --> $DIR/mutable_references.rs:26:1
3737 |
3838LL | const BLUNT: &mut i32 = &mut 42;
3939 | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
4040 |
4141 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
4242 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
43 HEX_DUMP
43 ╾ALLOC$ID╼ │ ╾─╼
4444 }
4545
4646error[E0080]: constructing invalid value of type Meh: at .x.<deref>, encountered `UnsafeCell` in read-only memory
47 --> $DIR/mutable_references.rs:40:1
47 --> $DIR/mutable_references.rs:41:1
4848 |
4949LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) };
5050 | ^^^^^^^^^^^^^^^ it is undefined behavior to use this value
5151 |
5252 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
5353 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
54 HEX_DUMP
54 ╾ALLOC$ID╼ │ ╾─╼
5555 }
5656
5757error[E0080]: constructing invalid value of type Meh: at .x.<deref>, encountered `UnsafeCell` in read-only memory
58 --> $DIR/mutable_references.rs:45:1
58 --> $DIR/mutable_references.rs:46:1
5959 |
6060LL | const MUH: Meh = Meh {
6161 | ^^^^^^^^^^^^^^ it is undefined behavior to use this value
6262 |
6363 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
6464 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
65 HEX_DUMP
65 ╾ALLOC$ID╼ │ ╾─╼
6666 }
6767
6868error[E0080]: constructing invalid value of type &dyn Sync: at .<deref>.<dyn-downcast(Synced)>.x, encountered `UnsafeCell` in read-only memory
69 --> $DIR/mutable_references.rs:56:1
69 --> $DIR/mutable_references.rs:57:1
7070 |
7171LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
7272 | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
7373 |
7474 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
7575 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
76 HEX_DUMP
76 ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼
7777 }
7878
7979error[E0080]: constructing invalid value of type &mut i32: encountered mutable reference or box pointing to read-only memory
80 --> $DIR/mutable_references.rs:62:1
80 --> $DIR/mutable_references.rs:63:1
8181 |
8282LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
8383 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
8484 |
8585 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
8686 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
87 HEX_DUMP
87 ╾ALLOC$ID╼ │ ╾─╼
8888 }
8989
9090error[E0080]: constant accesses mutable global memory
91 --> $DIR/mutable_references.rs:73:43
91 --> $DIR/mutable_references.rs:74:43
9292 |
9393LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
9494 | ^^^^^^^^^^^^^ evaluation of `POINTS_TO_MUTABLE2` failed here
9595
9696error: encountered mutable pointer in final value of constant
97 --> $DIR/mutable_references.rs:76:1
97 --> $DIR/mutable_references.rs:77:1
9898 |
9999LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _;
100100 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
101101
102102error: encountered mutable pointer in final value of constant
103 --> $DIR/mutable_references.rs:79:1
103 --> $DIR/mutable_references.rs:80:1
104104 |
105105LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _;
106106 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
107107
108108error: encountered mutable pointer in final value of constant
109 --> $DIR/mutable_references.rs:99:1
109 --> $DIR/mutable_references.rs:100:1
110110 |
111111LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x: &mut 42 as *mut _ as *const _ };
112112 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
113113
114114error: encountered mutable pointer in final value of constant
115 --> $DIR/mutable_references.rs:102:1
115 --> $DIR/mutable_references.rs:103:1
116116 |
117117LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
118118 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
119119
120120error[E0594]: cannot assign to `*OH_YES`, as `OH_YES` is an immutable static item
121 --> $DIR/mutable_references.rs:109:5
121 --> $DIR/mutable_references.rs:110:5
122122 |
123123LL | static OH_YES: &mut i32 = &mut 42;
124124 | ----------------------- this `static` cannot be written to
......@@ -129,72 +129,72 @@ LL | *OH_YES = 99;
129129warning: skipping const checks
130130 |
131131help: skipping check that does not even have a feature gate
132 --> $DIR/mutable_references.rs:13:26
132 --> $DIR/mutable_references.rs:14:26
133133 |
134134LL | static FOO: &&mut u32 = &&mut 42;
135135 | ^^^^^^^
136136help: skipping check that does not even have a feature gate
137 --> $DIR/mutable_references.rs:15:27
137 --> $DIR/mutable_references.rs:16:27
138138 |
139139LL | static OH_YES: &mut i32 = &mut 42;
140140 | ^^^^^^^
141141help: skipping check that does not even have a feature gate
142 --> $DIR/mutable_references.rs:17:23
142 --> $DIR/mutable_references.rs:18:23
143143 |
144144LL | static BAR: &mut () = &mut ();
145145 | ^^^^^^^
146146help: skipping check that does not even have a feature gate
147 --> $DIR/mutable_references.rs:22:28
147 --> $DIR/mutable_references.rs:23:28
148148 |
149149LL | static BOO: &mut Foo<()> = &mut Foo(());
150150 | ^^^^^^^^^^^^
151151help: skipping check that does not even have a feature gate
152 --> $DIR/mutable_references.rs:25:25
152 --> $DIR/mutable_references.rs:26:25
153153 |
154154LL | const BLUNT: &mut i32 = &mut 42;
155155 | ^^^^^^^
156156help: skipping check that does not even have a feature gate
157 --> $DIR/mutable_references.rs:40:28
157 --> $DIR/mutable_references.rs:41:28
158158 |
159159LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) };
160160 | ^^^^^^^^^^^^^^^^^^^^
161161help: skipping check that does not even have a feature gate
162 --> $DIR/mutable_references.rs:47:8
162 --> $DIR/mutable_references.rs:48:8
163163 |
164164LL | x: &UnsafeCell::new(42),
165165 | ^^^^^^^^^^^^^^^^^^^^
166166help: skipping check that does not even have a feature gate
167 --> $DIR/mutable_references.rs:56:27
167 --> $DIR/mutable_references.rs:57:27
168168 |
169169LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
170170 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
171171help: skipping check that does not even have a feature gate
172 --> $DIR/mutable_references.rs:76:45
172 --> $DIR/mutable_references.rs:77:45
173173 |
174174LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _;
175175 | ^^^^^^^
176176help: skipping check that does not even have a feature gate
177 --> $DIR/mutable_references.rs:79:46
177 --> $DIR/mutable_references.rs:80:46
178178 |
179179LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _;
180180 | ^^^^^^^
181181help: skipping check that does not even have a feature gate
182 --> $DIR/mutable_references.rs:84:47
182 --> $DIR/mutable_references.rs:85:47
183183 |
184184LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
185185 | ^^^^^^^^^^^^^^^^^^^^
186186help: skipping check that does not even have a feature gate
187 --> $DIR/mutable_references.rs:96:51
187 --> $DIR/mutable_references.rs:97:51
188188 |
189189LL | const RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
190190 | ^^^^^^^^^^^^^^^^^^^
191191help: skipping check that does not even have a feature gate
192 --> $DIR/mutable_references.rs:99:49
192 --> $DIR/mutable_references.rs:100:49
193193 |
194194LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x: &mut 42 as *mut _ as *const _ };
195195 | ^^^^^^^
196196help: skipping check that does not even have a feature gate
197 --> $DIR/mutable_references.rs:102:51
197 --> $DIR/mutable_references.rs:103:51
198198 |
199199LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
200200 | ^^^^^^
tests/ui/consts/miri_unleashed/static-no-inner-mut.32bit.stderr+4-4
......@@ -6,7 +6,7 @@ LL | static REF: &AtomicI32 = &AtomicI32::new(42);
66 |
77 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88 = note: the raw bytes of the constant (size: 4, align: 4) {
9 ╾ALLOC0╼ │ ╾──╼
9 ╾ALLOC$ID╼ │ ╾──╼
1010 }
1111
1212error[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;
1717 |
1818 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
1919 = note: the raw bytes of the constant (size: 4, align: 4) {
20 ╾ALLOC1╼ │ ╾──╼
20 ╾ALLOC$ID╼ │ ╾──╼
2121 }
2222
2323error[E0080]: constructing invalid value of type &Atomic<i32>: at .<deref>.v, encountered `UnsafeCell` in read-only memory
......@@ -28,7 +28,7 @@ LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}};
2828 |
2929 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
3030 = note: the raw bytes of the constant (size: 4, align: 4) {
31 ╾ALLOC2╼ │ ╾──╼
31 ╾ALLOC$ID╼ │ ╾──╼
3232 }
3333
3434error[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}};
3939 |
4040 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
4141 = note: the raw bytes of the constant (size: 4, align: 4) {
42 ╾ALLOC3╼ │ ╾──╼
42 ╾ALLOC$ID╼ │ ╾──╼
4343 }
4444
4545error: encountered mutable pointer in final value of static
tests/ui/consts/miri_unleashed/static-no-inner-mut.64bit.stderr+4-4
......@@ -6,7 +6,7 @@ LL | static REF: &AtomicI32 = &AtomicI32::new(42);
66 |
77 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88 = note: the raw bytes of the constant (size: 8, align: 8) {
9 ╾ALLOC0╼ │ ╾──────╼
9 ╾ALLOC$ID╼ │ ╾──────╼
1010 }
1111
1212error[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;
1717 |
1818 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
1919 = note: the raw bytes of the constant (size: 8, align: 8) {
20 ╾ALLOC1╼ │ ╾──────╼
20 ╾ALLOC$ID╼ │ ╾──────╼
2121 }
2222
2323error[E0080]: constructing invalid value of type &Atomic<i32>: at .<deref>.v, encountered `UnsafeCell` in read-only memory
......@@ -28,7 +28,7 @@ LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}};
2828 |
2929 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
3030 = note: the raw bytes of the constant (size: 8, align: 8) {
31 ╾ALLOC2╼ │ ╾──────╼
31 ╾ALLOC$ID╼ │ ╾──────╼
3232 }
3333
3434error[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}};
3939 |
4040 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
4141 = note: the raw bytes of the constant (size: 8, align: 8) {
42 ╾ALLOC3╼ │ ╾──────╼
42 ╾ALLOC$ID╼ │ ╾──────╼
4343 }
4444
4545error: encountered mutable pointer in final value of static
tests/ui/consts/miri_unleashed/static-no-inner-mut.rs+1-1
......@@ -1,6 +1,6 @@
11//@ stderr-per-bitwidth
22//@ compile-flags: -Zunleash-the-miri-inside-of-you
3//@ ignore-parallel-frontend different alloc ids
3
44// All "inner" allocations that come with a `static` are interned immutably. This means it is
55// crucial that we do not accept any form of (interior) mutability there.
66use std::sync::atomic::*;
tests/ui/consts/missing_span_in_backtrace.rs+1-1
......@@ -1,7 +1,7 @@
11//! Check what happens when the error occurs inside a std function that we can't print the span of.
22//@ ignore-backends: gcc
33//@ compile-flags: -Z ui-testing=no --diagnostic-width=80
4//@ ignore-parallel-frontend different alloc ids
4
55use std::{
66 mem::{self, MaybeUninit},
77 ptr,
tests/ui/consts/missing_span_in_backtrace.stderr+1-1
......@@ -1,4 +1,4 @@
1error[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
1error[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
22 --> $DIR/missing_span_in_backtrace.rs:16:9
33 |
4416 | / ... ptr::swap_nonoverlapping(
tests/ui/consts/offset_ub.rs+1-1
......@@ -1,5 +1,5 @@
11use std::ptr;
2//@ ignore-parallel-frontend different alloc ids
2
33//@ normalize-stderr: "0xf+" -> "0xf..f"
44//@ normalize-stderr: "0x7f+" -> "0x7f..f"
55//@ normalize-stderr: "\d+ bytes" -> "$$BYTES bytes"
tests/ui/consts/offset_ub.stderr+5-5
......@@ -1,16 +1,16 @@
1error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got ALLOC0 which is at the beginning of the allocation
1error[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
22 --> $DIR/offset_ub.rs:8:46
33 |
44LL | pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) };
55 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BEFORE_START` failed here
66
7error[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
7error[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
88 --> $DIR/offset_ub.rs:9:43
99 |
1010LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) };
1111 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `AFTER_END` failed here
1212
13error[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
13error[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
1414 --> $DIR/offset_ub.rs:10:45
1515 |
1616LL | 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
4040LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) };
4141 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNDERFLOW_ADDRESS_SPACE` failed here
4242
43error[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
43error[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
4444 --> $DIR/offset_ub.rs:16:49
4545 |
4646LL | ...nst u8 = unsafe { [0u8; 1].as_ptr().wrapping_offset(-2).offset(-2) };
4747 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `NEGATIVE_OFFSET` failed here
4848
49error[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
49error[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
5050 --> $DIR/offset_ub.rs:18:50
5151 |
5252LL | pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1) };
tests/ui/delegation/self-mapping-output-privacy.rs created+28
......@@ -0,0 +1,28 @@
1#![feature(fn_delegation)]
2
3trait Trait {
4 fn method(&self) -> Self;
5}
6
7pub struct S;
8impl Trait for S {
9 fn method(&self) -> S {
10 S
11 }
12}
13
14mod private {
15 pub struct W(super::S);
16}
17
18impl Trait for private::W {
19 reuse Trait::method { S }
20 //~^ ERROR: field `0` of struct `W` is private
21}
22
23impl private::W {
24 reuse Trait::method { S }
25 //~^ ERROR: field `0` of struct `W` is private
26}
27
28fn main() {}
tests/ui/delegation/self-mapping-output-privacy.stderr created+15
......@@ -0,0 +1,15 @@
1error[E0451]: field `0` of struct `W` is private
2 --> $DIR/self-mapping-output-privacy.rs:19:18
3 |
4LL | reuse Trait::method { S }
5 | ^^^^^^ private field
6
7error[E0451]: field `0` of struct `W` is private
8 --> $DIR/self-mapping-output-privacy.rs:24:18
9 |
10LL | reuse Trait::method { S }
11 | ^^^^^^ private field
12
13error: aborting due to 2 previous errors
14
15For more information about this error, try `rustc --explain E0451`.
tests/ui/delegation/self-mapping-output.rs created+357
......@@ -0,0 +1,357 @@
1#![feature(fn_delegation)]
2
3mod success {
4 trait Trait {
5 fn method(&self) -> Self;
6 fn r#static() -> Self;
7 fn raw_S(&self) -> S { S }
8 }
9
10 struct S;
11 impl Trait for S {
12 fn method(&self) -> S { S }
13 fn r#static() -> S { S }
14 }
15
16 struct W(S);
17 impl Trait for W {
18 reuse Trait::method { self.0 }
19 reuse Trait::r#static;
20 //~^ WARN: function cannot return without recursing [unconditional_recursion]
21 reuse Trait::raw_S { self.0 }
22 }
23
24 impl W {
25 reuse Trait::method { self.0 }
26 reuse Trait::r#static;
27 reuse Trait::raw_S { self.0 }
28 }
29}
30
31mod success_non_field {
32 trait Trait {
33 fn method(&self) -> Self;
34 fn r#static() -> Self;
35 fn raw_S(&self) -> S { S }
36 }
37
38 struct S;
39 impl Trait for S {
40 fn method(&self) -> S { S }
41 fn r#static() -> S { S }
42 }
43
44 struct W(S);
45 impl Trait for W {
46 reuse Trait::method { S }
47 reuse Trait::r#static;
48 //~^ WARN: function cannot return without recursing [unconditional_recursion]
49 reuse Trait::raw_S { S }
50 }
51
52 impl W {
53 reuse Trait::method { S }
54 reuse Trait::r#static;
55 reuse Trait::raw_S { S }
56 }
57}
58
59mod success_generics {
60 trait Trait<'a, T, const N: usize> {
61 fn method(&self) -> Self;
62 fn r#static() -> Self;
63 fn raw_S(&self) -> S<'a, 'static, T, (), N, 123> {
64 S::<'a, 'static, T, (), N, 123>(std::marker::PhantomData)
65 }
66 }
67
68 struct S<'a, 'b, A, B, const N: usize, const M: usize>(
69 std::marker::PhantomData<&'a &'b (A, B, &'a [(); N], &'b [(); M])>
70 );
71
72 impl<'a, T, const N: usize> Trait<'a, T, N> for S<'a, 'static, T, (), N, 123> {
73 fn method(&self) -> S<'a, 'static, T, (), N, 123> {
74 S(std::marker::PhantomData)
75 }
76
77 fn r#static() -> S<'a, 'static, T, (), N, 123> { S(std::marker::PhantomData) }
78 }
79
80 struct W<'a, 'b, A, B, const N: usize, const M: usize>(S<'a, 'b, A, B, N, M>);
81 impl<'a, T, const N: usize> Trait<'a, T, N> for W<'a, 'static, T, (), N, 123> {
82 reuse Trait::<'a, T, N>::method { self.0 }
83 reuse Trait::<'a, T, N>::r#static;
84 //~^ WARN: function cannot return without recursing [unconditional_recursion]
85 reuse Trait::<'a, T, N>::raw_S { self.0 }
86 }
87
88 impl<'a, T, const N: usize> W<'a, 'static, T, (), N, 123> {
89 reuse Trait::<'a, T, N>::method { self.0 }
90 reuse Trait::<'a, T, N>::r#static;
91 reuse Trait::<'a, T, N>::raw_S { self.0 }
92 }
93}
94
95mod no_constructor {
96 trait Trait {
97 fn method(&self) -> Self;
98 fn r#static() -> Self;
99 fn raw_S(&self) -> S { S }
100 }
101
102 struct S;
103 impl Trait for S {
104 fn method(&self) -> S { S }
105 fn r#static() -> S { S }
106 }
107
108 struct W { s: S }
109 impl Trait for W {
110 reuse Trait::method { self.0 }
111 //~^ ERROR: no field `0` on type `&no_constructor::W`
112 //~| ERROR: struct `no_constructor::W` has no field named `0`
113 reuse Trait::r#static;
114 //~^ WARN: function cannot return without recursing [unconditional_recursion]
115 reuse Trait::raw_S { self.0 }
116 //~^ ERROR: no field `0` on type `&no_constructor::W`
117 }
118
119 impl W {
120 reuse Trait::method { self.0 }
121 //~^ ERROR: no field `0` on type `&no_constructor::W`
122 //~| ERROR: struct `no_constructor::W` has no field named `0`
123 reuse Trait::r#static;
124 reuse Trait::raw_S { self.0 }
125 //~^ ERROR: no field `0` on type `&no_constructor::W`
126 }
127}
128
129mod more_than_one_field {
130 trait Trait {
131 fn method(&self) -> Self;
132 fn r#static() -> Self;
133 fn raw_S(&self) -> S { S }
134 }
135
136 struct S;
137 impl Trait for S {
138 fn method(&self) -> S { S }
139 fn r#static() -> S { S }
140 }
141
142 struct W(S, S, S);
143 impl Trait for W {
144 reuse Trait::method { self.0 }
145 //~^ ERROR: missing fields `1` and `2` in initializer of `more_than_one_field::W`
146 reuse Trait::r#static;
147 //~^ WARN: function cannot return without recursing [unconditional_recursion]
148 reuse Trait::raw_S { self.0 }
149 }
150
151 impl W {
152 reuse Trait::method { self.0 }
153 //~^ ERROR: missing fields `1` and `2` in initializer of `more_than_one_field::W`
154 reuse Trait::r#static;
155 reuse Trait::raw_S { self.0 }
156 }
157}
158
159mod non_trait_path_reuse {
160 trait Trait {
161 fn method(&self) -> Self;
162 fn r#static() -> Self;
163 fn raw_S(&self) -> S { S }
164 }
165
166 mod to_reuse {
167 pub fn method(_: impl super::Trait) -> impl super::Trait {
168 super::S
169 }
170
171 pub fn r#static() -> impl super::Trait {
172 super::S
173 }
174 }
175
176 pub struct S;
177 impl Trait for S {
178 fn method(&self) -> S { S }
179 fn r#static() -> S { S }
180 }
181
182 struct W(S);
183 impl Trait for W {
184 reuse to_reuse::method { self.0 }
185 //~^ ERROR: mismatched types
186 reuse to_reuse::r#static;
187 //~^ ERROR: mismatched types
188 }
189
190 impl W {
191 reuse to_reuse::method { self.0 }
192 //~^ ERROR: no field `0` on type `impl super::Trait`
193 reuse to_reuse::r#static;
194 }
195}
196
197mod non_Self_return_type {
198 trait Trait {
199 fn method(&self) -> ();
200 fn r#static() -> ();
201 fn raw_S(&self) -> S { S }
202 }
203
204 struct S;
205 impl Trait for S {
206 fn method(&self) -> () { () }
207 fn r#static() -> () { () }
208 fn raw_S(&self) -> S { S }
209 }
210
211 struct W(());
212 impl Trait for W {
213 reuse Trait::method { self.0 }
214 //~^ ERROR: mismatched types
215
216 reuse Trait::r#static;
217 //~^ ERROR: type annotations needed
218
219 reuse Trait::raw_S { self.0 }
220 //~^ ERROR: mismatched types
221 }
222
223 impl W {
224 reuse Trait::method { self.0 }
225 //~^ ERROR: mismatched types
226
227 reuse Trait::r#static;
228 //~^ ERROR: type annotations needed
229
230 reuse Trait::raw_S { self.0 }
231 //~^ ERROR: mismatched types
232 }
233}
234
235mod wrong_return_type {
236 trait Trait {
237 fn method(&self) -> Self;
238 fn r#static() -> Self;
239 fn raw_S(&self) -> S { S }
240 }
241
242 struct F;
243 impl Trait for F {
244 fn method(&self) -> F { F }
245 fn r#static() -> F { F }
246 }
247
248 struct S;
249 impl Trait for S {
250 fn method(&self) -> S { S }
251 fn r#static() -> S { S }
252 }
253
254 struct W(S);
255 impl Trait for W {
256 reuse <F as Trait>::method { self.0 }
257 //~^ ERROR: mismatched types
258 //~| ERROR: mismatched types
259
260 reuse <F as Trait>::r#static;
261 //~^ ERROR: mismatched types
262
263 reuse <F as Trait>::raw_S { self.0 }
264 //~^ ERROR: mismatched types
265 }
266
267 impl W {
268 reuse <F as Trait>::method { self.0 }
269 //~^ ERROR: mismatched types
270 //~| ERROR: mismatched types
271
272 reuse <F as Trait>::r#static;
273 //~^ ERROR: mismatched types
274
275 reuse <F as Trait>::raw_S { self.0 }
276 //~^ ERROR: mismatched types
277 }
278}
279
280mod wrong_target_expression {
281 trait Trait {
282 fn method(&self) -> Self;
283 fn r#static() -> Self;
284 fn raw_S(&self) -> S { S }
285 }
286
287 struct S;
288 impl Trait for S {
289 fn method(&self) -> S { S }
290 fn r#static() -> S { S }
291 }
292
293 struct F;
294 impl Trait for F {
295 fn method(&self) -> F { F }
296 fn r#static() -> F { F }
297 }
298
299 struct W(S);
300 impl Trait for W {
301 reuse Trait::method { F }
302 //~^ ERROR: mismatched types
303
304 reuse Trait::r#static;
305 //~^ WARN: function cannot return without recursing [unconditional_recursion]
306 reuse Trait::raw_S { F }
307 }
308
309 impl W {
310 reuse Trait::method { F }
311 //~^ ERROR: mismatched types
312
313 reuse Trait::r#static;
314 reuse Trait::raw_S { F }
315 }
316}
317
318mod privacy {
319 trait Trait {
320 fn method(&self) -> Self;
321 fn r#static() -> Self;
322 fn raw_S(&self) -> S { S }
323 }
324
325 pub struct S;
326 impl Trait for S {
327 fn method(&self) -> S { S }
328 fn r#static() -> S { S }
329 }
330
331 mod private {
332 pub struct W(super::S);
333 }
334
335 impl Trait for private::W {
336 reuse Trait::method { self.0 }
337 //~^ ERROR: field `0` of struct `private::W` is private
338
339 reuse Trait::r#static;
340 //~^ WARN: function cannot return without recursing [unconditional_recursion]
341
342 reuse Trait::raw_S { self.0 }
343 //~^ ERROR: field `0` of struct `private::W` is private
344 }
345
346 impl private::W {
347 reuse Trait::method { self.0 }
348 //~^ ERROR: field `0` of struct `private::W` is private
349
350 reuse Trait::r#static;
351
352 reuse Trait::raw_S { self.0 }
353 //~^ ERROR: field `0` of struct `private::W` is private
354 }
355}
356
357fn main() {}
tests/ui/delegation/self-mapping-output.stderr created+468
......@@ -0,0 +1,468 @@
1error[E0560]: struct `no_constructor::W` has no field named `0`
2 --> $DIR/self-mapping-output.rs:110:22
3 |
4LL | reuse Trait::method { self.0 }
5 | ^^^^^^ unknown field
6 |
7help: a field with a similar name exists
8 |
9LL - reuse Trait::method { self.0 }
10LL + reuse Trait::s { self.0 }
11 |
12
13error[E0609]: no field `0` on type `&no_constructor::W`
14 --> $DIR/self-mapping-output.rs:110:36
15 |
16LL | reuse Trait::method { self.0 }
17 | ^ unknown field
18 |
19help: a field with a similar name exists
20 |
21LL - reuse Trait::method { self.0 }
22LL + reuse Trait::method { self.s }
23 |
24
25error[E0609]: no field `0` on type `&no_constructor::W`
26 --> $DIR/self-mapping-output.rs:115:35
27 |
28LL | reuse Trait::raw_S { self.0 }
29 | ^ unknown field
30 |
31help: a field with a similar name exists
32 |
33LL - reuse Trait::raw_S { self.0 }
34LL + reuse Trait::raw_S { self.s }
35 |
36
37error[E0560]: struct `no_constructor::W` has no field named `0`
38 --> $DIR/self-mapping-output.rs:120:22
39 |
40LL | reuse Trait::method { self.0 }
41 | ^^^^^^ unknown field
42 |
43help: a field with a similar name exists
44 |
45LL - reuse Trait::method { self.0 }
46LL + reuse Trait::s { self.0 }
47 |
48
49error[E0609]: no field `0` on type `&no_constructor::W`
50 --> $DIR/self-mapping-output.rs:120:36
51 |
52LL | reuse Trait::method { self.0 }
53 | ^ unknown field
54 |
55help: a field with a similar name exists
56 |
57LL - reuse Trait::method { self.0 }
58LL + reuse Trait::method { self.s }
59 |
60
61error[E0609]: no field `0` on type `&no_constructor::W`
62 --> $DIR/self-mapping-output.rs:124:35
63 |
64LL | reuse Trait::raw_S { self.0 }
65 | ^ unknown field
66 |
67help: a field with a similar name exists
68 |
69LL - reuse Trait::raw_S { self.0 }
70LL + reuse Trait::raw_S { self.s }
71 |
72
73error[E0063]: missing fields `1` and `2` in initializer of `more_than_one_field::W`
74 --> $DIR/self-mapping-output.rs:144:22
75 |
76LL | reuse Trait::method { self.0 }
77 | ^^^^^^ missing `1` and `2`
78
79error[E0063]: missing fields `1` and `2` in initializer of `more_than_one_field::W`
80 --> $DIR/self-mapping-output.rs:152:22
81 |
82LL | reuse Trait::method { self.0 }
83 | ^^^^^^ missing `1` and `2`
84
85error[E0308]: mismatched types
86 --> $DIR/self-mapping-output.rs:184:25
87 |
88LL | pub fn method(_: impl super::Trait) -> impl super::Trait {
89 | ----------------- the found opaque type
90...
91LL | reuse to_reuse::method { self.0 }
92 | ^^^^^^
93 | |
94 | expected `W`, found opaque type
95 | expected `non_trait_path_reuse::W` because of return type
96 |
97 = note: expected struct `non_trait_path_reuse::W`
98 found opaque type `impl non_trait_path_reuse::Trait`
99
100error[E0308]: mismatched types
101 --> $DIR/self-mapping-output.rs:186:25
102 |
103LL | pub fn r#static() -> impl super::Trait {
104 | ----------------- the found opaque type
105...
106LL | reuse to_reuse::r#static;
107 | ^^^^^^^^
108 | |
109 | expected `W`, found opaque type
110 | expected `non_trait_path_reuse::W` because of return type
111 |
112 = note: expected struct `non_trait_path_reuse::W`
113 found opaque type `impl non_trait_path_reuse::Trait`
114
115error[E0609]: no field `0` on type `impl super::Trait`
116 --> $DIR/self-mapping-output.rs:191:39
117 |
118LL | reuse to_reuse::method { self.0 }
119 | ^ unknown field
120
121error[E0308]: mismatched types
122 --> $DIR/self-mapping-output.rs:213:31
123 |
124LL | reuse Trait::method { self.0 }
125 | ------ ^^^^^^ expected `&_`, found `()`
126 | |
127 | arguments to this function are incorrect
128 |
129 = note: expected reference `&_`
130 found unit type `()`
131note: method defined here
132 --> $DIR/self-mapping-output.rs:199:12
133 |
134LL | fn method(&self) -> ();
135 | ^^^^^^ ----
136help: consider borrowing here
137 |
138LL | reuse Trait::method { &self.0 }
139 | +
140
141error[E0283]: type annotations needed
142 --> $DIR/self-mapping-output.rs:216:22
143 |
144LL | reuse Trait::r#static;
145 | ^^^^^^^^ cannot infer type
146 |
147 = note: the type must implement `non_Self_return_type::Trait`
148help: the following types implement trait `non_Self_return_type::Trait`
149 --> $DIR/self-mapping-output.rs:205:5
150 |
151LL | impl Trait for S {
152 | ^^^^^^^^^^^^^^^^ `non_Self_return_type::S`
153...
154LL | impl Trait for W {
155 | ^^^^^^^^^^^^^^^^ `non_Self_return_type::W`
156
157error[E0308]: mismatched types
158 --> $DIR/self-mapping-output.rs:219:30
159 |
160LL | reuse Trait::raw_S { self.0 }
161 | ----- ^^^^^^ expected `&_`, found `()`
162 | |
163 | arguments to this function are incorrect
164 |
165 = note: expected reference `&_`
166 found unit type `()`
167note: method defined here
168 --> $DIR/self-mapping-output.rs:201:12
169 |
170LL | fn raw_S(&self) -> S { S }
171 | ^^^^^ -----
172help: consider borrowing here
173 |
174LL | reuse Trait::raw_S { &self.0 }
175 | +
176
177error[E0308]: mismatched types
178 --> $DIR/self-mapping-output.rs:224:31
179 |
180LL | reuse Trait::method { self.0 }
181 | ------ ^^^^^^ expected `&_`, found `()`
182 | |
183 | arguments to this function are incorrect
184 |
185 = note: expected reference `&_`
186 found unit type `()`
187note: method defined here
188 --> $DIR/self-mapping-output.rs:199:12
189 |
190LL | fn method(&self) -> ();
191 | ^^^^^^ ----
192help: consider borrowing here
193 |
194LL | reuse Trait::method { &self.0 }
195 | +
196
197error[E0283]: type annotations needed
198 --> $DIR/self-mapping-output.rs:227:22
199 |
200LL | reuse Trait::r#static;
201 | ^^^^^^^^ cannot infer type
202 |
203 = note: the type must implement `non_Self_return_type::Trait`
204help: the following types implement trait `non_Self_return_type::Trait`
205 --> $DIR/self-mapping-output.rs:205:5
206 |
207LL | impl Trait for S {
208 | ^^^^^^^^^^^^^^^^ `non_Self_return_type::S`
209...
210LL | impl Trait for W {
211 | ^^^^^^^^^^^^^^^^ `non_Self_return_type::W`
212
213error[E0308]: mismatched types
214 --> $DIR/self-mapping-output.rs:230:30
215 |
216LL | reuse Trait::raw_S { self.0 }
217 | ----- ^^^^^^ expected `&_`, found `()`
218 | |
219 | arguments to this function are incorrect
220 |
221 = note: expected reference `&_`
222 found unit type `()`
223note: method defined here
224 --> $DIR/self-mapping-output.rs:201:12
225 |
226LL | fn raw_S(&self) -> S { S }
227 | ^^^^^ -----
228help: consider borrowing here
229 |
230LL | reuse Trait::raw_S { &self.0 }
231 | +
232
233error[E0308]: mismatched types
234 --> $DIR/self-mapping-output.rs:256:38
235 |
236LL | reuse <F as Trait>::method { self.0 }
237 | ------ ^^^^^^ expected `&F`, found `&S`
238 | |
239 | arguments to this function are incorrect
240 | this return type influences the call expression's return type
241 |
242 = note: expected reference `&wrong_return_type::F`
243 found reference `&wrong_return_type::S`
244note: method defined here
245 --> $DIR/self-mapping-output.rs:237:12
246 |
247LL | fn method(&self) -> Self;
248 | ^^^^^^ ----
249
250error[E0308]: mismatched types
251 --> $DIR/self-mapping-output.rs:256:29
252 |
253LL | reuse <F as Trait>::method { self.0 }
254 | ^^^^^^ expected `S`, found `F`
255
256error[E0308]: mismatched types
257 --> $DIR/self-mapping-output.rs:260:29
258 |
259LL | reuse <F as Trait>::r#static;
260 | ^^^^^^^^
261 | |
262 | expected `W`, found `F`
263 | expected `wrong_return_type::W` because of return type
264
265error[E0308]: mismatched types
266 --> $DIR/self-mapping-output.rs:263:37
267 |
268LL | reuse <F as Trait>::raw_S { self.0 }
269 | ----- ^^^^^^ expected `&F`, found `&S`
270 | |
271 | arguments to this function are incorrect
272 |
273 = note: expected reference `&wrong_return_type::F`
274 found reference `&wrong_return_type::S`
275note: method defined here
276 --> $DIR/self-mapping-output.rs:239:12
277 |
278LL | fn raw_S(&self) -> S { S }
279 | ^^^^^ -----
280
281error[E0308]: mismatched types
282 --> $DIR/self-mapping-output.rs:268:38
283 |
284LL | reuse <F as Trait>::method { self.0 }
285 | ------ ^^^^^^ expected `&F`, found `&S`
286 | |
287 | arguments to this function are incorrect
288 | this return type influences the call expression's return type
289 |
290 = note: expected reference `&wrong_return_type::F`
291 found reference `&wrong_return_type::S`
292note: method defined here
293 --> $DIR/self-mapping-output.rs:237:12
294 |
295LL | fn method(&self) -> Self;
296 | ^^^^^^ ----
297
298error[E0308]: mismatched types
299 --> $DIR/self-mapping-output.rs:268:29
300 |
301LL | reuse <F as Trait>::method { self.0 }
302 | ^^^^^^ expected `S`, found `F`
303
304error[E0308]: mismatched types
305 --> $DIR/self-mapping-output.rs:272:29
306 |
307LL | reuse <F as Trait>::r#static;
308 | ^^^^^^^^
309 | |
310 | expected `W`, found `F`
311 | expected `wrong_return_type::W` because of return type
312
313error[E0308]: mismatched types
314 --> $DIR/self-mapping-output.rs:275:37
315 |
316LL | reuse <F as Trait>::raw_S { self.0 }
317 | ----- ^^^^^^ expected `&F`, found `&S`
318 | |
319 | arguments to this function are incorrect
320 |
321 = note: expected reference `&wrong_return_type::F`
322 found reference `&wrong_return_type::S`
323note: method defined here
324 --> $DIR/self-mapping-output.rs:239:12
325 |
326LL | fn raw_S(&self) -> S { S }
327 | ^^^^^ -----
328
329error[E0308]: mismatched types
330 --> $DIR/self-mapping-output.rs:301:31
331 |
332LL | reuse Trait::method { F }
333 | ------ ^ expected `&S`, found `&F`
334 | |
335 | arguments to this function are incorrect
336 | this return type influences the call expression's return type
337 |
338 = note: expected reference `&wrong_target_expression::S`
339 found reference `&wrong_target_expression::F`
340note: method defined here
341 --> $DIR/self-mapping-output.rs:282:12
342 |
343LL | fn method(&self) -> Self;
344 | ^^^^^^ ----
345
346error[E0308]: mismatched types
347 --> $DIR/self-mapping-output.rs:310:31
348 |
349LL | reuse Trait::method { F }
350 | ------ ^ expected `&S`, found `&F`
351 | |
352 | arguments to this function are incorrect
353 | this return type influences the call expression's return type
354 |
355 = note: expected reference `&wrong_target_expression::S`
356 found reference `&wrong_target_expression::F`
357note: method defined here
358 --> $DIR/self-mapping-output.rs:282:12
359 |
360LL | fn method(&self) -> Self;
361 | ^^^^^^ ----
362
363error[E0616]: field `0` of struct `private::W` is private
364 --> $DIR/self-mapping-output.rs:336:36
365 |
366LL | reuse Trait::method { self.0 }
367 | ^ private field
368
369error[E0616]: field `0` of struct `private::W` is private
370 --> $DIR/self-mapping-output.rs:342:35
371 |
372LL | reuse Trait::raw_S { self.0 }
373 | ^ private field
374
375error[E0616]: field `0` of struct `private::W` is private
376 --> $DIR/self-mapping-output.rs:347:36
377 |
378LL | reuse Trait::method { self.0 }
379 | ^ private field
380
381error[E0616]: field `0` of struct `private::W` is private
382 --> $DIR/self-mapping-output.rs:352:35
383 |
384LL | reuse Trait::raw_S { self.0 }
385 | ^ private field
386
387warning: function cannot return without recursing
388 --> $DIR/self-mapping-output.rs:19:22
389 |
390LL | reuse Trait::r#static;
391 | ^^^^^^^^
392 | |
393 | cannot return without recursing
394 | recursive call site
395 |
396 = help: a `loop` may express intention better if this is on purpose
397 = note: `#[warn(unconditional_recursion)]` on by default
398
399warning: function cannot return without recursing
400 --> $DIR/self-mapping-output.rs:47:22
401 |
402LL | reuse Trait::r#static;
403 | ^^^^^^^^
404 | |
405 | cannot return without recursing
406 | recursive call site
407 |
408 = help: a `loop` may express intention better if this is on purpose
409
410warning: function cannot return without recursing
411 --> $DIR/self-mapping-output.rs:83:34
412 |
413LL | reuse Trait::<'a, T, N>::r#static;
414 | ^^^^^^^^
415 | |
416 | cannot return without recursing
417 | recursive call site
418 |
419 = help: a `loop` may express intention better if this is on purpose
420
421warning: function cannot return without recursing
422 --> $DIR/self-mapping-output.rs:113:22
423 |
424LL | reuse Trait::r#static;
425 | ^^^^^^^^
426 | |
427 | cannot return without recursing
428 | recursive call site
429 |
430 = help: a `loop` may express intention better if this is on purpose
431
432warning: function cannot return without recursing
433 --> $DIR/self-mapping-output.rs:146:22
434 |
435LL | reuse Trait::r#static;
436 | ^^^^^^^^
437 | |
438 | cannot return without recursing
439 | recursive call site
440 |
441 = help: a `loop` may express intention better if this is on purpose
442
443warning: function cannot return without recursing
444 --> $DIR/self-mapping-output.rs:304:22
445 |
446LL | reuse Trait::r#static;
447 | ^^^^^^^^
448 | |
449 | cannot return without recursing
450 | recursive call site
451 |
452 = help: a `loop` may express intention better if this is on purpose
453
454warning: function cannot return without recursing
455 --> $DIR/self-mapping-output.rs:339:22
456 |
457LL | reuse Trait::r#static;
458 | ^^^^^^^^
459 | |
460 | cannot return without recursing
461 | recursive call site
462 |
463 = help: a `loop` may express intention better if this is on purpose
464
465error: aborting due to 31 previous errors; 7 warnings emitted
466
467Some errors have detailed explanations: E0063, E0283, E0308, E0560, E0609, E0616.
468For more information about an error, try `rustc --explain E0063`.
tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs+1-1
......@@ -1,6 +1,6 @@
11//@ normalize-stderr: "[[:xdigit:]]{2} __ ([[:xdigit:]]{2}\s){2}" -> "HEX_DUMP"
22#![feature(core_intrinsics)]
3//@ ignore-parallel-frontend different alloc ids
3
44const RAW_EQ_PADDING: bool = unsafe {
55 std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16))
66//~^ ERROR requires initialized memory
tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr+1-1
......@@ -1,4 +1,4 @@
1error[E0080]: reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory
1error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory
22 --> $DIR/intrinsic-raw_eq-const-bad.rs:5:5
33 |
44LL | std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16))
tests/ui/statics/mutable_memory_validation.rs+1
......@@ -3,6 +3,7 @@
33// Strip out raw byte dumps to make comparison platform-independent:
44//@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
55//@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*A(LLOC)?[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP"
6//@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼"
67
78use std::cell::UnsafeCell;
89
tests/ui/statics/mutable_memory_validation.stderr+2-2
......@@ -1,12 +1,12 @@
11error[E0080]: constructing invalid value of type Meh: at .x.<deref>, encountered `UnsafeCell` in read-only memory
2 --> $DIR/mutable_memory_validation.rs:13:1
2 --> $DIR/mutable_memory_validation.rs:14:1
33 |
44LL | const MUH: Meh = Meh { x: unsafe { &mut *(&READONLY as *const _ as *mut _) } };
55 | ^^^^^^^^^^^^^^ it is undefined behavior to use this value
66 |
77 = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
9 HEX_DUMP
9 ╾ALLOC$ID╼ │ ╾─╼
1010 }
1111
1212error: aborting due to 1 previous error
tests/ui/std/linux-getrandom-fallback.rs+1
......@@ -1,5 +1,6 @@
11//@ only-linux
22//@ run-pass
3//@ needs-unwind
34
45#![feature(random)]
56#![feature(rustc_private)]
tests/ui/type/pattern_types/validity.rs+1-1
......@@ -1,7 +1,7 @@
11//! Check that pattern types have their validity checked
22// Strip out raw byte dumps to make tests platform-independent:
33//@ normalize-stderr: "([[:xdigit:]]{2}\s){4,8}\s+│\s.{4,8}" -> "HEX_DUMP"
4//@ ignore-parallel-frontend different alloc ids
4
55#![feature(pattern_types, const_trait_impl, pattern_type_range_trait)]
66#![feature(pattern_type_macro)]
77
tests/ui/type/pattern_types/validity.stderr+2-2
......@@ -9,7 +9,7 @@ LL | const BAD: pattern_type!(u32 is 1..) = unsafe { std::mem::transmute(0) };
99 HEX_DUMP
1010 }
1111
12error[E0080]: reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
12error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
1313 --> $DIR/validity.rs:13:1
1414 |
1515LL | const BAD_UNINIT: pattern_type!(u32 is 1..) =
......@@ -50,7 +50,7 @@ LL | const BAD_FOO: Foo = Foo(Bar(unsafe { std::mem::transmute(0) }));
5050 HEX_DUMP
5151 }
5252
53error[E0080]: reading memory at ALLOC1[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
53error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
5454 --> $DIR/validity.rs:29:1
5555 |
5656LL | const CHAR_UNINIT: pattern_type!(char is 'A'..'Z') =
typos.toml+1
......@@ -21,6 +21,7 @@ extend-exclude = [
2121# right now. Entries should look like `mipsel = "mipsel"`.
2222#
2323# tidy-alphabetical-start
24EXPORTAS = "EXPORTAS" # MSVC linker keyword used with /EXPORT directives
2425anser = "anser" # an ANSI parsing package used by rust-analyzer
2526arange = "arange" # short for A-range
2627childs = "childs"