From 4bd4838c15f75c693840d33b9c48ad7d6a310791 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 5 Jul 2022 09:08:00 +0000 Subject: [PATCH 01/17] Implement strict comment parsing for ui tests --- miri | 2 +- ui_test/src/comments.rs | 240 +++++++++++++++++++++++++++++----- ui_test/src/comments/tests.rs | 25 ++++ 3 files changed, 235 insertions(+), 32 deletions(-) diff --git a/miri b/miri index f0d92b6a2b..be51535d59 100755 --- a/miri +++ b/miri @@ -181,8 +181,8 @@ test|test-debug|bless|bless-debug) esac # Then test, and let caller control flags. # Only in root project and ui_test as `cargo-miri` has no tests. - $CARGO test $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml "$@" $CARGO test $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/ui_test/Cargo.toml "$@" + $CARGO test $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml "$@" ;; run|run-debug) # Scan for "--target" to overwrite the "MIRI_TEST_TARGET" env var so diff --git a/ui_test/src/comments.rs b/ui_test/src/comments.rs index 3fd65d643a..d4ee3efd14 100644 --- a/ui_test/src/comments.rs +++ b/ui_test/src/comments.rs @@ -64,6 +64,43 @@ impl Condition { } } +macro_rules! checked { + ($path:expr, $l:expr) => { + let path = $path; + let l = $l; + #[allow(unused_macros)] + macro_rules! exit { + ($fmt:expr $$(,$args:expr)*) => {{ + eprint!("{}:{l}: ", path.display()); + eprintln!($fmt, $$($args,)*); + #[cfg(not(test))] + std::process::exit(1); + #[cfg(test)] + panic!(); + }}; + } + #[allow(unused_macros)] + macro_rules! check { + ($cond:expr, $fmt:expr $$(,$args:expr)*) => {{ + if !$cond { + exit!($fmt $$(,$args)*); + } + }}; + } + #[allow(unused_macros)] + macro_rules! unwrap { + ($cond:expr, $fmt:expr $$(,$args:expr)*) => {{ + match $cond { + Some(val) => val, + None => { + exit!($fmt $$(,$args)*); + } + } + }}; + } + }; +} + impl Comments { pub(crate) fn parse_file(path: &Path) -> Self { let content = std::fs::read_to_string(path).unwrap(); @@ -72,14 +109,45 @@ impl Comments { /// Parse comments in `content`. /// `path` is only used to emit diagnostics if parsing fails. - pub(crate) fn parse(path: &Path, content: &str) -> Self { + /// + /// This function will only parse `//@` and `//~` style comments + /// and ignore all others + fn parse_checked(path: &Path, content: &str) -> Self { let mut this = Self::default(); - let error_pattern_regex = - Regex::new(r"//(\[(?P[^\]]+)\])?~(?P\||[\^]+)? *(?PERROR|HELP|WARN|NOTE)?:?(?P.*)") - .unwrap(); // The line that a `|` will refer to let mut fallthrough_to = None; + for (l, line) in content.lines().enumerate() { + let l = l + 1; // enumerate starts at 0, but line numbers start at 1 + if let Some((_, command)) = line.split_once("//@") { + let command = command.trim(); + if let Some((command, args)) = command.split_once(':') { + this.parse_command_with_args(command, args, path, l); + } else if let Some((command, _comments)) = command.split_once(' ') { + this.parse_command(command, path, l) + } else { + this.parse_command(command, path, l) + } + } else if let Some((_, pattern)) = line.split_once("//~") { + this.parse_pattern(pattern, &mut fallthrough_to, path, l) + } else if let Some((_, pattern)) = line.split_once("//[") { + this.parse_revisioned_pattern(pattern, &mut fallthrough_to, path, l) + } else { + fallthrough_to = None; + } + } + this + } + + /// Parse comments in `content`. + /// `path` is only used to emit diagnostics if parsing fails. + pub(crate) fn parse(path: &Path, content: &str) -> Self { + let mut this = Self::parse_checked(path, content); + if content.contains("//@") { + // Migration mode: if new syntax is used, ignore all old syntax + return this; + } + for (l, line) in content.lines().enumerate() { let l = l + 1; // enumerate starts at 0, but line numbers start at 1 if let Some(revisions) = line.strip_prefix("// revisions:") { @@ -140,36 +208,146 @@ impl Comments { ); this.error_pattern = Some((s.trim().to_string(), l)); } - if let Some(captures) = error_pattern_regex.captures(line) { - // FIXME: check that the error happens on the marked line - let matched = captures["text"].trim().to_string(); + } + this + } - let revision = captures.name("revision").map(|rev| rev.as_str().to_string()); + fn parse_command_with_args(&mut self, command: &str, args: &str, path: &Path, l: usize) { + checked!(path, l); + match command { + "revisions" => { + check!(self.revisions.is_none(), "cannot specifiy revisions twice"); + self.revisions = Some(args.split_whitespace().map(|s| s.to_string()).collect()); + } + "compile-flags" => { + self.compile_flags.extend(args.split_whitespace().map(|s| s.to_string())); + } + "rustc-env" => + for env in args.split_whitespace() { + let (k, v) = unwrap!( + env.split_once('='), + "environment variables must be key/value pairs separated by a `=`" + ); + self.env_vars.push((k.to_string(), v.to_string())); + }, + "normalize-stderr-test" => { + let (from, to) = + unwrap!(args.split_once("->"), "normalize-stderr-test needs a `->`"); + let from = from.trim().trim_matches('"'); + let to = to.trim().trim_matches('"'); + let from = unwrap!(Regex::new(from).ok(), "invalid regex"); + self.normalize_stderr.push((from, to.to_string())); + } + "error-pattern" => { + check!( + self.error_pattern.is_none(), + "cannot specifiy error_pattern twice, previous: {:?}", + self.error_pattern + ); + self.error_pattern = Some((args.trim().to_string(), l)); + } + _ => exit!("unknown command {command} with args {args}"), + } + } - let level = captures.name("level").map(|rev| rev.as_str().parse().unwrap()); + fn parse_command(&mut self, command: &str, path: &Path, l: usize) { + checked!(path, l); - let match_line = match captures.name("offset").map(|rev| rev.as_str()) { - Some("|") => fallthrough_to.expect("`//~|` pattern without preceding line"), - Some(pat) => { - debug_assert!(pat.chars().all(|c| c == '^')); - l - pat.len() - } - None => l, - }; - - fallthrough_to = Some(match_line); - - this.error_matches.push(ErrorMatch { - matched, - revision, - level, - definition_line: l, - line: match_line, - }); - } else { - fallthrough_to = None; - } + if let Some(s) = command.strip_prefix("ignore-") { + self.ignore.push(Condition::parse(s)); + return; } - this + + if let Some(s) = command.strip_prefix("only-") { + self.only.push(Condition::parse(s)); + return; + } + + if command.starts_with("stderr-per-bitwidth") { + check!(!self.stderr_per_bitwidth, "cannot specifiy stderr-per-bitwidth twice"); + self.stderr_per_bitwidth = true; + return; + } + + exit!("unknown command {command}"); + } + + fn parse_pattern( + &mut self, + pattern: &str, + fallthrough_to: &mut Option, + path: &Path, + l: usize, + ) { + self.parse_pattern_inner(pattern, fallthrough_to, None, path, l) + } + + fn parse_revisioned_pattern( + &mut self, + pattern: &str, + fallthrough_to: &mut Option, + path: &Path, + l: usize, + ) { + checked!(path, l); + let (revision, pattern) = + unwrap!(pattern.split_once(']'), "`//[` without corresponding `]`"); + if pattern.starts_with('~') { + self.parse_pattern_inner( + &pattern[1..], + fallthrough_to, + Some(revision.to_owned()), + path, + l, + ) + } else { + exit!("revisioned pattern must have `~` following the `]`"); + } + } + + // parse something like (?P\||[\^]+)? *(?PERROR|HELP|WARN|NOTE)?:?(?P.*) + fn parse_pattern_inner( + &mut self, + pattern: &str, + fallthrough_to: &mut Option, + revision: Option, + path: &Path, + l: usize, + ) { + checked!(path, l); + // FIXME: check that the error happens on the marked line + + let (match_line, pattern) = match unwrap!(pattern.chars().next(), "no pattern specified") { + '|' => + (*unwrap!(fallthrough_to, "`//~|` pattern without preceding line"), &pattern[1..]), + '^' => { + let offset = pattern.chars().take_while(|&c| c == '^').count(); + (l - offset, &pattern[offset..]) + } + _ => (l, pattern), + }; + + let (level, pattern) = match pattern.trim_start().split_once(|c| matches!(c, ':' | ' ')) { + None => (None, pattern), + Some((level, pattern_without_level)) => + match level.parse().ok() { + Some(level) => (Some(level), pattern_without_level), + None => (None, pattern), + }, + }; + + let matched = pattern.trim().to_string(); + + check!(!matched.is_empty(), "no pattern specified"); + + *fallthrough_to = Some(match_line); + + self.error_matches.push(ErrorMatch { + matched, + revision, + level, + definition_line: l, + line: match_line, + }); } } diff --git a/ui_test/src/comments/tests.rs b/ui_test/src/comments/tests.rs index ef96622414..dc69a5d4d6 100644 --- a/ui_test/src/comments/tests.rs +++ b/ui_test/src/comments/tests.rs @@ -20,3 +20,28 @@ fn main() { "encountered a dangling reference (address $HEX is unallocated)" ); } + +#[test] +fn parse_slash_slash_at() { + let s = r" +//@ error-pattern: foomp +use std::mem; + + "; + let comments = Comments::parse(Path::new(""), s); + println!("parsed comments: {:#?}", comments); + assert_eq!(comments.error_pattern, Some(("foomp".to_string(), 2))); +} + +#[test] +#[should_panic] +fn parse_slash_slash_at_fail() { + let s = r" +//@ error-pattern foomp +use std::mem; + + "; + let comments = Comments::parse(Path::new(""), s); + println!("parsed comments: {:#?}", comments); + assert_eq!(comments.error_pattern, Some(("foomp".to_string(), 2))); +} From 389915e09b2c5759865e829050cf0574d2cbe587 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 5 Jul 2022 09:15:22 +0000 Subject: [PATCH 02/17] Replace all //error-pattern comments with strict syntax and fix other comments in the same files --- tests/fail/alloc/deallocate-bad-alignment.rs | 2 +- tests/fail/alloc/deallocate-bad-size.rs | 2 +- tests/fail/alloc/deallocate-twice.rs | 2 +- tests/fail/alloc/global_system_mixup.rs | 8 ++++---- tests/fail/alloc/reallocate-bad-size.rs | 2 +- tests/fail/alloc/reallocate-dangling.rs | 2 +- tests/fail/alloc/stack_free.rs | 4 ++-- .../libc_pthread_create_main_terminate.rs | 4 ++-- tests/fail/concurrency/thread-spawn.rs | 4 ++-- .../dangling_pointers/null_pointer_write_zst.rs | 4 ++-- tests/fail/fs/isolated_file.rs | 4 ++-- tests/fail/intrinsics/copy_overflow.rs | 2 +- tests/fail/intrinsics/out_of_bounds_ptr_1.rs | 2 +- tests/fail/intrinsics/out_of_bounds_ptr_2.rs | 2 +- tests/fail/intrinsics/out_of_bounds_ptr_3.rs | 2 +- tests/fail/intrinsics/ptr_offset_0_plus_0.rs | 4 ++-- tests/fail/intrinsics/ptr_offset_int_plus_int.rs | 4 ++-- tests/fail/intrinsics/ptr_offset_int_plus_ptr.rs | 4 ++-- tests/fail/intrinsics/ptr_offset_overflow.rs | 2 +- tests/fail/intrinsics/ptr_offset_ptr_plus_0.rs | 2 +- tests/fail/intrinsics/simd-float-to-int.rs | 2 +- tests/fail/intrinsics/simd-gather.rs | 2 +- tests/fail/intrinsics/simd-scatter.rs | 2 +- tests/fail/intrinsics/write_bytes_overflow.rs | 2 +- tests/fail/invalid_enum_tag.rs | 4 ++-- tests/fail/memleak.rs | 4 ++-- tests/fail/memleak_rc.rs | 6 +++--- tests/fail/memleak_rc.stderr | 11 +++++++++++ tests/fail/no_main.rs | 2 +- tests/fail/panic/double_panic.rs | 6 +++--- tests/fail/panic/panic_abort1.rs | 8 ++++---- tests/fail/panic/panic_abort2.rs | 8 ++++---- tests/fail/panic/panic_abort3.rs | 8 ++++---- tests/fail/panic/panic_abort4.rs | 8 ++++---- tests/fail/provenance/ptr_invalid_offset.rs | 4 ++-- tests/fail/should-pass/cpp20_rwc_syncs.rs | 6 +++--- .../stacked_borrows/deallocate_against_barrier1.rs | 2 +- .../stacked_borrows/deallocate_against_barrier2.rs | 2 +- tests/fail/stacked_borrows/issue-miri-1050-1.rs | 2 +- tests/fail/stacked_borrows/issue-miri-1050-2.rs | 2 +- tests/fail/stacked_borrows/newtype_retagging.rs | 4 ++-- tests/fail/stacked_borrows/vtable.rs | 2 +- tests/fail/stacked_borrows/zst_slice.rs | 2 +- tests/fail/uninit_buffer.rs | 2 +- tests/fail/unreachable.rs | 2 +- ui_test/README.md | 4 +--- ui_test/src/comments.rs | 13 ++++--------- ui_test/src/lib.rs | 2 +- 48 files changed, 94 insertions(+), 90 deletions(-) create mode 100644 tests/fail/memleak_rc.stderr diff --git a/tests/fail/alloc/deallocate-bad-alignment.rs b/tests/fail/alloc/deallocate-bad-alignment.rs index 852a066021..a07d8254ad 100644 --- a/tests/fail/alloc/deallocate-bad-alignment.rs +++ b/tests/fail/alloc/deallocate-bad-alignment.rs @@ -1,6 +1,6 @@ use std::alloc::{alloc, dealloc, Layout}; -// error-pattern: has size 1 and alignment 1, but gave size 1 and alignment 2 +//@error-pattern: has size 1 and alignment 1, but gave size 1 and alignment 2 fn main() { unsafe { diff --git a/tests/fail/alloc/deallocate-bad-size.rs b/tests/fail/alloc/deallocate-bad-size.rs index 167cc015c2..47aaef1935 100644 --- a/tests/fail/alloc/deallocate-bad-size.rs +++ b/tests/fail/alloc/deallocate-bad-size.rs @@ -1,6 +1,6 @@ use std::alloc::{alloc, dealloc, Layout}; -// error-pattern: has size 1 and alignment 1, but gave size 2 and alignment 1 +//@error-pattern: has size 1 and alignment 1, but gave size 2 and alignment 1 fn main() { unsafe { diff --git a/tests/fail/alloc/deallocate-twice.rs b/tests/fail/alloc/deallocate-twice.rs index 67312b0d96..1eb9bbf91c 100644 --- a/tests/fail/alloc/deallocate-twice.rs +++ b/tests/fail/alloc/deallocate-twice.rs @@ -1,6 +1,6 @@ use std::alloc::{alloc, dealloc, Layout}; -// error-pattern: dereferenced after this allocation got freed +//@error-pattern: dereferenced after this allocation got freed fn main() { unsafe { diff --git a/tests/fail/alloc/global_system_mixup.rs b/tests/fail/alloc/global_system_mixup.rs index 735c52500a..01db2f1a22 100644 --- a/tests/fail/alloc/global_system_mixup.rs +++ b/tests/fail/alloc/global_system_mixup.rs @@ -1,10 +1,10 @@ // Make sure we detect when the `Global` and `System` allocators are mixed // (even when the default `Global` uses `System`). -// error-pattern: which is Rust heap memory, using +//@error-pattern: which is Rust heap memory, using -// normalize-stderr-test: "using [A-Za-z]+ heap deallocation operation" -> "using PLATFORM heap deallocation operation" -// normalize-stderr-test: "\| +\^+" -> "| ^" -// normalize-stderr-test: "libc::free\([^()]*\)|unsafe \{ HeapFree\([^()]*\) \};" -> "FREE();" +//@normalize-stderr-test: "using [A-Za-z]+ heap deallocation operation" -> "using PLATFORM heap deallocation operation" +//@normalize-stderr-test: "\| +\^+" -> "| ^" +//@normalize-stderr-test: "libc::free\([^()]*\)|unsafe \{ HeapFree\([^()]*\) \};" -> "FREE();" #![feature(allocator_api, slice_ptr_get)] diff --git a/tests/fail/alloc/reallocate-bad-size.rs b/tests/fail/alloc/reallocate-bad-size.rs index d6a27c930a..145c3393d6 100644 --- a/tests/fail/alloc/reallocate-bad-size.rs +++ b/tests/fail/alloc/reallocate-bad-size.rs @@ -1,6 +1,6 @@ use std::alloc::{alloc, realloc, Layout}; -// error-pattern: has size 1 and alignment 1, but gave size 2 and alignment 1 +//@error-pattern: has size 1 and alignment 1, but gave size 2 and alignment 1 fn main() { unsafe { diff --git a/tests/fail/alloc/reallocate-dangling.rs b/tests/fail/alloc/reallocate-dangling.rs index 62eb7582a2..34f1658344 100644 --- a/tests/fail/alloc/reallocate-dangling.rs +++ b/tests/fail/alloc/reallocate-dangling.rs @@ -1,6 +1,6 @@ use std::alloc::{alloc, dealloc, realloc, Layout}; -// error-pattern: dereferenced after this allocation got freed +//@error-pattern: dereferenced after this allocation got freed fn main() { unsafe { diff --git a/tests/fail/alloc/stack_free.rs b/tests/fail/alloc/stack_free.rs index d854fa993a..a97431bc2f 100644 --- a/tests/fail/alloc/stack_free.rs +++ b/tests/fail/alloc/stack_free.rs @@ -1,7 +1,7 @@ // Validation/SB changes why we fail -// compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows +//@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows -// error-pattern: which is stack variable memory, using Rust heap deallocation operation +//@error-pattern: which is stack variable memory, using Rust heap deallocation operation fn main() { let x = 42; diff --git a/tests/fail/concurrency/libc_pthread_create_main_terminate.rs b/tests/fail/concurrency/libc_pthread_create_main_terminate.rs index 9b576bbb08..ab80cdd205 100644 --- a/tests/fail/concurrency/libc_pthread_create_main_terminate.rs +++ b/tests/fail/concurrency/libc_pthread_create_main_terminate.rs @@ -1,5 +1,5 @@ -// ignore-windows: No libc on Windows -// error-pattern: the main thread terminated without waiting for all remaining threads +//@ignore-windows: No libc on Windows +//@error-pattern: the main thread terminated without waiting for all remaining threads // Check that we terminate the program when the main thread terminates. diff --git a/tests/fail/concurrency/thread-spawn.rs b/tests/fail/concurrency/thread-spawn.rs index 948ce946d8..650a42b43b 100644 --- a/tests/fail/concurrency/thread-spawn.rs +++ b/tests/fail/concurrency/thread-spawn.rs @@ -1,8 +1,8 @@ -// only-windows: Only Windows is not supported. +//@only-windows: Only Windows is not supported. use std::thread; -// error-pattern: can't create threads on Windows +//@error-pattern: can't create threads on Windows fn main() { thread::spawn(|| {}); diff --git a/tests/fail/dangling_pointers/null_pointer_write_zst.rs b/tests/fail/dangling_pointers/null_pointer_write_zst.rs index 60e2d7c663..7181a5979b 100644 --- a/tests/fail/dangling_pointers/null_pointer_write_zst.rs +++ b/tests/fail/dangling_pointers/null_pointer_write_zst.rs @@ -1,6 +1,6 @@ // Some optimizations remove ZST accesses, thus masking this UB. -// compile-flags: -Zmir-opt-level=0 -// error-pattern: memory access failed: null pointer is a dangling pointer +//@compile-flags: -Zmir-opt-level=0 +//@error-pattern: memory access failed: null pointer is a dangling pointer #[allow(deref_nullptr)] fn main() { diff --git a/tests/fail/fs/isolated_file.rs b/tests/fail/fs/isolated_file.rs index 5b7270f189..00bb492147 100644 --- a/tests/fail/fs/isolated_file.rs +++ b/tests/fail/fs/isolated_file.rs @@ -1,5 +1,5 @@ -// ignore-windows: File handling is not implemented yet -// error-pattern: `open` not available when isolation is enabled +//@ignore-windows: File handling is not implemented yet +//@error-pattern: `open` not available when isolation is enabled fn main() { let _file = std::fs::File::open("file.txt").unwrap(); diff --git a/tests/fail/intrinsics/copy_overflow.rs b/tests/fail/intrinsics/copy_overflow.rs index b09aedcf74..c4ce192c44 100644 --- a/tests/fail/intrinsics/copy_overflow.rs +++ b/tests/fail/intrinsics/copy_overflow.rs @@ -1,4 +1,4 @@ -// error-pattern: overflow computing total size +//@error-pattern: overflow computing total size use std::mem; fn main() { diff --git a/tests/fail/intrinsics/out_of_bounds_ptr_1.rs b/tests/fail/intrinsics/out_of_bounds_ptr_1.rs index d200b3eb02..0109bff696 100644 --- a/tests/fail/intrinsics/out_of_bounds_ptr_1.rs +++ b/tests/fail/intrinsics/out_of_bounds_ptr_1.rs @@ -1,4 +1,4 @@ -// error-pattern: pointer to 5 bytes starting at offset 0 is out-of-bounds +//@error-pattern: pointer to 5 bytes starting at offset 0 is out-of-bounds fn main() { let v = [0i8; 4]; let x = &v as *const i8; diff --git a/tests/fail/intrinsics/out_of_bounds_ptr_2.rs b/tests/fail/intrinsics/out_of_bounds_ptr_2.rs index 52b385b8e3..74d391dc21 100644 --- a/tests/fail/intrinsics/out_of_bounds_ptr_2.rs +++ b/tests/fail/intrinsics/out_of_bounds_ptr_2.rs @@ -1,4 +1,4 @@ -// error-pattern: overflowing in-bounds pointer arithmetic +//@error-pattern: overflowing in-bounds pointer arithmetic fn main() { let v = [0i8; 4]; let x = &v as *const i8; diff --git a/tests/fail/intrinsics/out_of_bounds_ptr_3.rs b/tests/fail/intrinsics/out_of_bounds_ptr_3.rs index cd0861efe5..b54cf3dd25 100644 --- a/tests/fail/intrinsics/out_of_bounds_ptr_3.rs +++ b/tests/fail/intrinsics/out_of_bounds_ptr_3.rs @@ -1,4 +1,4 @@ -// error-pattern: pointer to 1 byte starting at offset -1 is out-of-bounds +//@error-pattern: pointer to 1 byte starting at offset -1 is out-of-bounds fn main() { let v = [0i8; 4]; let x = &v as *const i8; diff --git a/tests/fail/intrinsics/ptr_offset_0_plus_0.rs b/tests/fail/intrinsics/ptr_offset_0_plus_0.rs index 4098d6b0ce..32974a825a 100644 --- a/tests/fail/intrinsics/ptr_offset_0_plus_0.rs +++ b/tests/fail/intrinsics/ptr_offset_0_plus_0.rs @@ -1,5 +1,5 @@ -// error-pattern: null pointer is a dangling pointer -// compile-flags: -Zmiri-permissive-provenance +//@error-pattern: null pointer is a dangling pointer +//@compile-flags: -Zmiri-permissive-provenance fn main() { let x = 0 as *mut i32; diff --git a/tests/fail/intrinsics/ptr_offset_int_plus_int.rs b/tests/fail/intrinsics/ptr_offset_int_plus_int.rs index 817a8b9801..f51e00746e 100644 --- a/tests/fail/intrinsics/ptr_offset_int_plus_int.rs +++ b/tests/fail/intrinsics/ptr_offset_int_plus_int.rs @@ -1,5 +1,5 @@ -// error-pattern: is a dangling pointer -// compile-flags: -Zmiri-permissive-provenance +//@error-pattern: is a dangling pointer +//@compile-flags: -Zmiri-permissive-provenance fn main() { // Can't offset an integer pointer by non-zero offset. diff --git a/tests/fail/intrinsics/ptr_offset_int_plus_ptr.rs b/tests/fail/intrinsics/ptr_offset_int_plus_ptr.rs index ed6370bf7f..8fc4d7fe73 100644 --- a/tests/fail/intrinsics/ptr_offset_int_plus_ptr.rs +++ b/tests/fail/intrinsics/ptr_offset_int_plus_ptr.rs @@ -1,5 +1,5 @@ -// error-pattern: is a dangling pointer -// compile-flags: -Zmiri-permissive-provenance +//@error-pattern: is a dangling pointer +//@compile-flags: -Zmiri-permissive-provenance fn main() { let ptr = Box::into_raw(Box::new(0u32)); diff --git a/tests/fail/intrinsics/ptr_offset_overflow.rs b/tests/fail/intrinsics/ptr_offset_overflow.rs index 734547b601..829cf90c85 100644 --- a/tests/fail/intrinsics/ptr_offset_overflow.rs +++ b/tests/fail/intrinsics/ptr_offset_overflow.rs @@ -1,4 +1,4 @@ -// error-pattern: overflowing in-bounds pointer arithmetic +//@error-pattern: overflowing in-bounds pointer arithmetic fn main() { let v = [1i8, 2]; let x = &v[1] as *const i8; diff --git a/tests/fail/intrinsics/ptr_offset_ptr_plus_0.rs b/tests/fail/intrinsics/ptr_offset_ptr_plus_0.rs index 8760345409..f8ee7d0b50 100644 --- a/tests/fail/intrinsics/ptr_offset_ptr_plus_0.rs +++ b/tests/fail/intrinsics/ptr_offset_ptr_plus_0.rs @@ -1,4 +1,4 @@ -// error-pattern: pointer at offset 32 is out-of-bounds +//@error-pattern: pointer at offset 32 is out-of-bounds fn main() { let x = Box::into_raw(Box::new(0u32)); diff --git a/tests/fail/intrinsics/simd-float-to-int.rs b/tests/fail/intrinsics/simd-float-to-int.rs index bb9adf07c9..a5bae36d92 100644 --- a/tests/fail/intrinsics/simd-float-to-int.rs +++ b/tests/fail/intrinsics/simd-float-to-int.rs @@ -1,4 +1,4 @@ -// error-pattern: cannot be represented in target type `i32` +//@error-pattern: cannot be represented in target type `i32` #![feature(portable_simd)] use std::simd::*; diff --git a/tests/fail/intrinsics/simd-gather.rs b/tests/fail/intrinsics/simd-gather.rs index ab9cb56ed0..e394cce9a4 100644 --- a/tests/fail/intrinsics/simd-gather.rs +++ b/tests/fail/intrinsics/simd-gather.rs @@ -1,4 +1,4 @@ -// error-pattern: pointer to 1 byte starting at offset 9 is out-of-bounds +//@error-pattern: pointer to 1 byte starting at offset 9 is out-of-bounds #![feature(portable_simd)] use std::simd::*; diff --git a/tests/fail/intrinsics/simd-scatter.rs b/tests/fail/intrinsics/simd-scatter.rs index d7a7e344aa..d2bc733995 100644 --- a/tests/fail/intrinsics/simd-scatter.rs +++ b/tests/fail/intrinsics/simd-scatter.rs @@ -1,4 +1,4 @@ -// error-pattern: pointer to 1 byte starting at offset 9 is out-of-bounds +//@error-pattern: pointer to 1 byte starting at offset 9 is out-of-bounds #![feature(portable_simd)] use std::simd::*; diff --git a/tests/fail/intrinsics/write_bytes_overflow.rs b/tests/fail/intrinsics/write_bytes_overflow.rs index a6bf2acb16..5c49dc0016 100644 --- a/tests/fail/intrinsics/write_bytes_overflow.rs +++ b/tests/fail/intrinsics/write_bytes_overflow.rs @@ -1,4 +1,4 @@ -// error-pattern: overflow computing total size of `write_bytes` +//@error-pattern: overflow computing total size of `write_bytes` use std::mem; fn main() { diff --git a/tests/fail/invalid_enum_tag.rs b/tests/fail/invalid_enum_tag.rs index 7ba4da9018..92cc1d1d34 100644 --- a/tests/fail/invalid_enum_tag.rs +++ b/tests/fail/invalid_enum_tag.rs @@ -1,8 +1,8 @@ // Validation makes this fail in the wrong place // Make sure we find these even with many checks disabled. -// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation +//@compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation -// error-pattern: enum value has invalid tag +//@error-pattern: enum value has invalid tag use std::mem; diff --git a/tests/fail/memleak.rs b/tests/fail/memleak.rs index 7dee9ddf1c..d384caf81a 100644 --- a/tests/fail/memleak.rs +++ b/tests/fail/memleak.rs @@ -1,5 +1,5 @@ -// error-pattern: the evaluated program leaked memory -// normalize-stderr-test: ".*│.*" -> "$$stripped$$" +//@error-pattern: the evaluated program leaked memory +//@normalize-stderr-test: ".*│.*" -> "$$stripped$$" fn main() { std::mem::forget(Box::new(42)); diff --git a/tests/fail/memleak_rc.rs b/tests/fail/memleak_rc.rs index 9ea809f762..76ecd71b01 100644 --- a/tests/fail/memleak_rc.rs +++ b/tests/fail/memleak_rc.rs @@ -1,6 +1,6 @@ -// error-pattern: the evaluated program leaked memory -// stderr-per-bitwidth -// normalize-stderr-test: ".*│.*" -> "$$stripped$$" +//@error-pattern: the evaluated program leaked memory +//@stderr-per-bitwidth +//@normalize-stderr-test: ".*│.*" -> "$$stripped$$" use std::cell::RefCell; use std::rc::Rc; diff --git a/tests/fail/memleak_rc.stderr b/tests/fail/memleak_rc.stderr new file mode 100644 index 0000000000..290de49c82 --- /dev/null +++ b/tests/fail/memleak_rc.stderr @@ -0,0 +1,11 @@ +The following memory was leaked: ALLOC (Rust heap, size: 32, align: 8) { + 0x00 │ 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 │ ................ + 0x10 │ 00 00 00 00 00 00 00 00 ╾$HEX[a1765]─╼ │ ........╾──────╼ +} + +error: the evaluated program leaked memory + +note: pass `-Zmiri-ignore-leaks` to disable this check + +error: aborting due to previous error + diff --git a/tests/fail/no_main.rs b/tests/fail/no_main.rs index a9e8e81682..e282050408 100644 --- a/tests/fail/no_main.rs +++ b/tests/fail/no_main.rs @@ -1,2 +1,2 @@ -// error-pattern: miri can only run programs that have a main function +//@error-pattern: miri can only run programs that have a main function #![no_main] diff --git a/tests/fail/panic/double_panic.rs b/tests/fail/panic/double_panic.rs index f3af66a79a..8919d51bb2 100644 --- a/tests/fail/panic/double_panic.rs +++ b/tests/fail/panic/double_panic.rs @@ -1,6 +1,6 @@ -// error-pattern: the program aborted -// normalize-stderr-test: "\| +\^+" -> "| ^" -// normalize-stderr-test: "unsafe \{ libc::abort\(\) \}|crate::intrinsics::abort\(\);" -> "ABORT();" +//@error-pattern: the program aborted +//@normalize-stderr-test: "\| +\^+" -> "| ^" +//@normalize-stderr-test: "unsafe \{ libc::abort\(\) \}|crate::intrinsics::abort\(\);" -> "ABORT();" struct Foo; impl Drop for Foo { diff --git a/tests/fail/panic/panic_abort1.rs b/tests/fail/panic/panic_abort1.rs index 9c094c6598..00a01ce6e8 100644 --- a/tests/fail/panic/panic_abort1.rs +++ b/tests/fail/panic/panic_abort1.rs @@ -1,7 +1,7 @@ -// error-pattern: the program aborted execution -// normalize-stderr-test: "\| +\^+" -> "| ^" -// normalize-stderr-test: "libc::abort\(\);|core::intrinsics::abort\(\);" -> "ABORT();" -// compile-flags: -C panic=abort +//@error-pattern: the program aborted execution +//@normalize-stderr-test: "\| +\^+" -> "| ^" +//@normalize-stderr-test: "libc::abort\(\);|core::intrinsics::abort\(\);" -> "ABORT();" +//@compile-flags: -C panic=abort fn main() { std::panic!("panicking from libstd"); diff --git a/tests/fail/panic/panic_abort2.rs b/tests/fail/panic/panic_abort2.rs index 7eb9a3c24a..dee0de9670 100644 --- a/tests/fail/panic/panic_abort2.rs +++ b/tests/fail/panic/panic_abort2.rs @@ -1,7 +1,7 @@ -// error-pattern: the program aborted execution -// normalize-stderr-test: "\| +\^+" -> "| ^" -// normalize-stderr-test: "libc::abort\(\);|core::intrinsics::abort\(\);" -> "ABORT();" -// compile-flags: -C panic=abort +//@error-pattern: the program aborted execution +//@normalize-stderr-test: "\| +\^+" -> "| ^" +//@normalize-stderr-test: "libc::abort\(\);|core::intrinsics::abort\(\);" -> "ABORT();" +//@compile-flags: -C panic=abort fn main() { std::panic!("{}-panicking from libstd", 42); diff --git a/tests/fail/panic/panic_abort3.rs b/tests/fail/panic/panic_abort3.rs index 1940b48bad..a448aab3ea 100644 --- a/tests/fail/panic/panic_abort3.rs +++ b/tests/fail/panic/panic_abort3.rs @@ -1,7 +1,7 @@ -// error-pattern: the program aborted execution -// normalize-stderr-test: "\| +\^+" -> "| ^" -// normalize-stderr-test: "libc::abort\(\);|core::intrinsics::abort\(\);" -> "ABORT();" -// compile-flags: -C panic=abort +//@error-pattern: the program aborted execution +//@normalize-stderr-test: "\| +\^+" -> "| ^" +//@normalize-stderr-test: "libc::abort\(\);|core::intrinsics::abort\(\);" -> "ABORT();" +//@compile-flags: -C panic=abort fn main() { core::panic!("panicking from libcore"); diff --git a/tests/fail/panic/panic_abort4.rs b/tests/fail/panic/panic_abort4.rs index e5190ea076..4995dad9d7 100644 --- a/tests/fail/panic/panic_abort4.rs +++ b/tests/fail/panic/panic_abort4.rs @@ -1,7 +1,7 @@ -// error-pattern: the program aborted execution -// normalize-stderr-test: "\| +\^+" -> "| ^" -// normalize-stderr-test: "libc::abort\(\);|core::intrinsics::abort\(\);" -> "ABORT();" -// compile-flags: -C panic=abort +//@error-pattern: the program aborted execution +//@normalize-stderr-test: "\| +\^+" -> "| ^" +//@normalize-stderr-test: "libc::abort\(\);|core::intrinsics::abort\(\);" -> "ABORT();" +//@compile-flags: -C panic=abort fn main() { core::panic!("{}-panicking from libcore", 42); diff --git a/tests/fail/provenance/ptr_invalid_offset.rs b/tests/fail/provenance/ptr_invalid_offset.rs index 08fb57a656..a3510d8e89 100644 --- a/tests/fail/provenance/ptr_invalid_offset.rs +++ b/tests/fail/provenance/ptr_invalid_offset.rs @@ -1,5 +1,5 @@ -// compile-flags: -Zmiri-strict-provenance -// error-pattern: is a dangling pointer +//@compile-flags: -Zmiri-strict-provenance +//@error-pattern: is a dangling pointer #![feature(strict_provenance)] fn main() { diff --git a/tests/fail/should-pass/cpp20_rwc_syncs.rs b/tests/fail/should-pass/cpp20_rwc_syncs.rs index 85c24246db..6478f446ac 100644 --- a/tests/fail/should-pass/cpp20_rwc_syncs.rs +++ b/tests/fail/should-pass/cpp20_rwc_syncs.rs @@ -1,6 +1,6 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-ignore-leaks -// error-pattern: unreachable +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-ignore-leaks +//@error-pattern: unreachable // https://plv.mpi-sws.org/scfix/paper.pdf // 2.2 Second Problem: SC Fences are Too Weak diff --git a/tests/fail/stacked_borrows/deallocate_against_barrier1.rs b/tests/fail/stacked_borrows/deallocate_against_barrier1.rs index bf18c9a058..0798f863ce 100644 --- a/tests/fail/stacked_borrows/deallocate_against_barrier1.rs +++ b/tests/fail/stacked_borrows/deallocate_against_barrier1.rs @@ -1,4 +1,4 @@ -// error-pattern: deallocating while item is protected +//@error-pattern: deallocating while item is protected fn inner(x: &mut i32, f: fn(&mut i32)) { // `f` may mutate, but it may not deallocate! diff --git a/tests/fail/stacked_borrows/deallocate_against_barrier2.rs b/tests/fail/stacked_borrows/deallocate_against_barrier2.rs index 4680f6769a..23c54c8d89 100644 --- a/tests/fail/stacked_borrows/deallocate_against_barrier2.rs +++ b/tests/fail/stacked_borrows/deallocate_against_barrier2.rs @@ -1,4 +1,4 @@ -// error-pattern: deallocating while item is protected +//@error-pattern: deallocating while item is protected use std::marker::PhantomPinned; pub struct NotUnpin(i32, PhantomPinned); diff --git a/tests/fail/stacked_borrows/issue-miri-1050-1.rs b/tests/fail/stacked_borrows/issue-miri-1050-1.rs index c1fc695e0d..6e14b9af14 100644 --- a/tests/fail/stacked_borrows/issue-miri-1050-1.rs +++ b/tests/fail/stacked_borrows/issue-miri-1050-1.rs @@ -1,4 +1,4 @@ -// error-pattern: pointer to 4 bytes starting at offset 0 is out-of-bounds +//@error-pattern: pointer to 4 bytes starting at offset 0 is out-of-bounds fn main() { unsafe { diff --git a/tests/fail/stacked_borrows/issue-miri-1050-2.rs b/tests/fail/stacked_borrows/issue-miri-1050-2.rs index 2a969686d4..571cb6213f 100644 --- a/tests/fail/stacked_borrows/issue-miri-1050-2.rs +++ b/tests/fail/stacked_borrows/issue-miri-1050-2.rs @@ -1,4 +1,4 @@ -// error-pattern: is a dangling pointer +//@error-pattern: is a dangling pointer use std::ptr::NonNull; fn main() { diff --git a/tests/fail/stacked_borrows/newtype_retagging.rs b/tests/fail/stacked_borrows/newtype_retagging.rs index 8f932f0808..4786cd02d9 100644 --- a/tests/fail/stacked_borrows/newtype_retagging.rs +++ b/tests/fail/stacked_borrows/newtype_retagging.rs @@ -1,5 +1,5 @@ -// compile-flags: -Zmiri-retag-fields -// error-pattern: incompatible item is protected +//@compile-flags: -Zmiri-retag-fields +//@error-pattern: incompatible item is protected struct Newtype<'a>(&'a mut i32); fn dealloc_while_running(_n: Newtype<'_>, dealloc: impl FnOnce()) { diff --git a/tests/fail/stacked_borrows/vtable.rs b/tests/fail/stacked_borrows/vtable.rs index dd9ba1dfb2..27e035c404 100644 --- a/tests/fail/stacked_borrows/vtable.rs +++ b/tests/fail/stacked_borrows/vtable.rs @@ -1,4 +1,4 @@ -// error-pattern: vtable pointer does not have permission +//@error-pattern: vtable pointer does not have permission #![feature(ptr_metadata)] trait Foo {} diff --git a/tests/fail/stacked_borrows/zst_slice.rs b/tests/fail/stacked_borrows/zst_slice.rs index d45b3dcac0..336b1041df 100644 --- a/tests/fail/stacked_borrows/zst_slice.rs +++ b/tests/fail/stacked_borrows/zst_slice.rs @@ -1,5 +1,5 @@ // compile-flags: -Zmiri-strict-provenance -// error-pattern: does not exist in the borrow stack +//@error-pattern: does not exist in the borrow stack fn main() { unsafe { diff --git a/tests/fail/uninit_buffer.rs b/tests/fail/uninit_buffer.rs index c8ebd835d3..d21371225e 100644 --- a/tests/fail/uninit_buffer.rs +++ b/tests/fail/uninit_buffer.rs @@ -1,4 +1,4 @@ -// error-pattern: memory is uninitialized at [0x4..0x10] +//@error-pattern: memory is uninitialized at [0x4..0x10] use std::alloc::{alloc, dealloc, Layout}; use std::slice::from_raw_parts; diff --git a/tests/fail/unreachable.rs b/tests/fail/unreachable.rs index 245ef29cad..ef2bb42c65 100644 --- a/tests/fail/unreachable.rs +++ b/tests/fail/unreachable.rs @@ -1,4 +1,4 @@ -// error-pattern: entering unreachable code +//@error-pattern: entering unreachable code fn main() { unsafe { std::hint::unreachable_unchecked() } } diff --git a/ui_test/README.md b/ui_test/README.md index 07a0a67b91..f7852c82e4 100644 --- a/ui_test/README.md +++ b/ui_test/README.md @@ -7,14 +7,12 @@ A smaller version of compiletest-rs ## Supported magic comment annotations -Note that the space after `//`, when it is present, is *not* optional -- it must be exactly one. - * `// ignore-XXX` avoids running the test on targets whose triple contains `XXX` * `XXX` can also be one of `64bit`, `32bit` or `16bit` * `// only-XXX` avoids running the test on targets whose triple **does not** contain `XXX` * `XXX` can also be one of `64bit`, `32bit` or `16bit` * `// stderr-per-bitwidth` produces one stderr file per bitwidth, as they may differ significantly sometimes -* `// error-pattern: XXX` make sure the stderr output contains `XXX` +* `//@error-pattern: XXX` make sure the stderr output contains `XXX` * `//~ ERROR: XXX` make sure the stderr output contains `XXX` for an error in the line where this comment is written * Also supports `HELP`, `WARN` or `NOTE` for different kind of message * if one of those levels is specified explicitly, *all* diagnostics of this level or higher need an annotation. If you want to avoid this, just leave out the all caps level note entirely. diff --git a/ui_test/src/comments.rs b/ui_test/src/comments.rs index d4ee3efd14..569dad5a25 100644 --- a/ui_test/src/comments.rs +++ b/ui_test/src/comments.rs @@ -246,7 +246,8 @@ impl Comments { ); self.error_pattern = Some((args.trim().to_string(), l)); } - _ => exit!("unknown command {command} with args {args}"), + // Maybe the user just left a comment explaining a command without arguments + _ => self.parse_command(command, path, l), } } @@ -292,14 +293,8 @@ impl Comments { checked!(path, l); let (revision, pattern) = unwrap!(pattern.split_once(']'), "`//[` without corresponding `]`"); - if pattern.starts_with('~') { - self.parse_pattern_inner( - &pattern[1..], - fallthrough_to, - Some(revision.to_owned()), - path, - l, - ) + if let Some(pattern) = pattern.strip_prefix('~') { + self.parse_pattern_inner(pattern, fallthrough_to, Some(revision.to_owned()), path, l) } else { exit!("revisioned pattern must have `~` following the `]`"); } diff --git a/ui_test/src/lib.rs b/ui_test/src/lib.rs index ff0c4e1c89..21b8c54ff2 100644 --- a/ui_test/src/lib.rs +++ b/ui_test/src/lib.rs @@ -377,7 +377,7 @@ fn check_annotations( ) { if let Some((ref error_pattern, definition_line)) = comments.error_pattern { // first check the diagnostics messages outside of our file. We check this first, so that - // you can mix in-file annotations with // error-pattern annotations, even if there is overlap + // you can mix in-file annotations with //@error-pattern annotations, even if there is overlap // in the messages. if let Some(i) = messages_from_unknown_file_or_line .iter() From b3e64c252a3834ba880daf478dd0630bb61365d3 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 6 Jul 2022 08:42:32 +0000 Subject: [PATCH 03/17] Revert testing ui_test before ui tests --- miri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miri b/miri index be51535d59..f0d92b6a2b 100755 --- a/miri +++ b/miri @@ -181,8 +181,8 @@ test|test-debug|bless|bless-debug) esac # Then test, and let caller control flags. # Only in root project and ui_test as `cargo-miri` has no tests. - $CARGO test $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/ui_test/Cargo.toml "$@" $CARGO test $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml "$@" + $CARGO test $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/ui_test/Cargo.toml "$@" ;; run|run-debug) # Scan for "--target" to overwrite the "MIRI_TEST_TARGET" env var so From 570032b0dd8042243721b78f50d186577a52a3a9 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 6 Jul 2022 09:09:53 +0000 Subject: [PATCH 04/17] Introduce a proper error handling framework --- Cargo.lock | 194 ++++++++++++++++++++++++++++++++++ tests/compiletest.rs | 20 ++-- ui_test/Cargo.lock | 194 ++++++++++++++++++++++++++++++++++ ui_test/Cargo.toml | 2 + ui_test/src/comments.rs | 18 ++-- ui_test/src/comments/tests.rs | 28 +++-- ui_test/src/lib.rs | 10 +- ui_test/src/tests.rs | 55 ++++++---- 8 files changed, 471 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 880fa271d9..cc707c630e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,21 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "aho-corasick" version = "0.7.18" @@ -37,18 +52,66 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "backtrace" +version = "0.3.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11a17d453482a265fd5f8479f2a3f405566e6ca627837aaddb85af8b1ab8ef61" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" + [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "color-eyre" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ebf286c900a6d5867aeff75cfee3192857bb7f24b547d4f0df2ed6baa812c90" +dependencies = [ + "backtrace", + "color-spantrace", + "eyre", + "indenter", + "once_cell", + "owo-colors", + "tracing-error", +] + +[[package]] +name = "color-spantrace" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ba75b3d9449ecdccb27ecbc479fdc0b87fa2dd43d2f8298f9bf0e59aacc8dce" +dependencies = [ + "once_cell", + "owo-colors", + "tracing-core", + "tracing-error", +] + [[package]] name = "colored" version = "2.0.0" @@ -158,6 +221,16 @@ dependencies = [ "termcolor", ] +[[package]] +name = "eyre" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb" +dependencies = [ + "indenter", + "once_cell", +] + [[package]] name = "getrandom" version = "0.2.3" @@ -169,6 +242,12 @@ dependencies = [ "wasi", ] +[[package]] +name = "gimli" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -184,6 +263,12 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "indenter" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" + [[package]] name = "instant" version = "0.1.12" @@ -267,6 +352,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "miniz_oxide" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc" +dependencies = [ + "adler", +] + [[package]] name = "miri" version = "0.1.0" @@ -286,6 +380,21 @@ dependencies = [ "ui_test", ] +[[package]] +name = "object" +version = "0.28.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" + [[package]] name = "output_vt100" version = "0.1.3" @@ -295,6 +404,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "owo-colors" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "decf7381921fea4dcb2549c5667eda59b3ec297ab7e2b5fc33eac69d2e7da87b" + [[package]] name = "parking_lot" version = "0.11.2" @@ -329,6 +444,12 @@ dependencies = [ "libc", ] +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + [[package]] name = "ppv-lite86" version = "0.2.15" @@ -431,6 +552,12 @@ version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +[[package]] +name = "rustc-demangle" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" + [[package]] name = "rustc-hash" version = "1.1.0" @@ -501,6 +628,15 @@ dependencies = [ "serde", ] +[[package]] +name = "sharded-slab" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +dependencies = [ + "lazy_static", +] + [[package]] name = "shell-escape" version = "0.1.5" @@ -533,10 +669,62 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "thread_local" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +dependencies = [ + "once_cell", +] + +[[package]] +name = "tracing" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a400e31aa60b9d44a52a8ee0343b5b18566b03a8321e0d321f695cf56e940160" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b7358be39f2f274f322d2aaed611acc57f382e8eb1e5b48cb9ae30933495ce7" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-error" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e" +dependencies = [ + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a713421342a5a666b7577783721d3117f1b69a393df803ee17bb73b1e122a59" +dependencies = [ + "sharded-slab", + "thread_local", + "tracing-core", +] + [[package]] name = "ui_test" version = "0.1.0" dependencies = [ + "color-eyre", "colored", "crossbeam", "lazy_static", @@ -553,6 +741,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "wasi" version = "0.10.2+wasi-snapshot-preview1" diff --git a/tests/compiletest.rs b/tests/compiletest.rs index 754fccd63b..9537fb993c 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -2,13 +2,13 @@ use colored::*; use regex::Regex; use std::env; use std::path::PathBuf; -use ui_test::{Config, Mode, OutputConflictHandling}; +use ui_test::{Config, Mode, OutputConflictHandling, color_eyre::Result}; fn miri_path() -> PathBuf { PathBuf::from(option_env!("MIRI").unwrap_or(env!("CARGO_BIN_EXE_miri"))) } -fn run_tests(mode: Mode, path: &str, target: Option) { +fn run_tests(mode: Mode, path: &str, target: Option) -> Result<()> { let in_rustc_test_suite = option_env!("RUSTC_STAGE").is_some(); // Add some flags we always want. @@ -108,7 +108,7 @@ regexes! { "sys/[a-z]+/" => "sys/PLATFORM/", } -fn ui(mode: Mode, path: &str) { +fn ui(mode: Mode, path: &str) -> Result<()> { let target = get_target(); let msg = format!( @@ -117,20 +117,24 @@ fn ui(mode: Mode, path: &str) { ); eprintln!("{}", msg.green().bold()); - run_tests(mode, path, target); + run_tests(mode, path, target) } fn get_target() -> Option { env::var("MIRI_TEST_TARGET").ok() } -fn main() { +fn main() -> Result<()> { + ui_test::color_eyre::install()?; + // Add a test env var to do environment communication tests. env::set_var("MIRI_ENV_VAR_TEST", "0"); // Let the tests know where to store temp files (they might run for a different target, which can make this hard to find). env::set_var("MIRI_TEMP", env::temp_dir()); - ui(Mode::Pass, "tests/pass"); - ui(Mode::Panic, "tests/panic"); - ui(Mode::Fail, "tests/fail"); + ui(Mode::Pass, "tests/pass")?; + ui(Mode::Panic, "tests/panic")?; + ui(Mode::Fail, "tests/fail")?; + + Ok(()) } diff --git a/ui_test/Cargo.lock b/ui_test/Cargo.lock index 5a4cdb8927..2065cc34be 100644 --- a/ui_test/Cargo.lock +++ b/ui_test/Cargo.lock @@ -2,6 +2,21 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "aho-corasick" version = "0.7.18" @@ -37,12 +52,60 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "backtrace" +version = "0.3.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11a17d453482a265fd5f8479f2a3f405566e6ca627837aaddb85af8b1ab8ef61" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" + [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "color-eyre" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ebf286c900a6d5867aeff75cfee3192857bb7f24b547d4f0df2ed6baa812c90" +dependencies = [ + "backtrace", + "color-spantrace", + "eyre", + "indenter", + "once_cell", + "owo-colors", + "tracing-error", +] + +[[package]] +name = "color-spantrace" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ba75b3d9449ecdccb27ecbc479fdc0b87fa2dd43d2f8298f9bf0e59aacc8dce" +dependencies = [ + "once_cell", + "owo-colors", + "tracing-core", + "tracing-error", +] + [[package]] name = "colored" version = "2.0.0" @@ -139,6 +202,22 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499" +[[package]] +name = "eyre" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb" +dependencies = [ + "indenter", + "once_cell", +] + +[[package]] +name = "gimli" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -148,6 +227,12 @@ dependencies = [ "libc", ] +[[package]] +name = "indenter" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" + [[package]] name = "itoa" version = "1.0.2" @@ -181,6 +266,30 @@ dependencies = [ "autocfg", ] +[[package]] +name = "miniz_oxide" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc" +dependencies = [ + "adler", +] + +[[package]] +name = "object" +version = "0.28.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" + [[package]] name = "output_vt100" version = "0.1.3" @@ -190,6 +299,18 @@ dependencies = [ "winapi", ] +[[package]] +name = "owo-colors" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "decf7381921fea4dcb2549c5667eda59b3ec297ab7e2b5fc33eac69d2e7da87b" + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + [[package]] name = "pretty_assertions" version = "1.2.1" @@ -237,6 +358,12 @@ version = "0.6.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" +[[package]] +name = "rustc-demangle" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" + [[package]] name = "rustc_version" version = "0.4.0" @@ -295,6 +422,15 @@ dependencies = [ "serde", ] +[[package]] +name = "sharded-slab" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +dependencies = [ + "lazy_static", +] + [[package]] name = "syn" version = "1.0.95" @@ -306,10 +442,62 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "thread_local" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +dependencies = [ + "once_cell", +] + +[[package]] +name = "tracing" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a400e31aa60b9d44a52a8ee0343b5b18566b03a8321e0d321f695cf56e940160" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b7358be39f2f274f322d2aaed611acc57f382e8eb1e5b48cb9ae30933495ce7" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-error" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e" +dependencies = [ + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a713421342a5a666b7577783721d3117f1b69a393df803ee17bb73b1e122a59" +dependencies = [ + "sharded-slab", + "thread_local", + "tracing-core", +] + [[package]] name = "ui_test" version = "0.1.0" dependencies = [ + "color-eyre", "colored", "crossbeam", "lazy_static", @@ -326,6 +514,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "winapi" version = "0.3.9" diff --git a/ui_test/Cargo.toml b/ui_test/Cargo.toml index 1d480b6938..94c5acb6b7 100644 --- a/ui_test/Cargo.toml +++ b/ui_test/Cargo.toml @@ -17,3 +17,5 @@ crossbeam = "0.8.1" lazy_static = "1.4.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" +color-eyre = "0.6.1" + diff --git a/ui_test/src/comments.rs b/ui_test/src/comments.rs index 569dad5a25..fcbcae33f2 100644 --- a/ui_test/src/comments.rs +++ b/ui_test/src/comments.rs @@ -4,6 +4,8 @@ use regex::Regex; use crate::rustc_stderr::Level; +use color_eyre::eyre::Result; + #[cfg(test)] mod tests; @@ -102,8 +104,8 @@ macro_rules! checked { } impl Comments { - pub(crate) fn parse_file(path: &Path) -> Self { - let content = std::fs::read_to_string(path).unwrap(); + pub(crate) fn parse_file(path: &Path) -> Result { + let content = std::fs::read_to_string(path)?; Self::parse(path, &content) } @@ -112,7 +114,7 @@ impl Comments { /// /// This function will only parse `//@` and `//~` style comments /// and ignore all others - fn parse_checked(path: &Path, content: &str) -> Self { + fn parse_checked(path: &Path, content: &str) -> Result { let mut this = Self::default(); // The line that a `|` will refer to @@ -136,16 +138,16 @@ impl Comments { fallthrough_to = None; } } - this + Ok(this) } /// Parse comments in `content`. /// `path` is only used to emit diagnostics if parsing fails. - pub(crate) fn parse(path: &Path, content: &str) -> Self { - let mut this = Self::parse_checked(path, content); + pub(crate) fn parse(path: &Path, content: &str) -> Result { + let mut this = Self::parse_checked(path, content)?; if content.contains("//@") { // Migration mode: if new syntax is used, ignore all old syntax - return this; + return Ok(this); } for (l, line) in content.lines().enumerate() { @@ -209,7 +211,7 @@ impl Comments { this.error_pattern = Some((s.trim().to_string(), l)); } } - this + Ok(this) } fn parse_command_with_args(&mut self, command: &str, args: &str, path: &Path, l: usize) { diff --git a/ui_test/src/comments/tests.rs b/ui_test/src/comments/tests.rs index dc69a5d4d6..0573ee8ba7 100644 --- a/ui_test/src/comments/tests.rs +++ b/ui_test/src/comments/tests.rs @@ -1,9 +1,13 @@ -use std::path::Path; +use std::{path::Path, panic::catch_unwind}; use super::Comments; +use color_eyre::eyre::{Result, bail}; +use crate::tests::init; + #[test] -fn parse_simple_comment() { +fn parse_simple_comment() -> Result<()> { + init(); let s = r" use std::mem; @@ -11,7 +15,7 @@ fn main() { let _x: &i32 = unsafe { mem::transmute(16usize) }; //~ ERROR encountered a dangling reference (address $HEX is unallocated) } "; - let comments = Comments::parse(Path::new(""), s); + let comments = Comments::parse(Path::new(""), s)?; println!("parsed comments: {:#?}", comments); assert_eq!(comments.error_matches[0].definition_line, 5); assert_eq!(comments.error_matches[0].revision, None); @@ -19,29 +23,33 @@ fn main() { comments.error_matches[0].matched, "encountered a dangling reference (address $HEX is unallocated)" ); + Ok(()) } #[test] -fn parse_slash_slash_at() { +fn parse_slash_slash_at() -> Result<()> { + init(); let s = r" //@ error-pattern: foomp use std::mem; "; - let comments = Comments::parse(Path::new(""), s); + let comments = Comments::parse(Path::new(""), s)?; println!("parsed comments: {:#?}", comments); assert_eq!(comments.error_pattern, Some(("foomp".to_string(), 2))); + Ok(()) } #[test] -#[should_panic] -fn parse_slash_slash_at_fail() { +fn parse_slash_slash_at_fail() -> Result<()> { + init(); let s = r" //@ error-pattern foomp use std::mem; "; - let comments = Comments::parse(Path::new(""), s); - println!("parsed comments: {:#?}", comments); - assert_eq!(comments.error_pattern, Some(("foomp".to_string(), 2))); + match catch_unwind(|| Comments::parse(Path::new(""), s)) { + Ok(_) => bail!("expected parsing to panic"), + Err(_) => Ok(()), + } } diff --git a/ui_test/src/lib.rs b/ui_test/src/lib.rs index 21b8c54ff2..90e7669f62 100644 --- a/ui_test/src/lib.rs +++ b/ui_test/src/lib.rs @@ -11,6 +11,8 @@ use colored::*; use comments::ErrorMatch; use regex::Regex; use rustc_stderr::{Level, Message}; +use color_eyre::eyre::Result; +pub use color_eyre; use crate::comments::{Comments, Condition}; @@ -51,7 +53,7 @@ pub enum OutputConflictHandling { pub type Filter = Vec<(Regex, &'static str)>; -pub fn run_tests(config: Config) { +pub fn run_tests(config: Config) -> Result<()> { eprintln!(" Compiler flags: {:?}", config.args); // Get the triple with which to run the tests @@ -94,7 +96,7 @@ pub fn run_tests(config: Config) { // Create N worker threads that receive files to test. for _ in 0..std::thread::available_parallelism().unwrap().get() { - s.spawn(|_| { + s.spawn(|_| -> Result<()> { for path in &receive { if !config.path_filter.is_empty() { let path_display = path.display().to_string(); @@ -103,7 +105,7 @@ pub fn run_tests(config: Config) { continue; } } - let comments = Comments::parse_file(&path); + let comments = Comments::parse_file(&path)?; // Ignore file if only/ignore rules do (not) apply if !test_file_conditions(&comments, &target) { ignored.fetch_add(1, Ordering::Relaxed); @@ -142,6 +144,7 @@ pub fn run_tests(config: Config) { } } } + Ok(()) }); } }) @@ -246,6 +249,7 @@ pub fn run_tests(config: Config) { filtered.to_string().yellow(), ); eprintln!(); + Ok(()) } #[derive(Debug)] diff --git a/ui_test/src/tests.rs b/ui_test/src/tests.rs index a45f8f8933..13a242f8d8 100644 --- a/ui_test/src/tests.rs +++ b/ui_test/src/tests.rs @@ -20,7 +20,8 @@ fn config() -> Config { } #[test] -fn issue_2156() { +fn issue_2156() -> Result<()> { + init(); let s = r" use std::mem; @@ -29,7 +30,7 @@ fn main() { } "; let path = Path::new("$DIR/"); - let comments = Comments::parse(path, s); + let comments = Comments::parse(path, s)?; let mut errors = vec![]; let config = config(); let messages = vec![ @@ -46,13 +47,14 @@ fn main() { [ Error::PatternNotFound { definition_line: 5, .. }, Error::ErrorsWithoutPattern { path: Some((_, 5)), .. }, - ] => {} + ] => Ok(()), _ => panic!("{:#?}", errors), } } #[test] -fn find_pattern() { +fn find_pattern() -> Result<()> { + init(); let s = r" use std::mem; @@ -60,7 +62,7 @@ fn main() { let _x: &i32 = unsafe { mem::transmute(16usize) }; //~ ERROR encountered a dangling reference (address 0x10 is unallocated) } "; - let comments = Comments::parse(Path::new(""), s); + let comments = Comments::parse(Path::new(""), s)?; let config = config(); { let messages = vec![vec![], vec![], vec![], vec![], vec![], vec![ @@ -137,14 +139,15 @@ fn main() { ); match &errors[..] { // Note no `ErrorsWithoutPattern`, because there are no `//~NOTE` in the test file, so we ignore them - [Error::PatternNotFound { definition_line: 5, .. }] => {} + [Error::PatternNotFound { definition_line: 5, .. }] => Ok(()), _ => panic!("not the expected error: {:#?}", errors), } } } #[test] -fn duplicate_pattern() { +fn duplicate_pattern() -> Result<()> { + init(); let s = r" use std::mem; @@ -153,7 +156,7 @@ fn main() { //~^ ERROR encountered a dangling reference (address 0x10 is unallocated) } "; - let comments = Comments::parse(Path::new(""), s); + let comments = Comments::parse(Path::new(""), s)?; let config = config(); let messages = vec![ vec![], vec![], vec![], vec![], vec![], @@ -167,13 +170,14 @@ fn main() { let mut errors = vec![]; check_annotations(messages, vec![], Path::new("moobar"), &mut errors, &config, "", &comments); match &errors[..] { - [Error::PatternNotFound { definition_line: 6, .. }] => {} + [Error::PatternNotFound { definition_line: 6, .. }] => Ok(()), _ => panic!("{:#?}", errors), } } #[test] -fn missing_pattern() { +fn missing_pattern() -> Result<()> { + init(); let s = r" use std::mem; @@ -181,7 +185,7 @@ fn main() { let _x: &i32 = unsafe { mem::transmute(16usize) }; //~ ERROR encountered a dangling reference (address 0x10 is unallocated) } "; - let comments = Comments::parse(Path::new(""), s); + let comments = Comments::parse(Path::new(""), s)?; let config = config(); let messages = vec![ vec![], vec![], vec![], vec![], vec![], @@ -199,13 +203,14 @@ fn main() { let mut errors = vec![]; check_annotations(messages, vec![], Path::new("moobar"), &mut errors, &config, "", &comments); match &errors[..] { - [Error::ErrorsWithoutPattern { path: Some((_, 5)), .. }] => {} + [Error::ErrorsWithoutPattern { path: Some((_, 5)), .. }] => Ok(()), _ => panic!("{:#?}", errors), } } #[test] -fn missing_warn_pattern() { +fn missing_warn_pattern() -> Result<()> { + init(); let s = r" use std::mem; @@ -214,7 +219,7 @@ fn main() { //~^ WARN cake } "; - let comments = Comments::parse(Path::new(""), s); + let comments = Comments::parse(Path::new(""), s)?; let config = config(); let messages= vec![ vec![], @@ -242,7 +247,7 @@ fn main() { match &errors[..] { [Error::ErrorsWithoutPattern { path: Some((_, 5)), msgs, .. }] => match &msgs[..] { - [Message { message, level: Level::Warn }] if message == "kaboom" => {} + [Message { message, level: Level::Warn }] if message == "kaboom" => Ok(()), _ => panic!("{:#?}", msgs), }, _ => panic!("{:#?}", errors), @@ -250,7 +255,8 @@ fn main() { } #[test] -fn missing_implicit_warn_pattern() { +fn missing_implicit_warn_pattern() -> Result<()> { + init(); let s = r" use std::mem; @@ -259,7 +265,7 @@ fn main() { //~^ cake } "; - let comments = Comments::parse(Path::new(""), s); + let comments = Comments::parse(Path::new(""), s)?; let config = config(); let messages = vec![ vec![], @@ -285,13 +291,14 @@ fn main() { let mut errors = vec![]; check_annotations(messages, vec![], Path::new("moobar"), &mut errors, &config, "", &comments); match &errors[..] { - [] => {} + [] => Ok(()), _ => panic!("{:#?}", errors), } } #[test] -fn implicit_err_pattern() { +fn implicit_err_pattern() -> Result<()> { + init(); let s = r" use std::mem; @@ -299,7 +306,7 @@ fn main() { let _x: &i32 = unsafe { mem::transmute(16usize) }; //~ encountered a dangling reference (address 0x10 is unallocated) } "; - let comments = Comments::parse(Path::new(""), s); + let comments = Comments::parse(Path::new(""), s)?; let config = config(); let messages = vec![ vec![], @@ -317,7 +324,13 @@ fn main() { let mut errors = vec![]; check_annotations(messages, vec![], Path::new("moobar"), &mut errors, &config, "", &comments); match &errors[..] { - [Error::ErrorPatternWithoutErrorAnnotation(_, 5)] => {} + [Error::ErrorPatternWithoutErrorAnnotation(_, 5)] => Ok(()), _ => panic!("{:#?}", errors), } } + +static INIT: std::sync::Once = std::sync::Once::new(); + +pub fn init() { + INIT.call_once(|| color_eyre::install().unwrap()); +} From 54b6b034104ce81a8d02800b9fc7d5181389b4df Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 6 Jul 2022 09:44:03 +0000 Subject: [PATCH 05/17] Actually use eyre and get rid of the ad-hoc macros emulating error handling --- tests/compiletest.rs | 2 +- ui_test/src/comments.rs | 166 +++++++++++++++------------------- ui_test/src/comments/tests.rs | 8 +- ui_test/src/lib.rs | 18 ++-- 4 files changed, 88 insertions(+), 106 deletions(-) diff --git a/tests/compiletest.rs b/tests/compiletest.rs index 9537fb993c..008fc78064 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -2,7 +2,7 @@ use colored::*; use regex::Regex; use std::env; use std::path::PathBuf; -use ui_test::{Config, Mode, OutputConflictHandling, color_eyre::Result}; +use ui_test::{color_eyre::Result, Config, Mode, OutputConflictHandling}; fn miri_path() -> PathBuf { PathBuf::from(option_env!("MIRI").unwrap_or(env!("CARGO_BIN_EXE_miri"))) diff --git a/ui_test/src/comments.rs b/ui_test/src/comments.rs index fcbcae33f2..481565cfea 100644 --- a/ui_test/src/comments.rs +++ b/ui_test/src/comments.rs @@ -4,7 +4,7 @@ use regex::Regex; use crate::rustc_stderr::Level; -use color_eyre::eyre::Result; +use color_eyre::eyre::{bail, ensure, eyre, Result}; #[cfg(test)] mod tests; @@ -66,43 +66,6 @@ impl Condition { } } -macro_rules! checked { - ($path:expr, $l:expr) => { - let path = $path; - let l = $l; - #[allow(unused_macros)] - macro_rules! exit { - ($fmt:expr $$(,$args:expr)*) => {{ - eprint!("{}:{l}: ", path.display()); - eprintln!($fmt, $$($args,)*); - #[cfg(not(test))] - std::process::exit(1); - #[cfg(test)] - panic!(); - }}; - } - #[allow(unused_macros)] - macro_rules! check { - ($cond:expr, $fmt:expr $$(,$args:expr)*) => {{ - if !$cond { - exit!($fmt $$(,$args)*); - } - }}; - } - #[allow(unused_macros)] - macro_rules! unwrap { - ($cond:expr, $fmt:expr $$(,$args:expr)*) => {{ - match $cond { - Some(val) => val, - None => { - exit!($fmt $$(,$args)*); - } - } - }}; - } - }; -} - impl Comments { pub(crate) fn parse_file(path: &Path) -> Result { let content = std::fs::read_to_string(path)?; @@ -121,24 +84,36 @@ impl Comments { let mut fallthrough_to = None; for (l, line) in content.lines().enumerate() { let l = l + 1; // enumerate starts at 0, but line numbers start at 1 - if let Some((_, command)) = line.split_once("//@") { - let command = command.trim(); - if let Some((command, args)) = command.split_once(':') { - this.parse_command_with_args(command, args, path, l); - } else if let Some((command, _comments)) = command.split_once(' ') { - this.parse_command(command, path, l) - } else { - this.parse_command(command, path, l) - } - } else if let Some((_, pattern)) = line.split_once("//~") { - this.parse_pattern(pattern, &mut fallthrough_to, path, l) - } else if let Some((_, pattern)) = line.split_once("//[") { - this.parse_revisioned_pattern(pattern, &mut fallthrough_to, path, l) + this.parse_checked_line(l, &mut fallthrough_to, line).map_err(|err| { + err.wrap_err(format!("{}:{l}: failed to parse annotation", path.display())) + })?; + } + Ok(this) + } + + fn parse_checked_line( + &mut self, + l: usize, + fallthrough_to: &mut Option, + line: &str, + ) -> Result<()> { + if let Some((_, command)) = line.split_once("//@") { + let command = command.trim(); + if let Some((command, args)) = command.split_once(':') { + self.parse_command_with_args(command, args, l) + } else if let Some((command, _comments)) = command.split_once(' ') { + self.parse_command(command) } else { - fallthrough_to = None; + self.parse_command(command) } + } else if let Some((_, pattern)) = line.split_once("//~") { + self.parse_pattern(pattern, fallthrough_to, l) + } else if let Some((_, pattern)) = line.split_once("//[") { + self.parse_revisioned_pattern(pattern, fallthrough_to, l) + } else { + *fallthrough_to = None; + Ok(()) } - Ok(this) } /// Parse comments in `content`. @@ -214,11 +189,10 @@ impl Comments { Ok(this) } - fn parse_command_with_args(&mut self, command: &str, args: &str, path: &Path, l: usize) { - checked!(path, l); + fn parse_command_with_args(&mut self, command: &str, args: &str, l: usize) -> Result<()> { match command { "revisions" => { - check!(self.revisions.is_none(), "cannot specifiy revisions twice"); + ensure!(self.revisions.is_none(), "cannot specifiy revisions twice"); self.revisions = Some(args.split_whitespace().map(|s| s.to_string()).collect()); } "compile-flags" => { @@ -226,22 +200,22 @@ impl Comments { } "rustc-env" => for env in args.split_whitespace() { - let (k, v) = unwrap!( - env.split_once('='), - "environment variables must be key/value pairs separated by a `=`" - ); + let (k, v) = env.split_once('=').ok_or_else(|| { + eyre!("environment variables must be key/value pairs separated by a `=`") + })?; self.env_vars.push((k.to_string(), v.to_string())); }, "normalize-stderr-test" => { - let (from, to) = - unwrap!(args.split_once("->"), "normalize-stderr-test needs a `->`"); + let (from, to) = args + .split_once("->") + .ok_or_else(|| eyre!("normalize-stderr-test needs a `->`"))?; let from = from.trim().trim_matches('"'); let to = to.trim().trim_matches('"'); - let from = unwrap!(Regex::new(from).ok(), "invalid regex"); + let from = Regex::new(from).ok().ok_or_else(|| eyre!("invalid regex"))?; self.normalize_stderr.push((from, to.to_string())); } "error-pattern" => { - check!( + ensure!( self.error_pattern.is_none(), "cannot specifiy error_pattern twice, previous: {:?}", self.error_pattern @@ -249,56 +223,52 @@ impl Comments { self.error_pattern = Some((args.trim().to_string(), l)); } // Maybe the user just left a comment explaining a command without arguments - _ => self.parse_command(command, path, l), + _ => self.parse_command(command)?, } + Ok(()) } - fn parse_command(&mut self, command: &str, path: &Path, l: usize) { - checked!(path, l); - + fn parse_command(&mut self, command: &str) -> Result<()> { if let Some(s) = command.strip_prefix("ignore-") { self.ignore.push(Condition::parse(s)); - return; + return Ok(()); } if let Some(s) = command.strip_prefix("only-") { self.only.push(Condition::parse(s)); - return; + return Ok(()); } if command.starts_with("stderr-per-bitwidth") { - check!(!self.stderr_per_bitwidth, "cannot specifiy stderr-per-bitwidth twice"); + ensure!(!self.stderr_per_bitwidth, "cannot specifiy stderr-per-bitwidth twice"); self.stderr_per_bitwidth = true; - return; + return Ok(()); } - exit!("unknown command {command}"); + bail!("unknown command {command}"); } fn parse_pattern( &mut self, pattern: &str, fallthrough_to: &mut Option, - path: &Path, l: usize, - ) { - self.parse_pattern_inner(pattern, fallthrough_to, None, path, l) + ) -> Result<()> { + self.parse_pattern_inner(pattern, fallthrough_to, None, l) } fn parse_revisioned_pattern( &mut self, pattern: &str, fallthrough_to: &mut Option, - path: &Path, l: usize, - ) { - checked!(path, l); + ) -> Result<()> { let (revision, pattern) = - unwrap!(pattern.split_once(']'), "`//[` without corresponding `]`"); + pattern.split_once(']').ok_or_else(|| eyre!("`//[` without corresponding `]`"))?; if let Some(pattern) = pattern.strip_prefix('~') { - self.parse_pattern_inner(pattern, fallthrough_to, Some(revision.to_owned()), path, l) + self.parse_pattern_inner(pattern, fallthrough_to, Some(revision.to_owned()), l) } else { - exit!("revisioned pattern must have `~` following the `]`"); + bail!("revisioned pattern must have `~` following the `]`"); } } @@ -308,21 +278,25 @@ impl Comments { pattern: &str, fallthrough_to: &mut Option, revision: Option, - path: &Path, l: usize, - ) { - checked!(path, l); + ) -> Result<()> { // FIXME: check that the error happens on the marked line - let (match_line, pattern) = match unwrap!(pattern.chars().next(), "no pattern specified") { - '|' => - (*unwrap!(fallthrough_to, "`//~|` pattern without preceding line"), &pattern[1..]), - '^' => { - let offset = pattern.chars().take_while(|&c| c == '^').count(); - (l - offset, &pattern[offset..]) - } - _ => (l, pattern), - }; + let (match_line, pattern) = + match pattern.chars().next().ok_or_else(|| eyre!("no pattern specified"))? { + '|' => + ( + *fallthrough_to + .as_mut() + .ok_or_else(|| eyre!("`//~|` pattern without preceding line"))?, + &pattern[1..], + ), + '^' => { + let offset = pattern.chars().take_while(|&c| c == '^').count(); + (l - offset, &pattern[offset..]) + } + _ => (l, pattern), + }; let (level, pattern) = match pattern.trim_start().split_once(|c| matches!(c, ':' | ' ')) { None => (None, pattern), @@ -335,7 +309,7 @@ impl Comments { let matched = pattern.trim().to_string(); - check!(!matched.is_empty(), "no pattern specified"); + ensure!(!matched.is_empty(), "no pattern specified"); *fallthrough_to = Some(match_line); @@ -346,5 +320,7 @@ impl Comments { definition_line: l, line: match_line, }); + + Ok(()) } } diff --git a/ui_test/src/comments/tests.rs b/ui_test/src/comments/tests.rs index 0573ee8ba7..cdd81aa990 100644 --- a/ui_test/src/comments/tests.rs +++ b/ui_test/src/comments/tests.rs @@ -1,9 +1,9 @@ -use std::{path::Path, panic::catch_unwind}; +use std::path::Path; use super::Comments; -use color_eyre::eyre::{Result, bail}; use crate::tests::init; +use color_eyre::eyre::{bail, Result}; #[test] fn parse_simple_comment() -> Result<()> { @@ -48,8 +48,8 @@ fn parse_slash_slash_at_fail() -> Result<()> { use std::mem; "; - match catch_unwind(|| Comments::parse(Path::new(""), s)) { - Ok(_) => bail!("expected parsing to panic"), + match Comments::parse(Path::new(""), s) { + Ok(_) => bail!("expected parsing to fail"), Err(_) => Ok(()), } } diff --git a/ui_test/src/lib.rs b/ui_test/src/lib.rs index 90e7669f62..da562fcac7 100644 --- a/ui_test/src/lib.rs +++ b/ui_test/src/lib.rs @@ -7,12 +7,12 @@ use std::process::{Command, ExitStatus}; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Mutex; +pub use color_eyre; +use color_eyre::eyre::Result; use colored::*; use comments::ErrorMatch; use regex::Regex; use rustc_stderr::{Level, Message}; -use color_eyre::eyre::Result; -pub use color_eyre; use crate::comments::{Comments, Condition}; @@ -68,7 +68,7 @@ pub fn run_tests(config: Config) -> Result<()> { let ignored = AtomicUsize::default(); let filtered = AtomicUsize::default(); - crossbeam::scope(|s| { + crossbeam::scope(|s| -> Result<()> { // Create a thread that is in charge of walking the directory and submitting jobs. // It closes the channel when it is done. s.spawn(|_| { @@ -94,9 +94,11 @@ pub fn run_tests(config: Config) -> Result<()> { drop(submit); }); + let mut threads = vec![]; + // Create N worker threads that receive files to test. for _ in 0..std::thread::available_parallelism().unwrap().get() { - s.spawn(|_| -> Result<()> { + threads.push(s.spawn(|_| -> Result<()> { for path in &receive { if !config.path_filter.is_empty() { let path_display = path.display().to_string(); @@ -145,10 +147,14 @@ pub fn run_tests(config: Config) -> Result<()> { } } Ok(()) - }); + })); + } + for thread in threads { + thread.join().unwrap()?; } + Ok(()) }) - .unwrap(); + .unwrap()?; // Print all errors in a single thread to show reliable output let failures = failures.into_inner().unwrap(); From 63916d6f0429718112661e47fac37b2fcfea338e Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 6 Jul 2022 09:53:52 +0000 Subject: [PATCH 06/17] Document all the things --- ui_test/README.md | 38 +++++++++++++++++++++++++------------- ui_test/src/comments.rs | 2 +- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/ui_test/README.md b/ui_test/README.md index f7852c82e4..fef2c6d44b 100644 --- a/ui_test/README.md +++ b/ui_test/README.md @@ -7,25 +7,37 @@ A smaller version of compiletest-rs ## Supported magic comment annotations -* `// ignore-XXX` avoids running the test on targets whose triple contains `XXX` +If your test tests for failure, you need to add a `//~` annotation where the error is happening +to make sure that the test will always keep failing with a specific message at the annotated line. + +`//~ ERROR: XXX` make sure the stderr output contains `XXX` for an error in the line where this comment is written + +* Also supports `HELP`, `WARN` or `NOTE` for different kind of message + * if one of those levels is specified explicitly, *all* diagnostics of this level or higher need an annotation. If you want to avoid this, just leave out the all caps level note entirely. +* If the all caps note is left out, a message of any level is matched. Leaving it out is not allowed for `ERROR` levels. +* This checks the output *before* normalization, so you can check things that get normalized away, but need to + be careful not to accidentally have a pattern that differs between platforms. + +In order to change how a single test is tested, you can add various `//@` comments to the test. +Any other comments will be ignored, and all `//@` comments must be formatted precisely as +their command specifies, or the test will fail without even being run. + +* `//@ignore-XXX` avoids running the test on targets whose triple contains `XXX` * `XXX` can also be one of `64bit`, `32bit` or `16bit` -* `// only-XXX` avoids running the test on targets whose triple **does not** contain `XXX` +* `//@only-XXX` avoids running the test on targets whose triple **does not** contain `XXX` * `XXX` can also be one of `64bit`, `32bit` or `16bit` -* `// stderr-per-bitwidth` produces one stderr file per bitwidth, as they may differ significantly sometimes +* `//@stderr-per-bitwidth` produces one stderr file per bitwidth, as they may differ significantly sometimes * `//@error-pattern: XXX` make sure the stderr output contains `XXX` -* `//~ ERROR: XXX` make sure the stderr output contains `XXX` for an error in the line where this comment is written - * Also supports `HELP`, `WARN` or `NOTE` for different kind of message - * if one of those levels is specified explicitly, *all* diagnostics of this level or higher need an annotation. If you want to avoid this, just leave out the all caps level note entirely. - * If the all caps note is left out, a message of any level is matched. Leaving it out is not allowed for `ERROR` levels. - * This checks the output *before* normalization, so you can check things that get normalized away, but need to - be careful not to accidentally have a pattern that differs between platforms. -* `// revisions: XXX YYY` runs the test once for each space separated name in the list +* `//@revisions: XXX YYY` runs the test once for each space separated name in the list * emits one stderr file per revision * `//~` comments can be restricted to specific revisions by adding the revision name before the `~` in square brackets: `//[XXX]~` -* `// compile-flags: XXX` appends `XXX` to the command line arguments passed to the rustc driver -* `// rustc-env: XXX=YYY` sets the env var `XXX` to `YYY` for the rustc driver execution. +* `//@compile-flags: XXX` appends `XXX` to the command line arguments passed to the rustc driver + * you can specify this multiple times, and all the flags will accumulate +* `//@rustc-env: XXX=YYY` sets the env var `XXX` to `YYY` for the rustc driver execution. * for Miri these env vars are used during compilation via rustc and during the emulation of the program -* `// normalize-stderr-test: "REGEX" -> "REPLACEMENT"` replaces all matches of `REGEX` in the stderr with `REPLACEMENT`. The replacement may specify `$1` and similar backreferences to paste captures. + * you can specify this multiple times, accumulating all the env vars +* `//@normalize-stderr-test: "REGEX" -> "REPLACEMENT"` replaces all matches of `REGEX` in the stderr with `REPLACEMENT`. The replacement may specify `$1` and similar backreferences to paste captures. + * you can specify multiple such commands, there is no need to create a single regex that handles multiple replacements that you want to perform. ## Significant differences to compiletest-rs diff --git a/ui_test/src/comments.rs b/ui_test/src/comments.rs index 481565cfea..dd6ca9581a 100644 --- a/ui_test/src/comments.rs +++ b/ui_test/src/comments.rs @@ -75,7 +75,7 @@ impl Comments { /// Parse comments in `content`. /// `path` is only used to emit diagnostics if parsing fails. /// - /// This function will only parse `//@` and `//~` style comments + /// This function will only parse `//@` and `//~` style comments (and the `//[xxx]~` variant) /// and ignore all others fn parse_checked(path: &Path, content: &str) -> Result { let mut this = Self::default(); From f15a56d9bcc9712bca842f182e160df1942aea98 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 6 Jul 2022 10:17:21 +0000 Subject: [PATCH 07/17] Implement a proper command parser... ... that grabs things from the front instead of splitting at spaces and colons and hoping for the best --- ui_test/src/comments.rs | 63 ++++++++++++++++++----------------- ui_test/src/comments/tests.rs | 2 +- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/ui_test/src/comments.rs b/ui_test/src/comments.rs index dd6ca9581a..fa46b54970 100644 --- a/ui_test/src/comments.rs +++ b/ui_test/src/comments.rs @@ -98,14 +98,7 @@ impl Comments { line: &str, ) -> Result<()> { if let Some((_, command)) = line.split_once("//@") { - let command = command.trim(); - if let Some((command, args)) = command.split_once(':') { - self.parse_command_with_args(command, args, l) - } else if let Some((command, _comments)) = command.split_once(' ') { - self.parse_command(command) - } else { - self.parse_command(command) - } + self.parse_command(command.trim(), l) } else if let Some((_, pattern)) = line.split_once("//~") { self.parse_pattern(pattern, fallthrough_to, l) } else if let Some((_, pattern)) = line.split_once("//[") { @@ -189,7 +182,22 @@ impl Comments { Ok(this) } - fn parse_command_with_args(&mut self, command: &str, args: &str, l: usize) -> Result<()> { + fn parse_command(&mut self, command: &str, l: usize) -> Result<()> { + // Commands are letters or dashes, grab everything until the first character that is neither of those. + let (command, args) = match command.chars().position(|c: char| !c.is_alphabetic() && c != '-') { + None => (command, ""), + Some(i) => { + let (command, args) = command.split_at(i); + let mut args = args.chars(); + let next = args.next().expect("the `position` above guarantees that there is at least one char"); + let args = match next { + ':' | ' ' => args.as_str(), + _ => bail!("expected space or `:`, got `{next}`"), + }; + (command, args) + } + }; + match command { "revisions" => { ensure!(self.revisions.is_none(), "cannot specifiy revisions twice"); @@ -222,30 +230,25 @@ impl Comments { ); self.error_pattern = Some((args.trim().to_string(), l)); } - // Maybe the user just left a comment explaining a command without arguments - _ => self.parse_command(command)?, - } - Ok(()) - } - - fn parse_command(&mut self, command: &str) -> Result<()> { - if let Some(s) = command.strip_prefix("ignore-") { - self.ignore.push(Condition::parse(s)); - return Ok(()); - } - - if let Some(s) = command.strip_prefix("only-") { - self.only.push(Condition::parse(s)); - return Ok(()); - } + "stderr-per-bitwidth" => { + ensure!(!self.stderr_per_bitwidth, "cannot specifiy stderr-per-bitwidth twice"); + self.stderr_per_bitwidth = true; + } + command => { + if let Some(s) = command.strip_prefix("ignore-") { + self.ignore.push(Condition::parse(s)); + return Ok(()); + } - if command.starts_with("stderr-per-bitwidth") { - ensure!(!self.stderr_per_bitwidth, "cannot specifiy stderr-per-bitwidth twice"); - self.stderr_per_bitwidth = true; - return Ok(()); + if let Some(s) = command.strip_prefix("only-") { + self.only.push(Condition::parse(s)); + return Ok(()); + } + bail!("unknown command {command}"); + } } - bail!("unknown command {command}"); + Ok(()) } fn parse_pattern( diff --git a/ui_test/src/comments/tests.rs b/ui_test/src/comments/tests.rs index cdd81aa990..15a0aae247 100644 --- a/ui_test/src/comments/tests.rs +++ b/ui_test/src/comments/tests.rs @@ -44,7 +44,7 @@ use std::mem; fn parse_slash_slash_at_fail() -> Result<()> { init(); let s = r" -//@ error-pattern foomp +//@ error-patttern foomp use std::mem; "; From eab02b69e51165274af4b1e1df9625df5347a6a5 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 6 Jul 2022 10:38:14 +0000 Subject: [PATCH 08/17] rustfmt --- ui_test/src/comments.rs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/ui_test/src/comments.rs b/ui_test/src/comments.rs index fa46b54970..727e6a2aa2 100644 --- a/ui_test/src/comments.rs +++ b/ui_test/src/comments.rs @@ -184,19 +184,22 @@ impl Comments { fn parse_command(&mut self, command: &str, l: usize) -> Result<()> { // Commands are letters or dashes, grab everything until the first character that is neither of those. - let (command, args) = match command.chars().position(|c: char| !c.is_alphabetic() && c != '-') { - None => (command, ""), - Some(i) => { - let (command, args) = command.split_at(i); - let mut args = args.chars(); - let next = args.next().expect("the `position` above guarantees that there is at least one char"); - let args = match next { - ':' | ' ' => args.as_str(), - _ => bail!("expected space or `:`, got `{next}`"), - }; - (command, args) - } - }; + let (command, args) = + match command.chars().position(|c: char| !c.is_alphabetic() && c != '-') { + None => (command, ""), + Some(i) => { + let (command, args) = command.split_at(i); + let mut args = args.chars(); + let next = args + .next() + .expect("the `position` above guarantees that there is at least one char"); + let args = match next { + ':' | ' ' => args.as_str(), + _ => bail!("expected space or `:`, got `{next}`"), + }; + (command, args) + } + }; match command { "revisions" => { From cc35d809c1d7585e03044524d9b2838200880791 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 7 Jul 2022 08:07:50 +0000 Subject: [PATCH 09/17] Remove an outdated comment --- ui_test/src/comments.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/ui_test/src/comments.rs b/ui_test/src/comments.rs index 727e6a2aa2..0727c182a3 100644 --- a/ui_test/src/comments.rs +++ b/ui_test/src/comments.rs @@ -286,8 +286,6 @@ impl Comments { revision: Option, l: usize, ) -> Result<()> { - // FIXME: check that the error happens on the marked line - let (match_line, pattern) = match pattern.chars().next().ok_or_else(|| eyre!("no pattern specified"))? { '|' => From a1e0d0df79d58aba78d2aabe783647e5cd80ba81 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 7 Jul 2022 08:13:24 +0000 Subject: [PATCH 10/17] Add some comments --- ui_test/src/comments.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui_test/src/comments.rs b/ui_test/src/comments.rs index 0727c182a3..905ce96c50 100644 --- a/ui_test/src/comments.rs +++ b/ui_test/src/comments.rs @@ -80,8 +80,7 @@ impl Comments { fn parse_checked(path: &Path, content: &str) -> Result { let mut this = Self::default(); - // The line that a `|` will refer to - let mut fallthrough_to = None; + let mut fallthrough_to = None; // The line that a `|` will refer to. for (l, line) in content.lines().enumerate() { let l = l + 1; // enumerate starts at 0, but line numbers start at 1 this.parse_checked_line(l, &mut fallthrough_to, line).map_err(|err| { @@ -190,6 +189,7 @@ impl Comments { Some(i) => { let (command, args) = command.split_at(i); let mut args = args.chars(); + // Commands are separated from their arguments by ':' or ' ' let next = args .next() .expect("the `position` above guarantees that there is at least one char"); From bc07c19961b889fbecbfea9f7bca43b6174cffdb Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 7 Jul 2022 08:15:21 +0000 Subject: [PATCH 11/17] Explain `tests::init` function --- ui_test/src/tests.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui_test/src/tests.rs b/ui_test/src/tests.rs index 13a242f8d8..11a3d6aca2 100644 --- a/ui_test/src/tests.rs +++ b/ui_test/src/tests.rs @@ -329,8 +329,8 @@ fn main() { } } -static INIT: std::sync::Once = std::sync::Once::new(); - +/// Call this from every test to initialize eyre only once across all tests. pub fn init() { + static INIT: std::sync::Once = std::sync::Once::new(); INIT.call_once(|| color_eyre::install().unwrap()); } From 9b71180e52bda136230b8185823728a7497556bb Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 7 Jul 2022 08:55:24 +0000 Subject: [PATCH 12/17] Create a proper normalization regex parser --- ui_test/src/comments.rs | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/ui_test/src/comments.rs b/ui_test/src/comments.rs index 905ce96c50..63a14ce13b 100644 --- a/ui_test/src/comments.rs +++ b/ui_test/src/comments.rs @@ -197,7 +197,7 @@ impl Comments { ':' | ' ' => args.as_str(), _ => bail!("expected space or `:`, got `{next}`"), }; - (command, args) + (command, args.trim()) } }; @@ -217,12 +217,37 @@ impl Comments { self.env_vars.push((k.to_string(), v.to_string())); }, "normalize-stderr-test" => { - let (from, to) = args - .split_once("->") - .ok_or_else(|| eyre!("normalize-stderr-test needs a `->`"))?; - let from = from.trim().trim_matches('"'); - let to = to.trim().trim_matches('"'); - let from = Regex::new(from).ok().ok_or_else(|| eyre!("invalid regex"))?; + fn parse_str(s: &str) -> Result<(&str, &str)> { + let mut chars = s.char_indices(); + match chars.next().ok_or_else(|| eyre!("missing arguments"))?.1 { + '"' => { + let s = chars.as_str(); + let mut escaped = false; + for (i, c) in chars { + if escaped { + escaped = false; + } else if c == '"' { + return Ok((&s[..(i - 1)], s[i..].trim_start())) + } else { + escaped = c == '\\'; + } + } + bail!("no closing quotes found for {s}") + } + c => bail!("expected '\"', got {c}"), + } + } + + let (from, rest) = parse_str(args)?; + + let to = rest.strip_prefix("->").ok_or_else(|| { + eyre!("normalize-stderr-test needs a pattern and replacement separated by `->`") + })?.trim_start(); + let (to, rest) = parse_str(to)?; + + ensure!(rest.is_empty(), "trailing text after pattern replacement: {rest}"); + + let from = Regex::new(from)?; self.normalize_stderr.push((from, to.to_string())); } "error-pattern" => { From af798232eb9ab5f7c8c8c5760d2c96d4612e0d7c Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 7 Jul 2022 09:20:48 +0000 Subject: [PATCH 13/17] Rustfmt --- ui_test/src/comments.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui_test/src/comments.rs b/ui_test/src/comments.rs index 63a14ce13b..6f2d8aa086 100644 --- a/ui_test/src/comments.rs +++ b/ui_test/src/comments.rs @@ -227,7 +227,7 @@ impl Comments { if escaped { escaped = false; } else if c == '"' { - return Ok((&s[..(i - 1)], s[i..].trim_start())) + return Ok((&s[..(i - 1)], s[i..].trim_start())); } else { escaped = c == '\\'; } From 334aa3d7f84f66bd96a94dda499d5300f3333b15 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Fri, 8 Jul 2022 15:14:25 +0000 Subject: [PATCH 14/17] Add FIXME --- ui_test/src/comments.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/ui_test/src/comments.rs b/ui_test/src/comments.rs index 6f2d8aa086..080a887d9e 100644 --- a/ui_test/src/comments.rs +++ b/ui_test/src/comments.rs @@ -193,6 +193,7 @@ impl Comments { let next = args .next() .expect("the `position` above guarantees that there is at least one char"); + // FIXME: this replicates the existing flexibility in our syntax. Consider requiring the colon. let args = match next { ':' | ' ' => args.as_str(), _ => bail!("expected space or `:`, got `{next}`"), From 1597cec887c0716fd0fa4e537d786b8a8d62829d Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Fri, 8 Jul 2022 15:16:16 +0000 Subject: [PATCH 15/17] Documentation --- ui_test/src/comments.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui_test/src/comments.rs b/ui_test/src/comments.rs index 080a887d9e..2b6108f255 100644 --- a/ui_test/src/comments.rs +++ b/ui_test/src/comments.rs @@ -218,6 +218,9 @@ impl Comments { self.env_vars.push((k.to_string(), v.to_string())); }, "normalize-stderr-test" => { + /// Parses a string literal. `s` has to start with `"`; everything until the next `"` is + /// returned in the first component. `\` can be used to escape arbitrary character. + /// Second return component is the rest of the string with leading whitespace removed. fn parse_str(s: &str) -> Result<(&str, &str)> { let mut chars = s.char_indices(); match chars.next().ok_or_else(|| eyre!("missing arguments"))?.1 { @@ -226,6 +229,7 @@ impl Comments { let mut escaped = false; for (i, c) in chars { if escaped { + // Accept any character as literal after a `\`. escaped = false; } else if c == '"' { return Ok((&s[..(i - 1)], s[i..].trim_start())); From e4f7c6845ce09da759bad521d4dd23cf70632874 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Fri, 8 Jul 2022 15:20:28 +0000 Subject: [PATCH 16/17] Hide regular backtrace information from user-facing errors --- ui_test/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui_test/Cargo.toml b/ui_test/Cargo.toml index 94c5acb6b7..cdc5e5db47 100644 --- a/ui_test/Cargo.toml +++ b/ui_test/Cargo.toml @@ -17,5 +17,5 @@ crossbeam = "0.8.1" lazy_static = "1.4.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -color-eyre = "0.6.1" +color-eyre = { version = "0.6.1", default-features = false, features = ["capture-spantrace"] } From 6e106617f10b2431aeb0fdb84d50cbdcb0d4dad8 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Fri, 8 Jul 2022 16:08:32 +0000 Subject: [PATCH 17/17] Port all tests --- tests/fail/box-cell-alias.rs | 2 +- .../concurrency/libc_pthread_join_detached.rs | 2 +- .../concurrency/libc_pthread_join_joined.rs | 2 +- .../concurrency/libc_pthread_join_main.rs | 2 +- .../concurrency/libc_pthread_join_multiple.rs | 2 +- .../concurrency/libc_pthread_join_self.rs | 4 +- .../thread_local_static_dealloc.rs | 2 +- tests/fail/concurrency/too_few_args.rs | 2 +- tests/fail/concurrency/too_many_args.rs | 2 +- tests/fail/concurrency/unwind_top_of_stack.rs | 4 +- .../dangling_pointer_addr_of.rs | 2 +- .../dangling_pointer_deref.rs | 2 +- .../dangling_pointers/dangling_zst_deref.rs | 2 +- .../dangling_pointers/deref-invalid-ptr.rs | 2 +- tests/fail/dangling_pointers/dyn_size.rs | 2 +- .../maybe_null_pointer_deref_zst.rs | 2 +- .../maybe_null_pointer_write_zst.rs | 2 +- .../null_pointer_deref_zst.rs | 2 +- .../fail/dangling_pointers/stack_temporary.rs | 2 +- .../storage_dead_dangling.rs | 2 +- .../dangling_pointers/wild_pointer_deref.rs | 2 +- tests/fail/data_race/alloc_read_race.rs | 4 +- tests/fail/data_race/alloc_write_race.rs | 4 +- .../data_race/atomic_read_na_write_race1.rs | 2 +- .../data_race/atomic_read_na_write_race2.rs | 2 +- .../data_race/atomic_write_na_read_race1.rs | 2 +- .../data_race/atomic_write_na_read_race2.rs | 2 +- .../data_race/atomic_write_na_write_race1.rs | 2 +- .../data_race/atomic_write_na_write_race2.rs | 2 +- .../data_race/dangling_thread_async_race.rs | 4 +- tests/fail/data_race/dangling_thread_race.rs | 4 +- tests/fail/data_race/dealloc_read_race1.rs | 2 +- tests/fail/data_race/dealloc_read_race2.rs | 2 +- .../fail/data_race/dealloc_read_race_stack.rs | 4 +- tests/fail/data_race/dealloc_write_race1.rs | 2 +- tests/fail/data_race/dealloc_write_race2.rs | 2 +- .../data_race/dealloc_write_race_stack.rs | 4 +- .../data_race/enable_after_join_to_main.rs | 2 +- tests/fail/data_race/fence_after_load.rs | 4 +- tests/fail/data_race/read_write_race.rs | 2 +- tests/fail/data_race/read_write_race_stack.rs | 4 +- tests/fail/data_race/relax_acquire_race.rs | 4 +- tests/fail/data_race/release_seq_race.rs | 4 +- .../data_race/release_seq_race_same_thread.rs | 4 +- tests/fail/data_race/rmw_race.rs | 4 +- tests/fail/data_race/stack_pop_race.rs | 4 +- tests/fail/data_race/write_write_race.rs | 2 +- .../fail/data_race/write_write_race_stack.rs | 4 +- tests/fail/environ-gets-deallocated.rs | 2 +- tests/fail/erroneous_const.rs | 2 +- tests/fail/fs/close_stdout.rs | 4 +- tests/fail/fs/isolated_stdin.rs | 2 +- tests/fail/fs/read_from_stdout.rs | 4 +- .../fs/unix_open_missing_required_mode.rs | 4 +- tests/fail/fs/write_to_stdin.rs | 2 +- .../exported_symbol_abi_mismatch.rs | 2 +- .../exported_symbol_bad_unwind1.rs | 2 +- .../exported_symbol_bad_unwind2.rs | 2 +- .../cast_box_int_to_fn_ptr.rs | 2 +- .../function_pointers/cast_int_to_fn_ptr.rs | 2 +- .../fail/function_pointers/execute_memory.rs | 2 +- tests/fail/function_pointers/fn_ptr_offset.rs | 2 +- tests/fail/generator-pinned-moved.rs | 2 +- tests/fail/invalid_bool.rs | 2 +- tests/fail/invalid_char.rs | 2 +- tests/fail/invalid_int.rs | 2 +- tests/fail/modifying_constants.rs | 2 +- tests/fail/never_say_never.rs | 2 +- tests/fail/never_transmute_humans.rs | 2 +- tests/fail/never_transmute_void.rs | 2 +- tests/fail/panic/bad_miri_start_panic.rs | 2 +- tests/fail/panic/unwind_panic_abort.rs | 2 +- tests/fail/pointer_partial_overwrite.rs | 2 +- tests/fail/provenance/provenance_transmute.rs | 2 +- tests/fail/provenance/ptr_int_unexposed.rs | 2 +- .../fail/provenance/strict_provenance_cast.rs | 2 +- tests/fail/rc_as_ptr.rs | 2 +- tests/fail/shim_arg_size.rs | 2 +- tests/fail/stacked_borrows/exposed_only_ro.rs | 2 +- tests/fail/stacked_borrows/illegal_read5.rs | 2 +- .../illegal_read_despite_exposed1.rs | 2 +- .../illegal_read_despite_exposed2.rs | 2 +- .../illegal_write_despite_exposed1.rs | 2 +- .../fail/stacked_borrows/load_invalid_mut.rs | 2 +- .../fail/stacked_borrows/load_invalid_shr.rs | 2 +- .../shared_rw_borrows_are_weak2.rs | 2 +- tests/fail/stacked_borrows/unescaped_local.rs | 2 +- tests/fail/stacked_borrows/zst_slice.rs | 2 +- tests/fail/static_memory_modification1.rs | 2 +- tests/fail/static_memory_modification2.rs | 2 +- tests/fail/static_memory_modification3.rs | 2 +- .../sync/libc_pthread_cond_double_destroy.rs | 2 +- .../libc_pthread_condattr_double_destroy.rs | 2 +- .../sync/libc_pthread_mutex_NULL_deadlock.rs | 2 +- .../fail/sync/libc_pthread_mutex_deadlock.rs | 2 +- .../libc_pthread_mutex_default_deadlock.rs | 2 +- .../sync/libc_pthread_mutex_destroy_locked.rs | 2 +- .../sync/libc_pthread_mutex_double_destroy.rs | 2 +- .../libc_pthread_mutex_normal_deadlock.rs | 2 +- ...bc_pthread_mutex_normal_unlock_unlocked.rs | 2 +- .../sync/libc_pthread_mutex_wrong_owner.rs | 2 +- .../libc_pthread_mutexattr_double_destroy.rs | 2 +- ...libc_pthread_rwlock_destroy_read_locked.rs | 2 +- ...ibc_pthread_rwlock_destroy_write_locked.rs | 2 +- .../libc_pthread_rwlock_double_destroy.rs | 2 +- ...wlock_read_write_deadlock_single_thread.rs | 2 +- .../libc_pthread_rwlock_read_wrong_owner.rs | 2 +- .../libc_pthread_rwlock_unlock_unlocked.rs | 2 +- ...libc_pthread_rwlock_write_read_deadlock.rs | 2 +- ...wlock_write_read_deadlock_single_thread.rs | 2 +- ...ibc_pthread_rwlock_write_write_deadlock.rs | 2 +- ...lock_write_write_deadlock_single_thread.rs | 2 +- .../libc_pthread_rwlock_write_wrong_owner.rs | 2 +- tests/fail/type-too-large.rs | 2 +- tests/fail/unaligned_pointers/alignment.rs | 2 +- .../unaligned_pointers/atomic_unaligned.rs | 2 +- .../fail/unaligned_pointers/dyn_alignment.rs | 2 +- .../intptrcast_alignment_check.rs | 2 +- .../unaligned_pointers/reference_to_packed.rs | 2 +- .../fail/unaligned_pointers/unaligned_ptr1.rs | 2 +- .../fail/unaligned_pointers/unaligned_ptr2.rs | 2 +- .../fail/unaligned_pointers/unaligned_ptr3.rs | 2 +- .../fail/unaligned_pointers/unaligned_ptr4.rs | 2 +- .../unaligned_ptr_addr_of.rs | 2 +- .../unaligned_pointers/unaligned_ptr_zst.rs | 2 +- tests/fail/uninit_byte_read.rs | 2 +- tests/fail/unsupported_signal.rs | 2 +- tests/fail/validity/cast_fn_ptr1.rs | 2 +- tests/fail/validity/cast_fn_ptr2.rs | 2 +- tests/fail/validity/dangling_ref1.rs | 2 +- tests/fail/validity/dangling_ref2.rs | 2 +- tests/fail/validity/dangling_ref3.rs | 2 +- .../invalid_enum_tag_256variants_uninit.rs | 2 +- tests/fail/validity/nonzero.rs | 2 +- tests/fail/weak_memory/racing_mixed_size.rs | 2 +- .../weak_memory/racing_mixed_size_read.rs | 2 +- tests/fail/zst2.rs | 2 +- tests/fail/zst3.rs | 2 +- tests/panic/panic/panic1.rs | 4 +- .../panic/unsupported_foreign_function.rs | 2 +- tests/panic/panic/unsupported_syscall.rs | 6 +- tests/pass/0weak_memory_consistency.rs | 4 +- tests/pass/adjacent-allocs.rs | 2 +- tests/pass/align.rs | 2 +- tests/pass/align_offset_symbolic.rs | 2 +- ...atomic-compare-exchange-weak-never-fail.rs | 2 +- tests/pass/atomic.rs | 2 +- tests/pass/backtrace/backtrace-api-v0.rs | 2 +- tests/pass/backtrace/backtrace-api-v1.rs | 2 +- .../pass/backtrace/backtrace-global-alloc.rs | 2 +- tests/pass/backtrace/backtrace-std.rs | 2 +- tests/pass/btreemap.rs | 2 +- tests/pass/calloc.rs | 2 +- tests/pass/concurrency/channels.rs | 4 +- .../concurrency/concurrent_caller_location.rs | 2 +- tests/pass/concurrency/data_race.rs | 4 +- .../concurrency/disable_data_race_detector.rs | 4 +- tests/pass/concurrency/issue1643.rs | 2 +- tests/pass/concurrency/libc_pthread_cond.rs | 6 +- tests/pass/concurrency/linux-futex.rs | 4 +- tests/pass/concurrency/mutex_leak.rs | 2 +- tests/pass/concurrency/simple.rs | 4 +- tests/pass/concurrency/spin_loop.rs | 2 +- .../pass/concurrency/spin_loops_nopreempt.rs | 4 +- tests/pass/concurrency/sync.rs | 4 +- tests/pass/concurrency/sync_nopreempt.rs | 4 +- tests/pass/concurrency/thread_locals.rs | 4 +- tests/pass/concurrency/tls_lib_drop.rs | 2 +- .../concurrency/tls_pthread_drop_order.rs | 2 +- tests/pass/current_dir.rs | 2 +- tests/pass/current_dir_with_isolation.rs | 6 +- tests/pass/disable-alignment-check.rs | 2 +- tests/pass/enum_discriminant_ptr_value.rs | 2 +- tests/pass/env-exclude.rs | 2 +- tests/pass/env-forward.rs | 2 +- tests/pass/env-without-isolation.rs | 2 +- tests/pass/fs.rs | 4 +- tests/pass/fs_with_isolation.rs | 6 +- .../pass/function_calls/disable_abi_check.rs | 2 +- tests/pass/getpid.rs | 2 +- tests/pass/hide_stdout.rs | 2 +- tests/pass/integer-ops.rs | 2 +- tests/pass/intptrcast.rs | 2 +- tests/pass/intrinsics.rs | 2 +- tests/pass/issues/issue-miri-1925.rs | 2 +- tests/pass/issues/issue-miri-2068-2.rs | 2 +- tests/pass/libc.rs | 4 +- .../pass/linux-getrandom-without-isolation.rs | 4 +- tests/pass/linux-getrandom.rs | 2 +- tests/pass/malloc.rs | 2 +- tests/pass/memleak_ignored.rs | 2 +- tests/pass/move-uninit-primval.rs | 2 +- tests/pass/no_std.rs | 2 +- tests/pass/observed_local_mut.rs | 2 +- tests/pass/overflow_checks_off.rs | 2 +- tests/pass/panic/catch_panic.rs | 2 +- tests/pass/panic/concurrent-panic.rs | 4 +- tests/pass/portable-simd.rs | 2 +- tests/pass/ptr_int_casts.rs | 2 +- tests/pass/ptr_int_from_exposed.rs | 2 +- tests/pass/ptr_offset.rs | 2 +- tests/pass/rc.rs | 2 +- tests/pass/slices.rs | 2 +- tests/pass/stacked-borrows/int-to-ptr.rs | 2 +- .../stacked-borrows/interior_mutability.rs | 2 +- tests/pass/stacked-borrows/stacked-borrows.rs | 2 +- tests/pass/strings.rs | 2 +- tests/pass/threadleak_ignored.rs | 4 +- tests/pass/time.rs | 2 +- tests/pass/track-alloc-1.rs | 4 +- tests/pass/transmute_fat.rs | 2 +- tests/pass/uninit_number_ignored.rs | 2 +- tests/pass/vec.rs | 2 +- tests/pass/vecdeque.rs | 2 +- tests/pass/weak_memory/extra_cpp.rs | 4 +- tests/pass/weak_memory/extra_cpp_unsafe.rs | 4 +- tests/pass/weak_memory/weak.rs | 4 +- tests/pass/without-validation.rs | 2 +- tests/pass/wtf8.rs | 2 +- tests/pass/zst.rs | 2 +- ui_test/src/comments.rs | 80 +------------------ 221 files changed, 269 insertions(+), 345 deletions(-) diff --git a/tests/fail/box-cell-alias.rs b/tests/fail/box-cell-alias.rs index d3f505d2da..319845d86a 100644 --- a/tests/fail/box-cell-alias.rs +++ b/tests/fail/box-cell-alias.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-strict-provenance +//@compile-flags: -Zmiri-strict-provenance // Taken from . diff --git a/tests/fail/concurrency/libc_pthread_join_detached.rs b/tests/fail/concurrency/libc_pthread_join_detached.rs index dcd06596de..1ec1d630ec 100644 --- a/tests/fail/concurrency/libc_pthread_join_detached.rs +++ b/tests/fail/concurrency/libc_pthread_join_detached.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows // Joining a detached thread is undefined behavior. diff --git a/tests/fail/concurrency/libc_pthread_join_joined.rs b/tests/fail/concurrency/libc_pthread_join_joined.rs index 26f33f1f5f..b067556e51 100644 --- a/tests/fail/concurrency/libc_pthread_join_joined.rs +++ b/tests/fail/concurrency/libc_pthread_join_joined.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows // Joining an already joined thread is undefined behavior. diff --git a/tests/fail/concurrency/libc_pthread_join_main.rs b/tests/fail/concurrency/libc_pthread_join_main.rs index 15e43776ab..ebfe8c865e 100644 --- a/tests/fail/concurrency/libc_pthread_join_main.rs +++ b/tests/fail/concurrency/libc_pthread_join_main.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows // Joining the main thread is undefined behavior. diff --git a/tests/fail/concurrency/libc_pthread_join_multiple.rs b/tests/fail/concurrency/libc_pthread_join_multiple.rs index d86233a676..39cd9ff779 100644 --- a/tests/fail/concurrency/libc_pthread_join_multiple.rs +++ b/tests/fail/concurrency/libc_pthread_join_multiple.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows // Joining the same thread from multiple threads is undefined behavior. diff --git a/tests/fail/concurrency/libc_pthread_join_self.rs b/tests/fail/concurrency/libc_pthread_join_self.rs index db45b33c14..7b91560ab6 100644 --- a/tests/fail/concurrency/libc_pthread_join_self.rs +++ b/tests/fail/concurrency/libc_pthread_join_self.rs @@ -1,6 +1,6 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows // We are making scheduler assumptions here. -// compile-flags: -Zmiri-preemption-rate=0 +//@compile-flags: -Zmiri-preemption-rate=0 // Joining itself is undefined behavior. diff --git a/tests/fail/concurrency/thread_local_static_dealloc.rs b/tests/fail/concurrency/thread_local_static_dealloc.rs index e6031b5e4c..8cca1eba2d 100644 --- a/tests/fail/concurrency/thread_local_static_dealloc.rs +++ b/tests/fail/concurrency/thread_local_static_dealloc.rs @@ -1,4 +1,4 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. //! Ensure that thread-local statics get deallocated when the thread dies. diff --git a/tests/fail/concurrency/too_few_args.rs b/tests/fail/concurrency/too_few_args.rs index 23fa38d881..5d173b3848 100644 --- a/tests/fail/concurrency/too_few_args.rs +++ b/tests/fail/concurrency/too_few_args.rs @@ -1,4 +1,4 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. //! The thread function must have exactly one argument. diff --git a/tests/fail/concurrency/too_many_args.rs b/tests/fail/concurrency/too_many_args.rs index af5a377a04..8305765a37 100644 --- a/tests/fail/concurrency/too_many_args.rs +++ b/tests/fail/concurrency/too_many_args.rs @@ -1,4 +1,4 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. //! The thread function must have exactly one argument. diff --git a/tests/fail/concurrency/unwind_top_of_stack.rs b/tests/fail/concurrency/unwind_top_of_stack.rs index 39f7ae8baf..d5dfcd0871 100644 --- a/tests/fail/concurrency/unwind_top_of_stack.rs +++ b/tests/fail/concurrency/unwind_top_of_stack.rs @@ -1,5 +1,5 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-disable-abi-check +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-disable-abi-check //! Unwinding past the top frame of a stack is Undefined Behavior. diff --git a/tests/fail/dangling_pointers/dangling_pointer_addr_of.rs b/tests/fail/dangling_pointers/dangling_pointer_addr_of.rs index 5de4138711..a38a44c18f 100644 --- a/tests/fail/dangling_pointers/dangling_pointer_addr_of.rs +++ b/tests/fail/dangling_pointers/dangling_pointer_addr_of.rs @@ -1,5 +1,5 @@ // Make sure we find these even with many checks disabled. -// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation +//@compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation use std::ptr; fn main() { diff --git a/tests/fail/dangling_pointers/dangling_pointer_deref.rs b/tests/fail/dangling_pointers/dangling_pointer_deref.rs index e088a55325..55b5205a8b 100644 --- a/tests/fail/dangling_pointers/dangling_pointer_deref.rs +++ b/tests/fail/dangling_pointers/dangling_pointer_deref.rs @@ -1,5 +1,5 @@ // Make sure we find these even with many checks disabled. -// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation +//@compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation fn main() { let p = { diff --git a/tests/fail/dangling_pointers/dangling_zst_deref.rs b/tests/fail/dangling_pointers/dangling_zst_deref.rs index 01e864213d..2a09dc4b0e 100644 --- a/tests/fail/dangling_pointers/dangling_zst_deref.rs +++ b/tests/fail/dangling_pointers/dangling_zst_deref.rs @@ -1,6 +1,6 @@ // Make sure we find these even with many checks disabled. // Some optimizations remove ZST accesses, thus masking this UB. -// compile-flags: -Zmir-opt-level=0 -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation +//@compile-flags: -Zmir-opt-level=0 -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation fn main() { let p = { diff --git a/tests/fail/dangling_pointers/deref-invalid-ptr.rs b/tests/fail/dangling_pointers/deref-invalid-ptr.rs index 31b52da774..924021e8cb 100644 --- a/tests/fail/dangling_pointers/deref-invalid-ptr.rs +++ b/tests/fail/dangling_pointers/deref-invalid-ptr.rs @@ -1,5 +1,5 @@ // This should fail even without validation. -// compile-flags: -Zmiri-disable-validation -Zmiri-permissive-provenance +//@compile-flags: -Zmiri-disable-validation -Zmiri-permissive-provenance fn main() { let x = 16usize as *const u32; diff --git a/tests/fail/dangling_pointers/dyn_size.rs b/tests/fail/dangling_pointers/dyn_size.rs index 56de3970f1..adb7febe50 100644 --- a/tests/fail/dangling_pointers/dyn_size.rs +++ b/tests/fail/dangling_pointers/dyn_size.rs @@ -1,5 +1,5 @@ // should find the bug even without these, but gets masked by optimizations -// compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows -Zmir-opt-level=0 +//@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows -Zmir-opt-level=0 struct SliceWithHead(u8, [u8]); diff --git a/tests/fail/dangling_pointers/maybe_null_pointer_deref_zst.rs b/tests/fail/dangling_pointers/maybe_null_pointer_deref_zst.rs index 357eadf91c..37fb91e28f 100644 --- a/tests/fail/dangling_pointers/maybe_null_pointer_deref_zst.rs +++ b/tests/fail/dangling_pointers/maybe_null_pointer_deref_zst.rs @@ -1,5 +1,5 @@ // Some optimizations remove ZST accesses, thus masking this UB. -// compile-flags: -Zmir-opt-level=0 +//@compile-flags: -Zmir-opt-level=0 fn main() { // This pointer *could* be NULL so we cannot load from it, not even at ZST diff --git a/tests/fail/dangling_pointers/maybe_null_pointer_write_zst.rs b/tests/fail/dangling_pointers/maybe_null_pointer_write_zst.rs index 4a8d498aa1..de8034bbba 100644 --- a/tests/fail/dangling_pointers/maybe_null_pointer_write_zst.rs +++ b/tests/fail/dangling_pointers/maybe_null_pointer_write_zst.rs @@ -1,5 +1,5 @@ // Some optimizations remove ZST accesses, thus masking this UB. -// compile-flags: -Zmir-opt-level=0 +//@compile-flags: -Zmir-opt-level=0 fn main() { // This pointer *could* be NULL so we cannot load from it, not even at ZST. diff --git a/tests/fail/dangling_pointers/null_pointer_deref_zst.rs b/tests/fail/dangling_pointers/null_pointer_deref_zst.rs index 21b0ce37d8..1f73983a81 100644 --- a/tests/fail/dangling_pointers/null_pointer_deref_zst.rs +++ b/tests/fail/dangling_pointers/null_pointer_deref_zst.rs @@ -1,5 +1,5 @@ // Some optimizations remove ZST accesses, thus masking this UB. -// compile-flags: -Zmir-opt-level=0 +//@compile-flags: -Zmir-opt-level=0 #[allow(deref_nullptr)] fn main() { diff --git a/tests/fail/dangling_pointers/stack_temporary.rs b/tests/fail/dangling_pointers/stack_temporary.rs index cbd788bbf4..dc446ca4b3 100644 --- a/tests/fail/dangling_pointers/stack_temporary.rs +++ b/tests/fail/dangling_pointers/stack_temporary.rs @@ -1,5 +1,5 @@ // This should fail even without validation, but some MIR opts mask the error -// compile-flags: -Zmiri-disable-validation -Zmir-opt-level=0 +//@compile-flags: -Zmiri-disable-validation -Zmir-opt-level=0 unsafe fn make_ref<'a>(x: *mut i32) -> &'a mut i32 { &mut *x diff --git a/tests/fail/dangling_pointers/storage_dead_dangling.rs b/tests/fail/dangling_pointers/storage_dead_dangling.rs index 64ed37d151..10c6e7f97d 100644 --- a/tests/fail/dangling_pointers/storage_dead_dangling.rs +++ b/tests/fail/dangling_pointers/storage_dead_dangling.rs @@ -1,5 +1,5 @@ // This should fail even without validation, but some MIR opts mask the error -// compile-flags: -Zmiri-disable-validation -Zmir-opt-level=0 -Zmiri-permissive-provenance +//@compile-flags: -Zmiri-disable-validation -Zmir-opt-level=0 -Zmiri-permissive-provenance static mut LEAK: usize = 0; diff --git a/tests/fail/dangling_pointers/wild_pointer_deref.rs b/tests/fail/dangling_pointers/wild_pointer_deref.rs index 9f6b370c05..15d71a6bcc 100644 --- a/tests/fail/dangling_pointers/wild_pointer_deref.rs +++ b/tests/fail/dangling_pointers/wild_pointer_deref.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-permissive-provenance +//@compile-flags: -Zmiri-permissive-provenance fn main() { let p = 44 as *const i32; diff --git a/tests/fail/data_race/alloc_read_race.rs b/tests/fail/data_race/alloc_read_race.rs index 1eac8ce0f2..e3c003a343 100644 --- a/tests/fail/data_race/alloc_read_race.rs +++ b/tests/fail/data_race/alloc_read_race.rs @@ -1,5 +1,5 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 #![feature(new_uninit)] use std::mem::MaybeUninit; diff --git a/tests/fail/data_race/alloc_write_race.rs b/tests/fail/data_race/alloc_write_race.rs index e618b72a82..4ad03ee87d 100644 --- a/tests/fail/data_race/alloc_write_race.rs +++ b/tests/fail/data_race/alloc_write_race.rs @@ -1,5 +1,5 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 #![feature(new_uninit)] use std::ptr::null_mut; diff --git a/tests/fail/data_race/atomic_read_na_write_race1.rs b/tests/fail/data_race/atomic_read_na_write_race1.rs index 3b948eea98..71d7a66597 100644 --- a/tests/fail/data_race/atomic_read_na_write_race1.rs +++ b/tests/fail/data_race/atomic_read_na_write_race1.rs @@ -1,4 +1,4 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. #![feature(core_intrinsics)] use std::intrinsics; diff --git a/tests/fail/data_race/atomic_read_na_write_race2.rs b/tests/fail/data_race/atomic_read_na_write_race2.rs index 44b4eebee8..a490f47da7 100644 --- a/tests/fail/data_race/atomic_read_na_write_race2.rs +++ b/tests/fail/data_race/atomic_read_na_write_race2.rs @@ -1,4 +1,4 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; diff --git a/tests/fail/data_race/atomic_write_na_read_race1.rs b/tests/fail/data_race/atomic_write_na_read_race1.rs index 44dc1a9084..40066d91b1 100644 --- a/tests/fail/data_race/atomic_write_na_read_race1.rs +++ b/tests/fail/data_race/atomic_write_na_read_race1.rs @@ -1,4 +1,4 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; diff --git a/tests/fail/data_race/atomic_write_na_read_race2.rs b/tests/fail/data_race/atomic_write_na_read_race2.rs index b4b21b64fc..0bfadcba3e 100644 --- a/tests/fail/data_race/atomic_write_na_read_race2.rs +++ b/tests/fail/data_race/atomic_write_na_read_race2.rs @@ -1,4 +1,4 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. #![feature(core_intrinsics)] use std::intrinsics::atomic_store; diff --git a/tests/fail/data_race/atomic_write_na_write_race1.rs b/tests/fail/data_race/atomic_write_na_write_race1.rs index b1a4cfb98b..258f5dd142 100644 --- a/tests/fail/data_race/atomic_write_na_write_race1.rs +++ b/tests/fail/data_race/atomic_write_na_write_race1.rs @@ -1,4 +1,4 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. #![feature(core_intrinsics)] use std::intrinsics::atomic_store; diff --git a/tests/fail/data_race/atomic_write_na_write_race2.rs b/tests/fail/data_race/atomic_write_na_write_race2.rs index dbdce8f623..51068262d5 100644 --- a/tests/fail/data_race/atomic_write_na_write_race2.rs +++ b/tests/fail/data_race/atomic_write_na_write_race2.rs @@ -1,4 +1,4 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; diff --git a/tests/fail/data_race/dangling_thread_async_race.rs b/tests/fail/data_race/dangling_thread_async_race.rs index 65325b60f2..7bb20adfcd 100644 --- a/tests/fail/data_race/dangling_thread_async_race.rs +++ b/tests/fail/data_race/dangling_thread_async_race.rs @@ -1,5 +1,5 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-disable-isolation +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-disable-isolation use std::mem; use std::thread::{sleep, spawn}; diff --git a/tests/fail/data_race/dangling_thread_race.rs b/tests/fail/data_race/dangling_thread_race.rs index 09e7032c93..7e198eef6e 100644 --- a/tests/fail/data_race/dangling_thread_race.rs +++ b/tests/fail/data_race/dangling_thread_race.rs @@ -1,5 +1,5 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-disable-isolation +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-disable-isolation use std::mem; use std::thread::{sleep, spawn}; diff --git a/tests/fail/data_race/dealloc_read_race1.rs b/tests/fail/data_race/dealloc_read_race1.rs index ff2ac8ca52..634904cbfd 100644 --- a/tests/fail/data_race/dealloc_read_race1.rs +++ b/tests/fail/data_race/dealloc_read_race1.rs @@ -1,4 +1,4 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. use std::thread::spawn; diff --git a/tests/fail/data_race/dealloc_read_race2.rs b/tests/fail/data_race/dealloc_read_race2.rs index 4bb6444f6a..91ec3c2bd8 100644 --- a/tests/fail/data_race/dealloc_read_race2.rs +++ b/tests/fail/data_race/dealloc_read_race2.rs @@ -1,4 +1,4 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. use std::thread::spawn; diff --git a/tests/fail/data_race/dealloc_read_race_stack.rs b/tests/fail/data_race/dealloc_read_race_stack.rs index e079581a0d..a43c96a670 100644 --- a/tests/fail/data_race/dealloc_read_race_stack.rs +++ b/tests/fail/data_race/dealloc_read_race_stack.rs @@ -1,5 +1,5 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-disable-isolation -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-disable-isolation -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 use std::ptr::null_mut; use std::sync::atomic::{AtomicPtr, Ordering}; diff --git a/tests/fail/data_race/dealloc_write_race1.rs b/tests/fail/data_race/dealloc_write_race1.rs index 9cd0ebc642..f95a9be172 100644 --- a/tests/fail/data_race/dealloc_write_race1.rs +++ b/tests/fail/data_race/dealloc_write_race1.rs @@ -1,4 +1,4 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. use std::thread::spawn; diff --git a/tests/fail/data_race/dealloc_write_race2.rs b/tests/fail/data_race/dealloc_write_race2.rs index 9b1b8f0614..922738354f 100644 --- a/tests/fail/data_race/dealloc_write_race2.rs +++ b/tests/fail/data_race/dealloc_write_race2.rs @@ -1,4 +1,4 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. use std::thread::spawn; diff --git a/tests/fail/data_race/dealloc_write_race_stack.rs b/tests/fail/data_race/dealloc_write_race_stack.rs index 2f12570892..6b87cbe61c 100644 --- a/tests/fail/data_race/dealloc_write_race_stack.rs +++ b/tests/fail/data_race/dealloc_write_race_stack.rs @@ -1,5 +1,5 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-disable-isolation -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-disable-isolation -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 use std::ptr::null_mut; use std::sync::atomic::{AtomicPtr, Ordering}; diff --git a/tests/fail/data_race/enable_after_join_to_main.rs b/tests/fail/data_race/enable_after_join_to_main.rs index 6f0735fac8..757a41adc9 100644 --- a/tests/fail/data_race/enable_after_join_to_main.rs +++ b/tests/fail/data_race/enable_after_join_to_main.rs @@ -1,4 +1,4 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. use std::thread::spawn; diff --git a/tests/fail/data_race/fence_after_load.rs b/tests/fail/data_race/fence_after_load.rs index 5a8c2e585f..7a8d66bf8f 100644 --- a/tests/fail/data_race/fence_after_load.rs +++ b/tests/fail/data_race/fence_after_load.rs @@ -1,6 +1,6 @@ // We want to control preemption here. -// compile-flags: -Zmiri-disable-isolation -Zmiri-preemption-rate=0 -// ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-disable-isolation -Zmiri-preemption-rate=0 +//@ignore-windows: Concurrency on Windows is not supported yet. use std::sync::atomic::{fence, AtomicUsize, Ordering}; use std::sync::Arc; use std::thread; diff --git a/tests/fail/data_race/read_write_race.rs b/tests/fail/data_race/read_write_race.rs index eeb49bb42a..cffbba1a70 100644 --- a/tests/fail/data_race/read_write_race.rs +++ b/tests/fail/data_race/read_write_race.rs @@ -1,4 +1,4 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. use std::thread::spawn; diff --git a/tests/fail/data_race/read_write_race_stack.rs b/tests/fail/data_race/read_write_race_stack.rs index 124f12d1ec..3999c57bcf 100644 --- a/tests/fail/data_race/read_write_race_stack.rs +++ b/tests/fail/data_race/read_write_race_stack.rs @@ -1,5 +1,5 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-disable-isolation -Zmir-opt-level=0 -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-disable-isolation -Zmir-opt-level=0 -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 // Note: mir-opt-level set to 0 to prevent the read of stack_var in thread 1 // from being optimized away and preventing the detection of the data-race. diff --git a/tests/fail/data_race/relax_acquire_race.rs b/tests/fail/data_race/relax_acquire_race.rs index faa23a150e..3038efe99e 100644 --- a/tests/fail/data_race/relax_acquire_race.rs +++ b/tests/fail/data_race/relax_acquire_race.rs @@ -1,5 +1,5 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 use std::sync::atomic::{AtomicUsize, Ordering}; use std::thread::spawn; diff --git a/tests/fail/data_race/release_seq_race.rs b/tests/fail/data_race/release_seq_race.rs index ab6926102a..ca227bf5ad 100644 --- a/tests/fail/data_race/release_seq_race.rs +++ b/tests/fail/data_race/release_seq_race.rs @@ -1,5 +1,5 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-disable-isolation -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-disable-isolation -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 use std::sync::atomic::{AtomicUsize, Ordering}; use std::thread::{sleep, spawn}; diff --git a/tests/fail/data_race/release_seq_race_same_thread.rs b/tests/fail/data_race/release_seq_race_same_thread.rs index d3d18f0e25..c9b0cd7773 100644 --- a/tests/fail/data_race/release_seq_race_same_thread.rs +++ b/tests/fail/data_race/release_seq_race_same_thread.rs @@ -1,5 +1,5 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-disable-isolation -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-disable-isolation -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 use std::sync::atomic::{AtomicUsize, Ordering}; use std::thread::spawn; diff --git a/tests/fail/data_race/rmw_race.rs b/tests/fail/data_race/rmw_race.rs index 800b1043c0..ca8123177a 100644 --- a/tests/fail/data_race/rmw_race.rs +++ b/tests/fail/data_race/rmw_race.rs @@ -1,5 +1,5 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 use std::sync::atomic::{AtomicUsize, Ordering}; use std::thread::spawn; diff --git a/tests/fail/data_race/stack_pop_race.rs b/tests/fail/data_race/stack_pop_race.rs index bae8856001..a31c434604 100644 --- a/tests/fail/data_race/stack_pop_race.rs +++ b/tests/fail/data_race/stack_pop_race.rs @@ -1,5 +1,5 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-preemption-rate=0 +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-preemption-rate=0 use std::thread; #[derive(Copy, Clone)] diff --git a/tests/fail/data_race/write_write_race.rs b/tests/fail/data_race/write_write_race.rs index 989ae31a6d..ddd710bce0 100644 --- a/tests/fail/data_race/write_write_race.rs +++ b/tests/fail/data_race/write_write_race.rs @@ -1,4 +1,4 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. use std::thread::spawn; diff --git a/tests/fail/data_race/write_write_race_stack.rs b/tests/fail/data_race/write_write_race_stack.rs index 3c1eabbf25..96b40affae 100644 --- a/tests/fail/data_race/write_write_race_stack.rs +++ b/tests/fail/data_race/write_write_race_stack.rs @@ -1,5 +1,5 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-disable-isolation -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-disable-isolation -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 use std::ptr::null_mut; use std::sync::atomic::{AtomicPtr, Ordering}; diff --git a/tests/fail/environ-gets-deallocated.rs b/tests/fail/environ-gets-deallocated.rs index f50a66e2c7..34941b9449 100644 --- a/tests/fail/environ-gets-deallocated.rs +++ b/tests/fail/environ-gets-deallocated.rs @@ -1,4 +1,4 @@ -// ignore-windows: Windows does not have a global environ list that the program can access directly +//@ignore-windows: Windows does not have a global environ list that the program can access directly #[cfg(any(target_os = "linux", target_os = "freebsd"))] fn get_environ() -> *const *const u8 { diff --git a/tests/fail/erroneous_const.rs b/tests/fail/erroneous_const.rs index 8975694f51..ce1392d102 100644 --- a/tests/fail/erroneous_const.rs +++ b/tests/fail/erroneous_const.rs @@ -1,7 +1,7 @@ //! Make sure we detect erroneous constants post-monomorphization even when they are unused. //! (https://github.com/rust-lang/miri/issues/1382) // Inlining changes the error location -// compile-flags: -Zmir-opt-level=0 +//@compile-flags: -Zmir-opt-level=0 #![feature(never_type)] #![warn(warnings, const_err)] diff --git a/tests/fail/fs/close_stdout.rs b/tests/fail/fs/close_stdout.rs index 4f10d5e0c9..2737011128 100644 --- a/tests/fail/fs/close_stdout.rs +++ b/tests/fail/fs/close_stdout.rs @@ -1,5 +1,5 @@ -// ignore-windows: No libc on Windows -// compile-flags: -Zmiri-disable-isolation +//@ignore-windows: No libc on Windows +//@compile-flags: -Zmiri-disable-isolation // FIXME: standard handles cannot be closed (https://github.com/rust-lang/rust/issues/40032) diff --git a/tests/fail/fs/isolated_stdin.rs b/tests/fail/fs/isolated_stdin.rs index 4098a10476..b41534c5c3 100644 --- a/tests/fail/fs/isolated_stdin.rs +++ b/tests/fail/fs/isolated_stdin.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] diff --git a/tests/fail/fs/read_from_stdout.rs b/tests/fail/fs/read_from_stdout.rs index 17f1735f6a..4862bf0a16 100644 --- a/tests/fail/fs/read_from_stdout.rs +++ b/tests/fail/fs/read_from_stdout.rs @@ -1,5 +1,5 @@ -// compile-flags: -Zmiri-disable-isolation -// ignore-windows: No libc on Windows +//@compile-flags: -Zmiri-disable-isolation +//@ignore-windows: No libc on Windows #![feature(rustc_private)] diff --git a/tests/fail/fs/unix_open_missing_required_mode.rs b/tests/fail/fs/unix_open_missing_required_mode.rs index bd2ae6094b..e714d26e78 100644 --- a/tests/fail/fs/unix_open_missing_required_mode.rs +++ b/tests/fail/fs/unix_open_missing_required_mode.rs @@ -1,5 +1,5 @@ -// ignore-windows: No libc on Windows -// compile-flags: -Zmiri-disable-isolation +//@ignore-windows: No libc on Windows +//@compile-flags: -Zmiri-disable-isolation #![feature(rustc_private)] diff --git a/tests/fail/fs/write_to_stdin.rs b/tests/fail/fs/write_to_stdin.rs index c2754636c8..9d55a60b64 100644 --- a/tests/fail/fs/write_to_stdin.rs +++ b/tests/fail/fs/write_to_stdin.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] diff --git a/tests/fail/function_calls/exported_symbol_abi_mismatch.rs b/tests/fail/function_calls/exported_symbol_abi_mismatch.rs index c337e1f29f..e7372d5ec5 100644 --- a/tests/fail/function_calls/exported_symbol_abi_mismatch.rs +++ b/tests/fail/function_calls/exported_symbol_abi_mismatch.rs @@ -1,4 +1,4 @@ -// revisions: no_cache cache fn_ptr +//@revisions: no_cache cache fn_ptr #[no_mangle] fn foo() {} diff --git a/tests/fail/function_calls/exported_symbol_bad_unwind1.rs b/tests/fail/function_calls/exported_symbol_bad_unwind1.rs index 91b0e8fc03..0a5636138d 100644 --- a/tests/fail/function_calls/exported_symbol_bad_unwind1.rs +++ b/tests/fail/function_calls/exported_symbol_bad_unwind1.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-disable-abi-check +//@compile-flags: -Zmiri-disable-abi-check #![feature(c_unwind)] #[no_mangle] diff --git a/tests/fail/function_calls/exported_symbol_bad_unwind2.rs b/tests/fail/function_calls/exported_symbol_bad_unwind2.rs index e80a79d102..861789f862 100644 --- a/tests/fail/function_calls/exported_symbol_bad_unwind2.rs +++ b/tests/fail/function_calls/exported_symbol_bad_unwind2.rs @@ -1,4 +1,4 @@ -// revisions: extern_block definition both +//@revisions: extern_block definition both #![feature(rustc_attrs, c_unwind)] #[cfg_attr(any(definition, both), rustc_allocator_nounwind)] diff --git a/tests/fail/function_pointers/cast_box_int_to_fn_ptr.rs b/tests/fail/function_pointers/cast_box_int_to_fn_ptr.rs index f7640cadcb..6edf88a543 100644 --- a/tests/fail/function_pointers/cast_box_int_to_fn_ptr.rs +++ b/tests/fail/function_pointers/cast_box_int_to_fn_ptr.rs @@ -1,5 +1,5 @@ // Validation makes this fail in the wrong place -// compile-flags: -Zmiri-disable-validation +//@compile-flags: -Zmiri-disable-validation fn main() { let b = Box::new(42); diff --git a/tests/fail/function_pointers/cast_int_to_fn_ptr.rs b/tests/fail/function_pointers/cast_int_to_fn_ptr.rs index e287533ffc..272376307d 100644 --- a/tests/fail/function_pointers/cast_int_to_fn_ptr.rs +++ b/tests/fail/function_pointers/cast_int_to_fn_ptr.rs @@ -1,5 +1,5 @@ // Validation makes this fail in the wrong place -// compile-flags: -Zmiri-disable-validation +//@compile-flags: -Zmiri-disable-validation fn main() { let g = unsafe { std::mem::transmute::(42) }; diff --git a/tests/fail/function_pointers/execute_memory.rs b/tests/fail/function_pointers/execute_memory.rs index 2e6b58a753..0ca29a3594 100644 --- a/tests/fail/function_pointers/execute_memory.rs +++ b/tests/fail/function_pointers/execute_memory.rs @@ -1,5 +1,5 @@ // Validation makes this fail in the wrong place -// compile-flags: -Zmiri-disable-validation +//@compile-flags: -Zmiri-disable-validation #![feature(box_syntax)] diff --git a/tests/fail/function_pointers/fn_ptr_offset.rs b/tests/fail/function_pointers/fn_ptr_offset.rs index 04c54c0159..5f269760f1 100644 --- a/tests/fail/function_pointers/fn_ptr_offset.rs +++ b/tests/fail/function_pointers/fn_ptr_offset.rs @@ -1,5 +1,5 @@ // Validation makes this fail in the wrong place -// compile-flags: -Zmiri-disable-validation +//@compile-flags: -Zmiri-disable-validation use std::mem; diff --git a/tests/fail/generator-pinned-moved.rs b/tests/fail/generator-pinned-moved.rs index 8c8e828470..915dcdea82 100644 --- a/tests/fail/generator-pinned-moved.rs +++ b/tests/fail/generator-pinned-moved.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-disable-validation +//@compile-flags: -Zmiri-disable-validation #![feature(generators, generator_trait)] use std::{ diff --git a/tests/fail/invalid_bool.rs b/tests/fail/invalid_bool.rs index c0c982b8ca..b2052d982e 100644 --- a/tests/fail/invalid_bool.rs +++ b/tests/fail/invalid_bool.rs @@ -1,6 +1,6 @@ // Validation makes this fail in the wrong place // Make sure we find these even with many checks disabled. -// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation +//@compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation #![feature(bench_black_box)] fn main() { diff --git a/tests/fail/invalid_char.rs b/tests/fail/invalid_char.rs index 9d485b73f2..8d814fd92e 100644 --- a/tests/fail/invalid_char.rs +++ b/tests/fail/invalid_char.rs @@ -1,6 +1,6 @@ // Validation makes this fail in the wrong place // Make sure we find these even with many checks disabled. -// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation +//@compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation fn main() { let c = 0xFFFFFFu32; diff --git a/tests/fail/invalid_int.rs b/tests/fail/invalid_int.rs index 26a8580207..6914c66fae 100644 --- a/tests/fail/invalid_int.rs +++ b/tests/fail/invalid_int.rs @@ -1,6 +1,6 @@ // Validation makes this fail in the wrong place // Make sure we find these even with many checks disabled. -// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation +//@compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation fn main() { let i = unsafe { std::mem::MaybeUninit::::uninit().assume_init() }; diff --git a/tests/fail/modifying_constants.rs b/tests/fail/modifying_constants.rs index 0c884142bf..3c47661a4b 100644 --- a/tests/fail/modifying_constants.rs +++ b/tests/fail/modifying_constants.rs @@ -1,5 +1,5 @@ // This should fail even without validation/SB -// compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows +//@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows fn main() { let x = &1; // the `&1` is promoted to a constant, but it used to be that only the pointer is marked static, not the pointee diff --git a/tests/fail/never_say_never.rs b/tests/fail/never_say_never.rs index 7aae8a2921..6beaada56e 100644 --- a/tests/fail/never_say_never.rs +++ b/tests/fail/never_say_never.rs @@ -1,5 +1,5 @@ // This should fail even without validation -// compile-flags: -Zmiri-disable-validation +//@compile-flags: -Zmiri-disable-validation #![feature(never_type)] #![allow(unreachable_code)] diff --git a/tests/fail/never_transmute_humans.rs b/tests/fail/never_transmute_humans.rs index 8a7d7bfcc6..010c9d4146 100644 --- a/tests/fail/never_transmute_humans.rs +++ b/tests/fail/never_transmute_humans.rs @@ -1,5 +1,5 @@ // This should fail even without validation -// compile-flags: -Zmiri-disable-validation +//@compile-flags: -Zmiri-disable-validation #![feature(never_type)] diff --git a/tests/fail/never_transmute_void.rs b/tests/fail/never_transmute_void.rs index f5d0f914da..d9c34aa7a5 100644 --- a/tests/fail/never_transmute_void.rs +++ b/tests/fail/never_transmute_void.rs @@ -1,5 +1,5 @@ // This should fail even without validation -// compile-flags: -Zmiri-disable-validation +//@compile-flags: -Zmiri-disable-validation #![feature(never_type)] #![allow(unused, invalid_value)] diff --git a/tests/fail/panic/bad_miri_start_panic.rs b/tests/fail/panic/bad_miri_start_panic.rs index 089cd86f1b..9beeccd1d2 100644 --- a/tests/fail/panic/bad_miri_start_panic.rs +++ b/tests/fail/panic/bad_miri_start_panic.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-disable-abi-check +//@compile-flags: -Zmiri-disable-abi-check // This feature is required to trigger the error using the "C" ABI. #![feature(c_unwind)] diff --git a/tests/fail/panic/unwind_panic_abort.rs b/tests/fail/panic/unwind_panic_abort.rs index 6afcd7ae7f..40dcf1bc2a 100644 --- a/tests/fail/panic/unwind_panic_abort.rs +++ b/tests/fail/panic/unwind_panic_abort.rs @@ -1,4 +1,4 @@ -// compile-flags: -Cpanic=abort +//@compile-flags: -Cpanic=abort //! Unwinding despite `-C panic=abort` is an error. diff --git a/tests/fail/pointer_partial_overwrite.rs b/tests/fail/pointer_partial_overwrite.rs index 1bbb33aa2b..95af3569f3 100644 --- a/tests/fail/pointer_partial_overwrite.rs +++ b/tests/fail/pointer_partial_overwrite.rs @@ -1,5 +1,5 @@ // Make sure we find these even with many checks disabled. -// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation +//@compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation // Test what happens when we overwrite parts of a pointer. // Also see . diff --git a/tests/fail/provenance/provenance_transmute.rs b/tests/fail/provenance/provenance_transmute.rs index 28e6ba6230..90208c88d6 100644 --- a/tests/fail/provenance/provenance_transmute.rs +++ b/tests/fail/provenance/provenance_transmute.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-permissive-provenance +//@compile-flags: -Zmiri-permissive-provenance #![feature(strict_provenance)] use std::mem; diff --git a/tests/fail/provenance/ptr_int_unexposed.rs b/tests/fail/provenance/ptr_int_unexposed.rs index ad29d38dc3..5522aa33c7 100644 --- a/tests/fail/provenance/ptr_int_unexposed.rs +++ b/tests/fail/provenance/ptr_int_unexposed.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-permissive-provenance +//@compile-flags: -Zmiri-permissive-provenance #![feature(strict_provenance)] fn main() { diff --git a/tests/fail/provenance/strict_provenance_cast.rs b/tests/fail/provenance/strict_provenance_cast.rs index 968c4dfded..bca7ea90a3 100644 --- a/tests/fail/provenance/strict_provenance_cast.rs +++ b/tests/fail/provenance/strict_provenance_cast.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-strict-provenance +//@compile-flags: -Zmiri-strict-provenance fn main() { let addr = &0 as *const i32 as usize; diff --git a/tests/fail/rc_as_ptr.rs b/tests/fail/rc_as_ptr.rs index 049330ef36..9aafa26284 100644 --- a/tests/fail/rc_as_ptr.rs +++ b/tests/fail/rc_as_ptr.rs @@ -1,5 +1,5 @@ // This should fail even without validation -// compile-flags: -Zmiri-disable-validation +//@compile-flags: -Zmiri-disable-validation use std::ptr; use std::rc::{Rc, Weak}; diff --git a/tests/fail/shim_arg_size.rs b/tests/fail/shim_arg_size.rs index 37557de0a5..d1ffdf8cdd 100644 --- a/tests/fail/shim_arg_size.rs +++ b/tests/fail/shim_arg_size.rs @@ -1,4 +1,4 @@ -// stderr-per-bitwidth +//@stderr-per-bitwidth fn main() { extern "C" { diff --git a/tests/fail/stacked_borrows/exposed_only_ro.rs b/tests/fail/stacked_borrows/exposed_only_ro.rs index 9b4234499d..f2fdc213b1 100644 --- a/tests/fail/stacked_borrows/exposed_only_ro.rs +++ b/tests/fail/stacked_borrows/exposed_only_ro.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-permissive-provenance +//@compile-flags: -Zmiri-permissive-provenance #![feature(strict_provenance)] // If we have only exposed read-only pointers, doing a write through a wildcard ptr should fail. diff --git a/tests/fail/stacked_borrows/illegal_read5.rs b/tests/fail/stacked_borrows/illegal_read5.rs index 71af84e5b5..8f86a4f0a6 100644 --- a/tests/fail/stacked_borrows/illegal_read5.rs +++ b/tests/fail/stacked_borrows/illegal_read5.rs @@ -1,6 +1,6 @@ // We *can* have aliasing &RefCell and &mut T, but we cannot read through the former. // Else we couldn't optimize based on the assumption that `xref` below is truly unique. -// normalize-stderr-test: "0x[0-9a-fA-F]+" -> "$$HEX" +//@normalize-stderr-test: "0x[0-9a-fA-F]+" -> "$$HEX" use std::cell::RefCell; use std::{mem, ptr}; diff --git a/tests/fail/stacked_borrows/illegal_read_despite_exposed1.rs b/tests/fail/stacked_borrows/illegal_read_despite_exposed1.rs index 61a5e05d34..d779d4e446 100644 --- a/tests/fail/stacked_borrows/illegal_read_despite_exposed1.rs +++ b/tests/fail/stacked_borrows/illegal_read_despite_exposed1.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-permissive-provenance +//@compile-flags: -Zmiri-permissive-provenance fn main() { unsafe { diff --git a/tests/fail/stacked_borrows/illegal_read_despite_exposed2.rs b/tests/fail/stacked_borrows/illegal_read_despite_exposed2.rs index 19d0784591..20b44e9e02 100644 --- a/tests/fail/stacked_borrows/illegal_read_despite_exposed2.rs +++ b/tests/fail/stacked_borrows/illegal_read_despite_exposed2.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-permissive-provenance +//@compile-flags: -Zmiri-permissive-provenance fn main() { unsafe { diff --git a/tests/fail/stacked_borrows/illegal_write_despite_exposed1.rs b/tests/fail/stacked_borrows/illegal_write_despite_exposed1.rs index b50399b9df..f14fcb1479 100644 --- a/tests/fail/stacked_borrows/illegal_write_despite_exposed1.rs +++ b/tests/fail/stacked_borrows/illegal_write_despite_exposed1.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-permissive-provenance +//@compile-flags: -Zmiri-permissive-provenance fn main() { unsafe { diff --git a/tests/fail/stacked_borrows/load_invalid_mut.rs b/tests/fail/stacked_borrows/load_invalid_mut.rs index c2c4ce6726..f0ae77f861 100644 --- a/tests/fail/stacked_borrows/load_invalid_mut.rs +++ b/tests/fail/stacked_borrows/load_invalid_mut.rs @@ -1,5 +1,5 @@ // Make sure we catch this even without validation -// compile-flags: -Zmiri-disable-validation +//@compile-flags: -Zmiri-disable-validation // Make sure that we cannot load from memory a `&mut` that got already invalidated. fn main() { diff --git a/tests/fail/stacked_borrows/load_invalid_shr.rs b/tests/fail/stacked_borrows/load_invalid_shr.rs index 7d681f649a..36ffef656e 100644 --- a/tests/fail/stacked_borrows/load_invalid_shr.rs +++ b/tests/fail/stacked_borrows/load_invalid_shr.rs @@ -1,5 +1,5 @@ // Make sure we catch this even without validation -// compile-flags: -Zmiri-disable-validation +//@compile-flags: -Zmiri-disable-validation // Make sure that we cannot load from memory a `&` that got already invalidated. fn main() { diff --git a/tests/fail/stacked_borrows/shared_rw_borrows_are_weak2.rs b/tests/fail/stacked_borrows/shared_rw_borrows_are_weak2.rs index 07163456ce..2fc05c2bf4 100644 --- a/tests/fail/stacked_borrows/shared_rw_borrows_are_weak2.rs +++ b/tests/fail/stacked_borrows/shared_rw_borrows_are_weak2.rs @@ -1,7 +1,7 @@ // We want to test that granting a SharedReadWrite will be added // *below* an already granted SharedReadWrite -- so writing to // the SharedReadWrite will invalidate the SharedReadWrite. -// normalize-stderr-test: "0x[0-9a-fA-F]+" -> "$$HEX" +//@normalize-stderr-test: "0x[0-9a-fA-F]+" -> "$$HEX" use std::cell::RefCell; use std::mem; diff --git a/tests/fail/stacked_borrows/unescaped_local.rs b/tests/fail/stacked_borrows/unescaped_local.rs index c994f6c381..e6cd8f09b1 100644 --- a/tests/fail/stacked_borrows/unescaped_local.rs +++ b/tests/fail/stacked_borrows/unescaped_local.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-permissive-provenance +//@compile-flags: -Zmiri-permissive-provenance // Make sure we cannot use raw ptrs to access a local that // we took the direct address of. diff --git a/tests/fail/stacked_borrows/zst_slice.rs b/tests/fail/stacked_borrows/zst_slice.rs index 336b1041df..3e27f514bc 100644 --- a/tests/fail/stacked_borrows/zst_slice.rs +++ b/tests/fail/stacked_borrows/zst_slice.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-strict-provenance +//@compile-flags: -Zmiri-strict-provenance //@error-pattern: does not exist in the borrow stack fn main() { diff --git a/tests/fail/static_memory_modification1.rs b/tests/fail/static_memory_modification1.rs index 6284fec160..38e8af4c4f 100644 --- a/tests/fail/static_memory_modification1.rs +++ b/tests/fail/static_memory_modification1.rs @@ -1,5 +1,5 @@ // Stacked Borrows detects that we are casting & to &mut and so it changes why we fail -// compile-flags: -Zmiri-disable-stacked-borrows +//@compile-flags: -Zmiri-disable-stacked-borrows static X: usize = 5; diff --git a/tests/fail/static_memory_modification2.rs b/tests/fail/static_memory_modification2.rs index 558070d8a7..2e9d123c6d 100644 --- a/tests/fail/static_memory_modification2.rs +++ b/tests/fail/static_memory_modification2.rs @@ -1,5 +1,5 @@ // Stacked Borrows detects that we are casting & to &mut and so it changes why we fail -// compile-flags: -Zmiri-disable-stacked-borrows +//@compile-flags: -Zmiri-disable-stacked-borrows use std::mem::transmute; diff --git a/tests/fail/static_memory_modification3.rs b/tests/fail/static_memory_modification3.rs index 93df1c5945..34ccd13c42 100644 --- a/tests/fail/static_memory_modification3.rs +++ b/tests/fail/static_memory_modification3.rs @@ -1,5 +1,5 @@ // Stacked Borrows detects that we are casting & to &mut and so it changes why we fail -// compile-flags: -Zmiri-disable-stacked-borrows +//@compile-flags: -Zmiri-disable-stacked-borrows use std::mem::transmute; diff --git a/tests/fail/sync/libc_pthread_cond_double_destroy.rs b/tests/fail/sync/libc_pthread_cond_double_destroy.rs index 18be75b308..d358b3d4f6 100644 --- a/tests/fail/sync/libc_pthread_cond_double_destroy.rs +++ b/tests/fail/sync/libc_pthread_cond_double_destroy.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] /// Test that destroying a pthread_cond twice fails, even without a check for number validity diff --git a/tests/fail/sync/libc_pthread_condattr_double_destroy.rs b/tests/fail/sync/libc_pthread_condattr_double_destroy.rs index 1543a5841a..bf6b038a21 100644 --- a/tests/fail/sync/libc_pthread_condattr_double_destroy.rs +++ b/tests/fail/sync/libc_pthread_condattr_double_destroy.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] /// Test that destroying a pthread_condattr twice fails, even without a check for number validity diff --git a/tests/fail/sync/libc_pthread_mutex_NULL_deadlock.rs b/tests/fail/sync/libc_pthread_mutex_NULL_deadlock.rs index 3a737b2e3e..22dd656023 100644 --- a/tests/fail/sync/libc_pthread_mutex_NULL_deadlock.rs +++ b/tests/fail/sync/libc_pthread_mutex_NULL_deadlock.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows // // Check that if we pass NULL attribute, then we get the default mutex type. diff --git a/tests/fail/sync/libc_pthread_mutex_deadlock.rs b/tests/fail/sync/libc_pthread_mutex_deadlock.rs index 5d04635a36..597d7721b1 100644 --- a/tests/fail/sync/libc_pthread_mutex_deadlock.rs +++ b/tests/fail/sync/libc_pthread_mutex_deadlock.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] diff --git a/tests/fail/sync/libc_pthread_mutex_default_deadlock.rs b/tests/fail/sync/libc_pthread_mutex_default_deadlock.rs index 0f6f570d70..e34dfe5e36 100644 --- a/tests/fail/sync/libc_pthread_mutex_default_deadlock.rs +++ b/tests/fail/sync/libc_pthread_mutex_default_deadlock.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows // // Check that if we do not set the mutex type, it is the default. diff --git a/tests/fail/sync/libc_pthread_mutex_destroy_locked.rs b/tests/fail/sync/libc_pthread_mutex_destroy_locked.rs index 85a37db341..ada3d31113 100644 --- a/tests/fail/sync/libc_pthread_mutex_destroy_locked.rs +++ b/tests/fail/sync/libc_pthread_mutex_destroy_locked.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] diff --git a/tests/fail/sync/libc_pthread_mutex_double_destroy.rs b/tests/fail/sync/libc_pthread_mutex_double_destroy.rs index 3710810cd2..4cf006437b 100644 --- a/tests/fail/sync/libc_pthread_mutex_double_destroy.rs +++ b/tests/fail/sync/libc_pthread_mutex_double_destroy.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] /// Test that destroying a pthread_mutex twice fails, even without a check for number validity diff --git a/tests/fail/sync/libc_pthread_mutex_normal_deadlock.rs b/tests/fail/sync/libc_pthread_mutex_normal_deadlock.rs index 7e29a41920..8ecad494cf 100644 --- a/tests/fail/sync/libc_pthread_mutex_normal_deadlock.rs +++ b/tests/fail/sync/libc_pthread_mutex_normal_deadlock.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] diff --git a/tests/fail/sync/libc_pthread_mutex_normal_unlock_unlocked.rs b/tests/fail/sync/libc_pthread_mutex_normal_unlock_unlocked.rs index 1f1a2ef34b..0109907a11 100644 --- a/tests/fail/sync/libc_pthread_mutex_normal_unlock_unlocked.rs +++ b/tests/fail/sync/libc_pthread_mutex_normal_unlock_unlocked.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] diff --git a/tests/fail/sync/libc_pthread_mutex_wrong_owner.rs b/tests/fail/sync/libc_pthread_mutex_wrong_owner.rs index d69929d4ed..d91245104b 100644 --- a/tests/fail/sync/libc_pthread_mutex_wrong_owner.rs +++ b/tests/fail/sync/libc_pthread_mutex_wrong_owner.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] diff --git a/tests/fail/sync/libc_pthread_mutexattr_double_destroy.rs b/tests/fail/sync/libc_pthread_mutexattr_double_destroy.rs index c232780ee2..ffa786b658 100644 --- a/tests/fail/sync/libc_pthread_mutexattr_double_destroy.rs +++ b/tests/fail/sync/libc_pthread_mutexattr_double_destroy.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] /// Test that destroying a pthread_mutexattr twice fails, even without a check for number validity diff --git a/tests/fail/sync/libc_pthread_rwlock_destroy_read_locked.rs b/tests/fail/sync/libc_pthread_rwlock_destroy_read_locked.rs index 8750a7388f..6a9f548d1a 100644 --- a/tests/fail/sync/libc_pthread_rwlock_destroy_read_locked.rs +++ b/tests/fail/sync/libc_pthread_rwlock_destroy_read_locked.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] diff --git a/tests/fail/sync/libc_pthread_rwlock_destroy_write_locked.rs b/tests/fail/sync/libc_pthread_rwlock_destroy_write_locked.rs index aecccfa503..5f5f16d2cf 100644 --- a/tests/fail/sync/libc_pthread_rwlock_destroy_write_locked.rs +++ b/tests/fail/sync/libc_pthread_rwlock_destroy_write_locked.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] diff --git a/tests/fail/sync/libc_pthread_rwlock_double_destroy.rs b/tests/fail/sync/libc_pthread_rwlock_double_destroy.rs index 055bb1af48..1ba89fb22c 100644 --- a/tests/fail/sync/libc_pthread_rwlock_double_destroy.rs +++ b/tests/fail/sync/libc_pthread_rwlock_double_destroy.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] /// Test that destroying a pthread_rwlock twice fails, even without a check for number validity diff --git a/tests/fail/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.rs b/tests/fail/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.rs index dd4707d60e..9c8d22310c 100644 --- a/tests/fail/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.rs +++ b/tests/fail/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] diff --git a/tests/fail/sync/libc_pthread_rwlock_read_wrong_owner.rs b/tests/fail/sync/libc_pthread_rwlock_read_wrong_owner.rs index a73a8496a3..361cc7cdd8 100644 --- a/tests/fail/sync/libc_pthread_rwlock_read_wrong_owner.rs +++ b/tests/fail/sync/libc_pthread_rwlock_read_wrong_owner.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] diff --git a/tests/fail/sync/libc_pthread_rwlock_unlock_unlocked.rs b/tests/fail/sync/libc_pthread_rwlock_unlock_unlocked.rs index 8b3de53828..7918a9665a 100644 --- a/tests/fail/sync/libc_pthread_rwlock_unlock_unlocked.rs +++ b/tests/fail/sync/libc_pthread_rwlock_unlock_unlocked.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] diff --git a/tests/fail/sync/libc_pthread_rwlock_write_read_deadlock.rs b/tests/fail/sync/libc_pthread_rwlock_write_read_deadlock.rs index 19dce431c8..3158b944a7 100644 --- a/tests/fail/sync/libc_pthread_rwlock_write_read_deadlock.rs +++ b/tests/fail/sync/libc_pthread_rwlock_write_read_deadlock.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] diff --git a/tests/fail/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.rs b/tests/fail/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.rs index 1b460e7174..c6b468eb89 100644 --- a/tests/fail/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.rs +++ b/tests/fail/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] diff --git a/tests/fail/sync/libc_pthread_rwlock_write_write_deadlock.rs b/tests/fail/sync/libc_pthread_rwlock_write_write_deadlock.rs index 098c1c2fe2..91adaf8549 100644 --- a/tests/fail/sync/libc_pthread_rwlock_write_write_deadlock.rs +++ b/tests/fail/sync/libc_pthread_rwlock_write_write_deadlock.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] diff --git a/tests/fail/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.rs b/tests/fail/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.rs index cc327ec46b..13a7ceefc7 100644 --- a/tests/fail/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.rs +++ b/tests/fail/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] diff --git a/tests/fail/sync/libc_pthread_rwlock_write_wrong_owner.rs b/tests/fail/sync/libc_pthread_rwlock_write_wrong_owner.rs index 663dedb6f6..a205bbcb6b 100644 --- a/tests/fail/sync/libc_pthread_rwlock_write_wrong_owner.rs +++ b/tests/fail/sync/libc_pthread_rwlock_write_wrong_owner.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] diff --git a/tests/fail/type-too-large.rs b/tests/fail/type-too-large.rs index 08f7a49b02..932964ebdd 100644 --- a/tests/fail/type-too-large.rs +++ b/tests/fail/type-too-large.rs @@ -1,4 +1,4 @@ -// ignore-32bit +//@ignore-32bit fn main() { let _fat: [u8; (1 << 61) + (1 << 31)]; diff --git a/tests/fail/unaligned_pointers/alignment.rs b/tests/fail/unaligned_pointers/alignment.rs index abee75ec71..438e74e5b8 100644 --- a/tests/fail/unaligned_pointers/alignment.rs +++ b/tests/fail/unaligned_pointers/alignment.rs @@ -1,4 +1,4 @@ -// normalize-stderr-test: "\| +\^+" -> "| ^" +//@normalize-stderr-test: "\| +\^+" -> "| ^" fn main() { // No retry needed, this fails reliably. diff --git a/tests/fail/unaligned_pointers/atomic_unaligned.rs b/tests/fail/unaligned_pointers/atomic_unaligned.rs index 74dd0b415c..68b0efdbfe 100644 --- a/tests/fail/unaligned_pointers/atomic_unaligned.rs +++ b/tests/fail/unaligned_pointers/atomic_unaligned.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-symbolic-alignment-check +//@compile-flags: -Zmiri-symbolic-alignment-check #![feature(core_intrinsics)] fn main() { diff --git a/tests/fail/unaligned_pointers/dyn_alignment.rs b/tests/fail/unaligned_pointers/dyn_alignment.rs index 730dd87cbb..fe9c395230 100644 --- a/tests/fail/unaligned_pointers/dyn_alignment.rs +++ b/tests/fail/unaligned_pointers/dyn_alignment.rs @@ -1,5 +1,5 @@ // should find the bug even without validation and stacked borrows, but gets masked by optimizations -// compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows -Zmir-opt-level=0 +//@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows -Zmir-opt-level=0 #[repr(align(256))] #[derive(Debug)] diff --git a/tests/fail/unaligned_pointers/intptrcast_alignment_check.rs b/tests/fail/unaligned_pointers/intptrcast_alignment_check.rs index dea9335ab7..172461424e 100644 --- a/tests/fail/unaligned_pointers/intptrcast_alignment_check.rs +++ b/tests/fail/unaligned_pointers/intptrcast_alignment_check.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-symbolic-alignment-check -Zmiri-permissive-provenance +//@compile-flags: -Zmiri-symbolic-alignment-check -Zmiri-permissive-provenance // With the symbolic alignment check, even with intptrcast and without // validation, we want to be *sure* to catch bugs that arise from pointers being // insufficiently aligned. The only way to achieve that is not not let programs diff --git a/tests/fail/unaligned_pointers/reference_to_packed.rs b/tests/fail/unaligned_pointers/reference_to_packed.rs index c42f0e27ae..b465980574 100644 --- a/tests/fail/unaligned_pointers/reference_to_packed.rs +++ b/tests/fail/unaligned_pointers/reference_to_packed.rs @@ -1,5 +1,5 @@ // This should fail even without validation/SB -// compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows +//@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows #![allow(dead_code, unused_variables, unaligned_references)] diff --git a/tests/fail/unaligned_pointers/unaligned_ptr1.rs b/tests/fail/unaligned_pointers/unaligned_ptr1.rs index 7d192e5d39..a3b4832811 100644 --- a/tests/fail/unaligned_pointers/unaligned_ptr1.rs +++ b/tests/fail/unaligned_pointers/unaligned_ptr1.rs @@ -1,5 +1,5 @@ // This should fail even without validation or Stacked Borrows. -// compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows +//@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows fn main() { // Try many times as this might work by chance. diff --git a/tests/fail/unaligned_pointers/unaligned_ptr2.rs b/tests/fail/unaligned_pointers/unaligned_ptr2.rs index 49612e2b8a..88fcd30278 100644 --- a/tests/fail/unaligned_pointers/unaligned_ptr2.rs +++ b/tests/fail/unaligned_pointers/unaligned_ptr2.rs @@ -1,5 +1,5 @@ // This should fail even without validation or Stacked Borrows. -// compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows +//@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows fn main() { // No retry needed, this fails reliably. diff --git a/tests/fail/unaligned_pointers/unaligned_ptr3.rs b/tests/fail/unaligned_pointers/unaligned_ptr3.rs index 748a31681a..3a4b1497ae 100644 --- a/tests/fail/unaligned_pointers/unaligned_ptr3.rs +++ b/tests/fail/unaligned_pointers/unaligned_ptr3.rs @@ -1,5 +1,5 @@ // This should fail even without validation or Stacked Borrows. -// compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows +//@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows fn main() { // Try many times as this might work by chance. diff --git a/tests/fail/unaligned_pointers/unaligned_ptr4.rs b/tests/fail/unaligned_pointers/unaligned_ptr4.rs index d01cabfa31..659fbf1470 100644 --- a/tests/fail/unaligned_pointers/unaligned_ptr4.rs +++ b/tests/fail/unaligned_pointers/unaligned_ptr4.rs @@ -1,5 +1,5 @@ // This should fail even without validation or Stacked Borrows. -// compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows +//@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows fn main() { // Make sure we notice when a u16 is loaded at offset 1 into a u8 allocation. diff --git a/tests/fail/unaligned_pointers/unaligned_ptr_addr_of.rs b/tests/fail/unaligned_pointers/unaligned_ptr_addr_of.rs index dff92d56d7..28a58556eb 100644 --- a/tests/fail/unaligned_pointers/unaligned_ptr_addr_of.rs +++ b/tests/fail/unaligned_pointers/unaligned_ptr_addr_of.rs @@ -1,5 +1,5 @@ // This should fail even without validation or Stacked Borrows. -// compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows +//@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows use std::ptr; fn main() { diff --git a/tests/fail/unaligned_pointers/unaligned_ptr_zst.rs b/tests/fail/unaligned_pointers/unaligned_ptr_zst.rs index 8252ea83c8..26c315d34b 100644 --- a/tests/fail/unaligned_pointers/unaligned_ptr_zst.rs +++ b/tests/fail/unaligned_pointers/unaligned_ptr_zst.rs @@ -1,6 +1,6 @@ // This should fail even without validation // Some optimizations remove ZST accesses, thus masking this UB. -// compile-flags: -Zmir-opt-level=0 -Zmiri-disable-validation +//@compile-flags: -Zmir-opt-level=0 -Zmiri-disable-validation fn main() { // Try many times as this might work by chance. diff --git a/tests/fail/uninit_byte_read.rs b/tests/fail/uninit_byte_read.rs index 683088e78b..e08d34d138 100644 --- a/tests/fail/uninit_byte_read.rs +++ b/tests/fail/uninit_byte_read.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-disable-stacked-borrows +//@compile-flags: -Zmiri-disable-stacked-borrows fn main() { let v: Vec = Vec::with_capacity(10); let undef = unsafe { *v.get_unchecked(5) }; //~ ERROR uninitialized diff --git a/tests/fail/unsupported_signal.rs b/tests/fail/unsupported_signal.rs index 3e76d1c3f3..9cdf3cfdc6 100644 --- a/tests/fail/unsupported_signal.rs +++ b/tests/fail/unsupported_signal.rs @@ -1,6 +1,6 @@ //! `signal()` is special on Linux and macOS that it's only supported within libstd. //! The implementation is not complete enough to permit user code to call it. -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] extern crate libc; diff --git a/tests/fail/validity/cast_fn_ptr1.rs b/tests/fail/validity/cast_fn_ptr1.rs index eb5774fe79..1bd889e899 100644 --- a/tests/fail/validity/cast_fn_ptr1.rs +++ b/tests/fail/validity/cast_fn_ptr1.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-permissive-provenance +//@compile-flags: -Zmiri-permissive-provenance fn main() { // Cast a function pointer such that on a call, the argument gets transmuted diff --git a/tests/fail/validity/cast_fn_ptr2.rs b/tests/fail/validity/cast_fn_ptr2.rs index 1cf4ca7d19..7e7ad4710f 100644 --- a/tests/fail/validity/cast_fn_ptr2.rs +++ b/tests/fail/validity/cast_fn_ptr2.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-permissive-provenance +//@compile-flags: -Zmiri-permissive-provenance fn main() { // Cast a function pointer such that when returning, the return value gets transmuted diff --git a/tests/fail/validity/dangling_ref1.rs b/tests/fail/validity/dangling_ref1.rs index 78425cde4a..cc94cc6ca0 100644 --- a/tests/fail/validity/dangling_ref1.rs +++ b/tests/fail/validity/dangling_ref1.rs @@ -1,5 +1,5 @@ // Make sure we catch this even without Stacked Borrows -// compile-flags: -Zmiri-disable-stacked-borrows +//@compile-flags: -Zmiri-disable-stacked-borrows use std::mem; fn main() { diff --git a/tests/fail/validity/dangling_ref2.rs b/tests/fail/validity/dangling_ref2.rs index 7aff1a4978..eba026fdda 100644 --- a/tests/fail/validity/dangling_ref2.rs +++ b/tests/fail/validity/dangling_ref2.rs @@ -1,5 +1,5 @@ // Make sure we catch this even without Stacked Borrows -// compile-flags: -Zmiri-disable-stacked-borrows +//@compile-flags: -Zmiri-disable-stacked-borrows use std::mem; fn main() { diff --git a/tests/fail/validity/dangling_ref3.rs b/tests/fail/validity/dangling_ref3.rs index 495a266a85..8decc845ec 100644 --- a/tests/fail/validity/dangling_ref3.rs +++ b/tests/fail/validity/dangling_ref3.rs @@ -1,5 +1,5 @@ // Make sure we catch this even without Stacked Borrows -// compile-flags: -Zmiri-disable-stacked-borrows +//@compile-flags: -Zmiri-disable-stacked-borrows use std::mem; fn dangling() -> *const u8 { diff --git a/tests/fail/validity/invalid_enum_tag_256variants_uninit.rs b/tests/fail/validity/invalid_enum_tag_256variants_uninit.rs index 7573a64d0e..10e30cf85f 100644 --- a/tests/fail/validity/invalid_enum_tag_256variants_uninit.rs +++ b/tests/fail/validity/invalid_enum_tag_256variants_uninit.rs @@ -1,5 +1,5 @@ // Even when uninit numbers are allowed, this enum is not. -// compile-flags: -Zmiri-allow-uninit-numbers +//@compile-flags: -Zmiri-allow-uninit-numbers #![allow(unused, deprecated, invalid_value)] #[derive(Copy, Clone)] diff --git a/tests/fail/validity/nonzero.rs b/tests/fail/validity/nonzero.rs index 8ff19a2b43..6344bb61ae 100644 --- a/tests/fail/validity/nonzero.rs +++ b/tests/fail/validity/nonzero.rs @@ -1,5 +1,5 @@ // gets masked by optimizations -// compile-flags: -Zmir-opt-level=0 +//@compile-flags: -Zmir-opt-level=0 #![feature(rustc_attrs)] #![allow(unused_attributes)] diff --git a/tests/fail/weak_memory/racing_mixed_size.rs b/tests/fail/weak_memory/racing_mixed_size.rs index 6d53670a4e..3608377e91 100644 --- a/tests/fail/weak_memory/racing_mixed_size.rs +++ b/tests/fail/weak_memory/racing_mixed_size.rs @@ -1,4 +1,4 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. #![feature(core_intrinsics)] diff --git a/tests/fail/weak_memory/racing_mixed_size_read.rs b/tests/fail/weak_memory/racing_mixed_size_read.rs index 0129b55aff..e87b6d6fd0 100644 --- a/tests/fail/weak_memory/racing_mixed_size_read.rs +++ b/tests/fail/weak_memory/racing_mixed_size_read.rs @@ -1,4 +1,4 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. #![feature(core_intrinsics)] diff --git a/tests/fail/zst2.rs b/tests/fail/zst2.rs index 9f92e8994d..55c78fe8f9 100644 --- a/tests/fail/zst2.rs +++ b/tests/fail/zst2.rs @@ -1,5 +1,5 @@ // Some optimizations remove ZST accesses, thus masking this UB. -// compile-flags: -Zmir-opt-level=0 +//@compile-flags: -Zmir-opt-level=0 fn main() { // Not using the () type here, as writes of that type do not even have MIR generated. diff --git a/tests/fail/zst3.rs b/tests/fail/zst3.rs index 3f3b0af14d..47a7c0d3c2 100644 --- a/tests/fail/zst3.rs +++ b/tests/fail/zst3.rs @@ -1,5 +1,5 @@ // Some optimizations remove ZST accesses, thus masking this UB. -// compile-flags: -Zmir-opt-level=0 +//@compile-flags: -Zmir-opt-level=0 fn main() { // Not using the () type here, as writes of that type do not even have MIR generated. diff --git a/tests/panic/panic/panic1.rs b/tests/panic/panic/panic1.rs index e15d7656de..dbddf41fdb 100644 --- a/tests/panic/panic/panic1.rs +++ b/tests/panic/panic/panic1.rs @@ -1,5 +1,5 @@ -// rustc-env: RUST_BACKTRACE=1 -// compile-flags: -Zmiri-disable-isolation +//@rustc-env: RUST_BACKTRACE=1 +//@compile-flags: -Zmiri-disable-isolation fn main() { std::panic!("panicking from libstd"); diff --git a/tests/panic/panic/unsupported_foreign_function.rs b/tests/panic/panic/unsupported_foreign_function.rs index bc3d02c5f2..a78646528f 100644 --- a/tests/panic/panic/unsupported_foreign_function.rs +++ b/tests/panic/panic/unsupported_foreign_function.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-panic-on-unsupported +//@compile-flags: -Zmiri-panic-on-unsupported fn main() { extern "Rust" { diff --git a/tests/panic/panic/unsupported_syscall.rs b/tests/panic/panic/unsupported_syscall.rs index 2e62a5d8ae..3338c46c04 100644 --- a/tests/panic/panic/unsupported_syscall.rs +++ b/tests/panic/panic/unsupported_syscall.rs @@ -1,6 +1,6 @@ -// ignore-windows: No libc on Windows -// ignore-apple: `syscall` is not supported on macOS -// compile-flags: -Zmiri-panic-on-unsupported +//@ignore-windows: No libc on Windows +//@ignore-apple: `syscall` is not supported on macOS +//@compile-flags: -Zmiri-panic-on-unsupported #![feature(rustc_private)] extern crate libc; diff --git a/tests/pass/0weak_memory_consistency.rs b/tests/pass/0weak_memory_consistency.rs index 0f798d2b57..19e19b47cf 100644 --- a/tests/pass/0weak_memory_consistency.rs +++ b/tests/pass/0weak_memory_consistency.rs @@ -1,5 +1,5 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-ignore-leaks -Zmiri-disable-stacked-borrows +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-ignore-leaks -Zmiri-disable-stacked-borrows // The following tests check whether our weak memory emulation produces // any inconsistent execution outcomes diff --git a/tests/pass/adjacent-allocs.rs b/tests/pass/adjacent-allocs.rs index d0dc8b5d87..0051c62121 100644 --- a/tests/pass/adjacent-allocs.rs +++ b/tests/pass/adjacent-allocs.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-permissive-provenance +//@compile-flags: -Zmiri-permissive-provenance fn ensure_allocs_can_be_adjacent() { for _ in 0..512 { diff --git a/tests/pass/align.rs b/tests/pass/align.rs index f412541bde..997abd7339 100644 --- a/tests/pass/align.rs +++ b/tests/pass/align.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-permissive-provenance +//@compile-flags: -Zmiri-permissive-provenance /// This manually makes sure that we have a pointer with the proper alignment. fn manual_alignment() { diff --git a/tests/pass/align_offset_symbolic.rs b/tests/pass/align_offset_symbolic.rs index b57a23ab83..b3e5733836 100644 --- a/tests/pass/align_offset_symbolic.rs +++ b/tests/pass/align_offset_symbolic.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-symbolic-alignment-check +//@compile-flags: -Zmiri-symbolic-alignment-check fn test_align_offset() { let d = Box::new([0u32; 4]); diff --git a/tests/pass/atomic-compare-exchange-weak-never-fail.rs b/tests/pass/atomic-compare-exchange-weak-never-fail.rs index 2c2d4e61d9..8d3d71869f 100644 --- a/tests/pass/atomic-compare-exchange-weak-never-fail.rs +++ b/tests/pass/atomic-compare-exchange-weak-never-fail.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-compare-exchange-weak-failure-rate=0.0 +//@compile-flags: -Zmiri-compare-exchange-weak-failure-rate=0.0 use std::sync::atomic::{AtomicBool, Ordering::*}; // Ensure that compare_exchange_weak never fails. diff --git a/tests/pass/atomic.rs b/tests/pass/atomic.rs index 75e9cbdf13..9b82e006fa 100644 --- a/tests/pass/atomic.rs +++ b/tests/pass/atomic.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-strict-provenance +//@compile-flags: -Zmiri-strict-provenance #![feature(strict_provenance, strict_provenance_atomic_ptr)] use std::sync::atomic::{ compiler_fence, fence, AtomicBool, AtomicIsize, AtomicPtr, AtomicU64, Ordering::*, diff --git a/tests/pass/backtrace/backtrace-api-v0.rs b/tests/pass/backtrace/backtrace-api-v0.rs index 32fd47d8c5..5cd12959ca 100644 --- a/tests/pass/backtrace/backtrace-api-v0.rs +++ b/tests/pass/backtrace/backtrace-api-v0.rs @@ -1,4 +1,4 @@ -// normalize-stderr-test: "::<.*>" -> "" +//@normalize-stderr-test: "::<.*>" -> "" #[inline(never)] fn func_a() -> Box<[*mut ()]> { diff --git a/tests/pass/backtrace/backtrace-api-v1.rs b/tests/pass/backtrace/backtrace-api-v1.rs index c24a5f3e81..1e35574b39 100644 --- a/tests/pass/backtrace/backtrace-api-v1.rs +++ b/tests/pass/backtrace/backtrace-api-v1.rs @@ -1,4 +1,4 @@ -// normalize-stderr-test: "::<.*>" -> "" +//@normalize-stderr-test: "::<.*>" -> "" #[inline(never)] fn func_a() -> Box<[*mut ()]> { diff --git a/tests/pass/backtrace/backtrace-global-alloc.rs b/tests/pass/backtrace/backtrace-global-alloc.rs index 8c51bf6270..45d6535bc1 100644 --- a/tests/pass/backtrace/backtrace-global-alloc.rs +++ b/tests/pass/backtrace/backtrace-global-alloc.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-disable-isolation +//@compile-flags: -Zmiri-disable-isolation #![feature(backtrace)] diff --git a/tests/pass/backtrace/backtrace-std.rs b/tests/pass/backtrace/backtrace-std.rs index 5de7cdd6a5..488b87ede8 100644 --- a/tests/pass/backtrace/backtrace-std.rs +++ b/tests/pass/backtrace/backtrace-std.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-disable-isolation +//@compile-flags: -Zmiri-disable-isolation #![feature(backtrace)] diff --git a/tests/pass/btreemap.rs b/tests/pass/btreemap.rs index 413d7ef53d..040c648d47 100644 --- a/tests/pass/btreemap.rs +++ b/tests/pass/btreemap.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-strict-provenance +//@compile-flags: -Zmiri-strict-provenance #![feature(btree_drain_filter)] use std::collections::{BTreeMap, BTreeSet}; use std::mem; diff --git a/tests/pass/calloc.rs b/tests/pass/calloc.rs index 9f614ce971..a75bb06061 100644 --- a/tests/pass/calloc.rs +++ b/tests/pass/calloc.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] diff --git a/tests/pass/concurrency/channels.rs b/tests/pass/concurrency/channels.rs index 0d6c1749eb..e94c69b286 100644 --- a/tests/pass/concurrency/channels.rs +++ b/tests/pass/concurrency/channels.rs @@ -1,5 +1,5 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-strict-provenance +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-strict-provenance use std::sync::mpsc::{channel, sync_channel}; use std::thread; diff --git a/tests/pass/concurrency/concurrent_caller_location.rs b/tests/pass/concurrency/concurrent_caller_location.rs index 003b9e9ca9..6bd601abd5 100644 --- a/tests/pass/concurrency/concurrent_caller_location.rs +++ b/tests/pass/concurrency/concurrent_caller_location.rs @@ -1,4 +1,4 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. use std::panic::Location; use std::thread::spawn; diff --git a/tests/pass/concurrency/data_race.rs b/tests/pass/concurrency/data_race.rs index 812003ef4d..69b6c53a2b 100644 --- a/tests/pass/concurrency/data_race.rs +++ b/tests/pass/concurrency/data_race.rs @@ -1,5 +1,5 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-disable-weak-memory-emulation +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-disable-weak-memory-emulation use std::sync::atomic::{fence, AtomicUsize, Ordering}; use std::thread::spawn; diff --git a/tests/pass/concurrency/disable_data_race_detector.rs b/tests/pass/concurrency/disable_data_race_detector.rs index 14e2d5651d..a3c1e4621a 100644 --- a/tests/pass/concurrency/disable_data_race_detector.rs +++ b/tests/pass/concurrency/disable_data_race_detector.rs @@ -1,5 +1,5 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-disable-data-race-detector +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-disable-data-race-detector use std::thread::spawn; diff --git a/tests/pass/concurrency/issue1643.rs b/tests/pass/concurrency/issue1643.rs index 1238a1bd6f..cfe9cf4cc2 100644 --- a/tests/pass/concurrency/issue1643.rs +++ b/tests/pass/concurrency/issue1643.rs @@ -1,4 +1,4 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. use std::thread::spawn; diff --git a/tests/pass/concurrency/libc_pthread_cond.rs b/tests/pass/concurrency/libc_pthread_cond.rs index 1f6f46cbeb..8d245e2f8d 100644 --- a/tests/pass/concurrency/libc_pthread_cond.rs +++ b/tests/pass/concurrency/libc_pthread_cond.rs @@ -1,6 +1,6 @@ -// ignore-windows: No libc on Windows -// ignore-apple: pthread_condattr_setclock is not supported on MacOS. -// compile-flags: -Zmiri-disable-isolation +//@ignore-windows: No libc on Windows +//@ignore-apple: pthread_condattr_setclock is not supported on MacOS. +//@compile-flags: -Zmiri-disable-isolation #![feature(rustc_private)] diff --git a/tests/pass/concurrency/linux-futex.rs b/tests/pass/concurrency/linux-futex.rs index b65dd46d59..1ec0ec599f 100644 --- a/tests/pass/concurrency/linux-futex.rs +++ b/tests/pass/concurrency/linux-futex.rs @@ -1,5 +1,5 @@ -// only-linux -// compile-flags: -Zmiri-disable-isolation +//@only-linux +//@compile-flags: -Zmiri-disable-isolation #![feature(rustc_private)] extern crate libc; diff --git a/tests/pass/concurrency/mutex_leak.rs b/tests/pass/concurrency/mutex_leak.rs index 7fbc6dd301..3ac0c9336b 100644 --- a/tests/pass/concurrency/mutex_leak.rs +++ b/tests/pass/concurrency/mutex_leak.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-ignore-leaks +//@compile-flags: -Zmiri-ignore-leaks use std::mem; use std::sync::Mutex; diff --git a/tests/pass/concurrency/simple.rs b/tests/pass/concurrency/simple.rs index 48c1f3d9fb..ac268dab5e 100644 --- a/tests/pass/concurrency/simple.rs +++ b/tests/pass/concurrency/simple.rs @@ -1,5 +1,5 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-strict-provenance +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-strict-provenance use std::thread; diff --git a/tests/pass/concurrency/spin_loop.rs b/tests/pass/concurrency/spin_loop.rs index e11f0789bb..e1c4725899 100644 --- a/tests/pass/concurrency/spin_loop.rs +++ b/tests/pass/concurrency/spin_loop.rs @@ -1,4 +1,4 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. use std::sync::atomic::{AtomicUsize, Ordering}; use std::thread; diff --git a/tests/pass/concurrency/spin_loops_nopreempt.rs b/tests/pass/concurrency/spin_loops_nopreempt.rs index 99a5410c95..823d2ec765 100644 --- a/tests/pass/concurrency/spin_loops_nopreempt.rs +++ b/tests/pass/concurrency/spin_loops_nopreempt.rs @@ -1,6 +1,6 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. // This specifically tests behavior *without* preemption. -// compile-flags: -Zmiri-preemption-rate=0 +//@compile-flags: -Zmiri-preemption-rate=0 use std::cell::Cell; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; diff --git a/tests/pass/concurrency/sync.rs b/tests/pass/concurrency/sync.rs index 396c1a97e0..b7e6f229fa 100644 --- a/tests/pass/concurrency/sync.rs +++ b/tests/pass/concurrency/sync.rs @@ -1,5 +1,5 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-disable-isolation -Zmiri-strict-provenance +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-disable-isolation -Zmiri-strict-provenance use std::sync::{Arc, Barrier, Condvar, Mutex, Once, RwLock}; use std::thread; diff --git a/tests/pass/concurrency/sync_nopreempt.rs b/tests/pass/concurrency/sync_nopreempt.rs index b5e726dac7..e6ee4fe594 100644 --- a/tests/pass/concurrency/sync_nopreempt.rs +++ b/tests/pass/concurrency/sync_nopreempt.rs @@ -1,6 +1,6 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. // We are making scheduler assumptions here. -// compile-flags: -Zmiri-strict-provenance -Zmiri-preemption-rate=0 +//@compile-flags: -Zmiri-strict-provenance -Zmiri-preemption-rate=0 use std::sync::{Arc, Condvar, Mutex, RwLock}; use std::thread; diff --git a/tests/pass/concurrency/thread_locals.rs b/tests/pass/concurrency/thread_locals.rs index 5b11539f7f..82ce61d958 100644 --- a/tests/pass/concurrency/thread_locals.rs +++ b/tests/pass/concurrency/thread_locals.rs @@ -1,5 +1,5 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-strict-provenance +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-strict-provenance //! The main purpose of this test is to check that if we take a pointer to //! thread's `t1` thread-local `A` and send it to another thread `t2`, diff --git a/tests/pass/concurrency/tls_lib_drop.rs b/tests/pass/concurrency/tls_lib_drop.rs index fe46406c28..74ba8ee762 100644 --- a/tests/pass/concurrency/tls_lib_drop.rs +++ b/tests/pass/concurrency/tls_lib_drop.rs @@ -1,4 +1,4 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. use std::cell::RefCell; use std::thread; diff --git a/tests/pass/concurrency/tls_pthread_drop_order.rs b/tests/pass/concurrency/tls_pthread_drop_order.rs index 29c57bf49a..b265e7da0b 100644 --- a/tests/pass/concurrency/tls_pthread_drop_order.rs +++ b/tests/pass/concurrency/tls_pthread_drop_order.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] extern crate libc; diff --git a/tests/pass/current_dir.rs b/tests/pass/current_dir.rs index a88f820951..069b462ab3 100644 --- a/tests/pass/current_dir.rs +++ b/tests/pass/current_dir.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-disable-isolation +//@compile-flags: -Zmiri-disable-isolation use std::env; use std::io::ErrorKind; diff --git a/tests/pass/current_dir_with_isolation.rs b/tests/pass/current_dir_with_isolation.rs index 98c44d57b6..9dbcfeae2d 100644 --- a/tests/pass/current_dir_with_isolation.rs +++ b/tests/pass/current_dir_with_isolation.rs @@ -1,6 +1,6 @@ -// compile-flags: -Zmiri-isolation-error=warn-nobacktrace -// normalize-stderr-test: "(getcwd|GetCurrentDirectoryW)" -> "$$GETCWD" -// normalize-stderr-test: "(chdir|SetCurrentDirectoryW)" -> "$$SETCWD" +//@compile-flags: -Zmiri-isolation-error=warn-nobacktrace +//@normalize-stderr-test: "(getcwd|GetCurrentDirectoryW)" -> "$$GETCWD" +//@normalize-stderr-test: "(chdir|SetCurrentDirectoryW)" -> "$$SETCWD" use std::env; use std::io::ErrorKind; diff --git a/tests/pass/disable-alignment-check.rs b/tests/pass/disable-alignment-check.rs index 2fb0dd8369..366aff4a9f 100644 --- a/tests/pass/disable-alignment-check.rs +++ b/tests/pass/disable-alignment-check.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-disable-alignment-check +//@compile-flags: -Zmiri-disable-alignment-check fn main() { let mut x = [0u8; 20]; diff --git a/tests/pass/enum_discriminant_ptr_value.rs b/tests/pass/enum_discriminant_ptr_value.rs index 618d503cd5..4a3820777c 100644 --- a/tests/pass/enum_discriminant_ptr_value.rs +++ b/tests/pass/enum_discriminant_ptr_value.rs @@ -1,6 +1,6 @@ // A niche-optimized enum where the discriminant is a pointer value -- relies on ptr-to-int casts in // the niche handling code. -// compile-flags: -Zmiri-disable-stacked-borrows -Zmiri-disable-validation +//@compile-flags: -Zmiri-disable-stacked-borrows -Zmiri-disable-validation fn main() { let x = 42; diff --git a/tests/pass/env-exclude.rs b/tests/pass/env-exclude.rs index 1e251084f0..14ad827463 100644 --- a/tests/pass/env-exclude.rs +++ b/tests/pass/env-exclude.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-disable-isolation -Zmiri-env-exclude=MIRI_ENV_VAR_TEST +//@compile-flags: -Zmiri-disable-isolation -Zmiri-env-exclude=MIRI_ENV_VAR_TEST fn main() { assert!(std::env::var("MIRI_ENV_VAR_TEST").is_err()); diff --git a/tests/pass/env-forward.rs b/tests/pass/env-forward.rs index 8eebc45f55..da7730b00f 100644 --- a/tests/pass/env-forward.rs +++ b/tests/pass/env-forward.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-env-forward=MIRI_ENV_VAR_TEST +//@compile-flags: -Zmiri-env-forward=MIRI_ENV_VAR_TEST fn main() { assert_eq!(std::env::var("MIRI_ENV_VAR_TEST"), Ok("0".to_owned())); diff --git a/tests/pass/env-without-isolation.rs b/tests/pass/env-without-isolation.rs index 6384762098..3d7461eecf 100644 --- a/tests/pass/env-without-isolation.rs +++ b/tests/pass/env-without-isolation.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-disable-isolation +//@compile-flags: -Zmiri-disable-isolation fn main() { assert_eq!(std::env::var("MIRI_ENV_VAR_TEST"), Ok("0".to_owned())); diff --git a/tests/pass/fs.rs b/tests/pass/fs.rs index e106ca5d02..ced7831568 100644 --- a/tests/pass/fs.rs +++ b/tests/pass/fs.rs @@ -1,5 +1,5 @@ -// ignore-windows: File handling is not implemented yet -// compile-flags: -Zmiri-disable-isolation +//@ignore-windows: File handling is not implemented yet +//@compile-flags: -Zmiri-disable-isolation #![feature(rustc_private)] #![feature(io_error_more)] diff --git a/tests/pass/fs_with_isolation.rs b/tests/pass/fs_with_isolation.rs index 6753145e92..719882702c 100644 --- a/tests/pass/fs_with_isolation.rs +++ b/tests/pass/fs_with_isolation.rs @@ -1,6 +1,6 @@ -// ignore-windows: File handling is not implemented yet -// compile-flags: -Zmiri-isolation-error=warn-nobacktrace -// normalize-stderr-test: "(stat(x)?)" -> "$$STAT" +//@ignore-windows: File handling is not implemented yet +//@compile-flags: -Zmiri-isolation-error=warn-nobacktrace +//@normalize-stderr-test: "(stat(x)?)" -> "$$STAT" #![feature(rustc_private)] diff --git a/tests/pass/function_calls/disable_abi_check.rs b/tests/pass/function_calls/disable_abi_check.rs index 1f85547413..e6251b5355 100644 --- a/tests/pass/function_calls/disable_abi_check.rs +++ b/tests/pass/function_calls/disable_abi_check.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-disable-abi-check +//@compile-flags: -Zmiri-disable-abi-check #![feature(core_intrinsics)] fn main() { diff --git a/tests/pass/getpid.rs b/tests/pass/getpid.rs index 258fdeaa84..733545462e 100644 --- a/tests/pass/getpid.rs +++ b/tests/pass/getpid.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-disable-isolation +//@compile-flags: -Zmiri-disable-isolation fn getpid() -> u32 { std::process::id() diff --git a/tests/pass/hide_stdout.rs b/tests/pass/hide_stdout.rs index 3ee68d01f4..cfd05a8396 100644 --- a/tests/pass/hide_stdout.rs +++ b/tests/pass/hide_stdout.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-mute-stdout-stderr +//@compile-flags: -Zmiri-mute-stdout-stderr fn main() { println!("print to stdout"); diff --git a/tests/pass/integer-ops.rs b/tests/pass/integer-ops.rs index 8e2799d689..8608d12d4d 100644 --- a/tests/pass/integer-ops.rs +++ b/tests/pass/integer-ops.rs @@ -1,4 +1,4 @@ -// compile-flags: -Coverflow-checks=off +//@compile-flags: -Coverflow-checks=off #![feature(int_log)] #![allow(arithmetic_overflow)] diff --git a/tests/pass/intptrcast.rs b/tests/pass/intptrcast.rs index aebf5b2223..e7ff90cb6b 100644 --- a/tests/pass/intptrcast.rs +++ b/tests/pass/intptrcast.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-permissive-provenance +//@compile-flags: -Zmiri-permissive-provenance use std::mem; diff --git a/tests/pass/intrinsics.rs b/tests/pass/intrinsics.rs index 0042872a3b..756744bada 100644 --- a/tests/pass/intrinsics.rs +++ b/tests/pass/intrinsics.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-permissive-provenance +//@compile-flags: -Zmiri-permissive-provenance #![feature(core_intrinsics, const_raw_ptr_comparison)] #![feature(layout_for_ptr)] diff --git a/tests/pass/issues/issue-miri-1925.rs b/tests/pass/issues/issue-miri-1925.rs index 262889f56e..8655681349 100644 --- a/tests/pass/issues/issue-miri-1925.rs +++ b/tests/pass/issues/issue-miri-1925.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-symbolic-alignment-check +//@compile-flags: -Zmiri-symbolic-alignment-check use std::mem::size_of; diff --git a/tests/pass/issues/issue-miri-2068-2.rs b/tests/pass/issues/issue-miri-2068-2.rs index 204a4dd056..f33806e8b4 100644 --- a/tests/pass/issues/issue-miri-2068-2.rs +++ b/tests/pass/issues/issue-miri-2068-2.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-disable-validation +//@compile-flags: -Zmiri-disable-validation use std::mem::MaybeUninit; diff --git a/tests/pass/libc.rs b/tests/pass/libc.rs index d08430a432..53c85d2b07 100644 --- a/tests/pass/libc.rs +++ b/tests/pass/libc.rs @@ -1,5 +1,5 @@ -// ignore-windows: No libc on Windows -// compile-flags: -Zmiri-disable-isolation +//@ignore-windows: No libc on Windows +//@compile-flags: -Zmiri-disable-isolation #![feature(rustc_private)] diff --git a/tests/pass/linux-getrandom-without-isolation.rs b/tests/pass/linux-getrandom-without-isolation.rs index 56a5369947..90e054533c 100644 --- a/tests/pass/linux-getrandom-without-isolation.rs +++ b/tests/pass/linux-getrandom-without-isolation.rs @@ -1,5 +1,5 @@ -// only-linux -// compile-flags: -Zmiri-disable-isolation +//@only-linux +//@compile-flags: -Zmiri-disable-isolation #![feature(rustc_private)] extern crate libc; diff --git a/tests/pass/linux-getrandom.rs b/tests/pass/linux-getrandom.rs index a3596e4c7a..70c106f646 100644 --- a/tests/pass/linux-getrandom.rs +++ b/tests/pass/linux-getrandom.rs @@ -1,4 +1,4 @@ -// only-linux +//@only-linux #![feature(rustc_private)] extern crate libc; diff --git a/tests/pass/malloc.rs b/tests/pass/malloc.rs index 72abc68bb9..c0a6a89fbe 100644 --- a/tests/pass/malloc.rs +++ b/tests/pass/malloc.rs @@ -1,4 +1,4 @@ -// ignore-windows: No libc on Windows +//@ignore-windows: No libc on Windows #![feature(rustc_private)] diff --git a/tests/pass/memleak_ignored.rs b/tests/pass/memleak_ignored.rs index fddf14121e..60e06094e1 100644 --- a/tests/pass/memleak_ignored.rs +++ b/tests/pass/memleak_ignored.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-ignore-leaks +//@compile-flags: -Zmiri-ignore-leaks fn main() { std::mem::forget(Box::new(42)); diff --git a/tests/pass/move-uninit-primval.rs b/tests/pass/move-uninit-primval.rs index 1ca3873d1d..220470b637 100644 --- a/tests/pass/move-uninit-primval.rs +++ b/tests/pass/move-uninit-primval.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-allow-uninit-numbers +//@compile-flags: -Zmiri-allow-uninit-numbers #![allow(deprecated)] struct Foo { diff --git a/tests/pass/no_std.rs b/tests/pass/no_std.rs index 6808dab814..d8a462daf5 100644 --- a/tests/pass/no_std.rs +++ b/tests/pass/no_std.rs @@ -3,7 +3,7 @@ // windows tls dtors go through libstd right now, thus this test // cannot pass. When windows tls dtors go through the special magic // windows linker section, we can run this test on windows again. -// ignore-windows +//@ignore-windows #[start] fn start(_: isize, _: *const *const u8) -> isize { diff --git a/tests/pass/observed_local_mut.rs b/tests/pass/observed_local_mut.rs index 888b6f85e3..ca0f569860 100644 --- a/tests/pass/observed_local_mut.rs +++ b/tests/pass/observed_local_mut.rs @@ -1,5 +1,5 @@ // Stacked Borrows catches this (correctly) as UB. -// compile-flags: -Zmiri-disable-stacked-borrows +//@compile-flags: -Zmiri-disable-stacked-borrows // This test is intended to guard against the problem described in commit // 39bb1254d1eaf74f45a4e741097e33fc942168d5. diff --git a/tests/pass/overflow_checks_off.rs b/tests/pass/overflow_checks_off.rs index 2896d3161f..79aa510ef9 100644 --- a/tests/pass/overflow_checks_off.rs +++ b/tests/pass/overflow_checks_off.rs @@ -1,4 +1,4 @@ -// compile-flags: -C overflow-checks=off +//@compile-flags: -C overflow-checks=off // Check that we correctly implement the intended behavior of these operators // when they are not being overflow-checked. diff --git a/tests/pass/panic/catch_panic.rs b/tests/pass/panic/catch_panic.rs index 3979fb3b07..3089044065 100644 --- a/tests/pass/panic/catch_panic.rs +++ b/tests/pass/panic/catch_panic.rs @@ -1,5 +1,5 @@ // We test the `align_offset` panic below, make sure we test the interpreter impl and not the "real" one. -// compile-flags: -Zmiri-symbolic-alignment-check -Zmiri-permissive-provenance +//@compile-flags: -Zmiri-symbolic-alignment-check -Zmiri-permissive-provenance #![feature(never_type)] #![allow(unconditional_panic, non_fmt_panics)] diff --git a/tests/pass/panic/concurrent-panic.rs b/tests/pass/panic/concurrent-panic.rs index 7b17ac4fa7..1231760865 100644 --- a/tests/pass/panic/concurrent-panic.rs +++ b/tests/pass/panic/concurrent-panic.rs @@ -1,6 +1,6 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. // We are making scheduler assumptions here. -// compile-flags: -Zmiri-preemption-rate=0 +//@compile-flags: -Zmiri-preemption-rate=0 //! Cause a panic in one thread while another thread is unwinding. This checks //! that separate threads have their own panicking state. diff --git a/tests/pass/portable-simd.rs b/tests/pass/portable-simd.rs index ffbaa1832e..0dfe617bd8 100644 --- a/tests/pass/portable-simd.rs +++ b/tests/pass/portable-simd.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-strict-provenance +//@compile-flags: -Zmiri-strict-provenance #![feature(portable_simd, platform_intrinsics)] use std::simd::*; diff --git a/tests/pass/ptr_int_casts.rs b/tests/pass/ptr_int_casts.rs index ffe6a114c6..3044ac092b 100644 --- a/tests/pass/ptr_int_casts.rs +++ b/tests/pass/ptr_int_casts.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-permissive-provenance +//@compile-flags: -Zmiri-permissive-provenance use std::mem; use std::ptr; diff --git a/tests/pass/ptr_int_from_exposed.rs b/tests/pass/ptr_int_from_exposed.rs index dc9cb393b7..ef7ff34d26 100644 --- a/tests/pass/ptr_int_from_exposed.rs +++ b/tests/pass/ptr_int_from_exposed.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-permissive-provenance +//@compile-flags: -Zmiri-permissive-provenance #![feature(strict_provenance)] use std::ptr; diff --git a/tests/pass/ptr_offset.rs b/tests/pass/ptr_offset.rs index b16a06a726..5270e8663b 100644 --- a/tests/pass/ptr_offset.rs +++ b/tests/pass/ptr_offset.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-permissive-provenance +//@compile-flags: -Zmiri-permissive-provenance use std::{mem, ptr}; fn main() { diff --git a/tests/pass/rc.rs b/tests/pass/rc.rs index 260e350f27..569dbc459a 100644 --- a/tests/pass/rc.rs +++ b/tests/pass/rc.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-strict-provenance +//@compile-flags: -Zmiri-strict-provenance #![feature(new_uninit)] #![feature(get_mut_unchecked)] diff --git a/tests/pass/slices.rs b/tests/pass/slices.rs index 3a13ec59a0..a56b97a508 100644 --- a/tests/pass/slices.rs +++ b/tests/pass/slices.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-strict-provenance +//@compile-flags: -Zmiri-strict-provenance #![feature(new_uninit)] #![feature(slice_as_chunks)] #![feature(slice_partition_dedup)] diff --git a/tests/pass/stacked-borrows/int-to-ptr.rs b/tests/pass/stacked-borrows/int-to-ptr.rs index dc36754062..c3e30627a7 100644 --- a/tests/pass/stacked-borrows/int-to-ptr.rs +++ b/tests/pass/stacked-borrows/int-to-ptr.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-permissive-provenance +//@compile-flags: -Zmiri-permissive-provenance #![feature(strict_provenance)] use std::ptr; diff --git a/tests/pass/stacked-borrows/interior_mutability.rs b/tests/pass/stacked-borrows/interior_mutability.rs index 96ad67505a..c6373a7eaf 100644 --- a/tests/pass/stacked-borrows/interior_mutability.rs +++ b/tests/pass/stacked-borrows/interior_mutability.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-retag-fields +//@compile-flags: -Zmiri-retag-fields use std::cell::{Cell, Ref, RefCell, RefMut, UnsafeCell}; use std::mem::{self, MaybeUninit}; diff --git a/tests/pass/stacked-borrows/stacked-borrows.rs b/tests/pass/stacked-borrows/stacked-borrows.rs index b915a2ddf8..ef6eb346c1 100644 --- a/tests/pass/stacked-borrows/stacked-borrows.rs +++ b/tests/pass/stacked-borrows/stacked-borrows.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-retag-fields +//@compile-flags: -Zmiri-retag-fields #![feature(allocator_api)] use std::ptr; diff --git a/tests/pass/strings.rs b/tests/pass/strings.rs index ccefc69bd1..5e2d2e9b5b 100644 --- a/tests/pass/strings.rs +++ b/tests/pass/strings.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-strict-provenance +//@compile-flags: -Zmiri-strict-provenance fn empty() -> &'static str { "" diff --git a/tests/pass/threadleak_ignored.rs b/tests/pass/threadleak_ignored.rs index 36d39a72b7..2ba0b453ff 100644 --- a/tests/pass/threadleak_ignored.rs +++ b/tests/pass/threadleak_ignored.rs @@ -1,6 +1,6 @@ -// ignore-windows: Concurrency on Windows is not supported yet. +//@ignore-windows: Concurrency on Windows is not supported yet. // FIXME: disallow preemption to work around https://github.com/rust-lang/rust/issues/55005 -// compile-flags: -Zmiri-ignore-leaks -Zmiri-preemption-rate=0 +//@compile-flags: -Zmiri-ignore-leaks -Zmiri-preemption-rate=0 //! Test that leaking threads works, and that their destructors are not executed. diff --git a/tests/pass/time.rs b/tests/pass/time.rs index 38e846309d..e1094006fb 100644 --- a/tests/pass/time.rs +++ b/tests/pass/time.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-disable-isolation +//@compile-flags: -Zmiri-disable-isolation use std::time::{Duration, Instant, SystemTime}; diff --git a/tests/pass/track-alloc-1.rs b/tests/pass/track-alloc-1.rs index bbd88ed5d5..427c800dc5 100644 --- a/tests/pass/track-alloc-1.rs +++ b/tests/pass/track-alloc-1.rs @@ -1,6 +1,6 @@ // Ensure that tracking early allocations doesn't ICE Miri. // Early allocations are probably part of the runtime and therefore uninteresting, but they // shouldn't cause a crash. -// compile-flags: -Zmiri-track-alloc-id=1 -// normalize-stderr-test: "[48] bytes" -> "SIZE bytes" +//@compile-flags: -Zmiri-track-alloc-id=1 +//@normalize-stderr-test: "[48] bytes" -> "SIZE bytes" fn main() {} diff --git a/tests/pass/transmute_fat.rs b/tests/pass/transmute_fat.rs index b752e5504d..dfd78ace52 100644 --- a/tests/pass/transmute_fat.rs +++ b/tests/pass/transmute_fat.rs @@ -1,5 +1,5 @@ // Stacked Borrows disallows this becuase the reference is never cast to a raw pointer. -// compile-flags: -Zmiri-disable-stacked-borrows +//@compile-flags: -Zmiri-disable-stacked-borrows fn main() { // If we are careful, we can exploit data layout... diff --git a/tests/pass/uninit_number_ignored.rs b/tests/pass/uninit_number_ignored.rs index 13aac61ba8..44f6fa2679 100644 --- a/tests/pass/uninit_number_ignored.rs +++ b/tests/pass/uninit_number_ignored.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-allow-uninit-numbers +//@compile-flags: -Zmiri-allow-uninit-numbers // This test is adapted from https://github.com/rust-lang/miri/issues/1340#issue-600900312. fn main() { diff --git a/tests/pass/vec.rs b/tests/pass/vec.rs index 89c2561acd..26732cec5e 100644 --- a/tests/pass/vec.rs +++ b/tests/pass/vec.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-strict-provenance +//@compile-flags: -Zmiri-strict-provenance // Gather all references from a mutable iterator and make sure Miri notices if // using them is dangerous. fn test_all_refs<'a, T: 'a>(dummy: &mut T, iter: impl Iterator) { diff --git a/tests/pass/vecdeque.rs b/tests/pass/vecdeque.rs index d2295a7afb..6f56f9d103 100644 --- a/tests/pass/vecdeque.rs +++ b/tests/pass/vecdeque.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-strict-provenance +//@compile-flags: -Zmiri-strict-provenance use std::collections::VecDeque; fn test_all_refs<'a, T: 'a>(dummy: &mut T, iter: impl Iterator) { diff --git a/tests/pass/weak_memory/extra_cpp.rs b/tests/pass/weak_memory/extra_cpp.rs index 750c628458..61ba1ab922 100644 --- a/tests/pass/weak_memory/extra_cpp.rs +++ b/tests/pass/weak_memory/extra_cpp.rs @@ -1,5 +1,5 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-ignore-leaks +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-ignore-leaks // Tests operations not perfomable through C++'s atomic API // but doable in safe (at least sound) Rust. diff --git a/tests/pass/weak_memory/extra_cpp_unsafe.rs b/tests/pass/weak_memory/extra_cpp_unsafe.rs index d77a090e6e..0aff70ab7b 100644 --- a/tests/pass/weak_memory/extra_cpp_unsafe.rs +++ b/tests/pass/weak_memory/extra_cpp_unsafe.rs @@ -1,5 +1,5 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-ignore-leaks +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-ignore-leaks // Tests operations not perfomable through C++'s atomic API // but doable in unsafe Rust which we think *should* be fine. diff --git a/tests/pass/weak_memory/weak.rs b/tests/pass/weak_memory/weak.rs index b9ceb61f0c..1d82b85844 100644 --- a/tests/pass/weak_memory/weak.rs +++ b/tests/pass/weak_memory/weak.rs @@ -1,5 +1,5 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-ignore-leaks -Zmiri-preemption-rate=0 +//@ignore-windows: Concurrency on Windows is not supported yet. +//@compile-flags: -Zmiri-ignore-leaks -Zmiri-preemption-rate=0 // Tests showing weak memory behaviours are exhibited. All tests // return true when the desired behaviour is seen. diff --git a/tests/pass/without-validation.rs b/tests/pass/without-validation.rs index 8cff3a5c4b..934c44a7de 100644 --- a/tests/pass/without-validation.rs +++ b/tests/pass/without-validation.rs @@ -1,5 +1,5 @@ // When we notice something breaks only without validation, we add a test here. -// compile-flags: -Zmiri-disable-validation +//@compile-flags: -Zmiri-disable-validation use std::cell::*; fn refcell_unsize() { diff --git a/tests/pass/wtf8.rs b/tests/pass/wtf8.rs index e31b00e952..bf23f65c7f 100644 --- a/tests/pass/wtf8.rs +++ b/tests/pass/wtf8.rs @@ -1,4 +1,4 @@ -// only-windows +//@only-windows use std::ffi::{OsStr, OsString}; use std::os::windows::ffi::{OsStrExt, OsStringExt}; diff --git a/tests/pass/zst.rs b/tests/pass/zst.rs index fade1e0dad..a56386a691 100644 --- a/tests/pass/zst.rs +++ b/tests/pass/zst.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-permissive-provenance +//@compile-flags: -Zmiri-permissive-provenance #[derive(PartialEq, Debug)] struct A; diff --git a/ui_test/src/comments.rs b/ui_test/src/comments.rs index 2b6108f255..4046a9fc0d 100644 --- a/ui_test/src/comments.rs +++ b/ui_test/src/comments.rs @@ -74,10 +74,7 @@ impl Comments { /// Parse comments in `content`. /// `path` is only used to emit diagnostics if parsing fails. - /// - /// This function will only parse `//@` and `//~` style comments (and the `//[xxx]~` variant) - /// and ignore all others - fn parse_checked(path: &Path, content: &str) -> Result { + pub(crate) fn parse(path: &Path, content: &str) -> Result { let mut this = Self::default(); let mut fallthrough_to = None; // The line that a `|` will refer to. @@ -108,83 +105,10 @@ impl Comments { } } - /// Parse comments in `content`. - /// `path` is only used to emit diagnostics if parsing fails. - pub(crate) fn parse(path: &Path, content: &str) -> Result { - let mut this = Self::parse_checked(path, content)?; - if content.contains("//@") { - // Migration mode: if new syntax is used, ignore all old syntax - return Ok(this); - } - - for (l, line) in content.lines().enumerate() { - let l = l + 1; // enumerate starts at 0, but line numbers start at 1 - if let Some(revisions) = line.strip_prefix("// revisions:") { - assert_eq!( - this.revisions, - None, - "{}:{l}, cannot specifiy revisions twice", - path.display() - ); - this.revisions = - Some(revisions.split_whitespace().map(|s| s.to_string()).collect()); - } - if let Some(s) = line.strip_prefix("// ignore-") { - let s = s - .split_once(|c: char| c == ':' || c.is_whitespace()) - .map(|(s, _)| s) - .unwrap_or(s); - this.ignore.push(Condition::parse(s)); - } - if let Some(s) = line.strip_prefix("// only-") { - let s = s - .split_once(|c: char| c == ':' || c.is_whitespace()) - .map(|(s, _)| s) - .unwrap_or(s); - this.only.push(Condition::parse(s)); - } - if line.starts_with("// stderr-per-bitwidth") { - assert!( - !this.stderr_per_bitwidth, - "{}:{l}, cannot specifiy stderr-per-bitwidth twice", - path.display() - ); - this.stderr_per_bitwidth = true; - } - if let Some(s) = line.strip_prefix("// compile-flags:") { - this.compile_flags.extend(s.split_whitespace().map(|s| s.to_string())); - } - if let Some(s) = line.strip_prefix("// rustc-env:") { - for env in s.split_whitespace() { - if let Some((k, v)) = env.split_once('=') { - this.env_vars.push((k.to_string(), v.to_string())); - } - } - } - if let Some(s) = line.strip_prefix("// normalize-stderr-test:") { - let (from, to) = s.split_once("->").expect("normalize-stderr-test needs a `->`"); - let from = from.trim().trim_matches('"'); - let to = to.trim().trim_matches('"'); - let from = Regex::new(from).unwrap(); - this.normalize_stderr.push((from, to.to_string())); - } - if let Some(s) = line.strip_prefix("// error-pattern:") { - assert_eq!( - this.error_pattern, - None, - "{}:{l}, cannot specifiy error_pattern twice", - path.display() - ); - this.error_pattern = Some((s.trim().to_string(), l)); - } - } - Ok(this) - } - fn parse_command(&mut self, command: &str, l: usize) -> Result<()> { // Commands are letters or dashes, grab everything until the first character that is neither of those. let (command, args) = - match command.chars().position(|c: char| !c.is_alphabetic() && c != '-') { + match command.chars().position(|c: char| !c.is_alphanumeric() && c != '-') { None => (command, ""), Some(i) => { let (command, args) = command.split_at(i);