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

Getting several no_effect_underscore_binding lints on #[launch] #2676

Closed
ShayBox opened this issue Dec 18, 2023 · 1 comment
Closed

Getting several no_effect_underscore_binding lints on #[launch] #2676

ShayBox opened this issue Dec 18, 2023 · 1 comment

Comments

@ShayBox
Copy link

ShayBox commented Dec 18, 2023

Description

I generally have clippy::pedantic set to warn, and trying to use the default example code.

The specific lints are:

* `clippy::no_effect_underscore_binding` (from pedantic)

* `clippy::uninlined_format_args` (from pedantic)

To Reproduce

The following code can be used with the latest version of rocket on a fresh cargo init.

#![warn(clippy::pedantic)]

#[macro_use]
extern crate rocket;

#[get("/<name>/<age>")]
fn hello(name: &str, age: u8) -> String {
    format!("Hello, {} year old named {}!", age, name)
}

#[launch]
fn rocket() -> _ {
    rocket::build().mount("/hello", routes![hello])
}

Switching to a static return type Rocket<Build> does not change the warnings.
I believe this is because the #[launch] macro uses many underscore bindings, without allow.

fn main() {
    let _ = ::rocket::async_main(
        {
            let ___rocket: ::rocket::Rocket<::rocket::Build> = {
                rocket::build()
                    .mount(
                        "/hello",
                        {
                            let ___vec: ::std::vec::Vec<::rocket::Route> = <[_]>::into_vec(
                                #[rustc_box]
                                ::alloc::boxed::Box::new([
                                    {
                                        let ___struct = hello {};
                                        let ___item: ::rocket::Route = ___struct.into_route();
                                        ___item
                                    },
                                ]),
                            );
                            ___vec
                        },
                    )
            };
            let ___rocket: ::rocket::Rocket<::rocket::Build> = ___rocket;
            ___rocket
        }
            .launch(),
    );
}

Expected Behavior

No unrelated lints to appear from within the launch derive.

Environment:

* OS Distribution and Kernel: Windows 11 23H2

* Rocket Version: 0.5.0

Based on a similar issue #2655

@SergioBenitez
Copy link
Member

There are no longer there on master.

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

No branches or pull requests

2 participants