Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid 'let _' in tests where we actually want the value to be computed #3507

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/fail/both_borrows/aliasing_mut4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::mem;
pub fn safe(x: &i32, y: &mut Cell<i32>) {
//~[stack]^ ERROR: protect
y.set(1);
let _ = *x;
let _load = *x;
}

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion tests/fail/dangling_pointers/storage_dead_dangling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn fill(v: &mut i32) {
}

fn evil() {
let _ = unsafe { &mut *(LEAK as *mut i32) }; //~ ERROR: is a dangling pointer
let _ref = unsafe { &mut *(LEAK as *mut i32) }; //~ ERROR: is a dangling pointer
}

fn main() {
Expand Down
4 changes: 2 additions & 2 deletions tests/fail/dangling_pointers/storage_dead_dangling.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: Undefined Behavior: out-of-bounds pointer use: $HEX[noalloc] is a dangling pointer (it has no provenance)
--> $DIR/storage_dead_dangling.rs:LL:CC
|
LL | let _ = unsafe { &mut *(LEAK as *mut i32) };
| ^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: $HEX[noalloc] is a dangling pointer (it has no provenance)
LL | let _ref = unsafe { &mut *(LEAK as *mut i32) };
| ^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: $HEX[noalloc] is a dangling pointer (it has no provenance)
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
Expand Down
2 changes: 1 addition & 1 deletion tests/pass/adjacent-allocs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn test1() {
// See https://github.com/rust-lang/miri/issues/1866#issuecomment-985770125
{
let m = 0u64;
let _ = &m as *const u64;
let _ptr = &m as *const u64;
}

let iptr = ptr as usize;
Expand Down
20 changes: 10 additions & 10 deletions tests/pass/dyn-upcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn basic() {
}

let baz: &dyn Baz = &1;
let _: &dyn fmt::Debug = baz;
let _up: &dyn fmt::Debug = baz;
assert_eq!(*baz, 1);
assert_eq!(baz.a(), 100);
assert_eq!(baz.b(), 200);
Expand All @@ -79,7 +79,7 @@ fn basic() {
assert_eq!(baz.w(), 21);

let bar: &dyn Bar = baz;
let _: &dyn fmt::Debug = bar;
let _up: &dyn fmt::Debug = bar;
assert_eq!(*bar, 1);
assert_eq!(bar.a(), 100);
assert_eq!(bar.b(), 200);
Expand All @@ -88,14 +88,14 @@ fn basic() {
assert_eq!(bar.w(), 21);

let foo: &dyn Foo = baz;
let _: &dyn fmt::Debug = foo;
let _up: &dyn fmt::Debug = foo;
assert_eq!(*foo, 1);
assert_eq!(foo.a(), 100);
assert_eq!(foo.z(), 11);
assert_eq!(foo.y(), 12);

let foo: &dyn Foo = bar;
let _: &dyn fmt::Debug = foo;
let _up: &dyn fmt::Debug = foo;
assert_eq!(*foo, 1);
assert_eq!(foo.a(), 100);
assert_eq!(foo.z(), 11);
Expand Down Expand Up @@ -168,7 +168,7 @@ fn diamond() {
}

let baz: &dyn Baz = &1;
let _: &dyn fmt::Debug = baz;
let _up: &dyn fmt::Debug = baz;
assert_eq!(*baz, 1);
assert_eq!(baz.a(), 100);
assert_eq!(baz.b(), 200);
Expand All @@ -180,7 +180,7 @@ fn diamond() {
assert_eq!(baz.v(), 31);

let bar1: &dyn Bar1 = baz;
let _: &dyn fmt::Debug = bar1;
let _up: &dyn fmt::Debug = bar1;
assert_eq!(*bar1, 1);
assert_eq!(bar1.a(), 100);
assert_eq!(bar1.b(), 200);
Expand All @@ -189,7 +189,7 @@ fn diamond() {
assert_eq!(bar1.w(), 21);

let bar2: &dyn Bar2 = baz;
let _: &dyn fmt::Debug = bar2;
let _up: &dyn fmt::Debug = bar2;
assert_eq!(*bar2, 1);
assert_eq!(bar2.a(), 100);
assert_eq!(bar2.c(), 300);
Expand All @@ -198,17 +198,17 @@ fn diamond() {
assert_eq!(bar2.v(), 31);

let foo: &dyn Foo = baz;
let _: &dyn fmt::Debug = foo;
let _up: &dyn fmt::Debug = foo;
assert_eq!(*foo, 1);
assert_eq!(foo.a(), 100);

let foo: &dyn Foo = bar1;
let _: &dyn fmt::Debug = foo;
let _up: &dyn fmt::Debug = foo;
assert_eq!(*foo, 1);
assert_eq!(foo.a(), 100);

let foo: &dyn Foo = bar2;
let _: &dyn fmt::Debug = foo;
let _up: &dyn fmt::Debug = foo;
assert_eq!(*foo, 1);
assert_eq!(foo.a(), 100);
}
Expand Down
Loading