2022-05-25 11:08:41 -05:00
|
|
|
use std::path::{Path, PathBuf};
|
|
|
|
|
2022-05-30 05:56:34 -05:00
|
|
|
use super::*;
|
2022-05-25 11:08:41 -05:00
|
|
|
|
|
|
|
fn config() -> Config {
|
|
|
|
Config {
|
|
|
|
args: vec![],
|
|
|
|
target: None,
|
|
|
|
stderr_filters: vec![],
|
|
|
|
stdout_filters: vec![],
|
2022-05-30 05:56:34 -05:00
|
|
|
root_dir: PathBuf::from("$RUSTROOT"),
|
2022-05-25 11:08:41 -05:00
|
|
|
mode: Mode::Fail,
|
2022-05-30 03:27:41 -05:00
|
|
|
path_filter: vec![],
|
2022-05-25 11:08:41 -05:00
|
|
|
program: PathBuf::from("cake"),
|
|
|
|
output_conflict_handling: OutputConflictHandling::Error,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn issue_2156() {
|
|
|
|
let s = r"
|
|
|
|
use std::mem;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let _x: &i32 = unsafe { mem::transmute(16usize) }; //~ ERROR encountered a dangling reference (address $HEX is unallocated)
|
|
|
|
}
|
|
|
|
";
|
2022-05-30 05:56:34 -05:00
|
|
|
let path = Path::new("$DIR/<dummy>");
|
|
|
|
let comments = Comments::parse(&path, s);
|
2022-05-25 11:08:41 -05:00
|
|
|
let mut errors = vec![];
|
|
|
|
let config = config();
|
2022-05-30 05:56:34 -05:00
|
|
|
// Crucially, the intended error string *does* appear in this output, as a quote of the comment itself.
|
|
|
|
let stderr = br"
|
2022-05-25 11:08:41 -05:00
|
|
|
error: Undefined Behavior: type validation failed: encountered a dangling reference (address 0x10 is unallocated)
|
|
|
|
--> tests/compile-fail/validity/dangling_ref1.rs:6:29
|
|
|
|
|
|
|
|
|
LL | let _x: &i32 = unsafe { mem::transmute(16usize) }; //~ ERROR encountered a dangling reference (address $HEX is unallocated)
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling reference (address 0x10 is unallocated)
|
|
|
|
|
|
|
|
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
|
|
|
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
|
|
|
|
|
|
|
= note: inside `main` at tests/compile-fail/validity/dangling_ref1.rs:6:29
|
|
|
|
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
|
|
|
error: aborting due to previous error
|
|
|
|
";
|
2022-05-30 05:56:34 -05:00
|
|
|
check_test_result(&path, &config, "", "", &comments, &mut errors, /*stdout*/ br"", stderr);
|
|
|
|
// The "OutputDiffers" is because we cannot open the .rs file
|
2022-05-25 11:08:41 -05:00
|
|
|
match &errors[..] {
|
2022-05-30 05:56:34 -05:00
|
|
|
[Error::OutputDiffers { .. }, Error::PatternNotFound { .. }] => {}
|
2022-05-30 05:28:13 -05:00
|
|
|
_ => panic!("not the expected error: {:#?}", errors),
|
2022-05-25 11:08:41 -05:00
|
|
|
}
|
|
|
|
}
|