rust-lang/rust-clippy

Lint request: Prevent lifetimes that are only used for function output

Open

#1874 aperta il 5 lug 2017

Vedi su GitHub
 (9 commenti) (0 reazioni) (0 assegnatari)Rust (1391 fork)batch import
A-lintL-correctnessS-needs-discussionT-middlegood first issue

Metriche repository

Star
 (10.406 star)
Metriche merge PR
 (Merge medio 19g 22h) (113 PR mergiate in 30 g)

Descrizione

The following:

fn lifetime<'a>() -> &'a str {
    "Why some people do that"
}

Can be more clearly written as this. Also, using 'static lifetime makes it clear that it was intended, especially in unsafe code where returning unbound lifetime may as well be a mistake.

fn lifetime() -> &'static str {
    "Why some people do that"
}

Guida contributor