-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
clippy: "warning: passing a unit value to a function" #1495
Comments
The generated code for such a route includes a pattern similar to this:
I think clippy is too eager to lint this; there's a similar case at rust-lang/rust-clippy#6447. If there is a reasonable way to generate code differently to avoid the lint I'd be interested, but it looks like the code is generated this way in order to provide better error messages. |
couldn't we just put a |
In principle we can (and I have opened a PR doing that). I'm not super happy about adding arbitrary clippy exemptions in generated code, since the exemptions may hide errors introduced in the future and this one really does look like a bug in clippy. |
This appears to have either been resolved upstream or no longer occur with the latest codegen: ❯ cat src/main.rs
use rocket::*;
#[get("/")]
fn index() { }
#[launch]
fn rocket() -> _ {
rocket::build().mount("/", routes![index])
}
❯ cargo clippy master ●
Finished dev [unoptimized + debuginfo] target(s) in 0.05s Closing as "resolved". |
Using 0.5.0-dec (rocket v0.5.0-dev (https://github.com/SergioBenitez/Rocket.git?branch=master#801e04bd))and clippy 0.1.51 (2fd73fa 2021-03-23) I see this warning on routes that accept data. Maybe it came back? Is there anything an end user had to do to silence these? |
rust-lang/rust-clippy#6447 was merged which probably fixed this, but that fix might not have made it to the |
version: latest master
os: arch/x86_64
description:
When a route returns a unit (
()
), clippy emits this warning:adding a return type resolves this warning.
The snipped which provoked this warning is this:
The text was updated successfully, but these errors were encountered: