2025-07-17 20:00:19 +02:00
|
|
|
//! Check what happens when the error occurs inside a std function that we can't print the span of.
|
2025-07-23 13:31:22 +02:00
|
|
|
//@ ignore-backends: gcc
|
2024-02-16 20:02:50 +00:00
|
|
|
//@ compile-flags: -Z ui-testing=no
|
2023-10-15 17:00:11 +00:00
|
|
|
|
2022-11-15 15:24:54 +00:00
|
|
|
use std::{
|
|
|
|
|
mem::{self, MaybeUninit},
|
|
|
|
|
ptr,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const X: () = {
|
2025-07-17 20:00:19 +02:00
|
|
|
let mut x1 = 1;
|
|
|
|
|
let mut x2 = 2;
|
2022-11-15 15:24:54 +00:00
|
|
|
|
|
|
|
|
// Swap them, bytewise.
|
|
|
|
|
unsafe {
|
2025-07-17 20:00:19 +02:00
|
|
|
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,
|
2022-11-15 15:24:54 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
X
|
|
|
|
|
}
|