rust/tests/ui/consts/missing_span_in_backtrace.rs
2026-01-19 18:54:02 +00:00

26 lines
580 B
Rust

//! Check what happens when the error occurs inside a std function that we can't print the span of.
//@ ignore-backends: gcc
//@ compile-flags: -Z ui-testing=no --diagnostic-width=80
use std::{
mem::{self, MaybeUninit},
ptr,
};
const X: () = {
let mut x1 = 1;
let mut x2 = 2;
// Swap them, bytewise.
unsafe {
ptr::swap_nonoverlapping( //~ ERROR beyond the end of the allocation
&mut x1 as *mut _ as *mut MaybeUninit<u8>,
&mut x2 as *mut _ as *mut MaybeUninit<u8>,
10,
);
}
};
fn main() {
X
}