summary refs log tree commit diff stats
path: root/tests/ui/no_uaf_1.rs
diff options
context:
space:
mode:
authorSoniEx2 <endermoneymod@gmail.com>2022-12-05 16:32:20 -0300
committerSoniEx2 <endermoneymod@gmail.com>2022-12-05 16:32:20 -0300
commit72841de072c4a904983e9eb631b690a61d3e06ff (patch)
tree18b5677a9bcc61e77a140b9012c1d82333e2f4f1 /tests/ui/no_uaf_1.rs
parent2b5d0cb87b13fd5354143bb0b802d06ca0715ca6 (diff)
Use closures for new_with
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();