Skip to content

Commit

Permalink
Use a real unsafe expr for the unsafe test
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Nov 22, 2021
1 parent bf31e76 commit 0b5c758
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/test_ensure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use std::fmt::Debug;
use std::iter;
use std::marker::PhantomData;
use std::ops::Add;
use std::ptr;

struct S;

Expand Down Expand Up @@ -262,10 +263,11 @@ fn test_atom() {
"Condition failed: `S + async move { 1 } == true` (false vs true)",
);

let test = || Ok(ensure!(S + unsafe { 1 } == true));
let x = &1;
let test = || Ok(ensure!(S + unsafe { ptr::read(x) } == true));
assert_err(
test,
"Condition failed: `S + unsafe { 1 } == true` (false vs true)",
"Condition failed: `S + unsafe { ptr::read(x) } == true` (false vs true)",
);
}

Expand Down

0 comments on commit 0b5c758

Please sign in to comment.