diff --git a/README.md b/README.md index d75f0cc1e80d4..7ad51520a4287 100644 --- a/README.md +++ b/README.md @@ -435,11 +435,10 @@ Moreover, Miri recognizes some environment variables: purpose. * `MIRI_NO_STD` (recognized by `cargo miri` and the test suite) makes sure that the target's sysroot is built without libstd. This allows testing and running no_std programs. -* `MIRI_BLESS` (recognized by the test suite) overwrite all `stderr` and `stdout` files - instead of checking whether the output matches. -* `MIRI_SKIP_UI_CHECKS` (recognized by the test suite) don't check whether the - `stderr` or `stdout` files match the actual output. Useful for the rustc test suite - which has subtle differences that we don't care about. +* `MIRI_BLESS` (recognized by the test suite and `cargo-miri-test/run-test.py`): overwrite all + `stderr` and `stdout` files instead of checking whether the output matches. +* `MIRI_SKIP_UI_CHECKS` (recognized by the test suite): don't check whether the + `stderr` or `stdout` files match the actual output. The following environment variables are *internal* and must not be used by anyone but Miri itself. They are used to communicate between different Miri diff --git a/cargo-miri/src/main.rs b/cargo-miri/src/main.rs index 9b5fa7ae8736e..c43bf0bfab11b 100644 --- a/cargo-miri/src/main.rs +++ b/cargo-miri/src/main.rs @@ -1,3 +1,4 @@ +#![cfg_attr(bootstrap, feature(let_else))] #![allow(clippy::useless_format, clippy::derive_partial_eq_without_eq, rustc::internal)] #[macro_use] diff --git a/rust-version b/rust-version index 78b9a110aa7c7..7729a184d3278 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -acb8934fd57b3c2740c4abac0a5728c2c9b1423b +e42c4d7218b2596276152c5eb1e69335621f3086 diff --git a/src/lib.rs b/src/lib.rs index 463feb4dcc8a1..8e2222c39a242 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,9 +7,10 @@ #![feature(int_log)] #![feature(variant_count)] #![feature(yeet_expr)] -#![feature(is_some_with)] +#![feature(is_some_and)] #![feature(nonzero_ops)] #![feature(local_key_cell_methods)] +#![cfg_attr(bootstrap, feature(let_else))] // Configure clippy and other lints #![allow( clippy::collapsible_else_if, @@ -27,6 +28,7 @@ clippy::type_complexity, clippy::single_element_loop, clippy::needless_return, + clippy::bool_to_int_with_if, // We are not implementing queries here so it's fine rustc::potential_query_instability )] diff --git a/src/shims/unix/android/dlsym.rs b/src/shims/unix/android/dlsym.rs index 4cb78d4dabdcf..b0c9d729c9d90 100644 --- a/src/shims/unix/android/dlsym.rs +++ b/src/shims/unix/android/dlsym.rs @@ -42,7 +42,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { ); } - let &[ref _sig, ref _func] = check_arg_count(args)?; + let [_sig, _func] = check_arg_count(args)?; this.write_null(dest)?; } } diff --git a/src/shims/unix/fs.rs b/src/shims/unix/fs.rs index 9713cd9265e55..ed68976773d11 100644 --- a/src/shims/unix/fs.rs +++ b/src/shims/unix/fs.rs @@ -1073,7 +1073,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { mask |= this.eval_libc("STATX_ATIME")?.to_u32()?; InterpResult::Ok(tup) }) - .unwrap_or(Ok((0, 0)))?; + .unwrap_or_else(|| Ok((0, 0)))?; let (created_sec, created_nsec) = metadata .created @@ -1081,7 +1081,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { mask |= this.eval_libc("STATX_BTIME")?.to_u32()?; InterpResult::Ok(tup) }) - .unwrap_or(Ok((0, 0)))?; + .unwrap_or_else(|| Ok((0, 0)))?; let (modified_sec, modified_nsec) = metadata .modified @@ -1089,7 +1089,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { mask |= this.eval_libc("STATX_MTIME")?.to_u32()?; InterpResult::Ok(tup) }) - .unwrap_or(Ok((0, 0)))?; + .unwrap_or_else(|| Ok((0, 0)))?; // Now we write everything to `statxbuf`. We write a zero for the unavailable fields. this.write_int_fields_named( diff --git a/src/stacked_borrows/mod.rs b/src/stacked_borrows/mod.rs index 2888f8e81fb51..09d36ca9dfdb0 100644 --- a/src/stacked_borrows/mod.rs +++ b/src/stacked_borrows/mod.rs @@ -45,6 +45,7 @@ impl SbTag { } // The default to be used when SB is disabled + #[allow(clippy::should_implement_trait)] pub fn default() -> Self { Self::new(1).unwrap() } diff --git a/src/stacked_borrows/stack.rs b/src/stacked_borrows/stack.rs index 57de1c21c8b2d..07c211512f871 100644 --- a/src/stacked_borrows/stack.rs +++ b/src/stacked_borrows/stack.rs @@ -214,7 +214,7 @@ impl<'tcx> Stack { } // Couldn't find it in the stack; but if there is an unknown bottom it might be there. - let found = self.unknown_bottom.is_some_and(|&unknown_limit| { + let found = self.unknown_bottom.is_some_and(|unknown_limit| { tag.0 < unknown_limit.0 // unknown_limit is an upper bound for what can be in the unknown bottom. }); if found { Ok(None) } else { Err(()) } diff --git a/test-cargo-miri/run-test.py b/test-cargo-miri/run-test.py index 4485d3252ccc2..c611b9c44be9d 100755 --- a/test-cargo-miri/run-test.py +++ b/test-cargo-miri/run-test.py @@ -33,10 +33,13 @@ def normalize_stderr(str): return str def check_output(actual, path, name): + if 'MIRI_BLESS' in os.environ: + open(path, mode='w').write(actual) + return True expected = open(path).read() if expected == actual: return True - print(f"{path} did not match reference!") + print(f"{name} output did not match reference in {path}!") print(f"--- BEGIN diff {name} ---") for text in difflib.unified_diff(expected.split("\n"), actual.split("\n")): print(text) diff --git a/test-cargo-miri/test.filter.cross-target.stdout.ref b/test-cargo-miri/test.filter.cross-target.stdout.ref index bb0282d6c9167..39e1857060d04 100644 --- a/test-cargo-miri/test.filter.cross-target.stdout.ref +++ b/test-cargo-miri/test.filter.cross-target.stdout.ref @@ -1,4 +1,9 @@ +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out + + running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 2 filtered out diff --git a/test-cargo-miri/test.filter.stdout.ref b/test-cargo-miri/test.filter.stdout.ref index c618956656a8a..39e1857060d04 100644 --- a/test-cargo-miri/test.filter.stdout.ref +++ b/test-cargo-miri/test.filter.stdout.ref @@ -1,4 +1,9 @@ +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out + + running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 2 filtered out @@ -10,8 +15,3 @@ test simple ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 5 filtered out - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 4 filtered out; finished in $TIME - diff --git a/tests/fail/concurrency/windows_join_detached.stderr b/tests/fail/concurrency/windows_join_detached.stderr index 78c75611d3333..20f34cf104d63 100644 --- a/tests/fail/concurrency/windows_join_detached.stderr +++ b/tests/fail/concurrency/windows_join_detached.stderr @@ -8,7 +8,7 @@ LL | let rc = unsafe { c::WaitForSingleObject(self.handle.as_raw_handle( = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information = note: BACKTRACE: = note: inside `std::sys::PLATFORM::thread::Thread::join` at RUSTLIB/std/src/sys/PLATFORM/thread.rs:LL:CC - = note: inside `std::thread::JoinInner::<()>::join` at RUSTLIB/std/src/thread/mod.rs:LL:CC + = note: inside `std::thread::JoinInner::<'_, ()>::join` at RUSTLIB/std/src/thread/mod.rs:LL:CC = note: inside `std::thread::JoinHandle::<()>::join` at RUSTLIB/std/src/thread/mod.rs:LL:CC note: inside `main` at $DIR/windows_join_detached.rs:LL:CC --> $DIR/windows_join_detached.rs:LL:CC diff --git a/tests/fail/erroneous_const2.stderr b/tests/fail/erroneous_const2.stderr index 05ed8ea1c14bc..4d402257b8bd0 100644 --- a/tests/fail/erroneous_const2.stderr +++ b/tests/fail/erroneous_const2.stderr @@ -4,9 +4,9 @@ error: any use of this value will cause an error LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; | -------------- ^^^^^ attempt to compute `5_u32 - 6_u32`, which would overflow | - = note: `#[deny(const_err)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #71800 + = note: `#[deny(const_err)]` on by default error[E0080]: evaluation of constant value failed --> $DIR/erroneous_const2.rs:LL:CC diff --git a/tests/fail/invalid_bool.rs b/tests/fail/invalid_bool.rs index 525f8831c1c00..fe9bb3bed7f01 100644 --- a/tests/fail/invalid_bool.rs +++ b/tests/fail/invalid_bool.rs @@ -1,7 +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 -#![feature(bench_black_box)] fn main() { let b = unsafe { std::mem::transmute::(2) }; diff --git a/tests/pass/float.rs b/tests/pass/float.rs index 48dd99441ebff..ce62fb0de04f8 100644 --- a/tests/pass/float.rs +++ b/tests/pass/float.rs @@ -1,4 +1,4 @@ -#![feature(stmt_expr_attributes, bench_black_box)] +#![feature(stmt_expr_attributes)] #![allow(arithmetic_overflow)] use std::fmt::Debug; use std::hint::black_box; diff --git a/tests/pass/issues/issue-miri-2433.rs b/tests/pass/issues/issue-miri-2433.rs new file mode 100644 index 0000000000000..a8281d30bac4a --- /dev/null +++ b/tests/pass/issues/issue-miri-2433.rs @@ -0,0 +1,24 @@ +#![feature(type_alias_impl_trait)] + +trait T { + type Item; +} + +type Alias<'a> = impl T; + +struct S; +impl<'a> T for &'a S { + type Item = &'a (); +} + +fn filter_positive<'a>() -> Alias<'a> { + &S +} + +fn with_positive(fun: impl Fn(Alias<'_>)) { + fun(filter_positive()); +} + +fn main() { + with_positive(|_| ()); +} diff --git a/tests/pass/u128.rs b/tests/pass/u128.rs index 0ef7a514cb653..6def529dbe7c3 100644 --- a/tests/pass/u128.rs +++ b/tests/pass/u128.rs @@ -1,4 +1,3 @@ -#![feature(bench_black_box)] use std::hint::black_box as b; fn main() {