Replace all //error-pattern comments with strict syntax and fix other comments in the same files
This commit is contained in:
parent
4bd4838c15
commit
389915e09b
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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)]
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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(|| {});
|
||||
|
@ -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() {
|
||||
|
@ -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();
|
||||
|
@ -1,4 +1,4 @@
|
||||
// error-pattern: overflow computing total size
|
||||
//@error-pattern: overflow computing total size
|
||||
use std::mem;
|
||||
|
||||
fn main() {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
|
@ -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::*;
|
||||
|
||||
|
@ -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::*;
|
||||
|
||||
|
@ -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::*;
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
|
11
tests/fail/memleak_rc.stderr
Normal file
11
tests/fail/memleak_rc.stderr
Normal file
@ -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]<TAG>─╼ │ ........╾──────╼
|
||||
}
|
||||
|
||||
error: the evaluated program leaked memory
|
||||
|
||||
note: pass `-Zmiri-ignore-leaks` to disable this check
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -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]
|
||||
|
@ -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 {
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
|
@ -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() {
|
||||
|
@ -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
|
||||
|
@ -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!
|
||||
|
@ -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);
|
||||
|
@ -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 {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// error-pattern: is a dangling pointer
|
||||
//@error-pattern: is a dangling pointer
|
||||
use std::ptr::NonNull;
|
||||
|
||||
fn main() {
|
||||
|
@ -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()) {
|
||||
|
@ -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 {}
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -1,4 +1,4 @@
|
||||
// error-pattern: entering unreachable code
|
||||
//@error-pattern: entering unreachable code
|
||||
fn main() {
|
||||
unsafe { std::hint::unreachable_unchecked() }
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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 `]`");
|
||||
}
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user