Closed
Description
Code
Unfortunately I couldn't minimize it further without using a dependency (code can be executed online here):
/*
[dependencies]
sycamore = "0.8.2"
web-sys = "0.3"
*/
use sycamore::prelude::{Scope, View, Html, DomNode, ReadSignal, GenericNode};
pub fn create_toggle_bool<'a>(cx: Scope<'a>, initial: bool) -> (&'a ReadSignal<bool>, impl Fn() + Copy + 'a) {
// let open = sycamore::prelude::create_signal(cx, false);
// let open_toggle = || open.set(!*open.get());
// (open, open_toggle)
(todo!(), || {})
}
pub fn Foo<G: Html>(cx: Scope) -> View<G> {
let (open, open_toggle) = create_toggle_bool(cx, false);
// Uncomment these 2 lines to make it compile (moved out of the function)
// let open = sycamore::prelude::create_signal(cx, false);
// let open_toggle = || open.set(!*open.get());
let a = move |_: web_sys::Event| open_toggle();
move || {
let __el = DomNode::text_node("test");
::sycamore::generic_node::GenericNode::event(&__el, cx, "click", a);
__el;
};
todo!()
}
fn main() {
}
The code compiles and runs with 1.66 but fails with 1.67:
error: `create_toggle_bool::{opaque#0}<'_>` does not live long enough
--> src/main.rs:28:9
|
28 | ::sycamore::generic_node::GenericNode::event(&__el, cx, "click", a);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I expect this code to still compile on 1.67
Version it worked on
1.66
Version with regression
1.67
rustc 1.67.0 (fc594f156 2023-01-24)
binary: rustc
commit-hash: fc594f15669680fa70d255faec3ca3fb507c3405
commit-date: 2023-01-24
host: x86_64-unknown-linux-gnu
release: 1.67.0
LLVM version: 15.0.6