| author | bors <bors@rust-lang.org> 2026-07-01 15:45:33 UTC |
| committer | bors <bors@rust-lang.org> 2026-07-01 15:45:33 UTC |
| log | 4c9d2bfe4ad7a65669098754964aaebe0ec1ced2 |
| tree | 64dafb7cf04f533b29d8b938bc2156cdc6469c9e |
| parent | e2b71ade2db4ea263ab0d561d889f3e3795a500d |
| parent | ddf0d0fd0bc5136f2778b9877e426ef6138cb704 |
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 { |
| 542 | 542 | |
| 543 | 543 | #[inline] |
| 544 | 544 | 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 | ||
| 545 | 548 | // Warning: this function is reentrant: `iter` could hold a reference to `&self` and |
| 546 | 549 | // allocate additional elements while we're iterating. |
| 547 | 550 | let iter = iter.into_iter(); |
| 548 | assert!(size_of::<T>() != 0); | |
| 549 | assert!(!mem::needs_drop::<T>()); | |
| 550 | 551 | |
| 551 | 552 | let size_hint = iter.size_hint(); |
| 552 | 553 | |
| ... | ... | @@ -577,6 +578,7 @@ impl DroplessArena { |
| 577 | 578 | ) -> Result<&mut [T], E> { |
| 578 | 579 | // Despite the similarity with `alloc_from_iter`, we cannot reuse their fast case, as we |
| 579 | 580 | // cannot know the minimum length of the iterator in this case. |
| 581 | assert!(!mem::needs_drop::<T>()); | |
| 580 | 582 | assert!(size_of::<T>() != 0); |
| 581 | 583 | |
| 582 | 584 | // Takes care of reentrancy. |
compiler/rustc_ast_lowering/src/delegation.rs+65-3| ... | ... | @@ -53,7 +53,7 @@ use rustc_middle::span_bug; |
| 53 | 53 | use rustc_middle::ty::{Asyncness, PerOwnerResolverData}; |
| 54 | 54 | use rustc_span::def_id::{DefId, LocalDefId}; |
| 55 | 55 | use rustc_span::symbol::kw; |
| 56 | use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol}; | |
| 56 | use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol, sym}; | |
| 57 | 57 | |
| 58 | 58 | use crate::delegation::generics::{ |
| 59 | 59 | GenericsGenerationResult, GenericsGenerationResults, GenericsPosition, |
| ... | ... | @@ -664,11 +664,34 @@ impl<'hir> LoweringContext<'_, 'hir> { |
| 664 | 664 | |
| 665 | 665 | let callee_path = self.arena.alloc(self.mk_expr(hir::ExprKind::Path(new_path), span)); |
| 666 | 666 | 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 | }; | |
| 668 | 691 | |
| 669 | 692 | let block = self.arena.alloc(hir::Block { |
| 670 | 693 | stmts, |
| 671 | expr: Some(call), | |
| 694 | expr: Some(expr), | |
| 672 | 695 | hir_id: self.next_id(), |
| 673 | 696 | rules: hir::BlockCheckMode::DefaultBlock, |
| 674 | 697 | span, |
| ... | ... | @@ -678,6 +701,45 @@ impl<'hir> LoweringContext<'_, 'hir> { |
| 678 | 701 | (self.mk_expr(hir::ExprKind::Block(block, None), span), call.hir_id) |
| 679 | 702 | } |
| 680 | 703 | |
| 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 | ||
| 681 | 743 | fn process_segment( |
| 682 | 744 | &mut self, |
| 683 | 745 | span: Span, |
compiler/rustc_ast_lowering/src/delegation/generics.rs+11-2| ... | ... | @@ -588,19 +588,28 @@ impl<'hir> LoweringContext<'_, 'hir> { |
| 588 | 588 | p.def_id.to_def_id(), |
| 589 | 589 | ); |
| 590 | 590 | |
| 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> { | |
| 591 | 600 | hir::QPath::Resolved( |
| 592 | 601 | None, |
| 593 | 602 | self.arena.alloc(hir::Path { |
| 594 | 603 | segments: self.arena.alloc_slice(&[hir::PathSegment { |
| 595 | 604 | args: None, |
| 596 | 605 | hir_id: self.next_id(), |
| 597 | ident: p.name.ident(), | |
| 606 | ident, | |
| 598 | 607 | infer_args: false, |
| 599 | 608 | res, |
| 600 | 609 | delegation_child_segment: false, |
| 601 | 610 | }]), |
| 602 | 611 | res, |
| 603 | span: p.span, | |
| 612 | span, | |
| 604 | 613 | }), |
| 605 | 614 | ) |
| 606 | 615 | } |
compiler/rustc_codegen_ssa/src/back/link.rs+59-8| ... | ... | @@ -63,7 +63,10 @@ use super::rmeta_link::RmetaLinkCache; |
| 63 | 63 | use super::rpath::{self, RPathConfig}; |
| 64 | 64 | use super::{apple, rmeta_link, versioned_llvm_target}; |
| 65 | 65 | use crate::base::needs_allocator_shim_for_linking; |
| 66 | use crate::{CodegenLintLevelSpecs, CompiledModule, CompiledModules, CrateInfo, NativeLib, errors}; | |
| 66 | use crate::{ | |
| 67 | CodegenLintLevelSpecs, CompiledModule, CompiledModules, CrateInfo, NativeLib, SymbolExport, | |
| 68 | errors, | |
| 69 | }; | |
| 67 | 70 | |
| 68 | 71 | pub fn ensure_removed(dcx: DiagCtxtHandle<'_>, path: &Path) { |
| 69 | 72 | if let Err(e) = fs::remove_file(path) { |
| ... | ... | @@ -593,7 +596,7 @@ fn link_staticlib( |
| 593 | 596 | crate_info |
| 594 | 597 | .exported_symbols |
| 595 | 598 | .get(&CrateType::StaticLib) |
| 596 | .map(|symbols| symbols.iter().map(|(s, _)| s.clone()).collect()) | |
| 599 | .map(|symbols| symbols.iter().map(|symbol| symbol.name.clone()).collect()) | |
| 597 | 600 | } |
| 598 | 601 | } else { |
| 599 | 602 | None |
| ... | ... | @@ -2196,9 +2199,15 @@ fn add_linked_symbol_object( |
| 2196 | 2199 | cmd: &mut dyn Linker, |
| 2197 | 2200 | sess: &Session, |
| 2198 | 2201 | tmpdir: &Path, |
| 2199 | symbols: &[(String, SymbolExportKind)], | |
| 2202 | crate_type: CrateType, | |
| 2203 | linked_symbols: &[(String, SymbolExportKind)], | |
| 2204 | exported_symbols: &[SymbolExport], | |
| 2200 | 2205 | ) { |
| 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 { | |
| 2202 | 2211 | return; |
| 2203 | 2212 | } |
| 2204 | 2213 | |
| ... | ... | @@ -2235,7 +2244,7 @@ fn add_linked_symbol_object( |
| 2235 | 2244 | None |
| 2236 | 2245 | }; |
| 2237 | 2246 | |
| 2238 | for (sym, kind) in symbols.iter() { | |
| 2247 | for (sym, kind) in linked_symbols.iter() { | |
| 2239 | 2248 | let symbol = file.add_symbol(object::write::Symbol { |
| 2240 | 2249 | name: sym.clone().into(), |
| 2241 | 2250 | value: 0, |
| ... | ... | @@ -2293,6 +2302,37 @@ fn add_linked_symbol_object( |
| 2293 | 2302 | } |
| 2294 | 2303 | } |
| 2295 | 2304 | |
| 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 | ||
| 2296 | 2336 | let path = tmpdir.join("symbols.o"); |
| 2297 | 2337 | let result = std::fs::write(&path, file.write().unwrap()); |
| 2298 | 2338 | if let Err(error) = result { |
| ... | ... | @@ -2486,7 +2526,7 @@ fn undecorate_c_symbol<'a>( |
| 2486 | 2526 | fn add_c_staticlib_symbols( |
| 2487 | 2527 | sess: &Session, |
| 2488 | 2528 | lib: &NativeLib, |
| 2489 | out: &mut Vec<(String, SymbolExportKind)>, | |
| 2529 | out: &mut Vec<SymbolExport>, | |
| 2490 | 2530 | ) -> io::Result<()> { |
| 2491 | 2531 | let file_path = find_native_static_library(lib.name.as_str(), lib.verbatim, sess); |
| 2492 | 2532 | |
| ... | ... | @@ -2549,7 +2589,11 @@ fn add_c_staticlib_symbols( |
| 2549 | 2589 | let Some(undecorated) = undecorate_c_symbol(name, sess, export_kind) else { |
| 2550 | 2590 | continue; |
| 2551 | 2591 | }; |
| 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 | )); | |
| 2553 | 2597 | } |
| 2554 | 2598 | } |
| 2555 | 2599 | |
| ... | ... | @@ -2629,7 +2673,14 @@ fn linker_with_args( |
| 2629 | 2673 | // Pre-link CRT objects. |
| 2630 | 2674 | add_pre_link_objects(cmd, sess, flavor, link_output_kind, self_contained_crt_objects); |
| 2631 | 2675 | |
| 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 | ); | |
| 2633 | 2684 | |
| 2634 | 2685 | // Sanitizer libraries. |
| 2635 | 2686 | 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; |
| 15 | 15 | use rustc_middle::middle::exported_symbols::{ |
| 16 | 16 | self, ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel, |
| 17 | 17 | }; |
| 18 | use rustc_middle::ty::TyCtxt; | |
| 18 | use rustc_middle::ty::{SymbolName, TyCtxt}; | |
| 19 | 19 | use rustc_session::Session; |
| 20 | 20 | use rustc_session::config::{self, CrateType, DebugInfo, LinkerPluginLto, Lto, OptLevel, Strip}; |
| 21 | 21 | use rustc_target::spec::{Arch, Cc, CfgAbi, LinkOutputKind, LinkerFlavor, Lld, Os}; |
| ... | ... | @@ -25,7 +25,7 @@ use super::command::Command; |
| 25 | 25 | use super::symbol_export; |
| 26 | 26 | use crate::back::symbol_export::allocator_shim_symbols; |
| 27 | 27 | use crate::base::needs_allocator_shim_for_linking; |
| 28 | use crate::errors; | |
| 28 | use crate::{SymbolExport, errors}; | |
| 29 | 29 | |
| 30 | 30 | #[cfg(test)] |
| 31 | 31 | mod tests; |
| ... | ... | @@ -338,12 +338,7 @@ pub(crate) trait Linker { |
| 338 | 338 | fn debuginfo(&mut self, strip: Strip, natvis_debugger_visualizers: &[PathBuf]); |
| 339 | 339 | fn no_crt_objects(&mut self); |
| 340 | 340 | 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]); | |
| 347 | 342 | fn windows_subsystem(&mut self, subsystem: WindowsSubsystemKind); |
| 348 | 343 | fn linker_plugin_lto(&mut self); |
| 349 | 344 | fn add_eh_frame_header(&mut self) {} |
| ... | ... | @@ -794,12 +789,7 @@ impl<'a> Linker for GccLinker<'a> { |
| 794 | 789 | } |
| 795 | 790 | } |
| 796 | 791 | |
| 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]) { | |
| 803 | 793 | // Symbol visibility in object files typically takes care of this. |
| 804 | 794 | if crate_type == CrateType::Executable { |
| 805 | 795 | let should_export_executable_symbols = |
| ... | ... | @@ -826,9 +816,9 @@ impl<'a> Linker for GccLinker<'a> { |
| 826 | 816 | // Write a plain, newline-separated list of symbols |
| 827 | 817 | let res = try { |
| 828 | 818 | 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)?; | |
| 832 | 822 | } |
| 833 | 823 | }; |
| 834 | 824 | if let Err(error) = res { |
| ... | ... | @@ -842,12 +832,13 @@ impl<'a> Linker for GccLinker<'a> { |
| 842 | 832 | // .def file similar to MSVC one but without LIBRARY section |
| 843 | 833 | // because LD doesn't like when it's empty |
| 844 | 834 | 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); | |
| 848 | 839 | // Quote the name in case it's reserved by linker in some way |
| 849 | 840 | // (this accounts for names with dots in particular). |
| 850 | writeln!(f, " \"{symbol}\"{kind_marker}")?; | |
| 841 | writeln!(f, " \"{}\"{kind_marker}", symbol.name)?; | |
| 851 | 842 | } |
| 852 | 843 | }; |
| 853 | 844 | if let Err(error) = res { |
| ... | ... | @@ -856,16 +847,16 @@ impl<'a> Linker for GccLinker<'a> { |
| 856 | 847 | self.link_arg(path); |
| 857 | 848 | } else if self.sess.target.is_like_wasm { |
| 858 | 849 | 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); | |
| 861 | 852 | } |
| 862 | 853 | } else if crate_type == CrateType::Executable && !self.sess.target.is_like_solaris { |
| 863 | 854 | let res = try { |
| 864 | 855 | let mut f = File::create_buffered(&path)?; |
| 865 | 856 | 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)?; | |
| 869 | 860 | } |
| 870 | 861 | writeln!(f, "}};")?; |
| 871 | 862 | }; |
| ... | ... | @@ -880,9 +871,9 @@ impl<'a> Linker for GccLinker<'a> { |
| 880 | 871 | writeln!(f, "{{")?; |
| 881 | 872 | if !symbols.is_empty() { |
| 882 | 873 | 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)?; | |
| 886 | 877 | } |
| 887 | 878 | } |
| 888 | 879 | writeln!(f, "\n local:\n *;\n}};")?; |
| ... | ... | @@ -1126,25 +1117,10 @@ impl<'a> Linker for MsvcLinker<'a> { |
| 1126 | 1117 | } |
| 1127 | 1118 | } |
| 1128 | 1119 | |
| 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. | |
| 1148 | 1124 | if crate_type == CrateType::Executable { |
| 1149 | 1125 | let should_export_executable_symbols = |
| 1150 | 1126 | self.sess.opts.unstable_opts.export_executable_symbols; |
| ... | ... | @@ -1156,16 +1132,8 @@ impl<'a> Linker for MsvcLinker<'a> { |
| 1156 | 1132 | let path = tmpdir.join("lib.def"); |
| 1157 | 1133 | let res = try { |
| 1158 | 1134 | let mut f = File::create_buffered(&path)?; |
| 1159 | ||
| 1160 | // Start off with the standard module name header and then go | |
| 1161 | // straight to exports. | |
| 1162 | 1135 | writeln!(f, "LIBRARY")?; |
| 1163 | 1136 | 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 | } | |
| 1169 | 1137 | }; |
| 1170 | 1138 | if let Err(error) = res { |
| 1171 | 1139 | self.sess.dcx().emit_fatal(errors::LibDefWriteFailure { error }); |
| ... | ... | @@ -1313,19 +1281,14 @@ impl<'a> Linker for EmLinker<'a> { |
| 1313 | 1281 | self.cc_arg("-nodefaultlibs"); |
| 1314 | 1282 | } |
| 1315 | 1283 | |
| 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]) { | |
| 1322 | 1285 | debug!("EXPORTED SYMBOLS:"); |
| 1323 | 1286 | |
| 1324 | 1287 | self.cc_arg("-s"); |
| 1325 | 1288 | |
| 1326 | 1289 | let mut arg = OsString::from("EXPORTED_FUNCTIONS="); |
| 1327 | 1290 | 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<_>>(), | |
| 1329 | 1292 | ) |
| 1330 | 1293 | .unwrap(); |
| 1331 | 1294 | debug!("{encoded}"); |
| ... | ... | @@ -1453,14 +1416,9 @@ impl<'a> Linker for WasmLd<'a> { |
| 1453 | 1416 | |
| 1454 | 1417 | fn no_default_libraries(&mut self) {} |
| 1455 | 1418 | |
| 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]); | |
| 1464 | 1422 | } |
| 1465 | 1423 | } |
| 1466 | 1424 | |
| ... | ... | @@ -1581,7 +1539,7 @@ impl<'a> Linker for L4Bender<'a> { |
| 1581 | 1539 | self.cc_arg("-nostdlib"); |
| 1582 | 1540 | } |
| 1583 | 1541 | |
| 1584 | fn export_symbols(&mut self, _: &Path, _: CrateType, _: &[(String, SymbolExportKind)]) { | |
| 1542 | fn export_symbols(&mut self, _: &Path, _: CrateType, _: &[SymbolExport]) { | |
| 1585 | 1543 | // ToDo, not implemented, copy from GCC |
| 1586 | 1544 | self.sess.dcx().emit_warn(errors::L4BenderExportingSymbolsUnimplemented); |
| 1587 | 1545 | } |
| ... | ... | @@ -1735,19 +1693,14 @@ impl<'a> Linker for AixLinker<'a> { |
| 1735 | 1693 | |
| 1736 | 1694 | fn no_default_libraries(&mut self) {} |
| 1737 | 1695 | |
| 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]) { | |
| 1744 | 1697 | let path = tmpdir.join("list.exp"); |
| 1745 | 1698 | let res = try { |
| 1746 | 1699 | let mut f = File::create_buffered(&path)?; |
| 1747 | 1700 | // 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)?; | |
| 1751 | 1704 | } |
| 1752 | 1705 | }; |
| 1753 | 1706 | if let Err(e) = res { |
| ... | ... | @@ -1792,15 +1745,36 @@ fn for_each_exported_symbols_include_dep<'tcx>( |
| 1792 | 1745 | } |
| 1793 | 1746 | } |
| 1794 | 1747 | |
| 1795 | pub(crate) fn exported_symbols( | |
| 1748 | fn 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 | ||
| 1760 | fn symbol_export_from_raw_name( | |
| 1796 | 1761 | 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 | ||
| 1771 | pub(crate) fn exported_symbols(tcx: TyCtxt<'_>, crate_type: CrateType) -> Vec<SymbolExport> { | |
| 1799 | 1772 | if let Some(ref exports) = tcx.sess.target.override_export_symbols { |
| 1800 | 1773 | return exports |
| 1801 | 1774 | .iter() |
| 1802 | 1775 | .map(|name| { |
| 1803 | ( | |
| 1776 | symbol_export_from_raw_name( | |
| 1777 | tcx, | |
| 1804 | 1778 | name.to_string(), |
| 1805 | 1779 | // FIXME use the correct export kind for this symbol. override_export_symbols |
| 1806 | 1780 | // can't directly specify the SymbolExportKind as it is defined in rustc_middle |
| ... | ... | @@ -1825,7 +1799,11 @@ pub(crate) fn exported_symbols( |
| 1825 | 1799 | && !tcx.sess.target.is_like_wasm |
| 1826 | 1800 | { |
| 1827 | 1801 | 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 | )); | |
| 1829 | 1807 | } |
| 1830 | 1808 | |
| 1831 | 1809 | symbols |
| ... | ... | @@ -1834,7 +1812,7 @@ pub(crate) fn exported_symbols( |
| 1834 | 1812 | fn exported_symbols_for_non_proc_macro( |
| 1835 | 1813 | tcx: TyCtxt<'_>, |
| 1836 | 1814 | crate_type: CrateType, |
| 1837 | ) -> Vec<(String, SymbolExportKind)> { | |
| 1815 | ) -> Vec<SymbolExport> { | |
| 1838 | 1816 | let mut symbols = Vec::new(); |
| 1839 | 1817 | let export_threshold = symbol_export::crates_export_threshold(&[crate_type]); |
| 1840 | 1818 | for_each_exported_symbols_include_dep(tcx, crate_type, |symbol, info, cnum| { |
| ... | ... | @@ -1842,10 +1820,7 @@ fn exported_symbols_for_non_proc_macro( |
| 1842 | 1820 | // from any dylib. The latter doesn't work anyway as we use hidden visibility for |
| 1843 | 1821 | // compiler-builtins. Most linkers silently ignore it, but ld64 gives a warning. |
| 1844 | 1822 | 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)); | |
| 1849 | 1824 | symbol_export::extend_exported_symbols(&mut symbols, tcx, symbol, cnum); |
| 1850 | 1825 | } |
| 1851 | 1826 | }); |
| ... | ... | @@ -1855,13 +1830,16 @@ fn exported_symbols_for_non_proc_macro( |
| 1855 | 1830 | && needs_allocator_shim_for_linking(tcx.dependency_formats(()), crate_type) |
| 1856 | 1831 | && let Some(kind) = tcx.allocator_kind(()) |
| 1857 | 1832 | { |
| 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 | ); | |
| 1859 | 1837 | } |
| 1860 | 1838 | |
| 1861 | 1839 | symbols |
| 1862 | 1840 | } |
| 1863 | 1841 | |
| 1864 | fn exported_symbols_for_proc_macro_crate(tcx: TyCtxt<'_>) -> Vec<(String, SymbolExportKind)> { | |
| 1842 | fn exported_symbols_for_proc_macro_crate(tcx: TyCtxt<'_>) -> Vec<SymbolExport> { | |
| 1865 | 1843 | // `exported_symbols` will be empty when !should_codegen. |
| 1866 | 1844 | if !tcx.sess.opts.output_types.should_codegen() { |
| 1867 | 1845 | return Vec::new(); |
| ... | ... | @@ -1870,7 +1848,7 @@ fn exported_symbols_for_proc_macro_crate(tcx: TyCtxt<'_>) -> Vec<(String, Symbol |
| 1870 | 1848 | let stable_crate_id = tcx.stable_crate_id(LOCAL_CRATE); |
| 1871 | 1849 | let proc_macro_decls_name = rustc_session::generate_proc_macro_decls_symbol(stable_crate_id); |
| 1872 | 1850 | |
| 1873 | vec![(proc_macro_decls_name, SymbolExportKind::Data)] | |
| 1851 | vec![symbol_export_from_raw_name(tcx, proc_macro_decls_name, SymbolExportKind::Data)] | |
| 1874 | 1852 | } |
| 1875 | 1853 | |
| 1876 | 1854 | pub(crate) fn linked_symbols( |
| ... | ... | @@ -1984,16 +1962,11 @@ impl<'a> Linker for LlbcLinker<'a> { |
| 1984 | 1962 | |
| 1985 | 1963 | fn ehcont_guard(&mut self) {} |
| 1986 | 1964 | |
| 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]) { | |
| 1993 | 1966 | match _crate_type { |
| 1994 | 1967 | 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]); | |
| 1997 | 1970 | } |
| 1998 | 1971 | } |
| 1999 | 1972 | _ => (), |
| ... | ... | @@ -2064,17 +2037,12 @@ impl<'a> Linker for BpfLinker<'a> { |
| 2064 | 2037 | |
| 2065 | 2038 | fn ehcont_guard(&mut self) {} |
| 2066 | 2039 | |
| 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]) { | |
| 2073 | 2041 | let path = tmpdir.join("symbols"); |
| 2074 | 2042 | let res = try { |
| 2075 | 2043 | 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)?; | |
| 2078 | 2046 | } |
| 2079 | 2047 | }; |
| 2080 | 2048 | 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; |
| 21 | 21 | use rustc_target::spec::{Arch, Os, TlsModel}; |
| 22 | 22 | use tracing::debug; |
| 23 | 23 | |
| 24 | use crate::SymbolExport; | |
| 24 | 25 | use crate::back::symbol_export; |
| 25 | 26 | use crate::base::allocator_shim_contents; |
| 26 | 27 | |
| ... | ... | @@ -721,7 +722,7 @@ pub(crate) fn exporting_symbol_name_for_instance_in_crate<'tcx>( |
| 721 | 722 | /// Add it to the symbols list for all kernel functions, so that it is exported in the linked |
| 722 | 723 | /// object. |
| 723 | 724 | pub(crate) fn extend_exported_symbols<'tcx>( |
| 724 | symbols: &mut Vec<(String, SymbolExportKind)>, | |
| 725 | symbols: &mut Vec<SymbolExport>, | |
| 725 | 726 | tcx: TyCtxt<'tcx>, |
| 726 | 727 | symbol: ExportedSymbol<'tcx>, |
| 727 | 728 | instantiating_crate: CrateNum, |
| ... | ... | @@ -737,7 +738,7 @@ pub(crate) fn extend_exported_symbols<'tcx>( |
| 737 | 738 | // Add the symbol for the kernel descriptor (with .kd suffix) |
| 738 | 739 | // Per https://llvm.org/docs/AMDGPUUsage.html#symbols these will always be `STT_OBJECT` so |
| 739 | 740 | // export as data. |
| 740 | symbols.push((format!("{undecorated}.kd"), SymbolExportKind::Data)); | |
| 741 | symbols.push(SymbolExport::new(format!("{undecorated}.kd"), SymbolExportKind::Data)); | |
| 741 | 742 | } |
| 742 | 743 | |
| 743 | 744 | fn maybe_emutls_symbol_name<'tcx>( |
compiler/rustc_codegen_ssa/src/lib.rs+23-1| ... | ... | @@ -233,6 +233,28 @@ impl From<&cstore::NativeLib> for NativeLib { |
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | /// A symbol to make visible from a linked artifact. | |
| 237 | #[derive(Clone, Debug, Encodable, Decodable)] | |
| 238 | pub 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 | ||
| 247 | impl 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 | ||
| 236 | 258 | /// Misc info we load from metadata to persist beyond the tcx. |
| 237 | 259 | /// |
| 238 | 260 | /// Note: though `CrateNum` is only meaningful within the same tcx, information within `CrateInfo` |
| ... | ... | @@ -247,7 +269,7 @@ pub struct CrateInfo { |
| 247 | 269 | pub target_cpu: String, |
| 248 | 270 | pub target_features: Vec<String>, |
| 249 | 271 | pub crate_types: Vec<CrateType>, |
| 250 | pub exported_symbols: UnordMap<CrateType, Vec<(String, SymbolExportKind)>>, | |
| 272 | pub exported_symbols: UnordMap<CrateType, Vec<SymbolExport>>, | |
| 251 | 273 | pub linked_symbols: FxIndexMap<CrateType, Vec<(String, SymbolExportKind)>>, |
| 252 | 274 | pub local_crate_name: Symbol, |
| 253 | 275 | pub compiler_builtins: Option<CrateNum>, |
compiler/rustc_expand/src/base.rs+1-1| ... | ... | @@ -1199,7 +1199,7 @@ pub trait LintStoreExpand { |
| 1199 | 1199 | |
| 1200 | 1200 | type LintStoreExpandDyn<'a> = Option<&'a (dyn LintStoreExpand + 'a)>; |
| 1201 | 1201 | |
| 1202 | #[derive(Debug, Clone, Default)] | |
| 1202 | #[derive(Debug, Default)] | |
| 1203 | 1203 | pub struct ModuleData { |
| 1204 | 1204 | /// Path to the module starting from the crate name, like `my_crate::foo::bar`. |
| 1205 | 1205 | 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<(), |
| 839 | 839 | tcx.ensure_ok().associated_items(def_id); |
| 840 | 840 | if of_trait { |
| 841 | 841 | 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())); | |
| 845 | 844 | |
| 846 | 845 | if res.is_ok() { |
| 847 | 846 | // 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 { |
| 45 | 45 | if let DefKind::AssocFn = tcx.def_kind(def_id) |
| 46 | 46 | && let Some(impl_id) = tcx.trait_impl_of_assoc(def_id.to_def_id()) |
| 47 | 47 | && 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) | |
| 49 | 49 | // avoid erroneous `Drop` impls from causing ICEs below |
| 50 | 50 | && let sig = tcx.fn_sig(def_id).instantiate_identity().skip_norm_wip() |
| 51 | 51 | && sig.inputs().skip_binder().len() == 1 |
compiler/rustc_resolve/src/error_helper.rs+1-1| ... | ... | @@ -109,7 +109,7 @@ impl TypoSuggestion { |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /// A free importable items suggested in case of resolution failure. |
| 112 | #[derive(Debug, Clone)] | |
| 112 | #[derive(Debug)] | |
| 113 | 113 | pub(crate) struct ImportSuggestion { |
| 114 | 114 | pub did: Option<DefId>, |
| 115 | 115 | pub descr: &'static str, |
compiler/rustc_resolve/src/imports.rs+4-5| ... | ... | @@ -69,7 +69,6 @@ impl<'ra> PendingDecl<'ra> { |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /// Contains data for specific kinds of imports. |
| 72 | #[derive(Clone)] | |
| 73 | 72 | pub(crate) enum ImportKind<'ra> { |
| 74 | 73 | Single { |
| 75 | 74 | /// `source` in `use prefix::source as target`. |
| ... | ... | @@ -157,7 +156,7 @@ impl<'ra> std::fmt::Debug for ImportKind<'ra> { |
| 157 | 156 | } |
| 158 | 157 | |
| 159 | 158 | /// One import. |
| 160 | #[derive(Debug, Clone)] | |
| 159 | #[derive(Debug)] | |
| 161 | 160 | pub(crate) struct ImportData<'ra> { |
| 162 | 161 | pub kind: ImportKind<'ra>, |
| 163 | 162 | |
| ... | ... | @@ -280,7 +279,7 @@ impl<'ra> ImportData<'ra> { |
| 280 | 279 | } |
| 281 | 280 | |
| 282 | 281 | /// Records information about the resolution of a name in a namespace of a module. |
| 283 | #[derive(Clone, Debug)] | |
| 282 | #[derive(Debug)] | |
| 284 | 283 | pub(crate) struct NameResolution<'ra> { |
| 285 | 284 | /// Single imports that may define the name in the namespace. |
| 286 | 285 | /// Imports are arena-allocated, so it's ok to use pointers as keys. |
| ... | ... | @@ -377,7 +376,7 @@ pub(crate) mod cycle_detection { |
| 377 | 376 | |
| 378 | 377 | /// An error that may be transformed into a diagnostic later. Used to combine multiple unresolved |
| 379 | 378 | /// import errors within the same use tree into a single diagnostic. |
| 380 | #[derive(Debug, Clone)] | |
| 379 | #[derive(Debug)] | |
| 381 | 380 | pub(crate) struct UnresolvedImportError { |
| 382 | 381 | pub(crate) span: Span, |
| 383 | 382 | pub(crate) label: Option<String>, |
| ... | ... | @@ -396,7 +395,7 @@ fn pub_use_of_private_extern_crate_hack( |
| 396 | 395 | import: ImportSummary, |
| 397 | 396 | decl: Decl<'_>, |
| 398 | 397 | ) -> Option<LocalDefId> { |
| 399 | match (import.is_single, decl.kind) { | |
| 398 | match (import.is_single, &decl.kind) { | |
| 400 | 399 | (true, DeclKind::Import { import: decl_import, .. }) |
| 401 | 400 | if let ImportKind::ExternCrate { def_id, .. } = decl_import.kind |
| 402 | 401 | && import.vis.is_public() => |
compiler/rustc_resolve/src/late/diagnostics.rs+1-1| ... | ... | @@ -133,7 +133,7 @@ pub(super) struct MissingLifetime { |
| 133 | 133 | |
| 134 | 134 | /// Description of the lifetimes appearing in a function parameter. |
| 135 | 135 | /// This is used to provide a literal explanation to the elision failure. |
| 136 | #[derive(Clone, Debug)] | |
| 136 | #[derive(Debug)] | |
| 137 | 137 | pub(super) struct ElisionFnParameter { |
| 138 | 138 | /// The index of the argument in the original definition. |
| 139 | 139 | pub index: usize, |
compiler/rustc_resolve/src/lib.rs+2-2| ... | ... | @@ -984,7 +984,7 @@ impl<'ra> fmt::Debug for LocalModule<'ra> { |
| 984 | 984 | } |
| 985 | 985 | |
| 986 | 986 | /// Data associated with any name declaration. |
| 987 | #[derive(Clone, Debug)] | |
| 987 | #[derive(Debug)] | |
| 988 | 988 | struct DeclData<'ra> { |
| 989 | 989 | kind: DeclKind<'ra>, |
| 990 | 990 | ambiguity: CmCell<Option<(Decl<'ra>, bool /*warning*/)>>, |
| ... | ... | @@ -1018,7 +1018,7 @@ impl std::hash::Hash for DeclData<'_> { |
| 1018 | 1018 | } |
| 1019 | 1019 | |
| 1020 | 1020 | /// Name declaration kind. |
| 1021 | #[derive(Clone, Copy, Debug)] | |
| 1021 | #[derive(Debug)] | |
| 1022 | 1022 | enum DeclKind<'ra> { |
| 1023 | 1023 | /// The name declaration is a definition (possibly without a `DefId`), |
| 1024 | 1024 | /// 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> { |
| 448 | 448 | } |
| 449 | 449 | } |
| 450 | 450 | |
| 451 | impl<I: Interner> EarlyBinder<I, ty::TraitRef<I>> { | |
| 452 | pub fn def_id(&self) -> I::TraitId { | |
| 453 | self.value.def_id | |
| 454 | } | |
| 455 | } | |
| 456 | ||
| 451 | 457 | impl<I: Interner, T> EarlyBinder<I, Option<T>> { |
| 452 | 458 | pub fn transpose(self) -> Option<EarlyBinder<I, T>> { |
| 453 | 459 | self.value.map(|value| EarlyBinder { value, _tcx: PhantomData }) |
library/core/src/slice/mod.rs+6-3| ... | ... | @@ -2738,10 +2738,12 @@ impl<T> [T] { |
| 2738 | 2738 | |
| 2739 | 2739 | /// Returns a subslice with the prefix and suffix removed. |
| 2740 | 2740 | /// |
| 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`. | |
| 2743 | 2744 | /// |
| 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`. | |
| 2745 | 2747 | /// |
| 2746 | 2748 | /// # Examples |
| 2747 | 2749 | /// |
| ... | ... | @@ -2754,6 +2756,7 @@ impl<T> [T] { |
| 2754 | 2756 | /// assert_eq!(v.strip_circumfix(&[10], &[40]), None); |
| 2755 | 2757 | /// assert_eq!(v.strip_circumfix(&[], &[40, 30]), Some(&[10, 50][..])); |
| 2756 | 2758 | /// assert_eq!(v.strip_circumfix(&[10, 50], &[]), Some(&[40, 30][..])); |
| 2759 | /// assert_eq!(v.strip_circumfix(&[10, 50, 40], &[50, 40, 30]), None); | |
| 2757 | 2760 | /// ``` |
| 2758 | 2761 | #[must_use = "returns the subslice without modifying the original"] |
| 2759 | 2762 | #[stable(feature = "strip_circumfix", since = "CURRENT_RUSTC_VERSION")] |
library/core/src/str/mod.rs+5-2| ... | ... | @@ -2492,12 +2492,14 @@ impl str { |
| 2492 | 2492 | |
| 2493 | 2493 | /// Returns a string slice with the prefix and suffix removed. |
| 2494 | 2494 | /// |
| 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 | |
| 2496 | 2497 | /// the substring after the prefix and before the suffix, wrapped in `Some`. |
| 2497 | 2498 | /// Unlike [`trim_start_matches`] and [`trim_end_matches`], this method removes both the prefix |
| 2498 | 2499 | /// and suffix exactly once. |
| 2499 | 2500 | /// |
| 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`. | |
| 2501 | 2503 | /// |
| 2502 | 2504 | /// Each [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a |
| 2503 | 2505 | /// function or closure that determines if a character matches. |
| ... | ... | @@ -2513,6 +2515,7 @@ impl str { |
| 2513 | 2515 | /// assert_eq!("bar:hello:foo".strip_circumfix("bar:", ":foo"), Some("hello")); |
| 2514 | 2516 | /// assert_eq!("bar:foo".strip_circumfix("foo", "foo"), None); |
| 2515 | 2517 | /// assert_eq!("foo:bar;".strip_circumfix("foo:", ';'), Some("bar")); |
| 2518 | /// assert_eq!("foo:bar:baz".strip_circumfix("foo:bar:", ":bar:baz"), None); | |
| 2516 | 2519 | /// ``` |
| 2517 | 2520 | #[must_use = "this returns the remaining substring as a new slice, \ |
| 2518 | 2521 | 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) { |
| 123 | 123 | GETRANDOM_AVAILABLE.store(false, Relaxed); |
| 124 | 124 | break; |
| 125 | 125 | } |
| 126 | _ => panic!("failed to generate random data"), | |
| 126 | other => { | |
| 127 | panic!("failed to generate random data: errno={other:?}, flags={flags:?}") | |
| 128 | } | |
| 127 | 129 | } |
| 128 | 130 | } |
| 129 | 131 | } |
src/tools/compiletest/src/runtest.rs+45-24| ... | ... | @@ -2580,31 +2580,52 @@ impl<'test> TestCx<'test> { |
| 2580 | 2580 | // that actually appear in the output. |
| 2581 | 2581 | // We use uppercase ALLOC to distinguish from the non-normalized version. |
| 2582 | 2582 | { |
| 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(); | |
| 2599 | 2594 | |
| 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 | } | |
| 2608 | 2629 | } |
| 2609 | 2630 | |
| 2610 | 2631 | // Custom normalization rules |
tests/pretty/delegation/self-mapping-output.pp created+44| ... | ... | @@ -0,0 +1,44 @@ |
| 1 | #![attr = Feature([fn_delegation#0])] | |
| 2 | extern crate std; | |
| 3 | #[attr = PreludeImport] | |
| 4 | use ::std::prelude::rust_2015::*; | |
| 5 | //@ pretty-compare-only | |
| 6 | //@ pretty-mode:hir | |
| 7 | //@ pp-exact:self-mapping-output.pp | |
| 8 | ||
| 9 | ||
| 10 | trait Trait { | |
| 11 | fn method(&self) | |
| 12 | -> Self; | |
| 13 | fn r#static() | |
| 14 | -> Self; | |
| 15 | fn raw_S(&self) -> S { S } | |
| 16 | } | |
| 17 | ||
| 18 | struct S; | |
| 19 | impl Trait for S { | |
| 20 | fn method(&self) -> S { S } | |
| 21 | fn r#static() -> S { S } | |
| 22 | } | |
| 23 | ||
| 24 | struct W(S); | |
| 25 | impl 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 | ||
| 35 | impl 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 | ||
| 44 | fn 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 | ||
| 7 | trait Trait { | |
| 8 | fn method(&self) -> Self; | |
| 9 | fn r#static() -> Self; | |
| 10 | fn raw_S(&self) -> S { S } | |
| 11 | } | |
| 12 | ||
| 13 | struct S; | |
| 14 | impl Trait for S { | |
| 15 | fn method(&self) -> S { S } | |
| 16 | fn r#static() -> S { S } | |
| 17 | } | |
| 18 | ||
| 19 | struct W(S); | |
| 20 | impl 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 | ||
| 27 | impl W { | |
| 28 | reuse Trait::method { self.0 } | |
| 29 | reuse Trait::r#static; | |
| 30 | reuse Trait::raw_S { self.0 } | |
| 31 | } | |
| 32 | ||
| 33 | fn 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 | ||
| 7 | use run_make_support::{dynamic_lib_name, llvm_readobj, rustc}; | |
| 8 | ||
| 9 | fn 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 | ||
| 20 | fn 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] | |
| 6 | pub fn weak_function() {} | |
| 7 | ||
| 8 | #[linkage = "weak"] | |
| 9 | #[no_mangle] | |
| 10 | pub static WEAK_STATIC: u8 = 42; |
tests/ui/const-generics/issues/issue-100313.rs+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | //@ dont-require-annotations: NOTE |
| 2 | //@ ignore-parallel-frontend different alloc ids | |
| 2 | ||
| 3 | 3 | #![allow(incomplete_features)] |
| 4 | 4 | #![feature(adt_const_params, unsized_const_params)] |
| 5 | 5 | |
| ... | ... | @@ -15,7 +15,7 @@ impl<const B: &'static bool> T<B> { |
| 15 | 15 | |
| 16 | 16 | const _: () = { |
| 17 | 17 | 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 | |
| 19 | 19 | }; |
| 20 | 20 | |
| 21 | 21 | fn main() {} |
tests/ui/const-generics/issues/issue-100313.stderr+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | error[E0080]: writing to ALLOC0 which is read-only | |
| 1 | error[E0080]: writing to ALLOC$ID which is read-only | |
| 2 | 2 | --> $DIR/issue-100313.rs:18:5 |
| 3 | 3 | | |
| 4 | 4 | LL | 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 |
| 46 | 46 | LL | fn get_flag<const FlagSet: bool, const ShortName: char>() -> Option<char> { |
| 47 | 47 | | ^^^^^^^^^^^^^^^^^^^^^ |
| 48 | 48 | |
| 49 | error[E0080]: reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory | |
| 49 | error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory | |
| 50 | 50 | --> $DIR/invalid-patterns.rs:40:32 |
| 51 | 51 | | |
| 52 | 52 | LL | get_flag::<false, { unsafe { char_raw.character } }>(); |
| ... | ... | @@ -78,7 +78,7 @@ LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character |
| 78 | 78 | 42 │ B |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | error[E0080]: reading memory at ALLOC1[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory | |
| 81 | error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory | |
| 82 | 82 | --> $DIR/invalid-patterns.rs:44:58 |
| 83 | 83 | | |
| 84 | 84 | LL | 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 |
| 46 | 46 | LL | fn get_flag<const FlagSet: bool, const ShortName: char>() -> Option<char> { |
| 47 | 47 | | ^^^^^^^^^^^^^^^^^^^^^ |
| 48 | 48 | |
| 49 | error[E0080]: reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory | |
| 49 | error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory | |
| 50 | 50 | --> $DIR/invalid-patterns.rs:40:32 |
| 51 | 51 | | |
| 52 | 52 | LL | get_flag::<false, { unsafe { char_raw.character } }>(); |
| ... | ... | @@ -78,7 +78,7 @@ LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character |
| 78 | 78 | 42 │ B |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | error[E0080]: reading memory at ALLOC1[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory | |
| 81 | error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory | |
| 82 | 82 | --> $DIR/invalid-patterns.rs:44:58 |
| 83 | 83 | | |
| 84 | 84 | LL | 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 @@ |
| 1 | 1 | //@ stderr-per-bitwidth |
| 2 | 2 | //@ dont-require-annotations: NOTE |
| 3 | //@ ignore-parallel-frontend different alloc ids | |
| 3 | ||
| 4 | 4 | use std::mem::transmute; |
| 5 | 5 | |
| 6 | 6 | fn get_flag<const FlagSet: bool, const ShortName: char>() -> Option<char> { |
tests/ui/const-ptr/forbidden_slices.rs+1-1| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | // Strip out raw byte dumps to make comparison platform-independent: |
| 2 | 2 | //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" |
| 3 | 3 | //@ 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 | ||
| 5 | 5 | #![feature( |
| 6 | 6 | slice_from_ptr_range, |
| 7 | 7 | 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) }; |
| 28 | 28 | | |
| 29 | 29 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 30 | 30 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 31 | HEX_DUMP | |
| 31 | ╾ALLOC$ID╼ HEX_DUMP | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | error[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) } |
| 39 | 39 | | |
| 40 | 40 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 41 | 41 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 42 | HEX_DUMP | |
| 42 | ╾ALLOC$ID╼ HEX_DUMP | |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | error[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 |
| 52 | 52 | = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 53 | 53 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 54 | 54 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 55 | HEX_DUMP | |
| 55 | ╾ALLOC$ID╼ HEX_DUMP | |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | error[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) |
| 63 | 63 | | |
| 64 | 64 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 65 | 65 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 66 | HEX_DUMP | |
| 66 | ╾ALLOC$ID╼ HEX_DUMP | |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | error[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 { |
| 74 | 74 | | |
| 75 | 75 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 76 | 76 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 77 | HEX_DUMP | |
| 77 | ╾ALLOC$ID╼ HEX_DUMP | |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | error[E0080]: constructing invalid value of type &[u64]: encountered a dangling reference (going beyond the bounds of its allocation) |
| ... | ... | @@ -85,7 +85,7 @@ LL | pub static S8: &[u64] = unsafe { |
| 85 | 85 | | |
| 86 | 86 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 87 | 87 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 88 | HEX_DUMP | |
| 88 | ╾ALLOC$ID╼ HEX_DUMP | |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | error[E0080]: constructing invalid value of type &[u32]: encountered a null reference |
| ... | ... | @@ -105,7 +105,7 @@ error[E0080]: evaluation panicked: assertion failed: 0 < pointee_size && pointee |
| 105 | 105 | LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; // errors inside libcore |
| 106 | 106 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `R1` failed here |
| 107 | 107 | |
| 108 | error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC10 which is only 4 bytes from the end of the allocation | |
| 108 | error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC$ID which is only 4 bytes from the end of the allocation | |
| 109 | 109 | --> $DIR/forbidden_slices.rs:54:25 |
| 110 | 110 | | |
| 111 | 111 | LL | from_ptr_range(ptr..ptr.add(2)) // errors inside libcore |
| ... | ... | @@ -119,7 +119,7 @@ LL | pub static R4: &[u8] = unsafe { |
| 119 | 119 | | |
| 120 | 120 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 121 | 121 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 122 | HEX_DUMP | |
| 122 | ╾ALLOC$ID╼ HEX_DUMP | |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | error[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 { |
| 132 | 132 | = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 133 | 133 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 134 | 134 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 135 | HEX_DUMP | |
| 135 | ╾ALLOC$ID╼ HEX_DUMP | |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | error[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 { |
| 143 | 143 | | |
| 144 | 144 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 145 | 145 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 146 | HEX_DUMP | |
| 146 | ╾ALLOC$ID╼ HEX_DUMP | |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | error[E0080]: constructing invalid value of type &[u16]: encountered an unaligned reference (required 2 byte alignment but found 1) |
| ... | ... | @@ -154,10 +154,10 @@ LL | pub static R7: &[u16] = unsafe { |
| 154 | 154 | | |
| 155 | 155 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 156 | 156 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 157 | HEX_DUMP | |
| 157 | ╾ALLOC$ID╼ HEX_DUMP | |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC11+0x1 which is only 7 bytes from the end of the allocation | |
| 160 | error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC$ID+0x1 which is only 7 bytes from the end of the allocation | |
| 161 | 161 | --> $DIR/forbidden_slices.rs:79:25 |
| 162 | 162 | | |
| 163 | 163 | LL | from_ptr_range(ptr..ptr.add(1)) |
tests/ui/const-ptr/out_of_bounds_read.rs+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | fn main() { |
| 2 | 2 | use std::ptr; |
| 3 | //@ ignore-parallel-frontend different alloc ids | |
| 3 | ||
| 4 | 4 | const DATA: [u32; 1] = [42]; |
| 5 | 5 | |
| 6 | 6 | 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 @@ |
| 1 | error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes | |
| 1 | error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID+0x4 which is at or beyond the end of the allocation of size 4 bytes | |
| 2 | 2 | --> $DIR/out_of_bounds_read.rs:8:33 |
| 3 | 3 | | |
| 4 | 4 | LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) }; |
| 5 | 5 | | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_READ` failed here |
| 6 | 6 | |
| 7 | error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes | |
| 7 | error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID+0x4 which is at or beyond the end of the allocation of size 4 bytes | |
| 8 | 8 | --> $DIR/out_of_bounds_read.rs:10:39 |
| 9 | 9 | | |
| 10 | 10 | LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; |
| 11 | 11 | | ^^^^^^^^^^^^^^^^^^^ evaluation of `main::_CONST_READ` failed here |
| 12 | 12 | |
| 13 | error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes | |
| 13 | error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID+0x4 which is at or beyond the end of the allocation of size 4 bytes | |
| 14 | 14 | --> $DIR/out_of_bounds_read.rs:12:37 |
| 15 | 15 | | |
| 16 | 16 | LL | 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 @@ |
| 1 | 1 | //@ check-fail |
| 2 | //@ ignore-parallel-frontend different alloc ids | |
| 2 | ||
| 3 | 3 | #![feature(core_intrinsics, const_cmp)] |
| 4 | 4 | use std::intrinsics::compare_bytes; |
| 5 | 5 | use 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 |
| 16 | 16 | LL | compare_bytes(1 as *const u8, 2 as *const u8, 1) |
| 17 | 17 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::DANGLING_PTR_NON_ZERO_LENGTH` failed here |
| 18 | 18 | |
| 19 | error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0 which is only 3 bytes from the end of the allocation | |
| 19 | error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID which is only 3 bytes from the end of the allocation | |
| 20 | 20 | --> $DIR/const-compare-bytes-ub.rs:21:9 |
| 21 | 21 | | |
| 22 | 22 | LL | compare_bytes([1, 2, 3].as_ptr(), [1, 2, 3, 4].as_ptr(), 4) |
| 23 | 23 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::LHS_OUT_OF_BOUNDS` failed here |
| 24 | 24 | |
| 25 | error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC1 which is only 3 bytes from the end of the allocation | |
| 25 | error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID which is only 3 bytes from the end of the allocation | |
| 26 | 26 | --> $DIR/const-compare-bytes-ub.rs:25:9 |
| 27 | 27 | | |
| 28 | 28 | LL | compare_bytes([1, 2, 3, 4].as_ptr(), [1, 2, 3].as_ptr(), 4) |
| 29 | 29 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::RHS_OUT_OF_BOUNDS` failed here |
| 30 | 30 | |
| 31 | error[E0080]: reading memory at ALLOC2[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory | |
| 31 | error[E0080]: reading memory at ALLOC$ID[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory | |
| 32 | 32 | --> $DIR/const-compare-bytes-ub.rs:29:9 |
| 33 | 33 | | |
| 34 | 34 | LL | compare_bytes(MaybeUninit::uninit().as_ptr(), [1].as_ptr(), 1) |
| ... | ... | @@ -38,7 +38,7 @@ LL | compare_bytes(MaybeUninit::uninit().as_ptr(), [1].as_ptr(), 1) |
| 38 | 38 | __ │ ░ |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | error[E0080]: reading memory at ALLOC3[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory | |
| 41 | error[E0080]: reading memory at ALLOC$ID[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory | |
| 42 | 42 | --> $DIR/const-compare-bytes-ub.rs:33:9 |
| 43 | 43 | | |
| 44 | 44 | LL | 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 @@ |
| 1 | error[E0080]: reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory | |
| 1 | error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory | |
| 2 | 2 | --> $DIR/const-err-enum-discriminant.rs:10:21 |
| 3 | 3 | | |
| 4 | 4 | LL | Boo = [unsafe { Foo { b: () }.a }; 4][3], |
tests/ui/consts/const-err-enum-discriminant.64bit.stderr+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | error[E0080]: reading memory at ALLOC0[0x0..0x8], but memory is uninitialized at [0x0..0x8], and this operation requires initialized memory | |
| 1 | error[E0080]: reading memory at ALLOC$ID[0x0..0x8], but memory is uninitialized at [0x0..0x8], and this operation requires initialized memory | |
| 2 | 2 | --> $DIR/const-err-enum-discriminant.rs:10:21 |
| 3 | 3 | | |
| 4 | 4 | LL | Boo = [unsafe { Foo { b: () }.a }; 4][3], |
tests/ui/consts/const-err-enum-discriminant.rs+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | //@ stderr-per-bitwidth |
| 2 | //@ ignore-parallel-frontend different alloc ids | |
| 2 | ||
| 3 | 3 | #[derive(Copy, Clone)] |
| 4 | 4 | union Foo { |
| 5 | 5 | a: isize, |
tests/ui/consts/const-eval/c-variadic-fail.rs+5-5| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | //@ build-fail |
| 2 | //@ ignore-parallel-frontend different alloc ids | |
| 2 | ||
| 3 | 3 | #![feature(c_variadic)] |
| 4 | 4 | #![feature(const_c_variadic)] |
| 5 | 5 | #![feature(const_trait_impl)] |
| ... | ... | @@ -138,7 +138,7 @@ fn use_after_free() { |
| 138 | 138 | let ap = helper(1, 2, 3); |
| 139 | 139 | let mut ap = std::mem::transmute::<_, VaList>(ap); |
| 140 | 140 | 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] | |
| 142 | 142 | } |
| 143 | 143 | }; |
| 144 | 144 | } |
| ... | ... | @@ -160,7 +160,7 @@ fn manual_copy_drop() { |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | 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] | |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | fn manual_copy_forget() { |
| ... | ... | @@ -176,7 +176,7 @@ fn manual_copy_forget() { |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | 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] | |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | fn manual_copy_read() { |
| ... | ... | @@ -189,7 +189,7 @@ fn manual_copy_read() { |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | 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] | |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | fn 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> |
| 418 | 418 | | |
| 419 | 419 | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` |
| 420 | 420 | |
| 421 | error[E0080]: memory access failed: ALLOC0 has been freed, so this pointer is dangling | |
| 421 | error[E0080]: memory access failed: ALLOC$ID has been freed, so this pointer is dangling | |
| 422 | 422 | --> $DIR/c-variadic-fail.rs:140:13 |
| 423 | 423 | | |
| 424 | 424 | LL | ap.next_arg::<i32>(); |
| ... | ... | @@ -451,7 +451,7 @@ LL | | }; |
| 451 | 451 | | |
| 452 | 452 | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` |
| 453 | 453 | |
| 454 | error[E0080]: using ALLOC1 as variable argument list pointer but it does not point to a variable argument list | |
| 454 | error[E0080]: using ALLOC$ID as variable argument list pointer but it does not point to a variable argument list | |
| 455 | 455 | --> $DIR/c-variadic-fail.rs:162:22 |
| 456 | 456 | | |
| 457 | 457 | LL | const { unsafe { helper(1, 2, 3) } }; |
| ... | ... | @@ -483,7 +483,7 @@ LL | const { unsafe { helper(1, 2, 3) } }; |
| 483 | 483 | | |
| 484 | 484 | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` |
| 485 | 485 | |
| 486 | error[E0080]: using ALLOC2 as variable argument list pointer but it does not point to a variable argument list | |
| 486 | error[E0080]: using ALLOC$ID as variable argument list pointer but it does not point to a variable argument list | |
| 487 | 487 | --> $DIR/c-variadic-fail.rs:178:22 |
| 488 | 488 | | |
| 489 | 489 | LL | const { unsafe { helper(1, 2, 3) } }; |
| ... | ... | @@ -515,7 +515,7 @@ LL | const { unsafe { helper(1, 2, 3) } }; |
| 515 | 515 | | |
| 516 | 516 | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` |
| 517 | 517 | |
| 518 | error[E0080]: using ALLOC3 as variable argument list pointer but it does not point to a variable argument list | |
| 518 | error[E0080]: using ALLOC$ID as variable argument list pointer but it does not point to a variable argument list | |
| 519 | 519 | --> $DIR/c-variadic-fail.rs:191:22 |
| 520 | 520 | | |
| 521 | 521 | LL | 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 |
| 43 | 43 | = help: this code performed an operation that depends on the underlying bytes representing a pointer |
| 44 | 44 | = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 45 | 45 | |
| 46 | error[E0080]: reading memory at ALLOC2[0x0..0x10], but memory is uninitialized at [0x8..0x10], and this operation requires initialized memory | |
| 46 | error[E0080]: reading memory at ALLOC$ID[0x0..0x10], but memory is uninitialized at [0x8..0x10], and this operation requires initialized memory | |
| 47 | 47 | --> $DIR/const-pointer-values-in-various-types.rs:42:47 |
| 48 | 48 | | |
| 49 | 49 | LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 }; |
| 50 | 50 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_U128_UNION` failed here |
| 51 | 51 | | |
| 52 | 52 | = note: the raw bytes of the constant (size: 16, align: 16) { |
| 53 | ╾ALLOC0<imm>╼ __ __ __ __ __ __ __ __ │ ╾──────╼░░░░░░░░ | |
| 53 | ╾ALLOC$ID╼ __ __ __ __ __ __ __ __ │ ╾──────╼░░░░░░░░ | |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | error[E0080]: unable to turn pointer into integer |
| ... | ... | @@ -89,14 +89,14 @@ LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int |
| 89 | 89 | = help: this code performed an operation that depends on the underlying bytes representing a pointer |
| 90 | 90 | = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 91 | 91 | |
| 92 | error[E0080]: reading memory at ALLOC3[0x0..0x10], but memory is uninitialized at [0x8..0x10], and this operation requires initialized memory | |
| 92 | error[E0080]: reading memory at ALLOC$ID[0x0..0x10], but memory is uninitialized at [0x8..0x10], and this operation requires initialized memory | |
| 93 | 93 | --> $DIR/const-pointer-values-in-various-types.rs:57:47 |
| 94 | 94 | | |
| 95 | 95 | LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 }; |
| 96 | 96 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_I128_UNION` failed here |
| 97 | 97 | | |
| 98 | 98 | = note: the raw bytes of the constant (size: 16, align: 16) { |
| 99 | ╾ALLOC1<imm>╼ __ __ __ __ __ __ __ __ │ ╾──────╼░░░░░░░░ | |
| 99 | ╾ALLOC$ID╼ __ __ __ __ __ __ __ __ │ ╾──────╼░░░░░░░░ | |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | error[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 @@ |
| 1 | 1 | //@ only-x86_64 |
| 2 | 2 | //@ stderr-per-bitwidth |
| 3 | 3 | //@ dont-require-annotations: NOTE |
| 4 | //@ ignore-parallel-frontend different alloc ids | |
| 4 | ||
| 5 | 5 | #[repr(C)] |
| 6 | 6 | union Nonsense { |
| 7 | 7 | u: usize, |
tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr+1-1| ... | ... | @@ -6,7 +6,7 @@ LL | const BAR: &i32 = unsafe { |
| 6 | 6 | | |
| 7 | 7 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 8 | 8 | = note: the raw bytes of the constant (size: 4, align: 4) { |
| 9 | ╾ALLOC0<imm>╼ │ ╾──╼ | |
| 9 | ╾ALLOC$ID╼ │ ╾──╼ | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | error: 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 { |
| 6 | 6 | | |
| 7 | 7 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 8 | 8 | = note: the raw bytes of the constant (size: 8, align: 8) { |
| 9 | ╾ALLOC0<imm>╼ │ ╾──────╼ | |
| 9 | ╾ALLOC$ID╼ │ ╾──────╼ | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | error: aborting due to 1 previous error |
tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs+1-1| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 | #![feature(core_intrinsics)] |
| 4 | 4 | #![feature(const_heap)] |
| 5 | 5 | use std::intrinsics; |
| 6 | //@ ignore-parallel-frontend different alloc ids | |
| 6 | ||
| 7 | 7 | const BAR: &i32 = unsafe { //~ ERROR: uninitialized memory |
| 8 | 8 | // Make the pointer immutable to avoid errors related to mutable pointers in constants. |
| 9 | 9 | &*(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 @@ |
| 1 | 1 | #![feature(core_intrinsics)] |
| 2 | 2 | #![feature(const_heap)] |
| 3 | //@ ignore-parallel-frontend different alloc ids | |
| 3 | ||
| 4 | 4 | // Strip out raw byte dumps to make comparison platform-independent: |
| 5 | 5 | //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" |
| 6 | 6 | //@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*A(LLOC)?[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP" |
| 7 | 7 | //@ normalize-stderr: "HEX_DUMP\s*\n\s*HEX_DUMP" -> "HEX_DUMP" |
| 8 | //@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼" | |
| 8 | 9 | |
| 9 | 10 | use std::intrinsics; |
| 10 | 11 |
tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr+4-4| ... | ... | @@ -1,16 +1,16 @@ |
| 1 | 1 | error[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 | |
| 3 | 3 | | |
| 4 | 4 | LL | const _X: &'static u8 = unsafe { |
| 5 | 5 | | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 6 | 6 | | |
| 7 | 7 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 8 | 8 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 9 | HEX_DUMP | |
| 9 | ╾ALLOC$ID╼ │ ╾─╼ | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | error[E0080]: memory access failed: ALLOC1 has been freed, so this pointer is dangling | |
| 13 | --> $DIR/dealloc_intrinsic_dangling.rs:22:5 | |
| 12 | error[E0080]: memory access failed: ALLOC$ID has been freed, so this pointer is dangling | |
| 13 | --> $DIR/dealloc_intrinsic_dangling.rs:23:5 | |
| 14 | 14 | | |
| 15 | 15 | LL | *reference |
| 16 | 16 | | ^^^^^^^^^^ evaluation of `_Y` failed here |
tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.rs+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | #![feature(core_intrinsics)] |
| 2 | 2 | #![feature(const_heap)] |
| 3 | //@ ignore-parallel-frontend different alloc ids | |
| 3 | ||
| 4 | 4 | use std::intrinsics; |
| 5 | 5 | |
| 6 | 6 | const _X: () = unsafe { |
tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | error[E0080]: memory access failed: ALLOC0 has been freed, so this pointer is dangling | |
| 1 | error[E0080]: memory access failed: ALLOC$ID has been freed, so this pointer is dangling | |
| 2 | 2 | --> $DIR/dealloc_intrinsic_duplicate.rs:9:5 |
| 3 | 3 | | |
| 4 | 4 | LL | intrinsics::const_deallocate(ptr, 4, 4); |
tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.rs+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | #![feature(core_intrinsics)] |
| 2 | 2 | #![feature(const_heap)] |
| 3 | //@ ignore-parallel-frontend different alloc ids | |
| 3 | ||
| 4 | 4 | use std::intrinsics; |
| 5 | 5 | |
| 6 | 6 | const _X: () = unsafe { |
tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr+3-3| ... | ... | @@ -1,16 +1,16 @@ |
| 1 | error[E0080]: incorrect layout on deallocation: ALLOC0 has size 4 and alignment 4, but gave size 4 and alignment 2 | |
| 1 | error[E0080]: incorrect layout on deallocation: ALLOC$ID has size 4 and alignment 4, but gave size 4 and alignment 2 | |
| 2 | 2 | --> $DIR/dealloc_intrinsic_incorrect_layout.rs:8:5 |
| 3 | 3 | | |
| 4 | 4 | LL | intrinsics::const_deallocate(ptr, 4, 2); |
| 5 | 5 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_X` failed here |
| 6 | 6 | |
| 7 | error[E0080]: incorrect layout on deallocation: ALLOC1 has size 4 and alignment 4, but gave size 2 and alignment 4 | |
| 7 | error[E0080]: incorrect layout on deallocation: ALLOC$ID has size 4 and alignment 4, but gave size 2 and alignment 4 | |
| 8 | 8 | --> $DIR/dealloc_intrinsic_incorrect_layout.rs:13:5 |
| 9 | 9 | | |
| 10 | 10 | LL | intrinsics::const_deallocate(ptr, 2, 4); |
| 11 | 11 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_Y` failed here |
| 12 | 12 | |
| 13 | error[E0080]: incorrect layout on deallocation: ALLOC2 has size 4 and alignment 4, but gave size 3 and alignment 4 | |
| 13 | error[E0080]: incorrect layout on deallocation: ALLOC$ID has size 4 and alignment 4, but gave size 3 and alignment 4 | |
| 14 | 14 | --> $DIR/dealloc_intrinsic_incorrect_layout.rs:19:5 |
| 15 | 15 | | |
| 16 | 16 | LL | intrinsics::const_deallocate(ptr, 3, 4); |
tests/ui/consts/const-eval/heap/make-global-dangling.rs+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // Ensure that we can't call `const_make_global` on dangling pointers. |
| 2 | //@ ignore-parallel-frontend different alloc ids | |
| 2 | ||
| 3 | 3 | #![feature(core_intrinsics)] |
| 4 | 4 | #![feature(const_heap)] |
| 5 | 5 |
tests/ui/consts/const-eval/heap/make-global-other.rs+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // Ensure that we can't call `const_make_global` on pointers not in the current interpreter. |
| 2 | //@ ignore-parallel-frontend different alloc ids | |
| 2 | ||
| 3 | 3 | #![feature(core_intrinsics)] |
| 4 | 4 | #![feature(const_heap)] |
| 5 | 5 | |
| ... | ... | @@ -9,7 +9,7 @@ const X: &i32 = &0; |
| 9 | 9 | |
| 10 | 10 | const Y: &i32 = unsafe { |
| 11 | 11 | &*(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 | |
| 13 | 13 | }; |
| 14 | 14 | |
| 15 | 15 | fn main() {} |
tests/ui/consts/const-eval/heap/make-global-other.stderr+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | error[E0080]: pointer passed to `const_make_global` does not point to a heap allocation: ALLOC0<imm> | |
| 1 | error[E0080]: pointer passed to `const_make_global` does not point to a heap allocation: ALLOC$ID<imm> | |
| 2 | 2 | --> $DIR/make-global-other.rs:11:8 |
| 3 | 3 | | |
| 4 | 4 | LL | &*(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 @@ |
| 1 | 1 | // Ensure that we can't call `const_make_global` twice. |
| 2 | //@ ignore-parallel-frontend different alloc ids | |
| 2 | ||
| 3 | 3 | #![feature(core_intrinsics)] |
| 4 | 4 | #![feature(const_heap)] |
| 5 | 5 | |
| ... | ... | @@ -11,7 +11,7 @@ const Y: &i32 = unsafe { |
| 11 | 11 | *i = 20; |
| 12 | 12 | intrinsics::const_make_global(ptr); |
| 13 | 13 | 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 | |
| 15 | 15 | &*i |
| 16 | 16 | }; |
| 17 | 17 |
tests/ui/consts/const-eval/heap/make-global-twice.stderr+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | error[E0080]: attempting to call `const_make_global` twice on the same allocation ALLOC0 | |
| 1 | error[E0080]: attempting to call `const_make_global` twice on the same allocation ALLOC$ID | |
| 2 | 2 | --> $DIR/make-global-twice.rs:13:5 |
| 3 | 3 | | |
| 4 | 4 | LL | intrinsics::const_make_global(ptr); |
tests/ui/consts/const-eval/heap/ptr_made_global_mutated.rs+2-2| ... | ... | @@ -2,13 +2,13 @@ |
| 2 | 2 | #![feature(core_intrinsics)] |
| 3 | 3 | #![feature(const_heap)] |
| 4 | 4 | use std::intrinsics; |
| 5 | //@ ignore-parallel-frontend different alloc ids | |
| 5 | ||
| 6 | 6 | const A: &u8 = unsafe { |
| 7 | 7 | let ptr = intrinsics::const_allocate(1, 1); |
| 8 | 8 | *ptr = 1; |
| 9 | 9 | let ptr: *const u8 = intrinsics::const_make_global(ptr); |
| 10 | 10 | *(ptr as *mut u8) = 2; |
| 11 | //~^ error: writing to ALLOC0 which is read-only | |
| 11 | //~^ error: writing to ALLOC$ID which is read-only | |
| 12 | 12 | &*ptr |
| 13 | 13 | }; |
| 14 | 14 |
tests/ui/consts/const-eval/heap/ptr_made_global_mutated.stderr+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | error[E0080]: writing to ALLOC0 which is read-only | |
| 1 | error[E0080]: writing to ALLOC$ID which is read-only | |
| 2 | 2 | --> $DIR/ptr_made_global_mutated.rs:10:5 |
| 3 | 3 | | |
| 4 | 4 | LL | *(ptr as *mut u8) = 2; |
tests/ui/consts/const-eval/issue-49296.rs+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // issue-49296: Unsafe shenigans in constants can result in missing errors |
| 2 | //@ ignore-parallel-frontend different alloc ids | |
| 2 | ||
| 3 | 3 | use std::mem::transmute; |
| 4 | 4 | |
| 5 | 5 | const fn wat(x: u64) -> &'static u64 { |
tests/ui/consts/const-eval/issue-49296.stderr+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | error[E0080]: memory access failed: ALLOC0 has been freed, so this pointer is dangling | |
| 1 | error[E0080]: memory access failed: ALLOC$ID has been freed, so this pointer is dangling | |
| 2 | 2 | --> $DIR/issue-49296.rs:9:16 |
| 3 | 3 | | |
| 4 | 4 | LL | const X: u64 = *wat(42); |
tests/ui/consts/const-eval/ptr_fragments_mixed.rs+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | //! This mixes fragments from different pointers, in a way that we should not accept. |
| 2 | 2 | //! See <https://github.com/rust-lang/rust/issues/146291>. |
| 3 | //@ ignore-parallel-frontend different alloc ids | |
| 3 | ||
| 4 | 4 | static A: u8 = 123; |
| 5 | 5 | static B: u8 = 123; |
| 6 | 6 |
tests/ui/consts/const-eval/ptr_fragments_mixed.stderr+2-2| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | error[E0080]: unable to read parts of a pointer from memory at ALLOC0 | |
| 1 | error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID | |
| 2 | 2 | --> $DIR/ptr_fragments_mixed.rs:19:9 |
| 3 | 3 | | |
| 4 | 4 | LL | y |
| ... | ... | @@ -7,7 +7,7 @@ LL | y |
| 7 | 7 | = help: this code performed an operation that depends on the underlying bytes representing a pointer |
| 8 | 8 | = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 9 | 9 | |
| 10 | error[E0080]: unable to read parts of a pointer from memory at ALLOC1 | |
| 10 | error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID | |
| 11 | 11 | --> $DIR/ptr_fragments_mixed.rs:33:9 |
| 12 | 12 | | |
| 13 | 13 | LL | y |
tests/ui/consts/const-eval/raw-bytes.32bit.stderr+88-88| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | error[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 | |
| 3 | 3 | | |
| 4 | 4 | LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; |
| 5 | 5 | | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -10,7 +10,7 @@ LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | error[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 | |
| 14 | 14 | | |
| 15 | 15 | LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; |
| 16 | 16 | | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -21,7 +21,7 @@ LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | error[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 | |
| 25 | 25 | | |
| 26 | 26 | LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; |
| 27 | 27 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -32,7 +32,7 @@ LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | error[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 | |
| 36 | 36 | | |
| 37 | 37 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; |
| 38 | 38 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -43,7 +43,7 @@ LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | error[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 | |
| 47 | 47 | | |
| 48 | 48 | LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); |
| 49 | 49 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | error[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 | |
| 58 | 58 | | |
| 59 | 59 | LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; |
| 60 | 60 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -65,7 +65,7 @@ LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | error[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 | |
| 69 | 69 | | |
| 70 | 70 | LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) }; |
| 71 | 71 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -76,7 +76,7 @@ LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) }; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | error[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 | |
| 80 | 80 | | |
| 81 | 81 | LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) }; |
| 82 | 82 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -87,7 +87,7 @@ LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) }; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | error[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 | |
| 91 | 91 | | |
| 92 | 92 | LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(mem::transmute(42_u32)) }; |
| 93 | 93 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -98,7 +98,7 @@ LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(mem::transmu |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | error[E0080]: constructing invalid value of type RestrictedRange2: at .0, encountered 20, but expected something less or equal to 10, or greater or equal to 30 |
| 101 | --> $DIR/raw-bytes.rs:72:1 | |
| 101 | --> $DIR/raw-bytes.rs:71:1 | |
| 102 | 102 | | |
| 103 | 103 | LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(mem::transmute(20_i32)) }; |
| 104 | 104 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -109,40 +109,40 @@ LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(mem::transmu |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | error[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 | |
| 113 | 113 | | |
| 114 | 114 | LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe { |
| 115 | 115 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 116 | 116 | | |
| 117 | 117 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 118 | 118 | = 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╼ │ ....╾──╼ | |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | error[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 | |
| 124 | 124 | | |
| 125 | 125 | LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; |
| 126 | 126 | | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 127 | 127 | | |
| 128 | 128 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 129 | 129 | = note: the raw bytes of the constant (size: 4, align: 4) { |
| 130 | ╾ALLOC_ID╼ │ ╾──╼ | |
| 130 | ╾ALLOC$ID╼ │ ╾──╼ | |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | error[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 | |
| 135 | 135 | | |
| 136 | 136 | LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) }; |
| 137 | 137 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 138 | 138 | | |
| 139 | 139 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 140 | 140 | = note: the raw bytes of the constant (size: 4, align: 4) { |
| 141 | ╾ALLOC_ID╼ │ ╾──╼ | |
| 141 | ╾ALLOC$ID╼ │ ╾──╼ | |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | error[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 | |
| 146 | 146 | | |
| 147 | 147 | LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; |
| 148 | 148 | | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -153,7 +153,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | error[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 | |
| 157 | 157 | | |
| 158 | 158 | LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; |
| 159 | 159 | | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -164,7 +164,7 @@ LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | error[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 | |
| 168 | 168 | | |
| 169 | 169 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; |
| 170 | 170 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -175,7 +175,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | error[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 | |
| 179 | 179 | | |
| 180 | 180 | LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; |
| 181 | 181 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -186,7 +186,7 @@ LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | error[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 | |
| 190 | 190 | | |
| 191 | 191 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; |
| 192 | 192 | | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -197,7 +197,7 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | error[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 | |
| 201 | 201 | | |
| 202 | 202 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; |
| 203 | 203 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -207,19 +207,19 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; |
| 207 | 207 | 0d 00 00 00 │ .... |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | error[E0080]: constructing invalid value of type fn(): encountered ALLOC3<imm>, but expected a function pointer | |
| 211 | --> $DIR/raw-bytes.rs:104:1 | |
| 210 | error[E0080]: constructing invalid value of type fn(): encountered ALLOC$ID<imm>, but expected a function pointer | |
| 211 | --> $DIR/raw-bytes.rs:103:1 | |
| 212 | 212 | | |
| 213 | 213 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; |
| 214 | 214 | | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 215 | 215 | | |
| 216 | 216 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 217 | 217 | = note: the raw bytes of the constant (size: 4, align: 4) { |
| 218 | ╾ALLOC_ID╼ │ ╾──╼ | |
| 218 | ╾ALLOC$ID╼ │ ╾──╼ | |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | error[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 | |
| 223 | 223 | | |
| 224 | 224 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; |
| 225 | 225 | | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -230,62 +230,62 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | error[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 | |
| 234 | 234 | | |
| 235 | 235 | LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; |
| 236 | 236 | | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 237 | 237 | | |
| 238 | 238 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 239 | 239 | = 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 │ ╾──╼.... | |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | error[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 | |
| 245 | 245 | | |
| 246 | 246 | LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); |
| 247 | 247 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 248 | 248 | | |
| 249 | 249 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 250 | 250 | = 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 │ ╾──╼.... | |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | error[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 | |
| 256 | 256 | | |
| 257 | 257 | LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; |
| 258 | 258 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 259 | 259 | | |
| 260 | 260 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 261 | 261 | = 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 │ ╾──╼.... | |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | error[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 | |
| 267 | 267 | | |
| 268 | 268 | LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; |
| 269 | 269 | | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 270 | 270 | | |
| 271 | 271 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 272 | 272 | = 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 │ ╾──╼.... | |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | error[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 | |
| 278 | 278 | | |
| 279 | 279 | LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; |
| 280 | 280 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 281 | 281 | | |
| 282 | 282 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 283 | 283 | = 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 │ ╾──╼.... | |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | error[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 | |
| 289 | 289 | | |
| 290 | 290 | LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; |
| 291 | 291 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -294,172 +294,172 @@ LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _> |
| 294 | 294 | = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 295 | 295 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 296 | 296 | = 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 │ ╾──╼.... | |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | error[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 | |
| 302 | 302 | | |
| 303 | 303 | LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; |
| 304 | 304 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 305 | 305 | | |
| 306 | 306 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 307 | 307 | = 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 │ ╾──╼.... | |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | error[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 | |
| 313 | 313 | | |
| 314 | 314 | LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; |
| 315 | 315 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 316 | 316 | | |
| 317 | 317 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 318 | 318 | = 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 │ ╾──╼.... | |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | error[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 | |
| 324 | 324 | | |
| 325 | 325 | LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; |
| 326 | 326 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 327 | 327 | | |
| 328 | 328 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 329 | 329 | = 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 │ ╾──╼.... | |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | error[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 | |
| 335 | 335 | | |
| 336 | 336 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; |
| 337 | 337 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 338 | 338 | | |
| 339 | 339 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 340 | 340 | = note: the raw bytes of the constant (size: 4, align: 4) { |
| 341 | ╾ALLOC_ID╼ │ ╾──╼ | |
| 341 | ╾ALLOC$ID╼ │ ╾──╼ | |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | note: erroneous constant encountered |
| 345 | --> $DIR/raw-bytes.rs:157:40 | |
| 345 | --> $DIR/raw-bytes.rs:156:40 | |
| 346 | 346 | | |
| 347 | 347 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; |
| 348 | 348 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 349 | 349 | |
| 350 | 350 | error[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 | |
| 352 | 352 | | |
| 353 | 353 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); |
| 354 | 354 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 355 | 355 | | |
| 356 | 356 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 357 | 357 | = note: the raw bytes of the constant (size: 4, align: 4) { |
| 358 | ╾ALLOC_ID╼ │ ╾──╼ | |
| 358 | ╾ALLOC$ID╼ │ ╾──╼ | |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | note: erroneous constant encountered |
| 362 | --> $DIR/raw-bytes.rs:161:42 | |
| 362 | --> $DIR/raw-bytes.rs:160:42 | |
| 363 | 363 | | |
| 364 | 364 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); |
| 365 | 365 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 366 | 366 | |
| 367 | 367 | error[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 | |
| 369 | 369 | | |
| 370 | 370 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); |
| 371 | 371 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 372 | 372 | | |
| 373 | 373 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 374 | 374 | = note: the raw bytes of the constant (size: 4, align: 4) { |
| 375 | ╾ALLOC_ID╼ │ ╾──╼ | |
| 375 | ╾ALLOC$ID╼ │ ╾──╼ | |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | note: erroneous constant encountered |
| 379 | --> $DIR/raw-bytes.rs:164:42 | |
| 379 | --> $DIR/raw-bytes.rs:163:42 | |
| 380 | 380 | | |
| 381 | 381 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); |
| 382 | 382 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 383 | 383 | |
| 384 | error[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 | |
| 384 | error[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 | |
| 386 | 386 | | |
| 387 | 387 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; |
| 388 | 388 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 389 | 389 | | |
| 390 | 390 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 391 | 391 | = note: the raw bytes of the constant (size: 8, align: 4) { |
| 392 | ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ | |
| 392 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼ | |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | error[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 | |
| 395 | error[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 | |
| 397 | 397 | | |
| 398 | 398 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; |
| 399 | 399 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 400 | 400 | | |
| 401 | 401 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 402 | 402 | = note: the raw bytes of the constant (size: 8, align: 4) { |
| 403 | ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ | |
| 403 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼ | |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | error[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 | |
| 408 | 408 | | |
| 409 | 409 | LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; |
| 410 | 410 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 411 | 411 | | |
| 412 | 412 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 413 | 413 | = 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 │ ╾──╼.... | |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | error[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 | |
| 417 | error[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 | |
| 419 | 419 | | |
| 420 | 420 | LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; |
| 421 | 421 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 422 | 422 | | |
| 423 | 423 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 424 | 424 | = note: the raw bytes of the constant (size: 8, align: 4) { |
| 425 | ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ | |
| 425 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼ | |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | error[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 | |
| 430 | 430 | | |
| 431 | 431 | LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; |
| 432 | 432 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 433 | 433 | | |
| 434 | 434 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 435 | 435 | = note: the raw bytes of the constant (size: 8, align: 4) { |
| 436 | ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ | |
| 436 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼ | |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | error[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 | |
| 441 | 441 | | |
| 442 | 442 | LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; |
| 443 | 443 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 444 | 444 | | |
| 445 | 445 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 446 | 446 | = 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 │ ╾──╼.... | |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | error[E0080]: constructing invalid value of type *const dyn Trait: encountered ALLOC27<imm>, but expected a vtable pointer | |
| 451 | --> $DIR/raw-bytes.rs:184:1 | |
| 450 | error[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 | |
| 452 | 452 | | |
| 453 | 453 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; |
| 454 | 454 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 455 | 455 | | |
| 456 | 456 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 457 | 457 | = note: the raw bytes of the constant (size: 8, align: 4) { |
| 458 | ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ | |
| 458 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼ | |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | error[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 | |
| 463 | 463 | | |
| 464 | 464 | LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; |
| 465 | 465 | | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -470,7 +470,7 @@ LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | error[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 | |
| 474 | 474 | | |
| 475 | 475 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; |
| 476 | 476 | | ^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -481,7 +481,7 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | error[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 | |
| 485 | 485 | | |
| 486 | 486 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; |
| 487 | 487 | | ^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -492,18 +492,18 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | error[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 | |
| 496 | 496 | | |
| 497 | 497 | LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; |
| 498 | 498 | | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 499 | 499 | | |
| 500 | 500 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 501 | 501 | = 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 │ ╾──╼.... | |
| 503 | 503 | } |
| 504 | 504 | |
| 505 | 505 | error[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 | |
| 507 | 507 | | |
| 508 | 508 | LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) }; |
| 509 | 509 | | ^^^^^^^^^^^^^^^^^^^^ 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: |
| 512 | 512 | = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 513 | 513 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 514 | 514 | = 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 │ ╾──╼.... | |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | error[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 | |
| 520 | 520 | | |
| 521 | 521 | LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; |
| 522 | 522 | | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 523 | 523 | | |
| 524 | 524 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 525 | 525 | = 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 │ ╾──╼.... | |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | error[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 | |
| 531 | 531 | | |
| 532 | 532 | LL | pub static S7: &[u16] = unsafe { |
| 533 | 533 | | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 534 | 534 | | |
| 535 | 535 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 536 | 536 | = 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 │ ╾──╼.... | |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | error[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 | |
| 542 | 542 | | |
| 543 | 543 | LL | pub static R4: &[u8] = unsafe { |
| 544 | 544 | | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 545 | 545 | | |
| 546 | 546 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 547 | 547 | = 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 │ ╾──╼.... | |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | error[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 | |
| 553 | 553 | | |
| 554 | 554 | LL | pub static R5: &[u8] = unsafe { |
| 555 | 555 | | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -558,18 +558,18 @@ LL | pub static R5: &[u8] = unsafe { |
| 558 | 558 | = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 559 | 559 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 560 | 560 | = 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 │ ╾──╼.... | |
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | error[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 | |
| 566 | 566 | | |
| 567 | 567 | LL | pub static R6: &[bool] = unsafe { |
| 568 | 568 | | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 569 | 569 | | |
| 570 | 570 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 571 | 571 | = 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 │ ╾──╼.... | |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | error: aborting due to 50 previous errors |
tests/ui/consts/const-eval/raw-bytes.64bit.stderr+88-88| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | error[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 | |
| 3 | 3 | | |
| 4 | 4 | LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; |
| 5 | 5 | | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -10,7 +10,7 @@ LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | error[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 | |
| 14 | 14 | | |
| 15 | 15 | LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; |
| 16 | 16 | | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -21,7 +21,7 @@ LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | error[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 | |
| 25 | 25 | | |
| 26 | 26 | LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; |
| 27 | 27 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -32,7 +32,7 @@ LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | error[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 | |
| 36 | 36 | | |
| 37 | 37 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; |
| 38 | 38 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -43,7 +43,7 @@ LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | error[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 | |
| 47 | 47 | | |
| 48 | 48 | LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); |
| 49 | 49 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | error[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 | |
| 58 | 58 | | |
| 59 | 59 | LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; |
| 60 | 60 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -65,7 +65,7 @@ LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | error[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 | |
| 69 | 69 | | |
| 70 | 70 | LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) }; |
| 71 | 71 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -76,7 +76,7 @@ LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) }; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | error[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 | |
| 80 | 80 | | |
| 81 | 81 | LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) }; |
| 82 | 82 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -87,7 +87,7 @@ LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) }; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | error[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 | |
| 91 | 91 | | |
| 92 | 92 | LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(mem::transmute(42_u32)) }; |
| 93 | 93 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -98,7 +98,7 @@ LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(mem::transmu |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | error[E0080]: constructing invalid value of type RestrictedRange2: at .0, encountered 20, but expected something less or equal to 10, or greater or equal to 30 |
| 101 | --> $DIR/raw-bytes.rs:72:1 | |
| 101 | --> $DIR/raw-bytes.rs:71:1 | |
| 102 | 102 | | |
| 103 | 103 | LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(mem::transmute(20_i32)) }; |
| 104 | 104 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -109,40 +109,40 @@ LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(mem::transmu |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | error[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 | |
| 113 | 113 | | |
| 114 | 114 | LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe { |
| 115 | 115 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 116 | 116 | | |
| 117 | 117 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 118 | 118 | = 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╼ │ ........╾──────╼ | |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | error[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 | |
| 124 | 124 | | |
| 125 | 125 | LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; |
| 126 | 126 | | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 127 | 127 | | |
| 128 | 128 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 129 | 129 | = note: the raw bytes of the constant (size: 8, align: 8) { |
| 130 | ╾ALLOC_ID╼ │ ╾──────╼ | |
| 130 | ╾ALLOC$ID╼ │ ╾──────╼ | |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | error[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 | |
| 135 | 135 | | |
| 136 | 136 | LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) }; |
| 137 | 137 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 138 | 138 | | |
| 139 | 139 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 140 | 140 | = note: the raw bytes of the constant (size: 8, align: 8) { |
| 141 | ╾ALLOC_ID╼ │ ╾──────╼ | |
| 141 | ╾ALLOC$ID╼ │ ╾──────╼ | |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | error[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 | |
| 146 | 146 | | |
| 147 | 147 | LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; |
| 148 | 148 | | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -153,7 +153,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | error[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 | |
| 157 | 157 | | |
| 158 | 158 | LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; |
| 159 | 159 | | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -164,7 +164,7 @@ LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | error[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 | |
| 168 | 168 | | |
| 169 | 169 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; |
| 170 | 170 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -175,7 +175,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | error[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 | |
| 179 | 179 | | |
| 180 | 180 | LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; |
| 181 | 181 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -186,7 +186,7 @@ LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | error[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 | |
| 190 | 190 | | |
| 191 | 191 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; |
| 192 | 192 | | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -197,7 +197,7 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | error[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 | |
| 201 | 201 | | |
| 202 | 202 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; |
| 203 | 203 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -207,19 +207,19 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; |
| 207 | 207 | 0d 00 00 00 00 00 00 00 │ ........ |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | error[E0080]: constructing invalid value of type fn(): encountered ALLOC3<imm>, but expected a function pointer | |
| 211 | --> $DIR/raw-bytes.rs:104:1 | |
| 210 | error[E0080]: constructing invalid value of type fn(): encountered ALLOC$ID<imm>, but expected a function pointer | |
| 211 | --> $DIR/raw-bytes.rs:103:1 | |
| 212 | 212 | | |
| 213 | 213 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; |
| 214 | 214 | | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 215 | 215 | | |
| 216 | 216 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 217 | 217 | = note: the raw bytes of the constant (size: 8, align: 8) { |
| 218 | ╾ALLOC_ID╼ │ ╾──────╼ | |
| 218 | ╾ALLOC$ID╼ │ ╾──────╼ | |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | error[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 | |
| 223 | 223 | | |
| 224 | 224 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; |
| 225 | 225 | | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -230,62 +230,62 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | error[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 | |
| 234 | 234 | | |
| 235 | 235 | LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; |
| 236 | 236 | | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 237 | 237 | | |
| 238 | 238 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 239 | 239 | = 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 │ ╾──────╼........ | |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | error[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 | |
| 245 | 245 | | |
| 246 | 246 | LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); |
| 247 | 247 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 248 | 248 | | |
| 249 | 249 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 250 | 250 | = 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 │ ╾──────╼........ | |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | error[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 | |
| 256 | 256 | | |
| 257 | 257 | LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; |
| 258 | 258 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 259 | 259 | | |
| 260 | 260 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 261 | 261 | = 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 │ ╾──────╼........ | |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | error[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 | |
| 267 | 267 | | |
| 268 | 268 | LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; |
| 269 | 269 | | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 270 | 270 | | |
| 271 | 271 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 272 | 272 | = 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 │ ╾──────╼........ | |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | error[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 | |
| 278 | 278 | | |
| 279 | 279 | LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; |
| 280 | 280 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 281 | 281 | | |
| 282 | 282 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 283 | 283 | = 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 │ ╾──────╼........ | |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | error[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 | |
| 289 | 289 | | |
| 290 | 290 | LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; |
| 291 | 291 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -294,172 +294,172 @@ LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _> |
| 294 | 294 | = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 295 | 295 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 296 | 296 | = 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 │ ╾──────╼........ | |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | error[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 | |
| 302 | 302 | | |
| 303 | 303 | LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; |
| 304 | 304 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 305 | 305 | | |
| 306 | 306 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 307 | 307 | = 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 │ ╾──────╼........ | |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | error[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 | |
| 313 | 313 | | |
| 314 | 314 | LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; |
| 315 | 315 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 316 | 316 | | |
| 317 | 317 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 318 | 318 | = 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 │ ╾──────╼........ | |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | error[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 | |
| 324 | 324 | | |
| 325 | 325 | LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; |
| 326 | 326 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 327 | 327 | | |
| 328 | 328 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 329 | 329 | = 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 │ ╾──────╼........ | |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | error[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 | |
| 335 | 335 | | |
| 336 | 336 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; |
| 337 | 337 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 338 | 338 | | |
| 339 | 339 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 340 | 340 | = note: the raw bytes of the constant (size: 8, align: 8) { |
| 341 | ╾ALLOC_ID╼ │ ╾──────╼ | |
| 341 | ╾ALLOC$ID╼ │ ╾──────╼ | |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | note: erroneous constant encountered |
| 345 | --> $DIR/raw-bytes.rs:157:40 | |
| 345 | --> $DIR/raw-bytes.rs:156:40 | |
| 346 | 346 | | |
| 347 | 347 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; |
| 348 | 348 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 349 | 349 | |
| 350 | 350 | error[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 | |
| 352 | 352 | | |
| 353 | 353 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); |
| 354 | 354 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 355 | 355 | | |
| 356 | 356 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 357 | 357 | = note: the raw bytes of the constant (size: 8, align: 8) { |
| 358 | ╾ALLOC_ID╼ │ ╾──────╼ | |
| 358 | ╾ALLOC$ID╼ │ ╾──────╼ | |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | note: erroneous constant encountered |
| 362 | --> $DIR/raw-bytes.rs:161:42 | |
| 362 | --> $DIR/raw-bytes.rs:160:42 | |
| 363 | 363 | | |
| 364 | 364 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); |
| 365 | 365 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 366 | 366 | |
| 367 | 367 | error[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 | |
| 369 | 369 | | |
| 370 | 370 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); |
| 371 | 371 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 372 | 372 | | |
| 373 | 373 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 374 | 374 | = note: the raw bytes of the constant (size: 8, align: 8) { |
| 375 | ╾ALLOC_ID╼ │ ╾──────╼ | |
| 375 | ╾ALLOC$ID╼ │ ╾──────╼ | |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | note: erroneous constant encountered |
| 379 | --> $DIR/raw-bytes.rs:164:42 | |
| 379 | --> $DIR/raw-bytes.rs:163:42 | |
| 380 | 380 | | |
| 381 | 381 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); |
| 382 | 382 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 383 | 383 | |
| 384 | error[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 | |
| 384 | error[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 | |
| 386 | 386 | | |
| 387 | 387 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; |
| 388 | 388 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 389 | 389 | | |
| 390 | 390 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 391 | 391 | = note: the raw bytes of the constant (size: 16, align: 8) { |
| 392 | ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ | |
| 392 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ | |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | error[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 | |
| 395 | error[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 | |
| 397 | 397 | | |
| 398 | 398 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; |
| 399 | 399 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 400 | 400 | | |
| 401 | 401 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 402 | 402 | = note: the raw bytes of the constant (size: 16, align: 8) { |
| 403 | ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ | |
| 403 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ | |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | error[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 | |
| 408 | 408 | | |
| 409 | 409 | LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; |
| 410 | 410 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 411 | 411 | | |
| 412 | 412 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 413 | 413 | = 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 │ ╾──────╼........ | |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | error[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 | |
| 417 | error[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 | |
| 419 | 419 | | |
| 420 | 420 | LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; |
| 421 | 421 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 422 | 422 | | |
| 423 | 423 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 424 | 424 | = note: the raw bytes of the constant (size: 16, align: 8) { |
| 425 | ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ | |
| 425 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ | |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | error[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 | |
| 430 | 430 | | |
| 431 | 431 | LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; |
| 432 | 432 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 433 | 433 | | |
| 434 | 434 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 435 | 435 | = note: the raw bytes of the constant (size: 16, align: 8) { |
| 436 | ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ | |
| 436 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ | |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | error[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 | |
| 441 | 441 | | |
| 442 | 442 | LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; |
| 443 | 443 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 444 | 444 | | |
| 445 | 445 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 446 | 446 | = 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 │ ╾──────╼........ | |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | error[E0080]: constructing invalid value of type *const dyn Trait: encountered ALLOC27<imm>, but expected a vtable pointer | |
| 451 | --> $DIR/raw-bytes.rs:184:1 | |
| 450 | error[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 | |
| 452 | 452 | | |
| 453 | 453 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; |
| 454 | 454 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 455 | 455 | | |
| 456 | 456 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 457 | 457 | = note: the raw bytes of the constant (size: 16, align: 8) { |
| 458 | ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ | |
| 458 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ | |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | error[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 | |
| 463 | 463 | | |
| 464 | 464 | LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; |
| 465 | 465 | | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -470,7 +470,7 @@ LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | error[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 | |
| 474 | 474 | | |
| 475 | 475 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; |
| 476 | 476 | | ^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -481,7 +481,7 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | error[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 | |
| 485 | 485 | | |
| 486 | 486 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; |
| 487 | 487 | | ^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -492,18 +492,18 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | error[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 | |
| 496 | 496 | | |
| 497 | 497 | LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; |
| 498 | 498 | | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 499 | 499 | | |
| 500 | 500 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 501 | 501 | = 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 │ ╾──────╼........ | |
| 503 | 503 | } |
| 504 | 504 | |
| 505 | 505 | error[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 | |
| 507 | 507 | | |
| 508 | 508 | LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) }; |
| 509 | 509 | | ^^^^^^^^^^^^^^^^^^^^ 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: |
| 512 | 512 | = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 513 | 513 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 514 | 514 | = 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 │ ╾──────╼........ | |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | error[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 | |
| 520 | 520 | | |
| 521 | 521 | LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; |
| 522 | 522 | | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 523 | 523 | | |
| 524 | 524 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 525 | 525 | = 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 │ ╾──────╼........ | |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | error[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 | |
| 531 | 531 | | |
| 532 | 532 | LL | pub static S7: &[u16] = unsafe { |
| 533 | 533 | | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 534 | 534 | | |
| 535 | 535 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 536 | 536 | = 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 │ ╾──────╼........ | |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | error[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 | |
| 542 | 542 | | |
| 543 | 543 | LL | pub static R4: &[u8] = unsafe { |
| 544 | 544 | | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 545 | 545 | | |
| 546 | 546 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 547 | 547 | = 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 │ ╾──────╼........ | |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | error[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 | |
| 553 | 553 | | |
| 554 | 554 | LL | pub static R5: &[u8] = unsafe { |
| 555 | 555 | | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -558,18 +558,18 @@ LL | pub static R5: &[u8] = unsafe { |
| 558 | 558 | = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 559 | 559 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 560 | 560 | = 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 │ ╾──────╼........ | |
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | error[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 | |
| 566 | 566 | | |
| 567 | 567 | LL | pub static R6: &[bool] = unsafe { |
| 568 | 568 | | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 569 | 569 | | |
| 570 | 570 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 571 | 571 | = 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 │ ╾──────╼........ | |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | error: aborting due to 50 previous errors |
tests/ui/consts/const-eval/raw-bytes.rs+1-2| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //@ stderr-per-bitwidth |
| 2 | 2 | //@ ignore-endian-big |
| 3 | 3 | // ignore-tidy-linelength |
| 4 | //@ normalize-stderr: "╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼" -> "╾ALLOC_ID$1╼" | |
| 5 | 4 | //@ dont-require-annotations: NOTE |
| 6 | //@ ignore-parallel-frontend different alloc ids | |
| 5 | ||
| 7 | 6 | #![allow(invalid_value, unnecessary_transmutes)] |
| 8 | 7 | #![feature(never_type, rustc_attrs, ptr_metadata, slice_from_ptr_range, const_slice_from_ptr_range)] |
| 9 | 8 | #![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 { |
| 4 | 4 | let _val = *ptr; //~NOTE: failed here |
| 5 | 5 | //~^ERROR: based on pointer with alignment 1, but alignment 4 is required |
| 6 | 6 | }; |
| 7 | //@ ignore-parallel-frontend different alloc ids | |
| 7 | ||
| 8 | 8 | const MISALIGNED_STORE: () = unsafe { |
| 9 | 9 | let mut mem = [0u32; 8]; |
| 10 | 10 | 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 |
| 25 | 25 | LL | let _val = (*ptr).0; |
| 26 | 26 | | ^^^^^^^^ evaluation of `MISALIGNED_FIELD` failed here |
| 27 | 27 | |
| 28 | error[E0080]: memory access failed: attempting to access 8 bytes, but got ALLOC0 which is only 4 bytes from the end of the allocation | |
| 28 | error[E0080]: memory access failed: attempting to access 8 bytes, but got ALLOC$ID which is only 4 bytes from the end of the allocation | |
| 29 | 29 | --> $DIR/raw-pointer-ub.rs:40:16 |
| 30 | 30 | | |
| 31 | 31 | LL | let _val = *ptr; |
tests/ui/consts/const-eval/read_partial_ptr.rs+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | //! Ensure we error when trying to load from a pointer whose provenance has been messed with. |
| 2 | //@ ignore-parallel-frontend different alloc ids | |
| 2 | ||
| 3 | 3 | const PARTIAL_OVERWRITE: () = { |
| 4 | 4 | let mut p = &42; |
| 5 | 5 | // Overwrite one byte with a no-provenance value. |
tests/ui/consts/const-eval/read_partial_ptr.stderr+4-4| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | error[E0080]: unable to read parts of a pointer from memory at ALLOC0 | |
| 1 | error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID | |
| 2 | 2 | --> $DIR/read_partial_ptr.rs:10:13 |
| 3 | 3 | | |
| 4 | 4 | LL | let x = *p; |
| ... | ... | @@ -7,7 +7,7 @@ LL | let x = *p; |
| 7 | 7 | = help: this code performed an operation that depends on the underlying bytes representing a pointer |
| 8 | 8 | = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 9 | 9 | |
| 10 | error[E0080]: unable to read parts of a pointer from memory at ALLOC1 | |
| 10 | error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID | |
| 11 | 11 | --> $DIR/read_partial_ptr.rs:23:13 |
| 12 | 12 | | |
| 13 | 13 | LL | let x = *p; |
| ... | ... | @@ -16,7 +16,7 @@ LL | let x = *p; |
| 16 | 16 | = help: this code performed an operation that depends on the underlying bytes representing a pointer |
| 17 | 17 | = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 18 | 18 | |
| 19 | error[E0080]: unable to read parts of a pointer from memory at ALLOC2 | |
| 19 | error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID | |
| 20 | 20 | --> $DIR/read_partial_ptr.rs:34:13 |
| 21 | 21 | | |
| 22 | 22 | LL | let x = *p; |
| ... | ... | @@ -25,7 +25,7 @@ LL | let x = *p; |
| 25 | 25 | = help: this code performed an operation that depends on the underlying bytes representing a pointer |
| 26 | 26 | = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 27 | 27 | |
| 28 | error[E0080]: unable to read parts of a pointer from memory at ALLOC3 | |
| 28 | error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID | |
| 29 | 29 | --> $DIR/read_partial_ptr.rs:46:13 |
| 30 | 30 | | |
| 31 | 31 | LL | let x = *p; |
tests/ui/consts/const-eval/ub-enum-overwrite.rs+1-1| ... | ... | @@ -2,7 +2,7 @@ enum E { |
| 2 | 2 | A(u8), |
| 3 | 3 | B, |
| 4 | 4 | } |
| 5 | //@ ignore-parallel-frontend different alloc ids | |
| 5 | ||
| 6 | 6 | const _: u8 = { |
| 7 | 7 | let mut e = E::A(1); |
| 8 | 8 | 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 @@ |
| 1 | error[E0080]: reading memory at ALLOC0[0x1..0x2], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory | |
| 1 | error[E0080]: reading memory at ALLOC$ID[0x1..0x2], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory | |
| 2 | 2 | --> $DIR/ub-enum-overwrite.rs:11:14 |
| 3 | 3 | | |
| 4 | 4 | LL | unsafe { *p } |
tests/ui/consts/const-eval/ub-enum.rs+1-1| ... | ... | @@ -4,7 +4,7 @@ |
| 4 | 4 | //@ normalize-stderr: "0x0+" -> "0x0" |
| 5 | 5 | //@ normalize-stderr: "0x[0-9](\.\.|\])" -> "0x%$1" |
| 6 | 6 | //@ dont-require-annotations: NOTE |
| 7 | //@ ignore-parallel-frontend different alloc ids | |
| 7 | ||
| 8 | 8 | #![feature(never_type)] |
| 9 | 9 | #![allow(invalid_value, unnecessary_transmutes)] |
| 10 | 10 |
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) }; |
| 56 | 56 | = help: this code performed an operation that depends on the underlying bytes representing a pointer |
| 57 | 57 | = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 58 | 58 | |
| 59 | error[E0080]: reading memory at ALLOC0[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory | |
| 59 | error[E0080]: reading memory at ALLOC$ID[0x%..0x%], but memory is uninitialized at [0x%..0x%], and this operation requires initialized memory | |
| 60 | 60 | --> $DIR/ub-enum.rs:62:41 |
| 61 | 61 | | |
| 62 | 62 | LL | 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 @@ |
| 1 | error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC1<imm>, but expected a vtable pointer | |
| 1 | error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC$ID<imm>, but expected a vtable pointer | |
| 2 | 2 | --> $DIR/ub-incorrect-vtable.rs:18:1 |
| 3 | 3 | | |
| 4 | 4 | LL | const INVALID_VTABLE_ALIGNMENT: &dyn Trait = |
| ... | ... | @@ -6,10 +6,10 @@ LL | const INVALID_VTABLE_ALIGNMENT: &dyn Trait = |
| 6 | 6 | | |
| 7 | 7 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 8 | 8 | = note: the raw bytes of the constant (size: 8, align: 4) { |
| 9 | ╾ALLOC0<imm>╼ ╾ALLOC1<imm>╼ │ ╾──╼╾──╼ | |
| 9 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼ | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC3<imm>, but expected a vtable pointer | |
| 12 | error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC$ID<imm>, but expected a vtable pointer | |
| 13 | 13 | --> $DIR/ub-incorrect-vtable.rs:22:1 |
| 14 | 14 | | |
| 15 | 15 | LL | const INVALID_VTABLE_SIZE: &dyn Trait = |
| ... | ... | @@ -17,10 +17,10 @@ LL | const INVALID_VTABLE_SIZE: &dyn Trait = |
| 17 | 17 | | |
| 18 | 18 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 19 | 19 | = note: the raw bytes of the constant (size: 8, align: 4) { |
| 20 | ╾ALLOC2<imm>╼ ╾ALLOC3<imm>╼ │ ╾──╼╾──╼ | |
| 20 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼ | |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC5<imm>, but expected a vtable pointer | |
| 23 | error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID<imm>, but expected a vtable pointer | |
| 24 | 24 | --> $DIR/ub-incorrect-vtable.rs:31:1 |
| 25 | 25 | | |
| 26 | 26 | LL | const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> = |
| ... | ... | @@ -28,10 +28,10 @@ LL | const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> = |
| 28 | 28 | | |
| 29 | 29 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 30 | 30 | = note: the raw bytes of the constant (size: 8, align: 4) { |
| 31 | ╾ALLOC4<imm>╼ ╾ALLOC5<imm>╼ │ ╾──╼╾──╼ | |
| 31 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼ | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC7<imm>, but expected a vtable pointer | |
| 34 | error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID<imm>, but expected a vtable pointer | |
| 35 | 35 | --> $DIR/ub-incorrect-vtable.rs:35:1 |
| 36 | 36 | | |
| 37 | 37 | LL | const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> = |
| ... | ... | @@ -39,10 +39,10 @@ LL | const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> = |
| 39 | 39 | | |
| 40 | 40 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 41 | 41 | = note: the raw bytes of the constant (size: 8, align: 4) { |
| 42 | ╾ALLOC6<imm>╼ ╾ALLOC7<imm>╼ │ ╾──╼╾──╼ | |
| 42 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼ | |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC9<imm>, but expected a vtable pointer | |
| 45 | error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID<imm>, but expected a vtable pointer | |
| 46 | 46 | --> $DIR/ub-incorrect-vtable.rs:40:1 |
| 47 | 47 | | |
| 48 | 48 | LL | const INVALID_VTABLE_UB: W<&dyn Trait> = |
| ... | ... | @@ -50,7 +50,7 @@ LL | const INVALID_VTABLE_UB: W<&dyn Trait> = |
| 50 | 50 | | |
| 51 | 51 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 52 | 52 | = note: the raw bytes of the constant (size: 8, align: 4) { |
| 53 | ╾ALLOC8<imm>╼ ╾ALLOC9<imm>╼ │ ╾──╼╾──╼ | |
| 53 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼ | |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | error[E0080]: constructing invalid value of type Wide<'_>: at .1, encountered a dangling reference (going beyond the bounds of its allocation) |
| ... | ... | @@ -61,7 +61,7 @@ LL | const G: Wide = unsafe { Transmute { t: FOO }.u }; |
| 61 | 61 | | |
| 62 | 62 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 63 | 63 | = note: the raw bytes of the constant (size: 8, align: 4) { |
| 64 | ╾ALLOC10<imm>╼ ╾ALLOC11╼ │ ╾──╼╾──╼ | |
| 64 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼ | |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | error: aborting due to 6 previous errors |
tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr+11-11| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC1<imm>, but expected a vtable pointer | |
| 1 | error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC$ID<imm>, but expected a vtable pointer | |
| 2 | 2 | --> $DIR/ub-incorrect-vtable.rs:18:1 |
| 3 | 3 | | |
| 4 | 4 | LL | const INVALID_VTABLE_ALIGNMENT: &dyn Trait = |
| ... | ... | @@ -6,10 +6,10 @@ LL | const INVALID_VTABLE_ALIGNMENT: &dyn Trait = |
| 6 | 6 | | |
| 7 | 7 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 8 | 8 | = note: the raw bytes of the constant (size: 16, align: 8) { |
| 9 | ╾ALLOC0<imm>╼ ╾ALLOC1<imm>╼ │ ╾──────╼╾──────╼ | |
| 9 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC3<imm>, but expected a vtable pointer | |
| 12 | error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC$ID<imm>, but expected a vtable pointer | |
| 13 | 13 | --> $DIR/ub-incorrect-vtable.rs:22:1 |
| 14 | 14 | | |
| 15 | 15 | LL | const INVALID_VTABLE_SIZE: &dyn Trait = |
| ... | ... | @@ -17,10 +17,10 @@ LL | const INVALID_VTABLE_SIZE: &dyn Trait = |
| 17 | 17 | | |
| 18 | 18 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 19 | 19 | = note: the raw bytes of the constant (size: 16, align: 8) { |
| 20 | ╾ALLOC2<imm>╼ ╾ALLOC3<imm>╼ │ ╾──────╼╾──────╼ | |
| 20 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ | |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC5<imm>, but expected a vtable pointer | |
| 23 | error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID<imm>, but expected a vtable pointer | |
| 24 | 24 | --> $DIR/ub-incorrect-vtable.rs:31:1 |
| 25 | 25 | | |
| 26 | 26 | LL | const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> = |
| ... | ... | @@ -28,10 +28,10 @@ LL | const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> = |
| 28 | 28 | | |
| 29 | 29 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 30 | 30 | = note: the raw bytes of the constant (size: 16, align: 8) { |
| 31 | ╾ALLOC4<imm>╼ ╾ALLOC5<imm>╼ │ ╾──────╼╾──────╼ | |
| 31 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC7<imm>, but expected a vtable pointer | |
| 34 | error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID<imm>, but expected a vtable pointer | |
| 35 | 35 | --> $DIR/ub-incorrect-vtable.rs:35:1 |
| 36 | 36 | | |
| 37 | 37 | LL | const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> = |
| ... | ... | @@ -39,10 +39,10 @@ LL | const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> = |
| 39 | 39 | | |
| 40 | 40 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 41 | 41 | = note: the raw bytes of the constant (size: 16, align: 8) { |
| 42 | ╾ALLOC6<imm>╼ ╾ALLOC7<imm>╼ │ ╾──────╼╾──────╼ | |
| 42 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ | |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC9<imm>, but expected a vtable pointer | |
| 45 | error[E0080]: constructing invalid value of type W<&dyn Trait>: at .0, encountered ALLOC$ID<imm>, but expected a vtable pointer | |
| 46 | 46 | --> $DIR/ub-incorrect-vtable.rs:40:1 |
| 47 | 47 | | |
| 48 | 48 | LL | const INVALID_VTABLE_UB: W<&dyn Trait> = |
| ... | ... | @@ -50,7 +50,7 @@ LL | const INVALID_VTABLE_UB: W<&dyn Trait> = |
| 50 | 50 | | |
| 51 | 51 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 52 | 52 | = note: the raw bytes of the constant (size: 16, align: 8) { |
| 53 | ╾ALLOC8<imm>╼ ╾ALLOC9<imm>╼ │ ╾──────╼╾──────╼ | |
| 53 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ | |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | error[E0080]: constructing invalid value of type Wide<'_>: at .1, encountered a dangling reference (going beyond the bounds of its allocation) |
| ... | ... | @@ -61,7 +61,7 @@ LL | const G: Wide = unsafe { Transmute { t: FOO }.u }; |
| 61 | 61 | | |
| 62 | 62 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 63 | 63 | = note: the raw bytes of the constant (size: 16, align: 8) { |
| 64 | ╾ALLOC10<imm>╼ ╾ALLOC11╼ │ ╾──────╼╾──────╼ | |
| 64 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ | |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | error: aborting due to 6 previous errors |
tests/ui/consts/const-eval/ub-incorrect-vtable.rs+1-1| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | |
| 13 | 13 | //@ stderr-per-bitwidth |
| 14 | 14 | //@ dont-require-annotations: NOTE |
| 15 | //@ ignore-parallel-frontend different alloc ids | |
| 15 | ||
| 16 | 16 | trait Trait {} |
| 17 | 17 | |
| 18 | 18 | const INVALID_VTABLE_ALIGNMENT: &dyn Trait = |
tests/ui/consts/const-eval/ub-nonnull.rs+3-1| ... | ... | @@ -1,8 +1,10 @@ |
| 1 | 1 | // Strip out raw byte dumps to make comparison platform-independent: |
| 2 | 2 | //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" |
| 3 | 3 | //@ 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╼ │ ╾─╼" | |
| 4 | 6 | //@ dont-require-annotations: NOTE |
| 5 | //@ ignore-parallel-frontend different alloc ids | |
| 7 | ||
| 6 | 8 | #![allow(invalid_value)] // make sure we cannot allow away the errors tested here |
| 7 | 9 | #![feature(rustc_attrs, ptr_metadata)] |
| 8 | 10 |
tests/ui/consts/const-eval/ub-nonnull.stderr+11-11| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | error[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 | |
| 3 | 3 | | |
| 4 | 4 | LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; |
| 5 | 5 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -9,14 +9,14 @@ LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; |
| 9 | 9 | HEX_DUMP |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 255 bytes, but got ALLOC2 which is only 1 byte from the end of the allocation | |
| 13 | --> $DIR/ub-nonnull.rs:22:29 | |
| 12 | error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 255 bytes, but got ALLOC$ID which is only 1 byte from the end of the allocation | |
| 13 | --> $DIR/ub-nonnull.rs:24:29 | |
| 14 | 14 | | |
| 15 | 15 | LL | let out_of_bounds_ptr = &ptr[255]; |
| 16 | 16 | | ^^^^^^^^^ evaluation of `OUT_OF_BOUNDS_PTR` failed here |
| 17 | 17 | |
| 18 | 18 | error[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 | |
| 20 | 20 | | |
| 21 | 21 | LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) }; |
| 22 | 22 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -27,7 +27,7 @@ LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) }; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | error[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 | |
| 31 | 31 | | |
| 32 | 32 | LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) }; |
| 33 | 33 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -37,8 +37,8 @@ LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) }; |
| 37 | 37 | HEX_DUMP |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | error[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 | |
| 40 | error[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 | |
| 42 | 42 | | |
| 43 | 43 | LL | const UNINIT: NonZero<u8> = unsafe { MaybeUninit { uninit: () }.init }; |
| 44 | 44 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNINIT` failed here |
| ... | ... | @@ -48,25 +48,25 @@ LL | const UNINIT: NonZero<u8> = unsafe { MaybeUninit { uninit: () }.init }; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | error[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 | |
| 52 | 52 | | |
| 53 | 53 | LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe { |
| 54 | 54 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 55 | 55 | | |
| 56 | 56 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 57 | 57 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 58 | HEX_DUMP | |
| 58 | HEX_DUMP ╾ALLOC$ID╼ │ ╾─╼ │ ╾─╼ | |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | error[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 | |
| 63 | 63 | | |
| 64 | 64 | LL | const MAYBE_NULL_PTR: NonNull<()> = unsafe { mem::transmute((&raw const S).wrapping_add(4)) }; |
| 65 | 65 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 66 | 66 | | |
| 67 | 67 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 68 | 68 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 69 | HEX_DUMP | |
| 69 | ╾ALLOC$ID╼ │ ╾─╼ | |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | error: aborting due to 7 previous errors |
tests/ui/consts/const-eval/ub-ref-ptr.rs+3-1| ... | ... | @@ -4,9 +4,11 @@ |
| 4 | 4 | //@ normalize-stderr: "([0-9a-f][0-9a-f] |__ |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP" |
| 5 | 5 | //@ dont-require-annotations: NOTE |
| 6 | 6 | //@ normalize-stderr: "0x[0-9](\.\.|\])" -> "0x%$1" |
| 7 | //@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼" | |
| 8 | ||
| 7 | 9 | #![feature(pattern_types, pattern_type_macro)] |
| 8 | 10 | #![allow(invalid_value)] |
| 9 | //@ ignore-parallel-frontend different alloc ids | |
| 11 | ||
| 10 | 12 | use std::{mem, pat::pattern_type}; |
| 11 | 13 | |
| 12 | 14 | #[repr(C)] |
tests/ui/consts/const-eval/ub-ref-ptr.stderr+28-28| ... | ... | @@ -1,27 +1,27 @@ |
| 1 | 1 | error[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 | |
| 3 | 3 | | |
| 4 | 4 | LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; |
| 5 | 5 | | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 6 | 6 | | |
| 7 | 7 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 8 | 8 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 9 | HEX_DUMP | |
| 9 | ╾ALLOC$ID╼ │ ╾─╼ | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | error[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 | |
| 14 | 14 | | |
| 15 | 15 | LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) }; |
| 16 | 16 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 17 | 17 | | |
| 18 | 18 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 19 | 19 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 20 | HEX_DUMP | |
| 20 | ╾ALLOC$ID╼ │ ╾─╼ | |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | error[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 | |
| 25 | 25 | | |
| 26 | 26 | LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; |
| 27 | 27 | | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -32,7 +32,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | error[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 | |
| 36 | 36 | | |
| 37 | 37 | LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; |
| 38 | 38 | | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -43,18 +43,18 @@ LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | error[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 | |
| 47 | 47 | | |
| 48 | 48 | LL | const MAYBE_NULL_BOX: Box<()> = unsafe { mem::transmute({ |
| 49 | 49 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 50 | 50 | | |
| 51 | 51 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 52 | 52 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 53 | HEX_DUMP | |
| 53 | ╾ALLOC$ID╼ │ ╾─╼ | |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | error[E0080]: unable to turn pointer into integer |
| 57 | --> $DIR/ub-ref-ptr.rs:39:1 | |
| 57 | --> $DIR/ub-ref-ptr.rs:41:1 | |
| 58 | 58 | | |
| 59 | 59 | LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; |
| 60 | 60 | | ^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `REF_AS_USIZE` failed here |
| ... | ... | @@ -63,7 +63,7 @@ LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; |
| 63 | 63 | = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 64 | 64 | |
| 65 | 65 | error[E0080]: unable to turn pointer into integer |
| 66 | --> $DIR/ub-ref-ptr.rs:42:39 | |
| 66 | --> $DIR/ub-ref-ptr.rs:44:39 | |
| 67 | 67 | | |
| 68 | 68 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; |
| 69 | 69 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `REF_AS_USIZE_SLICE` failed here |
| ... | ... | @@ -72,13 +72,13 @@ LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; |
| 72 | 72 | = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 73 | 73 | |
| 74 | 74 | note: erroneous constant encountered |
| 75 | --> $DIR/ub-ref-ptr.rs:42:38 | |
| 75 | --> $DIR/ub-ref-ptr.rs:44:38 | |
| 76 | 76 | | |
| 77 | 77 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; |
| 78 | 78 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 79 | 79 | |
| 80 | 80 | error[E0080]: unable to turn pointer into integer |
| 81 | --> $DIR/ub-ref-ptr.rs:45:86 | |
| 81 | --> $DIR/ub-ref-ptr.rs:47:86 | |
| 82 | 82 | | |
| 83 | 83 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; |
| 84 | 84 | | ^^^^^^^^^^^^^^^^^^^^ 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 |
| 87 | 87 | = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 88 | 88 | |
| 89 | 89 | note: erroneous constant encountered |
| 90 | --> $DIR/ub-ref-ptr.rs:45:85 | |
| 90 | --> $DIR/ub-ref-ptr.rs:47:85 | |
| 91 | 91 | | |
| 92 | 92 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; |
| 93 | 93 | | ^^^^^^^^^^^^^^^^^^^^^ |
| 94 | 94 | |
| 95 | 95 | error[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 | |
| 97 | 97 | | |
| 98 | 98 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; |
| 99 | 99 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -104,7 +104,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | error[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 | |
| 108 | 108 | | |
| 109 | 109 | LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; |
| 110 | 110 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -114,8 +114,8 @@ LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; |
| 114 | 114 | HEX_DUMP |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | error[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 | |
| 117 | error[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 | |
| 119 | 119 | | |
| 120 | 120 | LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init }; |
| 121 | 121 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNINIT_PTR` failed here |
| ... | ... | @@ -125,7 +125,7 @@ LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init }; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | error[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 | |
| 129 | 129 | | |
| 130 | 130 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; |
| 131 | 131 | | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -135,8 +135,8 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; |
| 135 | 135 | HEX_DUMP |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | error[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 | |
| 138 | error[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 | |
| 140 | 140 | | |
| 141 | 141 | LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init }; |
| 142 | 142 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNINIT_FN_PTR` failed here |
| ... | ... | @@ -146,7 +146,7 @@ LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init }; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | error[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 | |
| 150 | 150 | | |
| 151 | 151 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; |
| 152 | 152 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -156,30 +156,30 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; |
| 156 | 156 | HEX_DUMP |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | error[E0080]: constructing invalid value of type fn(): encountered ALLOC3<imm>, but expected a function pointer | |
| 160 | --> $DIR/ub-ref-ptr.rs:63:1 | |
| 159 | error[E0080]: constructing invalid value of type fn(): encountered ALLOC$ID<imm>, but expected a function pointer | |
| 160 | --> $DIR/ub-ref-ptr.rs:65:1 | |
| 161 | 161 | | |
| 162 | 162 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; |
| 163 | 163 | | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 164 | 164 | | |
| 165 | 165 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 166 | 166 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 167 | HEX_DUMP | |
| 167 | ╾ALLOC$ID╼ │ ╾─╼ | |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | error[E0080]: constructing invalid value of type fn(): encountered ALLOC4+0xa, but expected a function pointer | |
| 171 | --> $DIR/ub-ref-ptr.rs:65:1 | |
| 170 | error[E0080]: constructing invalid value of type fn(): encountered ALLOC$ID+0xa, but expected a function pointer | |
| 171 | --> $DIR/ub-ref-ptr.rs:67:1 | |
| 172 | 172 | | |
| 173 | 173 | LL | const MAYBE_NULL_FN_PTR: fn() = unsafe { mem::transmute({ |
| 174 | 174 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 175 | 175 | | |
| 176 | 176 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 177 | 177 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 178 | HEX_DUMP | |
| 178 | ╾ALLOC$ID╼ │ ╾─╼ | |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | error[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 | |
| 183 | 183 | | |
| 184 | 184 | LL | ptr.read(); |
| 185 | 185 | | ^^^^^^^^^^ 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() = &{ |
| 6 | 6 | | |
| 7 | 7 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 8 | 8 | = note: the raw bytes of the constant (size: 8, align: 4) { |
| 9 | ╾ALLOC0<imm>╼ ╾ALLOC1╼ │ ╾──╼╾──╼ | |
| 9 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──╼╾──╼ | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | error: 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() = &{ |
| 6 | 6 | | |
| 7 | 7 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 8 | 8 | = note: the raw bytes of the constant (size: 16, align: 8) { |
| 9 | ╾ALLOC0<imm>╼ ╾ALLOC1╼ │ ╾──────╼╾──────╼ | |
| 9 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | error: aborting due to 1 previous error |
tests/ui/consts/const-eval/ub-upvars.rs+1-1| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | //@ edition:2015..2021 |
| 2 | 2 | //@ stderr-per-bitwidth |
| 3 | 3 | #![allow(invalid_value)] // make sure we cannot allow away the errors tested here |
| 4 | //@ ignore-parallel-frontend different alloc ids | |
| 4 | ||
| 5 | 5 | use std::mem; |
| 6 | 6 | |
| 7 | 7 | const BAD_UPVAR: &dyn FnOnce() = &{ //~ ERROR null reference |
tests/ui/consts/const-eval/ub-wide-ptr.rs+2-2| ... | ... | @@ -3,13 +3,14 @@ |
| 3 | 3 | #![feature(ptr_metadata)] |
| 4 | 4 | |
| 5 | 5 | use std::{ptr, mem}; |
| 6 | //@ ignore-parallel-frontend different alloc ids | |
| 6 | ||
| 7 | 7 | // Strip out raw byte dumps to make comparison platform-independent: |
| 8 | 8 | //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" |
| 9 | 9 | //@ normalize-stderr: "([0-9a-f][0-9a-f] |__ |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP" |
| 10 | 10 | //@ normalize-stderr: "offset \d+" -> "offset N" |
| 11 | 11 | //@ normalize-stderr: "size \d+" -> "size N" |
| 12 | 12 | //@ normalize-stderr: "0x[0-9](\.\.|\])" -> "0x%$1" |
| 13 | //@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼" | |
| 13 | 14 | //@ dont-require-annotations: NOTE |
| 14 | 15 | |
| 15 | 16 | /// 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: |
| 137 | 138 | // Officially blessed way to get the vtable |
| 138 | 139 | const DYN_METADATA: ptr::DynMetadata<dyn Send> = ptr::metadata::<dyn Send>(ptr::null::<i32>()); |
| 139 | 140 | |
| 140 | ||
| 141 | 141 | static mut RAW_TRAIT_OBJ_VTABLE_NULL_THROUGH_REF: *const dyn Trait = unsafe { |
| 142 | 142 | mem::transmute::<_, &dyn Trait>((&92u8, 0usize)) |
| 143 | 143 | //~^^ ERROR null pointer |
tests/ui/consts/const-eval/ub-wide-ptr.stderr+63-63| ... | ... | @@ -1,27 +1,27 @@ |
| 1 | 1 | error[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 | |
| 3 | 3 | | |
| 4 | 4 | LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; |
| 5 | 5 | | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 6 | 6 | | |
| 7 | 7 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 8 | 8 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 9 | HEX_DUMP | |
| 9 | ╾ALLOC$ID╼ HEX_DUMP | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | error[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 | |
| 14 | 14 | | |
| 15 | 15 | LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); |
| 16 | 16 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 17 | 17 | | |
| 18 | 18 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 19 | 19 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 20 | HEX_DUMP | |
| 20 | ╾ALLOC$ID╼ HEX_DUMP | |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | error[E0080]: unable to turn pointer into integer |
| 24 | --> $DIR/ub-wide-ptr.rs:45:1 | |
| 24 | --> $DIR/ub-wide-ptr.rs:46:1 | |
| 25 | 25 | | |
| 26 | 26 | LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) }; |
| 27 | 27 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `STR_LENGTH_PTR` failed here |
| ... | ... | @@ -30,7 +30,7 @@ LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) }; |
| 30 | 30 | = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 31 | 31 | |
| 32 | 32 | error[E0080]: unable to turn pointer into integer |
| 33 | --> $DIR/ub-wide-ptr.rs:48:1 | |
| 33 | --> $DIR/ub-wide-ptr.rs:49:1 | |
| 34 | 34 | | |
| 35 | 35 | LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) }; |
| 36 | 36 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `MY_STR_LENGTH_PTR` failed here |
| ... | ... | @@ -39,40 +39,40 @@ LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) }; |
| 39 | 39 | = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 40 | 40 | |
| 41 | 41 | error[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 | |
| 43 | 43 | | |
| 44 | 44 | LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; |
| 45 | 45 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 46 | 46 | | |
| 47 | 47 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 48 | 48 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 49 | HEX_DUMP | |
| 49 | ╾ALLOC$ID╼ HEX_DUMP | |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | error[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 | |
| 54 | 54 | | |
| 55 | 55 | LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; |
| 56 | 56 | | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 57 | 57 | | |
| 58 | 58 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 59 | 59 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 60 | HEX_DUMP | |
| 60 | ╾ALLOC$ID╼ HEX_DUMP | |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | error[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 | |
| 65 | 65 | | |
| 66 | 66 | LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; |
| 67 | 67 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 68 | 68 | | |
| 69 | 69 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 70 | 70 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 71 | HEX_DUMP | |
| 71 | ╾ALLOC$ID╼ HEX_DUMP | |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | error[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 | |
| 74 | error[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 | |
| 76 | 76 | | |
| 77 | 77 | LL | const SLICE_LENGTH_UNINIT: &[u8] = unsafe { |
| 78 | 78 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SLICE_LENGTH_UNINIT` failed here |
| ... | ... | @@ -82,29 +82,29 @@ LL | const SLICE_LENGTH_UNINIT: &[u8] = unsafe { |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | error[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 | |
| 86 | 86 | | |
| 87 | 87 | LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; |
| 88 | 88 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 89 | 89 | | |
| 90 | 90 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 91 | 91 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 92 | HEX_DUMP | |
| 92 | ╾ALLOC$ID╼ HEX_DUMP | |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | error[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 | |
| 97 | 97 | | |
| 98 | 98 | LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; |
| 99 | 99 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 100 | 100 | | |
| 101 | 101 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 102 | 102 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 103 | HEX_DUMP | |
| 103 | ╾ALLOC$ID╼ HEX_DUMP | |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | error[E0080]: unable to turn pointer into integer |
| 107 | --> $DIR/ub-wide-ptr.rs:76:1 | |
| 107 | --> $DIR/ub-wide-ptr.rs:77:1 | |
| 108 | 108 | | |
| 109 | 109 | LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) }; |
| 110 | 110 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SLICE_LENGTH_PTR` failed here |
| ... | ... | @@ -113,18 +113,18 @@ LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) }; |
| 113 | 113 | = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 114 | 114 | |
| 115 | 115 | error[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 | |
| 117 | 117 | | |
| 118 | 118 | LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; |
| 119 | 119 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 120 | 120 | | |
| 121 | 121 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 122 | 122 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 123 | HEX_DUMP | |
| 123 | ╾ALLOC$ID╼ HEX_DUMP | |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | error[E0080]: unable to turn pointer into integer |
| 127 | --> $DIR/ub-wide-ptr.rs:82:1 | |
| 127 | --> $DIR/ub-wide-ptr.rs:83:1 | |
| 128 | 128 | | |
| 129 | 129 | LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) }; |
| 130 | 130 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) |
| 133 | 133 | = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported |
| 134 | 134 | |
| 135 | 135 | error[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 | |
| 137 | 137 | | |
| 138 | 138 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; |
| 139 | 139 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 140 | 140 | | |
| 141 | 141 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 142 | 142 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 143 | HEX_DUMP | |
| 143 | ╾ALLOC$ID╼ │ ╾─╼ | |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | note: erroneous constant encountered |
| 147 | --> $DIR/ub-wide-ptr.rs:86:40 | |
| 147 | --> $DIR/ub-wide-ptr.rs:87:40 | |
| 148 | 148 | | |
| 149 | 149 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; |
| 150 | 150 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 151 | 151 | |
| 152 | 152 | error[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 | |
| 154 | 154 | | |
| 155 | 155 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); |
| 156 | 156 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 157 | 157 | | |
| 158 | 158 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 159 | 159 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 160 | HEX_DUMP | |
| 160 | ╾ALLOC$ID╼ │ ╾─╼ | |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | note: erroneous constant encountered |
| 164 | --> $DIR/ub-wide-ptr.rs:92:42 | |
| 164 | --> $DIR/ub-wide-ptr.rs:93:42 | |
| 165 | 165 | | |
| 166 | 166 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); |
| 167 | 167 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 168 | 168 | |
| 169 | 169 | error[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 | |
| 171 | 171 | | |
| 172 | 172 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); |
| 173 | 173 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 174 | 174 | | |
| 175 | 175 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 176 | 176 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 177 | HEX_DUMP | |
| 177 | ╾ALLOC$ID╼ │ ╾─╼ | |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | note: erroneous constant encountered |
| 181 | --> $DIR/ub-wide-ptr.rs:95:42 | |
| 181 | --> $DIR/ub-wide-ptr.rs:96:42 | |
| 182 | 182 | | |
| 183 | 183 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); |
| 184 | 184 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 185 | 185 | |
| 186 | error[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 | |
| 186 | error[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 | |
| 188 | 188 | | |
| 189 | 189 | LL | const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe { |
| 190 | 190 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `RAW_SLICE_LENGTH_UNINIT` failed here |
| ... | ... | @@ -193,114 +193,114 @@ LL | const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe { |
| 193 | 193 | HEX_DUMP |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | error[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 | |
| 196 | error[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 | |
| 198 | 198 | | |
| 199 | 199 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; |
| 200 | 200 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 201 | 201 | | |
| 202 | 202 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 203 | 203 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 204 | HEX_DUMP | |
| 204 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼ | |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | error[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 | |
| 207 | error[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 | |
| 209 | 209 | | |
| 210 | 210 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; |
| 211 | 211 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 212 | 212 | | |
| 213 | 213 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 214 | 214 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 215 | HEX_DUMP | |
| 215 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼ | |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | error[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 | |
| 220 | 220 | | |
| 221 | 221 | LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; |
| 222 | 222 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 223 | 223 | | |
| 224 | 224 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 225 | 225 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 226 | HEX_DUMP | |
| 226 | ╾ALLOC$ID╼ HEX_DUMP | |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC17<imm>, but expected a vtable pointer | |
| 230 | --> $DIR/ub-wide-ptr.rs:118:1 | |
| 229 | error[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 | |
| 231 | 231 | | |
| 232 | 232 | LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) }; |
| 233 | 233 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 234 | 234 | | |
| 235 | 235 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 236 | 236 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 237 | HEX_DUMP | |
| 237 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼ | |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC19<imm>, but expected a vtable pointer | |
| 241 | --> $DIR/ub-wide-ptr.rs:120:1 | |
| 240 | error[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 | |
| 242 | 242 | | |
| 243 | 243 | LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) }; |
| 244 | 244 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 245 | 245 | | |
| 246 | 246 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 247 | 247 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 248 | HEX_DUMP | |
| 248 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼ | |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | error[E0080]: constructing invalid value of type &dyn Trait: encountered ALLOC21<imm>, but expected a vtable pointer | |
| 252 | --> $DIR/ub-wide-ptr.rs:122:1 | |
| 251 | error[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 | |
| 253 | 253 | | |
| 254 | 254 | LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) }; |
| 255 | 255 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 256 | 256 | | |
| 257 | 257 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 258 | 258 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 259 | HEX_DUMP | |
| 259 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼ | |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | error[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 | |
| 262 | error[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 | |
| 264 | 264 | | |
| 265 | 265 | LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; |
| 266 | 266 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 267 | 267 | | |
| 268 | 268 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 269 | 269 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 270 | HEX_DUMP | |
| 270 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼ | |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | error[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 | |
| 275 | 275 | | |
| 276 | 276 | LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; |
| 277 | 277 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 278 | 278 | | |
| 279 | 279 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 280 | 280 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 281 | HEX_DUMP | |
| 281 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼ | |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | error[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 | |
| 286 | 286 | | |
| 287 | 287 | LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; |
| 288 | 288 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 289 | 289 | | |
| 290 | 290 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 291 | 291 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 292 | HEX_DUMP | |
| 292 | ╾ALLOC$ID╼ HEX_DUMP | |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | error[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 | |
| 295 | error[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 | |
| 297 | 297 | | |
| 298 | 298 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; |
| 299 | 299 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 300 | 300 | | |
| 301 | 301 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 302 | 302 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 303 | HEX_DUMP | |
| 303 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼ | |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | error[E0080]: constructing invalid value of type *const dyn Trait: encountered null pointer, but expected a vtable pointer |
| ... | ... | @@ -311,10 +311,10 @@ LL | static mut RAW_TRAIT_OBJ_VTABLE_NULL_THROUGH_REF: *const dyn Trait = unsafe |
| 311 | 311 | | |
| 312 | 312 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 313 | 313 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 314 | HEX_DUMP | |
| 314 | ╾ALLOC$ID╼ HEX_DUMP | |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | error[E0080]: constructing invalid value of type *const dyn Trait: encountered ALLOC31<imm>, but expected a vtable pointer | |
| 317 | error[E0080]: constructing invalid value of type *const dyn Trait: encountered ALLOC$ID<imm>, but expected a vtable pointer | |
| 318 | 318 | --> $DIR/ub-wide-ptr.rs:145:1 |
| 319 | 319 | | |
| 320 | 320 | LL | static mut RAW_TRAIT_OBJ_VTABLE_INVALID_THROUGH_REF: *const dyn Trait = unsafe { |
| ... | ... | @@ -322,7 +322,7 @@ LL | static mut RAW_TRAIT_OBJ_VTABLE_INVALID_THROUGH_REF: *const dyn Trait = uns |
| 322 | 322 | | |
| 323 | 323 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 324 | 324 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 325 | HEX_DUMP | |
| 325 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼ | |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | error: aborting due to 29 previous errors |
tests/ui/consts/const-eval/union-const-eval-field.rs+1-1| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | //@ dont-require-annotations: NOTE |
| 2 | 2 | //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" |
| 3 | 3 | //@ normalize-stderr: "([[:xdigit:]]{2}\s){4}(__\s){4}\s+│\s+([?|\.]){4}\W{4}" -> "HEX_DUMP" |
| 4 | //@ ignore-parallel-frontend different alloc ids | |
| 4 | ||
| 5 | 5 | type Field1 = i32; |
| 6 | 6 | type Field2 = f32; |
| 7 | 7 | type Field3 = i64; |
tests/ui/consts/const-eval/union-const-eval-field.stderr+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | error[E0080]: reading memory at ALLOC0[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory | |
| 1 | error[E0080]: reading memory at ALLOC$ID[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory | |
| 2 | 2 | --> $DIR/union-const-eval-field.rs:30:37 |
| 3 | 3 | | |
| 4 | 4 | LL | const FIELD3: Field3 = unsafe { UNION.field3 }; |
tests/ui/consts/const-eval/union-ice.rs+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | //@ only-x86_64 |
| 2 | //@ ignore-parallel-frontend different alloc ids | |
| 2 | ||
| 3 | 3 | type Field1 = i32; |
| 4 | 4 | type Field3 = i64; |
| 5 | 5 |
tests/ui/consts/const-eval/union-ice.stderr+3-3| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | error[E0080]: reading memory at ALLOC0[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory | |
| 1 | error[E0080]: reading memory at ALLOC$ID[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory | |
| 2 | 2 | --> $DIR/union-ice.rs:14:33 |
| 3 | 3 | | |
| 4 | 4 | LL | const FIELD3: Field3 = unsafe { UNION.field3 }; |
| ... | ... | @@ -8,7 +8,7 @@ LL | const FIELD3: Field3 = unsafe { UNION.field3 }; |
| 8 | 8 | 00 00 80 3f __ __ __ __ │ ...?░░░░ |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | error[E0080]: reading memory at ALLOC1[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory | |
| 11 | error[E0080]: reading memory at ALLOC$ID[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory | |
| 12 | 12 | --> $DIR/union-ice.rs:19:17 |
| 13 | 13 | | |
| 14 | 14 | LL | b: unsafe { UNION.field3 }, |
| ... | ... | @@ -18,7 +18,7 @@ LL | b: unsafe { UNION.field3 }, |
| 18 | 18 | 00 00 80 3f __ __ __ __ │ ...?░░░░ |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | error[E0080]: reading memory at ALLOC2[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory | |
| 21 | error[E0080]: reading memory at ALLOC$ID[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory | |
| 22 | 22 | --> $DIR/union-ice.rs:31:18 |
| 23 | 23 | | |
| 24 | 24 | LL | 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 }; |
| 9 | 9 | 2a │ * |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | error[E0080]: reading memory at ALLOC0[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory | |
| 12 | error[E0080]: reading memory at ALLOC$ID[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory | |
| 13 | 13 | --> $DIR/union-ub.rs:35:36 |
| 14 | 14 | | |
| 15 | 15 | LL | 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 }; |
| 9 | 9 | 2a │ * |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | error[E0080]: reading memory at ALLOC0[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory | |
| 12 | error[E0080]: reading memory at ALLOC$ID[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory | |
| 13 | 13 | --> $DIR/union-ub.rs:35:36 |
| 14 | 14 | | |
| 15 | 15 | LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool }; |
tests/ui/consts/const-eval/union-ub.rs+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | //@ stderr-per-bitwidth |
| 2 | 2 | //@ dont-require-annotations: NOTE |
| 3 | //@ ignore-parallel-frontend different alloc ids | |
| 3 | ||
| 4 | 4 | #[repr(C)] |
| 5 | 5 | union DummyUnion { |
| 6 | 6 | unit: (), |
tests/ui/consts/const-mut-refs/mut_ref_in_final.rs+1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" |
| 2 | 2 | //@ normalize-stderr: "( 0x[0-9a-f][0-9a-f] │)? ([0-9a-f][0-9a-f] |__ |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> " HEX_DUMP" |
| 3 | 3 | //@ normalize-stderr: "HEX_DUMP\s*\n\s*HEX_DUMP" -> "HEX_DUMP" |
| 4 | //@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼" | |
| 4 | 5 | //@ dont-require-annotations: NOTE |
| 5 | 6 | |
| 6 | 7 | use std::cell::UnsafeCell; |
tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr+20-20| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | error[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 | |
| 3 | 3 | | |
| 4 | 4 | LL | const B: *mut i32 = &mut 4; |
| 5 | 5 | | ^^^^^^ this mutable borrow refers to such a temporary |
| ... | ... | @@ -9,7 +9,7 @@ LL | const B: *mut i32 = &mut 4; |
| 9 | 9 | = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` |
| 10 | 10 | |
| 11 | 11 | error[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 | |
| 13 | 13 | | |
| 14 | 14 | LL | const B3: Option<&mut i32> = Some(&mut 42); |
| 15 | 15 | | ^^^^^^^ this mutable borrow refers to such a temporary |
| ... | ... | @@ -19,7 +19,7 @@ LL | const B3: Option<&mut i32> = Some(&mut 42); |
| 19 | 19 | = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` |
| 20 | 20 | |
| 21 | 21 | error[E0716]: temporary value dropped while borrowed |
| 22 | --> $DIR/mut_ref_in_final.rs:24:42 | |
| 22 | --> $DIR/mut_ref_in_final.rs:25:42 | |
| 23 | 23 | | |
| 24 | 24 | LL | const B4: Option<&mut i32> = helper(&mut 42); |
| 25 | 25 | | ------------^^- |
| ... | ... | @@ -29,29 +29,29 @@ LL | const B4: Option<&mut i32> = helper(&mut 42); |
| 29 | 29 | | using this value as a constant requires that borrow lasts for `'static` |
| 30 | 30 | |
| 31 | 31 | error[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 | |
| 33 | 33 | | |
| 34 | 34 | LL | const IMMUT_MUT_REF: &mut u16 = unsafe { mem::transmute(&13) }; |
| 35 | 35 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 36 | 36 | | |
| 37 | 37 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 38 | 38 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 39 | HEX_DUMP | |
| 39 | ╾ALLOC$ID╼ │ ╾─╼ | |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | error[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 | |
| 44 | 44 | | |
| 45 | 45 | LL | static IMMUT_MUT_REF_STATIC: &mut u16 = unsafe { mem::transmute(&13) }; |
| 46 | 46 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 47 | 47 | | |
| 48 | 48 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 49 | 49 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 50 | HEX_DUMP | |
| 50 | ╾ALLOC$ID╼ │ ╾─╼ | |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | error[E0716]: temporary value dropped while borrowed |
| 54 | --> $DIR/mut_ref_in_final.rs:52:65 | |
| 54 | --> $DIR/mut_ref_in_final.rs:53:65 | |
| 55 | 55 | | |
| 56 | 56 | LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); |
| 57 | 57 | | -------------------------------^^-- |
| ... | ... | @@ -61,7 +61,7 @@ LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); |
| 61 | 61 | | using this value as a constant requires that borrow lasts for `'static` |
| 62 | 62 | |
| 63 | 63 | error[E0716]: temporary value dropped while borrowed |
| 64 | --> $DIR/mut_ref_in_final.rs:55:67 | |
| 64 | --> $DIR/mut_ref_in_final.rs:56:67 | |
| 65 | 65 | | |
| 66 | 66 | LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); |
| 67 | 67 | | -------------------------------^^-- |
| ... | ... | @@ -71,7 +71,7 @@ LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); |
| 71 | 71 | | using this value as a static requires that borrow lasts for `'static` |
| 72 | 72 | |
| 73 | 73 | error[E0716]: temporary value dropped while borrowed |
| 74 | --> $DIR/mut_ref_in_final.rs:58:71 | |
| 74 | --> $DIR/mut_ref_in_final.rs:59:71 | |
| 75 | 75 | | |
| 76 | 76 | LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); |
| 77 | 77 | | -------------------------------^^-- |
| ... | ... | @@ -81,7 +81,7 @@ LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); |
| 81 | 81 | | using this value as a static requires that borrow lasts for `'static` |
| 82 | 82 | |
| 83 | 83 | error[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 | |
| 85 | 85 | | |
| 86 | 86 | LL | static RAW_MUT_CAST_S: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ }; |
| 87 | 87 | | ^^^^^^^ 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 |
| 91 | 91 | = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` |
| 92 | 92 | |
| 93 | 93 | error[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 | |
| 95 | 95 | | |
| 96 | 96 | LL | static RAW_MUT_COERCE_S: SyncPtr<i32> = SyncPtr { x: &mut 0 }; |
| 97 | 97 | | ^^^^^^ this mutable borrow refers to such a temporary |
| ... | ... | @@ -101,7 +101,7 @@ LL | static RAW_MUT_COERCE_S: SyncPtr<i32> = SyncPtr { x: &mut 0 }; |
| 101 | 101 | = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` |
| 102 | 102 | |
| 103 | 103 | error[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 | |
| 105 | 105 | | |
| 106 | 106 | LL | const RAW_MUT_CAST_C: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ }; |
| 107 | 107 | | ^^^^^^^ 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 |
| 111 | 111 | = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` |
| 112 | 112 | |
| 113 | 113 | error[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 | |
| 115 | 115 | | |
| 116 | 116 | LL | const RAW_MUT_COERCE_C: SyncPtr<i32> = SyncPtr { x: &mut 0 }; |
| 117 | 117 | | ^^^^^^ this mutable borrow refers to such a temporary |
| ... | ... | @@ -121,7 +121,7 @@ LL | const RAW_MUT_COERCE_C: SyncPtr<i32> = SyncPtr { x: &mut 0 }; |
| 121 | 121 | = help: if you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` |
| 122 | 122 | |
| 123 | 123 | error[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 | |
| 125 | 125 | | |
| 126 | 126 | LL | const INT2PTR: Option<&mut i32> = helper_int2ptr(); |
| 127 | 127 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -132,7 +132,7 @@ LL | const INT2PTR: Option<&mut i32> = helper_int2ptr(); |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | error[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 | |
| 136 | 136 | | |
| 137 | 137 | LL | static INT2PTR_STATIC: Option<&mut i32> = helper_int2ptr(); |
| 138 | 138 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| ... | ... | @@ -143,25 +143,25 @@ LL | static INT2PTR_STATIC: Option<&mut i32> = helper_int2ptr(); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | error[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 | |
| 147 | 147 | | |
| 148 | 148 | LL | const DANGLING: Option<&mut i32> = helper_dangling(); |
| 149 | 149 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 150 | 150 | | |
| 151 | 151 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 152 | 152 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 153 | HEX_DUMP | |
| 153 | ╾ALLOC$ID╼ │ ╾─╼ | |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | error[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 | |
| 158 | 158 | | |
| 159 | 159 | LL | static DANGLING_STATIC: Option<&mut i32> = helper_dangling(); |
| 160 | 160 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 161 | 161 | | |
| 162 | 162 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 163 | 163 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 164 | HEX_DUMP | |
| 164 | ╾ALLOC$ID╼ │ ╾─╼ | |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | error: aborting due to 16 previous errors |
tests/ui/consts/const_refs_to_static_fail_invalid.rs+1| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" |
| 2 | 2 | //@ 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╼ │ ╾─╼" | |
| 3 | 4 | //@ dont-require-annotations: NOTE |
| 4 | 5 | |
| 5 | 6 | #![allow(static_mut_refs)] |
tests/ui/consts/const_refs_to_static_fail_invalid.stderr+4-4| ... | ... | @@ -1,16 +1,16 @@ |
| 1 | 1 | error[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 | |
| 3 | 3 | | |
| 4 | 4 | LL | const C: &bool = unsafe { std::mem::transmute(&S) }; |
| 5 | 5 | | ^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 6 | 6 | | |
| 7 | 7 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 8 | 8 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 9 | HEX_DUMP | |
| 9 | ╾ALLOC$ID╼ │ ╾─╼ | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | error: 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 | |
| 14 | 14 | | |
| 15 | 15 | LL | C => {} |
| 16 | 16 | | ^ |
| ... | ... | @@ -18,7 +18,7 @@ LL | C => {} |
| 18 | 18 | = note: constants that reference mutable or external memory cannot be used as patterns |
| 19 | 19 | |
| 20 | 20 | error: 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 | |
| 22 | 22 | | |
| 23 | 23 | LL | C => {} |
| 24 | 24 | | ^ |
tests/ui/consts/const_transmute_type_id7.rs+2| ... | ... | @@ -5,6 +5,8 @@ |
| 5 | 5 | //@ normalize-stderr: "\[&\(\); \d\]" -> "ARRAY" |
| 6 | 6 | //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" |
| 7 | 7 | //@ 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: "╾[╼╾─]*╼" -> "╾─╼" | |
| 8 | 10 | |
| 9 | 11 | #![feature(const_trait_impl, const_cmp)] |
| 10 | 12 |
tests/ui/consts/const_transmute_type_id7.stderr+2-2| ... | ... | @@ -1,12 +1,12 @@ |
| 1 | 1 | error[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 | |
| 3 | 3 | | |
| 4 | 4 | LL | const A: [&(); 16 / size_of::<*const ()>()] = unsafe { transmute(TypeId::of::<i32>()) }; |
| 5 | 5 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 6 | 6 | | |
| 7 | 7 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 8 | 8 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 9 | HEX_DUMP | |
| 9 | ╾ALLOC$IDs╼│ ╾─╼ | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | error: aborting due to 1 previous error |
tests/ui/consts/copy-intrinsic.rs+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | // ignore-tidy-linelength |
| 2 | 2 | #![feature(core_intrinsics)] |
| 3 | //@ ignore-parallel-frontend different alloc ids | |
| 3 | ||
| 4 | 4 | use std::intrinsics::{copy, copy_nonoverlapping}; |
| 5 | 5 | use std::mem; |
| 6 | 6 |
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[ |
| 4 | 4 | LL | copy_nonoverlapping(0x100 as *const i32, dangle, 1); |
| 5 | 5 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `COPY_OOB_1` failed here |
| 6 | 6 | |
| 7 | error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0+0x28 which is at or beyond the end of the allocation of size 4 bytes | |
| 7 | error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID+0x28 which is at or beyond the end of the allocation of size 4 bytes | |
| 8 | 8 | --> $DIR/copy-intrinsic.rs:28:5 |
| 9 | 9 | | |
| 10 | 10 | LL | copy_nonoverlapping(dangle, 0x100 as *mut i32, 1); |
tests/ui/consts/dangling-alloc-id-ice.rs+1| ... | ... | @@ -3,6 +3,7 @@ |
| 3 | 3 | //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" |
| 4 | 4 | //@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*A(LLOC)?[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP" |
| 5 | 5 | //@ normalize-stderr: "HEX_DUMP\s*\n\s*HEX_DUMP" -> "HEX_DUMP" |
| 6 | //@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼" | |
| 6 | 7 | |
| 7 | 8 | union Foo<'a> { |
| 8 | 9 | y: &'a (), |
tests/ui/consts/dangling-alloc-id-ice.stderr+2-2| ... | ... | @@ -1,12 +1,12 @@ |
| 1 | 1 | error[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 | |
| 3 | 3 | | |
| 4 | 4 | LL | const FOO: &() = { |
| 5 | 5 | | ^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 6 | 6 | | |
| 7 | 7 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 8 | 8 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 9 | HEX_DUMP | |
| 9 | ╾ALLOC$ID╼ │ ╾─╼ | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | error: aborting due to 1 previous error |
tests/ui/consts/dangling-zst-ice-issue-126393.rs+1| ... | ... | @@ -2,6 +2,7 @@ |
| 2 | 2 | //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" |
| 3 | 3 | //@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*A(LLOC)?[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP" |
| 4 | 4 | //@ normalize-stderr: "HEX_DUMP\s*\n\s*HEX_DUMP" -> "HEX_DUMP" |
| 5 | //@ normalize-stderr: "╾ALLOC\$ID╼\s+│.*╾.*╼" -> "╾ALLOC$$ID╼ │ ╾─╼" | |
| 5 | 6 | |
| 6 | 7 | pub struct Wrapper; |
| 7 | 8 | pub static MAGIC_FFI_REF: &'static Wrapper = unsafe { |
tests/ui/consts/dangling-zst-ice-issue-126393.stderr+2-2| ... | ... | @@ -1,12 +1,12 @@ |
| 1 | 1 | error[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 | |
| 3 | 3 | | |
| 4 | 4 | LL | pub static MAGIC_FFI_REF: &'static Wrapper = unsafe { |
| 5 | 5 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 6 | 6 | | |
| 7 | 7 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 8 | 8 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 9 | HEX_DUMP | |
| 9 | ╾ALLOC$ID╼ │ ╾─╼ | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | error: 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() { |
| 6 | 6 | | |
| 7 | 7 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 8 | 8 | = note: the raw bytes of the constant (size: 4, align: 4) { |
| 9 | ╾ALLOC0╼ │ ╾──╼ | |
| 9 | ╾ALLOC$ID╼ │ ╾──╼ | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | note: erroneous constant encountered |
tests/ui/consts/interior-mut-const-via-union.64bit.stderr+1-1| ... | ... | @@ -6,7 +6,7 @@ LL | fn main() { |
| 6 | 6 | | |
| 7 | 7 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 8 | 8 | = note: the raw bytes of the constant (size: 8, align: 8) { |
| 9 | ╾ALLOC0╼ │ ╾──────╼ | |
| 9 | ╾ALLOC$ID╼ │ ╾──────╼ | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | note: erroneous constant encountered |
tests/ui/consts/interior-mut-const-via-union.rs+1-1| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 | // |
| 4 | 4 | //@ build-fail |
| 5 | 5 | //@ stderr-per-bitwidth |
| 6 | //@ ignore-parallel-frontend different alloc ids | |
| 6 | ||
| 7 | 7 | use std::cell::Cell; |
| 8 | 8 | use std::mem::ManuallyDrop; |
| 9 | 9 |
tests/ui/consts/issue-63952.32bit.stderr+1-1| ... | ... | @@ -6,7 +6,7 @@ LL | const SLICE_WAY_TOO_LONG: &[u8] = unsafe { |
| 6 | 6 | | |
| 7 | 7 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 8 | 8 | = 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 │ ╾──╼.... | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | error: 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 { |
| 6 | 6 | | |
| 7 | 7 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 8 | 8 | = 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 │ ╾──────╼........ | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | error: aborting due to 1 previous error |
tests/ui/consts/issue-63952.rs+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | // Regression test for #63952, shouldn't hang. |
| 2 | 2 | //@ stderr-per-bitwidth |
| 3 | //@ ignore-parallel-frontend different alloc ids | |
| 3 | ||
| 4 | 4 | #[repr(C)] |
| 5 | 5 | #[derive(Copy, Clone)] |
| 6 | 6 | struct SliceRepr { |
tests/ui/consts/issue-79690.64bit.stderr+1-1| ... | ... | @@ -6,7 +6,7 @@ LL | const G: Fat = unsafe { Transmute { t: FOO }.u }; |
| 6 | 6 | | |
| 7 | 7 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 8 | 8 | = note: the raw bytes of the constant (size: 16, align: 8) { |
| 9 | ╾ALLOC0<imm>╼ ╾ALLOC1╼ │ ╾──────╼╾──────╼ | |
| 9 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾──────╼╾──────╼ | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | error: aborting due to 1 previous error |
tests/ui/consts/issue-79690.rs+1-1| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | //@ ignore-32bit |
| 2 | 2 | // This test gives a different error on 32-bit architectures. |
| 3 | 3 | //@ stderr-per-bitwidth |
| 4 | //@ ignore-parallel-frontend different alloc ids | |
| 4 | ||
| 5 | 5 | union Transmute<T: Copy, U: Copy> { |
| 6 | 6 | t: T, |
| 7 | 7 | u: U, |
tests/ui/consts/miri_unleashed/mutable_references.rs+1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | //@ compile-flags: -Zunleash-the-miri-inside-of-you |
| 2 | 2 | //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" |
| 3 | 3 | //@ 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╼ │ ╾─╼" | |
| 4 | 5 | //@ dont-require-annotations: NOTE |
| 5 | 6 | |
| 6 | 7 | #![allow(static_mut_refs)] |
tests/ui/consts/miri_unleashed/mutable_references.stderr+36-36| ... | ... | @@ -1,124 +1,124 @@ |
| 1 | 1 | error[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 | |
| 3 | 3 | | |
| 4 | 4 | LL | static FOO: &&mut u32 = &&mut 42; |
| 5 | 5 | | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 6 | 6 | | |
| 7 | 7 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 8 | 8 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 9 | HEX_DUMP | |
| 9 | ╾ALLOC$ID╼ │ ╾─╼ | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | error[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 | |
| 14 | 14 | | |
| 15 | 15 | LL | static OH_YES: &mut i32 = &mut 42; |
| 16 | 16 | | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 17 | 17 | | |
| 18 | 18 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 19 | 19 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 20 | HEX_DUMP | |
| 20 | ╾ALLOC$ID╼ │ ╾─╼ | |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | error: encountered mutable pointer in final value of static |
| 24 | --> $DIR/mutable_references.rs:17:1 | |
| 24 | --> $DIR/mutable_references.rs:18:1 | |
| 25 | 25 | | |
| 26 | 26 | LL | static BAR: &mut () = &mut (); |
| 27 | 27 | | ^^^^^^^^^^^^^^^^^^^ |
| 28 | 28 | |
| 29 | 29 | error: encountered mutable pointer in final value of static |
| 30 | --> $DIR/mutable_references.rs:22:1 | |
| 30 | --> $DIR/mutable_references.rs:23:1 | |
| 31 | 31 | | |
| 32 | 32 | LL | static BOO: &mut Foo<()> = &mut Foo(()); |
| 33 | 33 | | ^^^^^^^^^^^^^^^^^^^^^^^^ |
| 34 | 34 | |
| 35 | 35 | error[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 | |
| 37 | 37 | | |
| 38 | 38 | LL | const BLUNT: &mut i32 = &mut 42; |
| 39 | 39 | | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 40 | 40 | | |
| 41 | 41 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 42 | 42 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 43 | HEX_DUMP | |
| 43 | ╾ALLOC$ID╼ │ ╾─╼ | |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | error[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 | |
| 48 | 48 | | |
| 49 | 49 | LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) }; |
| 50 | 50 | | ^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 51 | 51 | | |
| 52 | 52 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 53 | 53 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 54 | HEX_DUMP | |
| 54 | ╾ALLOC$ID╼ │ ╾─╼ | |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | error[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 | |
| 59 | 59 | | |
| 60 | 60 | LL | const MUH: Meh = Meh { |
| 61 | 61 | | ^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 62 | 62 | | |
| 63 | 63 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 64 | 64 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 65 | HEX_DUMP | |
| 65 | ╾ALLOC$ID╼ │ ╾─╼ | |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | error[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 | |
| 70 | 70 | | |
| 71 | 71 | LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; |
| 72 | 72 | | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 73 | 73 | | |
| 74 | 74 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 75 | 75 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 76 | HEX_DUMP | |
| 76 | ╾ALLOC$ID╼ ╾ALLOC$ID╼ │ ╾─╼ | |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | error[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 | |
| 81 | 81 | | |
| 82 | 82 | LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) }; |
| 83 | 83 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 84 | 84 | | |
| 85 | 85 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 86 | 86 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 87 | HEX_DUMP | |
| 87 | ╾ALLOC$ID╼ │ ╾─╼ | |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | error[E0080]: constant accesses mutable global memory |
| 91 | --> $DIR/mutable_references.rs:73:43 | |
| 91 | --> $DIR/mutable_references.rs:74:43 | |
| 92 | 92 | | |
| 93 | 93 | LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF }; |
| 94 | 94 | | ^^^^^^^^^^^^^ evaluation of `POINTS_TO_MUTABLE2` failed here |
| 95 | 95 | |
| 96 | 96 | error: encountered mutable pointer in final value of constant |
| 97 | --> $DIR/mutable_references.rs:76:1 | |
| 97 | --> $DIR/mutable_references.rs:77:1 | |
| 98 | 98 | | |
| 99 | 99 | LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _; |
| 100 | 100 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 101 | 101 | |
| 102 | 102 | error: encountered mutable pointer in final value of constant |
| 103 | --> $DIR/mutable_references.rs:79:1 | |
| 103 | --> $DIR/mutable_references.rs:80:1 | |
| 104 | 104 | | |
| 105 | 105 | LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _; |
| 106 | 106 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 107 | 107 | |
| 108 | 108 | error: encountered mutable pointer in final value of constant |
| 109 | --> $DIR/mutable_references.rs:99:1 | |
| 109 | --> $DIR/mutable_references.rs:100:1 | |
| 110 | 110 | | |
| 111 | 111 | LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x: &mut 42 as *mut _ as *const _ }; |
| 112 | 112 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 113 | 113 | |
| 114 | 114 | error: encountered mutable pointer in final value of constant |
| 115 | --> $DIR/mutable_references.rs:102:1 | |
| 115 | --> $DIR/mutable_references.rs:103:1 | |
| 116 | 116 | | |
| 117 | 117 | LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 }; |
| 118 | 118 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 119 | 119 | |
| 120 | 120 | error[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 | |
| 122 | 122 | | |
| 123 | 123 | LL | static OH_YES: &mut i32 = &mut 42; |
| 124 | 124 | | ----------------------- this `static` cannot be written to |
| ... | ... | @@ -129,72 +129,72 @@ LL | *OH_YES = 99; |
| 129 | 129 | warning: skipping const checks |
| 130 | 130 | | |
| 131 | 131 | help: skipping check that does not even have a feature gate |
| 132 | --> $DIR/mutable_references.rs:13:26 | |
| 132 | --> $DIR/mutable_references.rs:14:26 | |
| 133 | 133 | | |
| 134 | 134 | LL | static FOO: &&mut u32 = &&mut 42; |
| 135 | 135 | | ^^^^^^^ |
| 136 | 136 | help: skipping check that does not even have a feature gate |
| 137 | --> $DIR/mutable_references.rs:15:27 | |
| 137 | --> $DIR/mutable_references.rs:16:27 | |
| 138 | 138 | | |
| 139 | 139 | LL | static OH_YES: &mut i32 = &mut 42; |
| 140 | 140 | | ^^^^^^^ |
| 141 | 141 | help: skipping check that does not even have a feature gate |
| 142 | --> $DIR/mutable_references.rs:17:23 | |
| 142 | --> $DIR/mutable_references.rs:18:23 | |
| 143 | 143 | | |
| 144 | 144 | LL | static BAR: &mut () = &mut (); |
| 145 | 145 | | ^^^^^^^ |
| 146 | 146 | help: skipping check that does not even have a feature gate |
| 147 | --> $DIR/mutable_references.rs:22:28 | |
| 147 | --> $DIR/mutable_references.rs:23:28 | |
| 148 | 148 | | |
| 149 | 149 | LL | static BOO: &mut Foo<()> = &mut Foo(()); |
| 150 | 150 | | ^^^^^^^^^^^^ |
| 151 | 151 | help: skipping check that does not even have a feature gate |
| 152 | --> $DIR/mutable_references.rs:25:25 | |
| 152 | --> $DIR/mutable_references.rs:26:25 | |
| 153 | 153 | | |
| 154 | 154 | LL | const BLUNT: &mut i32 = &mut 42; |
| 155 | 155 | | ^^^^^^^ |
| 156 | 156 | help: skipping check that does not even have a feature gate |
| 157 | --> $DIR/mutable_references.rs:40:28 | |
| 157 | --> $DIR/mutable_references.rs:41:28 | |
| 158 | 158 | | |
| 159 | 159 | LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) }; |
| 160 | 160 | | ^^^^^^^^^^^^^^^^^^^^ |
| 161 | 161 | help: skipping check that does not even have a feature gate |
| 162 | --> $DIR/mutable_references.rs:47:8 | |
| 162 | --> $DIR/mutable_references.rs:48:8 | |
| 163 | 163 | | |
| 164 | 164 | LL | x: &UnsafeCell::new(42), |
| 165 | 165 | | ^^^^^^^^^^^^^^^^^^^^ |
| 166 | 166 | help: skipping check that does not even have a feature gate |
| 167 | --> $DIR/mutable_references.rs:56:27 | |
| 167 | --> $DIR/mutable_references.rs:57:27 | |
| 168 | 168 | | |
| 169 | 169 | LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; |
| 170 | 170 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 171 | 171 | help: skipping check that does not even have a feature gate |
| 172 | --> $DIR/mutable_references.rs:76:45 | |
| 172 | --> $DIR/mutable_references.rs:77:45 | |
| 173 | 173 | | |
| 174 | 174 | LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _; |
| 175 | 175 | | ^^^^^^^ |
| 176 | 176 | help: skipping check that does not even have a feature gate |
| 177 | --> $DIR/mutable_references.rs:79:46 | |
| 177 | --> $DIR/mutable_references.rs:80:46 | |
| 178 | 178 | | |
| 179 | 179 | LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _; |
| 180 | 180 | | ^^^^^^^ |
| 181 | 181 | help: skipping check that does not even have a feature gate |
| 182 | --> $DIR/mutable_references.rs:84:47 | |
| 182 | --> $DIR/mutable_references.rs:85:47 | |
| 183 | 183 | | |
| 184 | 184 | LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; |
| 185 | 185 | | ^^^^^^^^^^^^^^^^^^^^ |
| 186 | 186 | help: skipping check that does not even have a feature gate |
| 187 | --> $DIR/mutable_references.rs:96:51 | |
| 187 | --> $DIR/mutable_references.rs:97:51 | |
| 188 | 188 | | |
| 189 | 189 | LL | const RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) }; |
| 190 | 190 | | ^^^^^^^^^^^^^^^^^^^ |
| 191 | 191 | help: skipping check that does not even have a feature gate |
| 192 | --> $DIR/mutable_references.rs:99:49 | |
| 192 | --> $DIR/mutable_references.rs:100:49 | |
| 193 | 193 | | |
| 194 | 194 | LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x: &mut 42 as *mut _ as *const _ }; |
| 195 | 195 | | ^^^^^^^ |
| 196 | 196 | help: skipping check that does not even have a feature gate |
| 197 | --> $DIR/mutable_references.rs:102:51 | |
| 197 | --> $DIR/mutable_references.rs:103:51 | |
| 198 | 198 | | |
| 199 | 199 | LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 }; |
| 200 | 200 | | ^^^^^^ |
tests/ui/consts/miri_unleashed/static-no-inner-mut.32bit.stderr+4-4| ... | ... | @@ -6,7 +6,7 @@ LL | static REF: &AtomicI32 = &AtomicI32::new(42); |
| 6 | 6 | | |
| 7 | 7 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 8 | 8 | = note: the raw bytes of the constant (size: 4, align: 4) { |
| 9 | ╾ALLOC0╼ │ ╾──╼ | |
| 9 | ╾ALLOC$ID╼ │ ╾──╼ | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | error[E0080]: constructing invalid value of type &mut i32: encountered mutable reference or box pointing to read-only memory |
| ... | ... | @@ -17,7 +17,7 @@ LL | static REFMUT: &mut i32 = &mut 0; |
| 17 | 17 | | |
| 18 | 18 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 19 | 19 | = note: the raw bytes of the constant (size: 4, align: 4) { |
| 20 | ╾ALLOC1╼ │ ╾──╼ | |
| 20 | ╾ALLOC$ID╼ │ ╾──╼ | |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | error[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}}; |
| 28 | 28 | | |
| 29 | 29 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 30 | 30 | = note: the raw bytes of the constant (size: 4, align: 4) { |
| 31 | ╾ALLOC2╼ │ ╾──╼ | |
| 31 | ╾ALLOC$ID╼ │ ╾──╼ | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | error[E0080]: constructing invalid value of type &mut i32: encountered mutable reference or box pointing to read-only memory |
| ... | ... | @@ -39,7 +39,7 @@ LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}}; |
| 39 | 39 | | |
| 40 | 40 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 41 | 41 | = note: the raw bytes of the constant (size: 4, align: 4) { |
| 42 | ╾ALLOC3╼ │ ╾──╼ | |
| 42 | ╾ALLOC$ID╼ │ ╾──╼ | |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | error: 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); |
| 6 | 6 | | |
| 7 | 7 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 8 | 8 | = note: the raw bytes of the constant (size: 8, align: 8) { |
| 9 | ╾ALLOC0╼ │ ╾──────╼ | |
| 9 | ╾ALLOC$ID╼ │ ╾──────╼ | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | error[E0080]: constructing invalid value of type &mut i32: encountered mutable reference or box pointing to read-only memory |
| ... | ... | @@ -17,7 +17,7 @@ LL | static REFMUT: &mut i32 = &mut 0; |
| 17 | 17 | | |
| 18 | 18 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 19 | 19 | = note: the raw bytes of the constant (size: 8, align: 8) { |
| 20 | ╾ALLOC1╼ │ ╾──────╼ | |
| 20 | ╾ALLOC$ID╼ │ ╾──────╼ | |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | error[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}}; |
| 28 | 28 | | |
| 29 | 29 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 30 | 30 | = note: the raw bytes of the constant (size: 8, align: 8) { |
| 31 | ╾ALLOC2╼ │ ╾──────╼ | |
| 31 | ╾ALLOC$ID╼ │ ╾──────╼ | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | error[E0080]: constructing invalid value of type &mut i32: encountered mutable reference or box pointing to read-only memory |
| ... | ... | @@ -39,7 +39,7 @@ LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}}; |
| 39 | 39 | | |
| 40 | 40 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 41 | 41 | = note: the raw bytes of the constant (size: 8, align: 8) { |
| 42 | ╾ALLOC3╼ │ ╾──────╼ | |
| 42 | ╾ALLOC$ID╼ │ ╾──────╼ | |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | error: encountered mutable pointer in final value of static |
tests/ui/consts/miri_unleashed/static-no-inner-mut.rs+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | //@ stderr-per-bitwidth |
| 2 | 2 | //@ compile-flags: -Zunleash-the-miri-inside-of-you |
| 3 | //@ ignore-parallel-frontend different alloc ids | |
| 3 | ||
| 4 | 4 | // All "inner" allocations that come with a `static` are interned immutably. This means it is |
| 5 | 5 | // crucial that we do not accept any form of (interior) mutability there. |
| 6 | 6 | use std::sync::atomic::*; |
tests/ui/consts/missing_span_in_backtrace.rs+1-1| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | //! Check what happens when the error occurs inside a std function that we can't print the span of. |
| 2 | 2 | //@ ignore-backends: gcc |
| 3 | 3 | //@ compile-flags: -Z ui-testing=no --diagnostic-width=80 |
| 4 | //@ ignore-parallel-frontend different alloc ids | |
| 4 | ||
| 5 | 5 | use std::{ |
| 6 | 6 | mem::{self, MaybeUninit}, |
| 7 | 7 | ptr, |
tests/ui/consts/missing_span_in_backtrace.stderr+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | error[E0080]: memory access failed: attempting to access 1 byte, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes | |
| 1 | error[E0080]: memory access failed: attempting to access 1 byte, but got ALLOC$ID+0x4 which is at or beyond the end of the allocation of size 4 bytes | |
| 2 | 2 | --> $DIR/missing_span_in_backtrace.rs:16:9 |
| 3 | 3 | | |
| 4 | 4 | 16 | / ... ptr::swap_nonoverlapping( |
tests/ui/consts/offset_ub.rs+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | use std::ptr; |
| 2 | //@ ignore-parallel-frontend different alloc ids | |
| 2 | ||
| 3 | 3 | //@ normalize-stderr: "0xf+" -> "0xf..f" |
| 4 | 4 | //@ normalize-stderr: "0x7f+" -> "0x7f..f" |
| 5 | 5 | //@ normalize-stderr: "\d+ bytes" -> "$$BYTES bytes" |
tests/ui/consts/offset_ub.stderr+5-5| ... | ... | @@ -1,16 +1,16 @@ |
| 1 | error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got ALLOC0 which is at the beginning of the allocation | |
| 1 | error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got ALLOC$ID which is at the beginning of the allocation | |
| 2 | 2 | --> $DIR/offset_ub.rs:8:46 |
| 3 | 3 | | |
| 4 | 4 | LL | pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) }; |
| 5 | 5 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BEFORE_START` failed here |
| 6 | 6 | |
| 7 | error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got ALLOC1 which is only 1 byte from the end of the allocation | |
| 7 | error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got ALLOC$ID which is only 1 byte from the end of the allocation | |
| 8 | 8 | --> $DIR/offset_ub.rs:9:43 |
| 9 | 9 | | |
| 10 | 10 | LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) }; |
| 11 | 11 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `AFTER_END` failed here |
| 12 | 12 | |
| 13 | error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got ALLOC2 which is only $BYTES bytes from the end of the allocation | |
| 13 | error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got ALLOC$ID which is only $BYTES bytes from the end of the allocation | |
| 14 | 14 | --> $DIR/offset_ub.rs:10:45 |
| 15 | 15 | | |
| 16 | 16 | LL | pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101) }; |
| ... | ... | @@ -40,13 +40,13 @@ error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer |
| 40 | 40 | LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) }; |
| 41 | 41 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNDERFLOW_ADDRESS_SPACE` failed here |
| 42 | 42 | |
| 43 | error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got ALLOC3-0x2 which points to before the beginning of the allocation | |
| 43 | error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got ALLOC$ID-0x2 which points to before the beginning of the allocation | |
| 44 | 44 | --> $DIR/offset_ub.rs:16:49 |
| 45 | 45 | | |
| 46 | 46 | LL | ...nst u8 = unsafe { [0u8; 1].as_ptr().wrapping_offset(-2).offset(-2) }; |
| 47 | 47 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `NEGATIVE_OFFSET` failed here |
| 48 | 48 | |
| 49 | error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 1 byte, but got ALLOC4 which is at or beyond the end of the allocation of size $BYTES bytes | |
| 49 | error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 1 byte, but got ALLOC$ID which is at or beyond the end of the allocation of size $BYTES bytes | |
| 50 | 50 | --> $DIR/offset_ub.rs:18:50 |
| 51 | 51 | | |
| 52 | 52 | LL | 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 | ||
| 3 | trait Trait { | |
| 4 | fn method(&self) -> Self; | |
| 5 | } | |
| 6 | ||
| 7 | pub struct S; | |
| 8 | impl Trait for S { | |
| 9 | fn method(&self) -> S { | |
| 10 | S | |
| 11 | } | |
| 12 | } | |
| 13 | ||
| 14 | mod private { | |
| 15 | pub struct W(super::S); | |
| 16 | } | |
| 17 | ||
| 18 | impl Trait for private::W { | |
| 19 | reuse Trait::method { S } | |
| 20 | //~^ ERROR: field `0` of struct `W` is private | |
| 21 | } | |
| 22 | ||
| 23 | impl private::W { | |
| 24 | reuse Trait::method { S } | |
| 25 | //~^ ERROR: field `0` of struct `W` is private | |
| 26 | } | |
| 27 | ||
| 28 | fn main() {} |
tests/ui/delegation/self-mapping-output-privacy.stderr created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | error[E0451]: field `0` of struct `W` is private | |
| 2 | --> $DIR/self-mapping-output-privacy.rs:19:18 | |
| 3 | | | |
| 4 | LL | reuse Trait::method { S } | |
| 5 | | ^^^^^^ private field | |
| 6 | ||
| 7 | error[E0451]: field `0` of struct `W` is private | |
| 8 | --> $DIR/self-mapping-output-privacy.rs:24:18 | |
| 9 | | | |
| 10 | LL | reuse Trait::method { S } | |
| 11 | | ^^^^^^ private field | |
| 12 | ||
| 13 | error: aborting due to 2 previous errors | |
| 14 | ||
| 15 | For 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 | ||
| 3 | mod 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 | ||
| 31 | mod 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 | ||
| 59 | mod 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 | ||
| 95 | mod 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 | ||
| 129 | mod 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 | ||
| 159 | mod 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 | ||
| 197 | mod 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 | ||
| 235 | mod 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 | ||
| 280 | mod 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 | ||
| 318 | mod 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 | ||
| 357 | fn main() {} |
tests/ui/delegation/self-mapping-output.stderr created+468| ... | ... | @@ -0,0 +1,468 @@ |
| 1 | error[E0560]: struct `no_constructor::W` has no field named `0` | |
| 2 | --> $DIR/self-mapping-output.rs:110:22 | |
| 3 | | | |
| 4 | LL | reuse Trait::method { self.0 } | |
| 5 | | ^^^^^^ unknown field | |
| 6 | | | |
| 7 | help: a field with a similar name exists | |
| 8 | | | |
| 9 | LL - reuse Trait::method { self.0 } | |
| 10 | LL + reuse Trait::s { self.0 } | |
| 11 | | | |
| 12 | ||
| 13 | error[E0609]: no field `0` on type `&no_constructor::W` | |
| 14 | --> $DIR/self-mapping-output.rs:110:36 | |
| 15 | | | |
| 16 | LL | reuse Trait::method { self.0 } | |
| 17 | | ^ unknown field | |
| 18 | | | |
| 19 | help: a field with a similar name exists | |
| 20 | | | |
| 21 | LL - reuse Trait::method { self.0 } | |
| 22 | LL + reuse Trait::method { self.s } | |
| 23 | | | |
| 24 | ||
| 25 | error[E0609]: no field `0` on type `&no_constructor::W` | |
| 26 | --> $DIR/self-mapping-output.rs:115:35 | |
| 27 | | | |
| 28 | LL | reuse Trait::raw_S { self.0 } | |
| 29 | | ^ unknown field | |
| 30 | | | |
| 31 | help: a field with a similar name exists | |
| 32 | | | |
| 33 | LL - reuse Trait::raw_S { self.0 } | |
| 34 | LL + reuse Trait::raw_S { self.s } | |
| 35 | | | |
| 36 | ||
| 37 | error[E0560]: struct `no_constructor::W` has no field named `0` | |
| 38 | --> $DIR/self-mapping-output.rs:120:22 | |
| 39 | | | |
| 40 | LL | reuse Trait::method { self.0 } | |
| 41 | | ^^^^^^ unknown field | |
| 42 | | | |
| 43 | help: a field with a similar name exists | |
| 44 | | | |
| 45 | LL - reuse Trait::method { self.0 } | |
| 46 | LL + reuse Trait::s { self.0 } | |
| 47 | | | |
| 48 | ||
| 49 | error[E0609]: no field `0` on type `&no_constructor::W` | |
| 50 | --> $DIR/self-mapping-output.rs:120:36 | |
| 51 | | | |
| 52 | LL | reuse Trait::method { self.0 } | |
| 53 | | ^ unknown field | |
| 54 | | | |
| 55 | help: a field with a similar name exists | |
| 56 | | | |
| 57 | LL - reuse Trait::method { self.0 } | |
| 58 | LL + reuse Trait::method { self.s } | |
| 59 | | | |
| 60 | ||
| 61 | error[E0609]: no field `0` on type `&no_constructor::W` | |
| 62 | --> $DIR/self-mapping-output.rs:124:35 | |
| 63 | | | |
| 64 | LL | reuse Trait::raw_S { self.0 } | |
| 65 | | ^ unknown field | |
| 66 | | | |
| 67 | help: a field with a similar name exists | |
| 68 | | | |
| 69 | LL - reuse Trait::raw_S { self.0 } | |
| 70 | LL + reuse Trait::raw_S { self.s } | |
| 71 | | | |
| 72 | ||
| 73 | error[E0063]: missing fields `1` and `2` in initializer of `more_than_one_field::W` | |
| 74 | --> $DIR/self-mapping-output.rs:144:22 | |
| 75 | | | |
| 76 | LL | reuse Trait::method { self.0 } | |
| 77 | | ^^^^^^ missing `1` and `2` | |
| 78 | ||
| 79 | error[E0063]: missing fields `1` and `2` in initializer of `more_than_one_field::W` | |
| 80 | --> $DIR/self-mapping-output.rs:152:22 | |
| 81 | | | |
| 82 | LL | reuse Trait::method { self.0 } | |
| 83 | | ^^^^^^ missing `1` and `2` | |
| 84 | ||
| 85 | error[E0308]: mismatched types | |
| 86 | --> $DIR/self-mapping-output.rs:184:25 | |
| 87 | | | |
| 88 | LL | pub fn method(_: impl super::Trait) -> impl super::Trait { | |
| 89 | | ----------------- the found opaque type | |
| 90 | ... | |
| 91 | LL | 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 | ||
| 100 | error[E0308]: mismatched types | |
| 101 | --> $DIR/self-mapping-output.rs:186:25 | |
| 102 | | | |
| 103 | LL | pub fn r#static() -> impl super::Trait { | |
| 104 | | ----------------- the found opaque type | |
| 105 | ... | |
| 106 | LL | 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 | ||
| 115 | error[E0609]: no field `0` on type `impl super::Trait` | |
| 116 | --> $DIR/self-mapping-output.rs:191:39 | |
| 117 | | | |
| 118 | LL | reuse to_reuse::method { self.0 } | |
| 119 | | ^ unknown field | |
| 120 | ||
| 121 | error[E0308]: mismatched types | |
| 122 | --> $DIR/self-mapping-output.rs:213:31 | |
| 123 | | | |
| 124 | LL | 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 `()` | |
| 131 | note: method defined here | |
| 132 | --> $DIR/self-mapping-output.rs:199:12 | |
| 133 | | | |
| 134 | LL | fn method(&self) -> (); | |
| 135 | | ^^^^^^ ---- | |
| 136 | help: consider borrowing here | |
| 137 | | | |
| 138 | LL | reuse Trait::method { &self.0 } | |
| 139 | | + | |
| 140 | ||
| 141 | error[E0283]: type annotations needed | |
| 142 | --> $DIR/self-mapping-output.rs:216:22 | |
| 143 | | | |
| 144 | LL | reuse Trait::r#static; | |
| 145 | | ^^^^^^^^ cannot infer type | |
| 146 | | | |
| 147 | = note: the type must implement `non_Self_return_type::Trait` | |
| 148 | help: the following types implement trait `non_Self_return_type::Trait` | |
| 149 | --> $DIR/self-mapping-output.rs:205:5 | |
| 150 | | | |
| 151 | LL | impl Trait for S { | |
| 152 | | ^^^^^^^^^^^^^^^^ `non_Self_return_type::S` | |
| 153 | ... | |
| 154 | LL | impl Trait for W { | |
| 155 | | ^^^^^^^^^^^^^^^^ `non_Self_return_type::W` | |
| 156 | ||
| 157 | error[E0308]: mismatched types | |
| 158 | --> $DIR/self-mapping-output.rs:219:30 | |
| 159 | | | |
| 160 | LL | 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 `()` | |
| 167 | note: method defined here | |
| 168 | --> $DIR/self-mapping-output.rs:201:12 | |
| 169 | | | |
| 170 | LL | fn raw_S(&self) -> S { S } | |
| 171 | | ^^^^^ ----- | |
| 172 | help: consider borrowing here | |
| 173 | | | |
| 174 | LL | reuse Trait::raw_S { &self.0 } | |
| 175 | | + | |
| 176 | ||
| 177 | error[E0308]: mismatched types | |
| 178 | --> $DIR/self-mapping-output.rs:224:31 | |
| 179 | | | |
| 180 | LL | 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 `()` | |
| 187 | note: method defined here | |
| 188 | --> $DIR/self-mapping-output.rs:199:12 | |
| 189 | | | |
| 190 | LL | fn method(&self) -> (); | |
| 191 | | ^^^^^^ ---- | |
| 192 | help: consider borrowing here | |
| 193 | | | |
| 194 | LL | reuse Trait::method { &self.0 } | |
| 195 | | + | |
| 196 | ||
| 197 | error[E0283]: type annotations needed | |
| 198 | --> $DIR/self-mapping-output.rs:227:22 | |
| 199 | | | |
| 200 | LL | reuse Trait::r#static; | |
| 201 | | ^^^^^^^^ cannot infer type | |
| 202 | | | |
| 203 | = note: the type must implement `non_Self_return_type::Trait` | |
| 204 | help: the following types implement trait `non_Self_return_type::Trait` | |
| 205 | --> $DIR/self-mapping-output.rs:205:5 | |
| 206 | | | |
| 207 | LL | impl Trait for S { | |
| 208 | | ^^^^^^^^^^^^^^^^ `non_Self_return_type::S` | |
| 209 | ... | |
| 210 | LL | impl Trait for W { | |
| 211 | | ^^^^^^^^^^^^^^^^ `non_Self_return_type::W` | |
| 212 | ||
| 213 | error[E0308]: mismatched types | |
| 214 | --> $DIR/self-mapping-output.rs:230:30 | |
| 215 | | | |
| 216 | LL | 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 `()` | |
| 223 | note: method defined here | |
| 224 | --> $DIR/self-mapping-output.rs:201:12 | |
| 225 | | | |
| 226 | LL | fn raw_S(&self) -> S { S } | |
| 227 | | ^^^^^ ----- | |
| 228 | help: consider borrowing here | |
| 229 | | | |
| 230 | LL | reuse Trait::raw_S { &self.0 } | |
| 231 | | + | |
| 232 | ||
| 233 | error[E0308]: mismatched types | |
| 234 | --> $DIR/self-mapping-output.rs:256:38 | |
| 235 | | | |
| 236 | LL | 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` | |
| 244 | note: method defined here | |
| 245 | --> $DIR/self-mapping-output.rs:237:12 | |
| 246 | | | |
| 247 | LL | fn method(&self) -> Self; | |
| 248 | | ^^^^^^ ---- | |
| 249 | ||
| 250 | error[E0308]: mismatched types | |
| 251 | --> $DIR/self-mapping-output.rs:256:29 | |
| 252 | | | |
| 253 | LL | reuse <F as Trait>::method { self.0 } | |
| 254 | | ^^^^^^ expected `S`, found `F` | |
| 255 | ||
| 256 | error[E0308]: mismatched types | |
| 257 | --> $DIR/self-mapping-output.rs:260:29 | |
| 258 | | | |
| 259 | LL | reuse <F as Trait>::r#static; | |
| 260 | | ^^^^^^^^ | |
| 261 | | | | |
| 262 | | expected `W`, found `F` | |
| 263 | | expected `wrong_return_type::W` because of return type | |
| 264 | ||
| 265 | error[E0308]: mismatched types | |
| 266 | --> $DIR/self-mapping-output.rs:263:37 | |
| 267 | | | |
| 268 | LL | 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` | |
| 275 | note: method defined here | |
| 276 | --> $DIR/self-mapping-output.rs:239:12 | |
| 277 | | | |
| 278 | LL | fn raw_S(&self) -> S { S } | |
| 279 | | ^^^^^ ----- | |
| 280 | ||
| 281 | error[E0308]: mismatched types | |
| 282 | --> $DIR/self-mapping-output.rs:268:38 | |
| 283 | | | |
| 284 | LL | 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` | |
| 292 | note: method defined here | |
| 293 | --> $DIR/self-mapping-output.rs:237:12 | |
| 294 | | | |
| 295 | LL | fn method(&self) -> Self; | |
| 296 | | ^^^^^^ ---- | |
| 297 | ||
| 298 | error[E0308]: mismatched types | |
| 299 | --> $DIR/self-mapping-output.rs:268:29 | |
| 300 | | | |
| 301 | LL | reuse <F as Trait>::method { self.0 } | |
| 302 | | ^^^^^^ expected `S`, found `F` | |
| 303 | ||
| 304 | error[E0308]: mismatched types | |
| 305 | --> $DIR/self-mapping-output.rs:272:29 | |
| 306 | | | |
| 307 | LL | reuse <F as Trait>::r#static; | |
| 308 | | ^^^^^^^^ | |
| 309 | | | | |
| 310 | | expected `W`, found `F` | |
| 311 | | expected `wrong_return_type::W` because of return type | |
| 312 | ||
| 313 | error[E0308]: mismatched types | |
| 314 | --> $DIR/self-mapping-output.rs:275:37 | |
| 315 | | | |
| 316 | LL | 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` | |
| 323 | note: method defined here | |
| 324 | --> $DIR/self-mapping-output.rs:239:12 | |
| 325 | | | |
| 326 | LL | fn raw_S(&self) -> S { S } | |
| 327 | | ^^^^^ ----- | |
| 328 | ||
| 329 | error[E0308]: mismatched types | |
| 330 | --> $DIR/self-mapping-output.rs:301:31 | |
| 331 | | | |
| 332 | LL | 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` | |
| 340 | note: method defined here | |
| 341 | --> $DIR/self-mapping-output.rs:282:12 | |
| 342 | | | |
| 343 | LL | fn method(&self) -> Self; | |
| 344 | | ^^^^^^ ---- | |
| 345 | ||
| 346 | error[E0308]: mismatched types | |
| 347 | --> $DIR/self-mapping-output.rs:310:31 | |
| 348 | | | |
| 349 | LL | 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` | |
| 357 | note: method defined here | |
| 358 | --> $DIR/self-mapping-output.rs:282:12 | |
| 359 | | | |
| 360 | LL | fn method(&self) -> Self; | |
| 361 | | ^^^^^^ ---- | |
| 362 | ||
| 363 | error[E0616]: field `0` of struct `private::W` is private | |
| 364 | --> $DIR/self-mapping-output.rs:336:36 | |
| 365 | | | |
| 366 | LL | reuse Trait::method { self.0 } | |
| 367 | | ^ private field | |
| 368 | ||
| 369 | error[E0616]: field `0` of struct `private::W` is private | |
| 370 | --> $DIR/self-mapping-output.rs:342:35 | |
| 371 | | | |
| 372 | LL | reuse Trait::raw_S { self.0 } | |
| 373 | | ^ private field | |
| 374 | ||
| 375 | error[E0616]: field `0` of struct `private::W` is private | |
| 376 | --> $DIR/self-mapping-output.rs:347:36 | |
| 377 | | | |
| 378 | LL | reuse Trait::method { self.0 } | |
| 379 | | ^ private field | |
| 380 | ||
| 381 | error[E0616]: field `0` of struct `private::W` is private | |
| 382 | --> $DIR/self-mapping-output.rs:352:35 | |
| 383 | | | |
| 384 | LL | reuse Trait::raw_S { self.0 } | |
| 385 | | ^ private field | |
| 386 | ||
| 387 | warning: function cannot return without recursing | |
| 388 | --> $DIR/self-mapping-output.rs:19:22 | |
| 389 | | | |
| 390 | LL | 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 | ||
| 399 | warning: function cannot return without recursing | |
| 400 | --> $DIR/self-mapping-output.rs:47:22 | |
| 401 | | | |
| 402 | LL | 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 | ||
| 410 | warning: function cannot return without recursing | |
| 411 | --> $DIR/self-mapping-output.rs:83:34 | |
| 412 | | | |
| 413 | LL | 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 | ||
| 421 | warning: function cannot return without recursing | |
| 422 | --> $DIR/self-mapping-output.rs:113:22 | |
| 423 | | | |
| 424 | LL | 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 | ||
| 432 | warning: function cannot return without recursing | |
| 433 | --> $DIR/self-mapping-output.rs:146:22 | |
| 434 | | | |
| 435 | LL | 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 | ||
| 443 | warning: function cannot return without recursing | |
| 444 | --> $DIR/self-mapping-output.rs:304:22 | |
| 445 | | | |
| 446 | LL | 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 | ||
| 454 | warning: function cannot return without recursing | |
| 455 | --> $DIR/self-mapping-output.rs:339:22 | |
| 456 | | | |
| 457 | LL | 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 | ||
| 465 | error: aborting due to 31 previous errors; 7 warnings emitted | |
| 466 | ||
| 467 | Some errors have detailed explanations: E0063, E0283, E0308, E0560, E0609, E0616. | |
| 468 | For more information about an error, try `rustc --explain E0063`. |
tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | //@ normalize-stderr: "[[:xdigit:]]{2} __ ([[:xdigit:]]{2}\s){2}" -> "HEX_DUMP" |
| 2 | 2 | #![feature(core_intrinsics)] |
| 3 | //@ ignore-parallel-frontend different alloc ids | |
| 3 | ||
| 4 | 4 | const RAW_EQ_PADDING: bool = unsafe { |
| 5 | 5 | std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16)) |
| 6 | 6 | //~^ ERROR requires initialized memory |
tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | error[E0080]: reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory | |
| 1 | error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory | |
| 2 | 2 | --> $DIR/intrinsic-raw_eq-const-bad.rs:5:5 |
| 3 | 3 | | |
| 4 | 4 | LL | std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16)) |
tests/ui/statics/mutable_memory_validation.rs+1| ... | ... | @@ -3,6 +3,7 @@ |
| 3 | 3 | // Strip out raw byte dumps to make comparison platform-independent: |
| 4 | 4 | //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" |
| 5 | 5 | //@ 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╼ │ ╾─╼" | |
| 6 | 7 | |
| 7 | 8 | use std::cell::UnsafeCell; |
| 8 | 9 |
tests/ui/statics/mutable_memory_validation.stderr+2-2| ... | ... | @@ -1,12 +1,12 @@ |
| 1 | 1 | error[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 | |
| 3 | 3 | | |
| 4 | 4 | LL | const MUH: Meh = Meh { x: unsafe { &mut *(&READONLY as *const _ as *mut _) } }; |
| 5 | 5 | | ^^^^^^^^^^^^^^ it is undefined behavior to use this value |
| 6 | 6 | | |
| 7 | 7 | = note: the rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. |
| 8 | 8 | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { |
| 9 | HEX_DUMP | |
| 9 | ╾ALLOC$ID╼ │ ╾─╼ | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | error: aborting due to 1 previous error |
tests/ui/std/linux-getrandom-fallback.rs+1| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | //@ only-linux |
| 2 | 2 | //@ run-pass |
| 3 | //@ needs-unwind | |
| 3 | 4 | |
| 4 | 5 | #![feature(random)] |
| 5 | 6 | #![feature(rustc_private)] |
tests/ui/type/pattern_types/validity.rs+1-1| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | //! Check that pattern types have their validity checked |
| 2 | 2 | // Strip out raw byte dumps to make tests platform-independent: |
| 3 | 3 | //@ normalize-stderr: "([[:xdigit:]]{2}\s){4,8}\s+│\s.{4,8}" -> "HEX_DUMP" |
| 4 | //@ ignore-parallel-frontend different alloc ids | |
| 4 | ||
| 5 | 5 | #![feature(pattern_types, const_trait_impl, pattern_type_range_trait)] |
| 6 | 6 | #![feature(pattern_type_macro)] |
| 7 | 7 |
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) }; |
| 9 | 9 | HEX_DUMP |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | error[E0080]: reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory | |
| 12 | error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory | |
| 13 | 13 | --> $DIR/validity.rs:13:1 |
| 14 | 14 | | |
| 15 | 15 | LL | const BAD_UNINIT: pattern_type!(u32 is 1..) = |
| ... | ... | @@ -50,7 +50,7 @@ LL | const BAD_FOO: Foo = Foo(Bar(unsafe { std::mem::transmute(0) })); |
| 50 | 50 | HEX_DUMP |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | error[E0080]: reading memory at ALLOC1[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory | |
| 53 | error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory | |
| 54 | 54 | --> $DIR/validity.rs:29:1 |
| 55 | 55 | | |
| 56 | 56 | LL | const CHAR_UNINIT: pattern_type!(char is 'A'..'Z') = |
typos.toml+1| ... | ... | @@ -21,6 +21,7 @@ extend-exclude = [ |
| 21 | 21 | # right now. Entries should look like `mipsel = "mipsel"`. |
| 22 | 22 | # |
| 23 | 23 | # tidy-alphabetical-start |
| 24 | EXPORTAS = "EXPORTAS" # MSVC linker keyword used with /EXPORT directives | |
| 24 | 25 | anser = "anser" # an ANSI parsing package used by rust-analyzer |
| 25 | 26 | arange = "arange" # short for A-range |
| 26 | 27 | childs = "childs" |