Rust: Warn on unused lifetime parameters

Created on 12 May 2017  路  11Comments  路  Source: rust-lang/rust

Somehow this made it into master without being warned:

#[stable(feature = "os_string_from_box", since = "1.17.0")]
impl<'a> From<Box<OsStr>> for OsString {
    fn from(boxed: Box<OsStr>) -> OsString {
        boxed.into_os_string()
    }
}

This should definitely trigger a warning.

A-diagnostics A-lint C-feature-request T-compiler

All 11 comments

Yikes, no warnings at all.

fn main() {
    trait T {}
    impl<'a> T for u8 {}
}

Triage: no change.

@varkor they should be accepted, just linted.

pub type UnusedHrtb = for<'a> fn();

Found something like this in my codebase today. No warning from rustc or clippy.

Any plans to add a warn-by-default lint?

We have an unused_lifetimes lint now.

@Mark-Simulacrum it is not warn by default and I think it probably should be (gated may be on ecosystem prevalence).

Hm, yeah, that makes sense. Reopening. I personally think we can probably "just" land this as a PR with FCP T-lang.

https://github.com/rust-lang/rust/issues/64493 should be considered blocking for making this warn-by-default.

Was this page helpful?
0 / 5 - 0 ratings