diff options
Diffstat (limited to 'tests/ui')
-rw-r--r-- | tests/ui/no_uaf_2.rs | 5 | ||||
-rw-r--r-- | tests/ui/no_uaf_2.stderr | 8 |
2 files changed, 5 insertions, 8 deletions
diff --git a/tests/ui/no_uaf_2.rs b/tests/ui/no_uaf_2.rs index 49694b2..53e3ad8 100644 --- a/tests/ui/no_uaf_2.rs +++ b/tests/ui/no_uaf_2.rs @@ -1,9 +1,6 @@ // by steffahn -#![feature(pin_macro)] - use std::cell::Cell; -use std::pin::pin; use selfref::opaque; use selfref::Holder; @@ -25,7 +22,7 @@ fn main() { Holder::<'_, MyStructKey>::new_with(|builder| builder.build(MyStruct { cell: Default::default(), })); - let s = pin!(s); + let s = Box::pin(s); s.as_ref().operate_in(|r| { r.cell.set(&String::from("hello world")); // temporary dropped at end of this statement println!("{}", r.cell.get()) // accesses dropped `String` data diff --git a/tests/ui/no_uaf_2.stderr b/tests/ui/no_uaf_2.stderr index 5737a38..5b9fa55 100644 --- a/tests/ui/no_uaf_2.stderr +++ b/tests/ui/no_uaf_2.stderr @@ -1,10 +1,10 @@ error[E0716]: temporary value dropped while borrowed - --> tests/ui/no_uaf_2.rs:30:21 + --> tests/ui/no_uaf_2.rs:27:21 | -29 | s.as_ref().operate_in(|r| { +26 | s.as_ref().operate_in(|r| { | - has type `OperateIn<'1, MyStructKey>` -30 | r.cell.set(&String::from("hello world")); // temporary dropped at end of this statement +27 | r.cell.set(&String::from("hello world")); // temporary dropped at end of this statement | ------------^^^^^^^^^^^^^^^^^^^^^^^^^^^-- temporary value is freed at the end of this statement | | | - | | creates a temporary value which is freed while still in use + | | creates a temporary which is freed while still in use | argument requires that borrow lasts for `'1` |