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

suppress needless_lifetimes lints from clippy 0.1.83 #391

Merged
merged 1 commit into from
Dec 3, 2024

Conversation

matt-phylum
Copy link
Contributor

I think I did this correctly.

In Clippy 0.1.83, without the changes in expand.rs, the new test in test_lints.rs fails with the following output:

error: the following explicit lifetimes could be elided: 'a
  --> tests/test_lints.rs:29:22
   |
29 |     pub enum MyError<'a> {
   |                      ^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
note: the lint level is defined here
  --> tests/test_lints.rs:25:13
   |
25 |     #![deny(clippy::needless_lifetimes)]
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^
help: elide the lifetimes
   |
29 -     pub enum MyError<'a> {
29 +     pub enum MyError'_> {
   |

error: could not compile `thiserror` (test "test_lints") due to 1 previous error

Clippy doesn't like the generated impl From and gets confused about what it's fixing (rust-lang/rust-clippy#12789?) and the result is a confusing message suggesting code that is broken in multiple ways. The Display and Error impls don't seem to be affected, so this probably only affects users that use borrowed errors and #[from].

I encountered this in a project I can't share, but it's the same case as ruffle-rs/ruffle#18761 https://github.com/ruffle-rs/ruffle/blob/bd89e5b216769168d08548f01e2b6871280ab829/core/src/avm1/error.rs

Copy link
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dtolnay dtolnay merged commit 4fde284 into dtolnay:master Dec 3, 2024
12 checks passed
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

Successfully merging this pull request may close these issues.

2 participants