Description
Describe the bug
When using the #[component] macro on Leptos 0.6.15 or 0.7.8, the generated code does not expand the Scope
type, leading to the following error even in a minimal project:
rror[E0412]: cannot find type Scope in this scope --> src/main.rs:4:18 | 4 | pub fn Hello(cx: Scope) -> impl IntoView { | ^^^^^ not found in this scope
This happens even with all dependencies aligned, a clean build, and the recommended macro usage.
To Reproduce
- Create a new project:
cargo new leptos_minimal cd leptos_minimal cargo add leptos@0.6.15 leptos_router@0.6.15 tracing@0.1
Replace src/main.rs with:
rust
use leptos::*;
#[component]
pub fn Hello(cx: Scope) -> impl IntoView {
view! { cx,
}
fn main() {}
Run:
sh
cargo check
Expected behavior
The macro should expand and the code should compile, as in the official documentation and examples.
Actual behavior
The macro does not expand Scope and compilation fails.
Environment
Leptos version: 0.6.15 and 0.7.8
Rust version: rustc 1.86.0 (2025-03-31)
OS: [ macOS 15.4.1]
Was the project in a workspace? Both inside and outside, same result.
The error persists even with all recommended dependencies and features.
The same code works in older toolchains (if tested).
No workaround found.
Thank you for your help!