Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markup issue: associated type may not live long enough #3380

Open
svieujot opened this issue Dec 17, 2024 · 2 comments
Open

Markup issue: associated type may not live long enough #3380

svieujot opened this issue Dec 17, 2024 · 2 comments

Comments

@svieujot
Copy link

The following markup works fine:

<Show
    when=show_tripped
    fallback=|| {
        view! {
            <span title="ON">
                <Icon icon={i::FaPowerOffSolid} {..} class=css::onIcon/>
            </span>
        }
    }
>
    <span title="Tripped" class=css::tripped>
        <Icon icon={i::TbCircuitSwitchOpen} />
    </span>
</Show>

But when moving the css::tripped after the {..} operator on the second <Icon/> tag like:

<Show
    when=show_tripped
    fallback=|| {
        view! {
            <span title="ON">
                <Icon icon={i::FaPowerOffSolid} {..} class=css::onIcon/>
            </span>
        }
    }
>
    <span title="Tripped" >
        <Icon icon={i::TbCircuitSwitchOpen} {..} class=css::tripped/>
    </span>
</Show>

Then the markup generates this error:


error[E0310]: the associated type `<impl leptos::IntoView as leptos::prelude::AddAnyAttr>::Output<(Class<&str>,)>` may not live long enough
   --> cmd/ui/src/components/propulsion/on_buttons.rs:135:5
    |
135 | /     view! {
136 | |             <Show when=move || show_on_button() || show_start_button() || show_throttle_warning()>
137 | |                 <Show when=show_hydraulic_pump_button>
138 | |                     <div class=classes!(css::hydraulicPump, "text-center")>
...   |
211 | |             </Show>
212 | |         }
    | |         ^
    | |         |
    | |_________the associated type `<impl leptos::IntoView as leptos::prelude::AddAnyAttr>::Output<(Class<&str>,)>` must be valid for the static lifetime...
    |           ...so that the type `<impl leptos::IntoView as leptos::prelude::AddAnyAttr>::Output<(Class<&str>,)>` will meet its required lifetime bounds
    |
    = help: consider adding an explicit lifetime bound `<impl leptos::IntoView as leptos::prelude::AddAnyAttr>::Output<(Class<&str>,)>: 'static`...
    = note: this error originates in the macro `view` (in Nightly builds, run with -Z macro-backtrace for more info)
@gbj
Copy link
Collaborator

gbj commented Dec 18, 2024

My assumption would be that at least one of these values (css::tripped, for example) is a borrowed, not an owned, type, and needs to be owned. For example, if css::tripped is &str, then it needs to be either a String or &'static str, etc.

If you provide a reproducible example (i.e., fill in the missing parts in the examples above), I'm happy to look at it in more depth.

@svieujot
Copy link
Author

css::tripped is a &str generated by stylance.

I will prepare a full example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants