Skip to content

Clippy told me to write an invalid line #1918

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

Closed
thomas-daniels opened this issue Aug 1, 2017 · 1 comment
Closed

Clippy told me to write an invalid line #1918

thomas-daniels opened this issue Aug 1, 2017 · 1 comment

Comments

@thomas-daniels
Copy link

I have this Rust function (the get attribute and Template come from the web framework Rocket):

#[get("/")]
fn index() -> Template {
    Template::render("home/index", empty_hashmap())
}

When running Clippy over my code, it said something about this function:

 --> src\controllers\home.rs:4:1
  |
4 | #[get("/")]
  | ^^^^^^^^^^^ help: consider taking a reference instead: `&#[get("/")]`
  |
  = note: #[warn(needless_pass_by_value)] on by default
  = help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#needless_pass_by_value

Alright, so I did what Clippy told me:

&#[get("/")]
fn index() -> Template {
    Template::render("home/index", empty_hashmap())
}

However, the compiler wasn't too happy with that:

error: expected item, found `&`
 --> src\controllers\home.rs:4:1
  |
4 | &#[get("/")]
  | ^

Is it a bug in Clippy that it suggests me to write this line? Or is it a problem from Rocket, or just my misunderstanding?

@oli-obk
Copy link
Contributor

oli-obk commented Aug 1, 2017

This is actually a rustc bug: rust-lang/rust#43268

We have an issue open in this repo at #1885, so I'll close this issue in favour of the other one.

@oli-obk oli-obk closed this as completed Aug 1, 2017
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