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

let_unit_value violation within html macro #2931

Closed
1 of 3 tasks
Starwort opened this issue Oct 22, 2022 · 1 comment · Fixed by #2970
Closed
1 of 3 tasks

let_unit_value violation within html macro #2931

Starwort opened this issue Oct 22, 2022 · 1 comment · Fixed by #2970
Labels

Comments

@Starwort
Copy link

Problem
Functional (and possibly struct?) components with no props (such as the routes generated by create-yew-app) cause violations of clippy::let_unit_value at their use sites.

Steps To Reproduce
Steps to reproduce the behavior:

  1. Write a functional component with no props
    /// About page
    #[function_component(About)]
    pub fn about() -> Html {
        html! {
            {"Todo"}
        }
    }
  2. Use the component within an invocation of html!:
    /// Switch app routes
    pub fn switch(routes: &AppRoute) -> Html {
        match routes.clone() {
            AppRoute::Home => html! { <Home /> },
            AppRoute::About => html! { <About /> },
            AppRoute::PageNotFound => html! { "Page not found" },
        }
    }
  3. Run clippy under pedantic settings (cargo clippy -W clippy::pedantic)
  4. See error

Expected behavior
No lint warning

Environment:

  • Yew version: 0.19.3
  • Rust version: 1.66.0-nightly (01af5040f 2022-10-04)
  • Target, if relevant: Not sure, but shouldn't be relevant
  • Build tool, if relevant: parcel-plugin-wasm.rs (shouldn't be relevant)
  • OS, if relevant: Linux (shouldn't be relevant)

Questionnaire

  • I'm interested in fixing this myself but don't know where to start
  • I would like to fix and I have a solution
  • I don't have time to fix this right now, but maybe later
@Starwort Starwort added the bug label Oct 22, 2022
@WorldSEnder
Copy link
Member

WorldSEnder commented Oct 22, 2022

Functional components with no properties get () assigned implicitly as <_ as BaseComponent>::Properties, which I would think is the cause of having such a let binding when constructing them in e.g. html! { <About /> }. A shame that clippy sees through the type aliases :D Thanks for the report!

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

Successfully merging a pull request may close this issue.

2 participants