Jelajahi Sumber

remove trybuild now that core is more safe

Evan Almloff 1 tahun lalu
induk
melakukan
7fe6e05da3

+ 0 - 1
packages/core/Cargo.toml

@@ -38,7 +38,6 @@ dioxus-html = { workspace = true, features = ["serialize"] }
 pretty_assertions = "1.3.0"
 rand = "0.8.5"
 dioxus-ssr = { workspace = true }
-trybuild = "1.0"
 
 [features]
 default = []

+ 0 - 26
packages/core/compile_tests/props_safety.rs

@@ -1,26 +0,0 @@
-use dioxus::prelude::*;
-
-fn main() {}
-
-fn app() -> Element {
-    let count: &RefCell<Vec<Element>> = cx.use_hook(|| RefCell::new(Vec::new()));
-
-    render! { unsafe_child_component { borrowed: count } }
-}
-
-#[derive(Props)]
-struct Testing<'a> {
-    borrowed: &'a RefCell<Vec<Element>>,
-}
-
-fn unsafe_child_component<'a>(cx: Testing) -> Element {
-    let Testing { borrowed } = cx;
-    let borrowed_temporary_data =
-        cx.use_hook(|| String::from("This data is only valid for the lifetime of the child"));
-
-    borrowed
-        .borrow_mut()
-        .push(render! {"{borrowed_temporary_data}"});
-
-    render! { div { "Hello, world!" } }
-}

+ 0 - 20
packages/core/compile_tests/props_safety.stderr

@@ -1,20 +0,0 @@
-error[E0521]: borrowed data escapes outside of function
-  --> compile_tests/props_safety.rs:8:5
-   |
-5  |   fn app() -> Element {
-   |          --
-   |          |
-   |          `cx` is a reference that is only valid in the function body
-   |          has type `&'1 Scoped<'1>`
-...
-8  | /     render! {
-9  | |         unsafe_child_component {
-10 | |             borrowed: count
-11 | |         }
-12 | |     }
-   | |     ^
-   | |     |
-   | |_____`cx` escapes the function body here
-   |       argument requires that `'1` must outlive `'static`
-   |
-   = note: this error originates in the macro `render` (in Nightly builds, run with -Z macro-backtrace for more info)

+ 0 - 18
packages/core/compile_tests/props_safety_temporary_values.rs

@@ -1,18 +0,0 @@
-use dioxus::prelude::*;
-
-fn main() {}
-
-fn app() -> Element {
-    let count = vec![1, 2, 3];
-
-    render! { unsafe_child_component { borrowed: &count } }
-}
-
-#[derive(Props)]
-struct Testing<'a> {
-    borrowed: &'a Vec<u32>,
-}
-
-fn unsafe_child_component<'a>(cx: Testing) -> Element {
-    render! { div { "{cx.borrowed:?}" } }
-}

+ 0 - 12
packages/core/compile_tests/props_safety_temporary_values.stderr

@@ -1,12 +0,0 @@
-error[E0515]: cannot return value referencing local variable `count`
-  --> compile_tests/props_safety_temporary_values.rs:8:5
-   |
-8  | /     render! {
-9  | |         unsafe_child_component {
-10 | |             borrowed: &count
-   | |                       ------ `count` is borrowed here
-11 | |         }
-12 | |     }
-   | |_____^ returns a value referencing data owned by the current function
-   |
-   = note: this error originates in the macro `render` (in Nightly builds, run with -Z macro-backtrace for more info)

+ 0 - 8
packages/core/src/properties.rs

@@ -112,11 +112,3 @@ fn test_empty_builder() {
     let builder = fc_to_builder(app2);
     builder.build();
 }
-
-#[cfg(not(miri))]
-#[test]
-fn unsafe_props_fail() {
-    let t = trybuild::TestCases::new();
-    t.compile_fail("compile_tests/props_safety.rs");
-    t.compile_fail("compile_tests/props_safety_temporary_values.rs");
-}