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

Lint for unused lifetime parameters #9445

Closed
jruderman opened this issue Sep 24, 2013 · 6 comments
Closed

Lint for unused lifetime parameters #9445

jruderman opened this issue Sep 24, 2013 · 6 comments
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@jruderman
Copy link
Contributor

This code in borrow.rs could trip a warning about having unnecessary lifetime parameters:

pub fn ref_eq<'a, 'b, T>(thing: &'a T, other: &'b T) -> bool {
    to_uint(thing) == to_uint(other)
}
@nikomatsakis
Copy link
Contributor

cc me

@reem
Copy link
Contributor

reem commented Aug 11, 2014

Triage: This is even more important given lifetime elision - we should warn when lifetimes are included that could be elided, not just when they aren't used.

@huonw
Copy link
Member

huonw commented Aug 11, 2014

I disagree about elision. It's very reasonable to include explicit lifetimes for clarity or to be 100% sure that unsafe code is doing what you want. (I could imagine a separate elidable_lifetimes lint, on allow by default.)

@zwarich
Copy link

zwarich commented Aug 11, 2014

I agree with @huonw. In Servo, where we have a lot of unsafe code, explicit lifetime parameters make things more understandable. The &self rule makes a lot of programs typecheck, but it is sometimes tricky for people to unravel when they have to investigate an issue.

@reem
Copy link
Contributor

reem commented Aug 11, 2014

That seems like a perfectly reasonable approach. I'll make an issue for a new lint for elidable lifetimes.

@steveklabnik steveklabnik added the A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. label Jan 23, 2015
@sanxiyn
Copy link
Member

sanxiyn commented Nov 27, 2015

This is implemented as needless_lifetimes in Clippy. @jruderman's example warns. Closing.

@sanxiyn sanxiyn closed this as completed Nov 27, 2015
flip1995 pushed a commit to flip1995/rust that referenced this issue Oct 6, 2022
Don't lint `*_interior_mutable_const` on unions due to potential ICE.

fixes rust-lang#9445
cc rust-lang#101113

This started ICE'ing sometime last month due to stricter UB checks. I'm not sure how we could check the value of a union as MIRI doesn't seem to store which field is currently active.

changelog: Don't ICE on const unions containing a `!Freeze` type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

No branches or pull requests

7 participants