summary refs log tree commit diff stats
path: root/tests/ui/no_uaf_1.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/no_uaf_1.rs')
-rw-r--r--tests/ui/no_uaf_1.rs18
1 files changed, 7 insertions, 11 deletions
diff --git a/tests/ui/no_uaf_1.rs b/tests/ui/no_uaf_1.rs
index e4d7ac4..1d9411e 100644
--- a/tests/ui/no_uaf_1.rs
+++ b/tests/ui/no_uaf_1.rs
@@ -1,7 +1,6 @@
 use core::cell::Cell;
 
 use selfref::Holder;
-use selfref::NewWith;
 use selfref::opaque;
 
 mod bad {
@@ -19,16 +18,13 @@ mod bad {
     }
     pub fn test() {
         let rc = Rc::new(Cell::new(""));
-        struct FooBuilder<'b>(Rc<Cell<&'b str>>);
-        impl<'k, 'b> NewWith<'k, FooOpaque> for FooBuilder<'b> {
-            fn new_with<'a>(self) -> Foo<'a> where 'k: 'a {
-                Foo {
-                    x: "Hello".to_owned(),
-                    y: self.0,
-                }
-            }
-        }
-        let x = Holder::new_with(FooBuilder(rc.clone()));
+        let rc_clone = rc.clone();
+        let x = Holder::<'_, FooOpaque>::new_with(move |builder| {
+            builder.build(Foo {
+                x: "Hello".to_owned(),
+                y: rc_clone,
+            });
+        });
         let x = Box::pin(x);
         x.as_ref().operate_in(|foo| {
             let foo = foo.get_ref();