2022-05-25 11:08:41 -05:00
|
|
|
use std::path::{Path, PathBuf};
|
|
|
|
|
2022-05-25 13:24:55 -05:00
|
|
|
use super::{check_annotations, Comments, Config, Error, Mode, OutputConflictHandling};
|
2022-05-25 11:08:41 -05:00
|
|
|
|
|
|
|
fn config() -> Config {
|
|
|
|
Config {
|
|
|
|
args: vec![],
|
|
|
|
target: None,
|
|
|
|
stderr_filters: vec![],
|
|
|
|
stdout_filters: vec![],
|
|
|
|
root_dir: PathBuf::from("."),
|
|
|
|
mode: Mode::Fail,
|
2022-05-27 06:43:14 -05:00
|
|
|
path_filter: None,
|
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)
|
|
|
|
}
|
|
|
|
";
|
|
|
|
let comments = Comments::parse(Path::new("<dummy>"), s);
|
|
|
|
let mut errors = vec![];
|
|
|
|
let config = config();
|
|
|
|
let unnormalized_stderr = r"
|
|
|
|
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
|
|
|
|
";
|
|
|
|
check_annotations(unnormalized_stderr.as_bytes(), &mut errors, &config, "", &comments);
|
|
|
|
match &errors[..] {
|
|
|
|
[Error::PatternNotFound { .. }] => {}
|
|
|
|
_ => panic!("{:#?}", errors),
|
|
|
|
}
|
|
|
|
}
|