jiebi/CodeConvo huggingface dataset:
use std::mem; use crate::errors::{ <del> ChangeFieldsToBeOfUnitType, IgnoredDerivedImpls, MultipleDeadCodes, ParentInfo, UselessAssignment, </del> <ins> ChangeFields, IgnoredDerivedImpls, MultipleDeadCodes, ParentInfo, UselessAssignment, </ins> }; // Any local node that may call something in its body block should be
}; let diag = match report_on { <del> ReportOn::TupleField => MultipleDeadCodes::UnusedTupleStructFields { multiple, num, descr, participle, name_list, change_fields_suggestion: ChangeFieldsToBeOfUnitType { num, spans: spans.clone() }, parent_info, ignored_derived_impls, }, </del> <ins> ReportOn::TupleField => { let tuple_fields = if let Some(parent_id) = parent_item && let node = tcx.hir_node_by_def_id(parent_id) && let hir::Node::Item(hir::Item { kind: hir::ItemKind::Struct(hir::VariantData::Tuple(fields, _, _), _), .. }) = node { *fields } else { &[] }; let trailing_tuple_fields = if tuple_fields.len() >= dead_codes.len() { LocalDefIdSet::from_iter( tuple_fields .iter() .skip(tuple_fields.len() - dead_codes.len()) .map(|f| f.def_id), ) } else { LocalDefIdSet::default() }; let fields_suggestion = // Suggest removal if all tuple fields are at the end. // Otherwise suggest removal or changing to unit type if dead_codes.iter().all(|dc| trailing_tuple_fields.contains(&dc.def_id)) { ChangeFields::Remove { num } } else { ChangeFields::ChangeToUnitTypeOrRemove { num, spans: spans.clone() } }; MultipleDeadCodes::UnusedTupleStructFields { multiple, num, descr, participle, name_list, change_fields_suggestion: fields_suggestion, parent_info, ignored_derived_impls, } } </ins> ReportOn::NamedField => MultipleDeadCodes::DeadCodes { multiple, num,
} #[derive(Subdiagnostic)] <del> #[multipart_suggestion(passes_change_fields_to_be_of_unit_type, applicability = "has-placeholders")] pub struct ChangeFieldsToBeOfUnitType { pub num: usize, #[suggestion_part(code = "()")] pub spans: Vec<Span>, </del> <ins> pub enum ChangeFields { #[multipart_suggestion( passes_change_fields_to_be_of_unit_type, applicability = "has-placeholders" )] ChangeToUnitTypeOrRemove { num: usize, #[suggestion_part(code = "()")] spans: Vec<Span>, }, #[help(passes_remove_fields)] Remove { num: usize }, </ins> } #[derive(Diagnostic)]
const LEN: usize = 4; <del> struct SingleUnused(i32, [u8; LEN], String); //~^ ERROR: field `1` is never read </del> <ins> struct UnusedAtTheEnd(i32, f32, [u8; LEN], String, u8); //~^ ERROR:fields `1`, `2`, `3`, and `4` are never read //~| NOTE: fields in this struct //~| HELP: consider removing these fields struct UnusedJustOneField(i32); //~^ ERROR: field `0` is never read </ins> //~| NOTE: field in this struct <del> //~| HELP: consider changing the field to be of unit type </del> <ins> //~| HELP: consider removing this field </ins> <del> struct MultipleUnused(i32, f32, String, u8); //~^ ERROR: fields `0`, `1`, `2`, and `3` are never read </del> <ins> struct UnusedInTheMiddle(i32, f32, String, u8, u32); //~^ ERROR: fields `1`, `2`, and `4` are never read </ins> //~| NOTE: fields in this struct <del> //~| HELP: consider changing the fields to be of unit type </del> <ins> //~| HELP: consider changing the fields to be of unit type to suppress this warning while preserving the field numbering, or remove the fields </ins> struct GoodUnit(());
struct GoodVoid(Void); fn main() { <del> let w = SingleUnused(42, [0, 1, 2, 3], "abc".to_string()); let _ = w.0; let _ = w.2; </del> <ins> let u1 = UnusedAtTheEnd(42, 3.14, [0, 1, 2, 3], "def".to_string(), 4u8); let _ = u1.0; let _ = UnusedJustOneField(42); let u2 = UnusedInTheMiddle(42, 3.14, "def".to_string(), 4u8, 5); let _ = u2.0; let _ = u2.3; </ins> <del> let m = MultipleUnused(42, 3.14, "def".to_string(), 4u8); </del> let gu = GoodUnit(()); let gp = GoodPhantom(PhantomData); let gv = GoodVoid(Void); <del> let _ = (gu, gp, gv, m); </del> <ins> let _ = (gu, gp, gv); </ins> }
<del> error: field `1` is never read --> $DIR/tuple-struct-field.rs:8:26 </del> <ins> error: fields `1`, `2`, `3`, and `4` are never read --> $DIR/tuple-struct-field.rs:8:28 </ins> | <del> LL | struct SingleUnused(i32, [u8; LEN], String); |        ------------      ^^^^^^^^^ </del> <ins> LL | struct UnusedAtTheEnd(i32, f32, [u8; LEN], String, u8); |        --------------      ^^^  ^^^^^^^^^  ^^^^^^  ^^ </ins> |        | <del> |        field in this struct </del> <ins> |        fields in this struct </ins> | <ins> = help: consider removing these fields </ins> note: the lint level is defined here --> $DIR/tuple-struct-field.rs:1:9 | LL | #![deny(dead_code)] |         ^^^^^^^^^ <del> help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field </del> <ins> error: field `0` is never read --> $DIR/tuple-struct-field.rs:13:27 | LL | struct UnusedJustOneField(i32); |        ------------------ ^^^ |        | |        field in this struct </ins> | <del> LL | struct SingleUnused(i32, (), String); |                          ~~ </del> <ins> = help: consider removing this field </ins> <del> error: fields `0`, `1`, `2`, and `3` are never read --> $DIR/tuple-struct-field.rs:13:23 </del> <ins> error: fields `1`, `2`, and `4` are never read --> $DIR/tuple-struct-field.rs:18:31 </ins> | <del> LL | struct MultipleUnused(i32, f32, String, u8); |        -------------- ^^^  ^^^  ^^^^^^  ^^ </del> <ins> LL | struct UnusedInTheMiddle(i32, f32, String, u8, u32); |        -----------------      ^^^  ^^^^^^      ^^^ </ins> |        | |        fields in this struct | help: consider changing the fields to be of unit type to suppress this warning while preserving the field numbering, or remove the fields | <del> LL | struct MultipleUnused((), (), (), ()); |                       ~~  ~~  ~~  ~~ </del> <ins> LL | struct UnusedInTheMiddle(i32, (), (), u8, ()); |                               ~~  ~~      ~~ </ins> <del> error: aborting due to 2 previous errors </del> <ins> error: aborting due to 3 previous errors </ins>
let Some(module) = single_import.imported_module.get() else { return Err((Undetermined, Weak::No)); }; <del> let ImportKind::Single { source: ident, source_bindings, .. } = &single_import.kind </del> <ins> let ImportKind::Single { source: ident, target, target_bindings, .. } = &single_import.kind </ins> else { unreachable!(); }; <del> if binding.map_or(false, |binding| binding.module().is_some()) && source_bindings.iter().all(|binding| matches!(binding.get(), Err(Undetermined))) { // This branch allows the binding to be defined or updated later, </del> <ins> if (ident != target) && target_bindings.iter().all(|binding| binding.get().is_none()) { // This branch allows the binding to be defined or updated later if the target name // can hide the source but these bindings are not obtained. </ins> // avoiding module inconsistency between the resolve process and the finalize process. // See more details in #124840 return Err((Undetermined, Weak::No));
<ins> error[E0432]: unresolved import `ops` --> $DIR/cycle-import-in-std-1.rs:5:11 | LL | use ops::{self as std}; |           ^^^^^^^^^^^ no external crate `ops` | = help: consider importing one of these items instead: core::ops std::ops error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0432`. </ins>
<ins> error[E0432]: unresolved import `ops` --> $DIR/cycle-import-in-std-2.rs:5:11 | LL | use ops::{self as std}; |           ^^^^^^^^^^^ no external crate `ops` | = help: consider importing one of these items instead: core::ops std::ops error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0432`. </ins>
use rustc_hir::def::{CtorOf, Res}; use rustc_hir::def_id::LocalDefId; use rustc_hir::{HirId, PatKind}; <del> use rustc_middle::{bug, span_bug}; </del> use rustc_middle::hir::place::ProjectionKind; use rustc_middle::mir::FakeReadCause; use rustc_middle::ty::{ self, adjustment, AdtKind, Ty, TyCtxt, TypeFoldable, TypeVisitableExt as _, }; <ins> use rustc_middle::{bug, span_bug}; </ins> use rustc_span::{ErrorGuaranteed, Span}; use rustc_target::abi::{FieldIdx, VariantIdx, FIRST_VARIANT}; use rustc_trait_selection::infer::InferCtxtExt;
debug!("pat_ty(pat={:?}) found adjusted ty `{:?}`", pat, first_ty); return Ok(*first_ty); } <ins> } else if let PatKind::Ref(subpat, _) = pat.kind && self.cx.typeck_results().skipped_ref_pats().contains(pat.hir_id) { return self.pat_ty_adjusted(subpat); </ins> } self.pat_ty_unadjusted(pat)
self.cat_pattern(place_with_id, subpat, op)?; } <ins> PatKind::Ref(subpat, _) if self.cx.typeck_results().skipped_ref_pats().contains(pat.hir_id) => { self.cat_pattern(place_with_id, subpat, op)?; } </ins> PatKind::Box(subpat) | PatKind::Ref(subpat, _) => { // box p1, &p1, &mut p1. we can ignore the mutability of // PatKind::Ref since that information is already contained
<ins> //@ run-pass //@ edition: 2024 //@ compile-flags: -Zunstable-options #![allow(incomplete_features)] #![feature(ref_pat_eat_one_layer_2024)] struct Foo; //~^ WARN struct `Foo` is never constructed fn main() { || { //~^ WARN unused closure that must be used if let Some(Some(&mut x)) = &mut Some(&mut Some(0)) { let _: u32 = x; } }; } </ins>
<ins> warning: struct `Foo` is never constructed --> $DIR/skipped-ref-pats-issue-125058.rs:8:8 | LL | struct Foo; |        ^^^ | = note: `#[warn(dead_code)]` on by default warning: unused closure that must be used --> $DIR/skipped-ref-pats-issue-125058.rs:12:5 | LL | /     || { LL | | LL | |         if let Some(Some(&mut x)) = &mut Some(&mut Some(0)) { LL | |             let _: u32 = x; LL | |         } LL | |     }; | |_____^ | = note: closures are lazy and do nothing unless called = note: `#[warn(unused_must_use)]` on by default warning: 2 warnings emitted </ins>
codegen_ssa_select_cpp_build_tool_workload = in the Visual Studio installer, ensure the "C++ build tools" workload is selected <ins> codegen_ssa_self_contained_linker_missing = the self-contained linker was requested, but it wasn't found in the target's sysroot, or in rustc's sysroot </ins> codegen_ssa_shuffle_indices_evaluation = could not evaluate shuffle_indices at compile time codegen_ssa_specify_libraries_to_link = use the `-l` flag to specify native libraries to link
let self_contained_linker = self_contained_cli || self_contained_target; if self_contained_linker && !sess.opts.cg.link_self_contained.is_linker_disabled() { <ins> let mut linker_path_exists = false; </ins> for path in sess.get_tools_search_paths(false) { <ins> let linker_path = path.join("gcc-ld"); linker_path_exists |= linker_path.exists(); </ins> cmd.arg({ let mut arg = OsString::from("-B"); <del> arg.push(path.join("gcc-ld")); </del> <ins> arg.push(linker_path); </ins> arg }); } <ins> if !linker_path_exists { // As a sanity check, we emit an error if none of these paths exist: we want // self-contained linking and have no linker. sess.dcx().emit_fatal(errors::SelfContainedLinkerMissing); } </ins> } // 2. Implement the "linker flavor" part of this feature by asking `cc` to use some kind of
PathBuf::from_iter([sysroot, Path::new(&rustlib_path), Path::new("lib")]) } <ins> /// Returns a path to the target's `bin` folder within its `rustlib` path in the sysroot. This is /// where binaries are usually installed, e.g. the self-contained linkers, lld-wrappers, LLVM tools, /// etc. pub fn make_target_bin_path(sysroot: &Path, target_triple: &str) -> PathBuf { let rustlib_path = rustc_target::target_rustlib_path(sysroot, target_triple); PathBuf::from_iter([sysroot, Path::new(&rustlib_path), Path::new("bin")]) } </ins> #[cfg(unix)] fn current_dll_path() -> Result<PathBuf, String> { use std::ffi::{CStr, OsStr};
) } <del> /// Returns a list of directories where target-specific tool binaries are located. </del> <ins> /// Returns a list of directories where target-specific tool binaries are located. Some fallback /// directories are also returned, for example if `--sysroot` is used but tools are missing /// (#125246): we also add the bin directories to the sysroot where rustc is located. </ins> pub fn get_tools_search_paths(&self, self_contained: bool) -> Vec<PathBuf> { <del> let rustlib_path = rustc_target::target_rustlib_path(&self.sysroot, config::host_triple()); let p = PathBuf::from_iter([ Path::new(&self.sysroot), Path::new(&rustlib_path), Path::new("bin"), ]); if self_contained { vec![p.clone(), p.join("self-contained")] } else { vec![p] } </del> <ins> let bin_path = filesearch::make_target_bin_path(&self.sysroot, config::host_triple()); let fallback_sysroot_paths = filesearch::sysroot_candidates() .into_iter() .map(|sysroot| filesearch::make_target_bin_path(&sysroot, config::host_triple())); let search_paths = std::iter::once(bin_path).chain(fallback_sysroot_paths); if self_contained { // The self-contained tools are expected to be e.g. in `bin/self-contained` in the // sysroot's `rustlib` path, so we add such a subfolder to the bin path, and the // fallback paths. search_paths.flat_map(|path| [path.clone(), path.join("self-contained")]).collect() } else { search_paths.collect() } </ins> } pub fn init_incr_comp_session(&self, session_dir: PathBuf, lock_file: flock::Lock) {
("avx512bw", Unstable(sym::avx512_target_feature)), ("avx512cd", Unstable(sym::avx512_target_feature)), ("avx512dq", Unstable(sym::avx512_target_feature)), <del> ("avx512er", Unstable(sym::avx512_target_feature)), </del> ("avx512f", Unstable(sym::avx512_target_feature)), ("avx512fp16", Unstable(sym::avx512_target_feature)), ("avx512ifma", Unstable(sym::avx512_target_feature)), <del> ("avx512pf", Unstable(sym::avx512_target_feature)), </del> ("avx512vbmi", Unstable(sym::avx512_target_feature)), ("avx512vbmi2", Unstable(sym::avx512_target_feature)), ("avx512vl", Unstable(sym::avx512_target_feature)),
println!("avx512bw: {:?}", is_x86_feature_detected!("avx512bw")); println!("avx512cd: {:?}", is_x86_feature_detected!("avx512cd")); println!("avx512dq: {:?}", is_x86_feature_detected!("avx512dq")); <del> println!("avx512er: {:?}", is_x86_feature_detected!("avx512er")); </del> println!("avx512f: {:?}", is_x86_feature_detected!("avx512f")); println!("avx512ifma: {:?}", is_x86_feature_detected!("avx512ifma")); <del> println!("avx512pf: {:?}", is_x86_feature_detected!("avx512pf")); </del> println!("avx512vbmi2: {:?}", is_x86_feature_detected!("avx512vbmi2")); println!("avx512vbmi: {:?}", is_x86_feature_detected!("avx512vbmi")); println!("avx512vl: {:?}", is_x86_feature_detected!("avx512vl"));
LL |     cfg!(target_feature = "zebra"); |          ^^^^^^^^^^^^^^^^^^^^^^^^ | <del> = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512er`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512pf`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, `avx512vpopcntdq`, `bf16`, `bmi1`, and `bmi2` and 188 more </del> <ins> = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, `avx512vpopcntdq`, `bf16`, `bmi1`, `bmi2`, `bti`, and `bulk-memory` and 186 more </ins> = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration warning: 27 warnings emitted
} fn is_internal_abi(&self, abi: SpecAbi) -> bool { <del> matches!(abi, SpecAbi::Rust | SpecAbi::RustCall | SpecAbi::RustIntrinsic) </del> <ins> matches!( abi, SpecAbi::Rust | SpecAbi::RustCall | SpecAbi::RustCold | SpecAbi::RustIntrinsic ) </ins> } /// Find any fn-ptr types with external ABIs in `ty`.
<ins> //@ check-pass #![feature(rust_cold_cc)] // extern "rust-cold" is a "Rust" ABI so we accept `repr(Rust)` types as arg/ret without warnings. pub extern "rust-cold" fn f(_: ()) -> Result<(), ()> { Ok(()) } extern "rust-cold" { pub fn g(_: ()) -> Result<(), ()>; } fn main() {} </ins>
AR_loongarch64_unknown_linux_gnu=loongarch64-unknown-linux-gnu-ar  CXX_loongarch64_unknown_linux_gnu=loongarch64-unknown-linux-gnu-g++ <ins> # We re-use the Linux toolchain for bare-metal, because upstream bare-metal # target support for LoongArch is only available from GCC 14+. # # See: https://github.com/gcc-mirror/gcc/commit/976f4f9e4770 ENV CC_loongarch64_unknown_none=loongarch64-unknown-linux-gnu-gcc  AR_loongarch64_unknown_none=loongarch64-unknown-linux-gnu-ar  CXX_loongarch64_unknown_none=loongarch64-unknown-linux-gnu-g++  CFLAGS_loongarch64_unknown_none="-ffreestanding -mabi=lp64d"  CXXFLAGS_loongarch64_unknown_none="-ffreestanding -mabi=lp64d"  CC_loongarch64_unknown_none_softfloat=loongarch64-unknown-linux-gnu-gcc  AR_loongarch64_unknown_none_softfloat=loongarch64-unknown-linux-gnu-ar  CXX_loongarch64_unknown_none_softfloat=loongarch64-unknown-linux-gnu-g++  CFLAGS_loongarch64_unknown_none_softfloat="-ffreestanding -mabi=lp64s -mfpu=none"  CXXFLAGS_loongarch64_unknown_none_softfloat="-ffreestanding -mabi=lp64s -mfpu=none" </ins> ENV HOSTS=loongarch64-unknown-linux-gnu <ins> ENV TARGETS=$HOSTS ENV TARGETS=$TARGETS,loongarch64-unknown-none ENV TARGETS=$TARGETS,loongarch64-unknown-none-softfloat </ins> ENV RUST_CONFIGURE_ARGS  --enable-extended
ENV TARGETS=$TARGETS,armv7-unknown-linux-musleabi ENV TARGETS=$TARGETS,i686-unknown-freebsd ENV TARGETS=$TARGETS,x86_64-unknown-none <del> ENV TARGETS=$TARGETS,loongarch64-unknown-none ENV TARGETS=$TARGETS,loongarch64-unknown-none-softfloat </del> ENV TARGETS=$TARGETS,aarch64-unknown-uefi ENV TARGETS=$TARGETS,i686-unknown-uefi ENV TARGETS=$TARGETS,x86_64-unknown-uefi
unsafe { self.current = unlinked_node.as_ref().next; self.list.unlink_node(unlinked_node); <del> let unlinked_node = Box::from_raw(unlinked_node.as_ptr()); </del> <ins> let unlinked_node = Box::from_raw_in(unlinked_node.as_ptr(), &self.list.alloc); </ins> Some(unlinked_node.element) } }
if (self.pred)(&mut node.as_mut().element) { // `unlink_node` is okay with aliasing `element` references. self.list.unlink_node(node); <del> return Some(Box::from_raw(node.as_ptr()).element); </del> <ins> return Some(Box::from_raw_in(node.as_ptr(), &self.list.alloc).element); </ins> } } }
assert_eq!(unsafe { DROPS }, 8); } <ins> #[test] fn test_allocator() { use core::alloc::AllocError; use core::alloc::Allocator; use core::alloc::Layout; use core::cell::Cell; struct A { has_allocated: Cell<bool>, has_deallocated: Cell<bool>, } unsafe impl Allocator for A { fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> { assert!(!self.has_allocated.get()); self.has_allocated.set(true); Global.allocate(layout) } unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) { assert!(!self.has_deallocated.get()); self.has_deallocated.set(true); unsafe { Global.deallocate(ptr, layout) } } } let alloc = &A { has_allocated: Cell::new(false), has_deallocated: Cell::new(false) }; { let mut list = LinkedList::new_in(alloc); list.push_back(5u32); list.remove(0); } assert!(alloc.has_allocated.get()); assert!(alloc.has_deallocated.get()); } </ins>
use std::hash::Hash; use super::{ <del> err_ub, format_interp_error, machine::AllocMap, throw_ub, AllocId, CheckInAllocMsg, </del> <ins> err_ub, format_interp_error, machine::AllocMap, throw_ub, AllocId, AllocKind, CheckInAllocMsg, </ins> GlobalAlloc, ImmTy, Immediate, InterpCx, InterpResult, MPlaceTy, Machine, MemPlaceMeta, OpTy, Pointer, Projectable, Scalar, ValueVisitor, };
} } <del> // Mutability check. </del> <ins> // Dangling and Mutability check. let (size, _align, alloc_kind) = self.ecx.get_alloc_info(alloc_id); if alloc_kind == AllocKind::Dead { // This can happen for zero-sized references. We can't have *any* references to non-existing // allocations though, interning rejects them all as the rest of rustc isn't happy with them... // so we throw an error, even though this isn't really UB. // A potential future alternative would be to resurrect this as a zero-sized allocation // (which codegen will then compile to an aligned dummy pointer anyway). throw_validation_failure!(self.path, DanglingPtrUseAfterFree { ptr_kind }); } </ins> // If this allocation has size zero, there is no actual mutability here. <del> let (size, _align, _alloc_kind) = self.ecx.get_alloc_info(alloc_id); </del> if size != Size::ZERO { let alloc_actual_mutbl = mutability(self.ecx, alloc_id); // Mutable pointer to immutable memory is no good.
<del> error: encountered dangling pointer in final value of constant </del> <ins> error[E0080]: it is undefined behavior to use this value </ins> --> $DIR/dangling-alloc-id-ice.rs:12:1 | LL | const FOO: &() = { <del> | ^^^^^^^^^^^^^^ </del> <ins> | ^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (use-after-free) | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } </ins> error: aborting due to 1 previous error <ins> For more information about this error, try `rustc --explain E0080`. </ins>
<ins> // Strip out raw byte dumps to make comparison platform-independent: //@ normalize-stderr-test "(the raw bytes of the constant) (size: [0-9]*, align: [0-9]*)" -> "$1 (size: $$SIZE, align: $$ALIGN)" //@ normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*A(LLOC)?[0-9]+(+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP" //@ normalize-stderr-test "HEX_DUMPs*ns*HEX_DUMP" -> "HEX_DUMP" pub struct Wrapper; pub static MAGIC_FFI_REF: &'static Wrapper = unsafe { //~^ERROR: it is undefined behavior to use this value std::mem::transmute(&{ let y = 42; y }) }; fn main() {} </ins>
<ins> error[E0080]: it is undefined behavior to use this value --> $DIR/dangling-zst-ice-issue-126393.rs:7:1 | LL | pub static MAGIC_FFI_REF: &'static Wrapper = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (use-after-free) | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0080`. </ins>
variant_index: VariantIdx, ) -> InterpResult<'tcx, Option<(ScalarInt, usize)>> { match self.layout_of(ty)?.variants { <del> abi::Variants::Single { .. } => Ok(None), </del> <ins> abi::Variants::Single { .. } => { // The tag of a `Single` enum is like the tag of the niched // variant: there's no tag as the discriminant is encoded // entirely implicitly. If `write_discriminant` ever hits this // case, we do a "validation read" to ensure the the right // discriminant is encoded implicitly, so any attempt to write // the wrong discriminant for a `Single` enum will reliably // result in UB. Ok(None) } </ins> abi::Variants::Multiple { tag_encoding: TagEncoding::Direct,