remove trybuild now that core is more safe
This commit is contained in:
1 parent
fd0a53ab63
commit
7fe6e05da3
6 files changed
-85
No files matched your search
@@ -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 = []
|
||||
|
||||
@@ -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!" } }
|
||||
}
|
||||
@@ -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)
|
||||
@@ -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:?}" } }
|
||||
}
|
||||
@@ -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)
|
||||
@@ -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");
|
||||
}
|
||||
Reference in new issue
Block a user