rust-lang/rust-clippy

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

Open

#1 874 ouverte le 5 juil. 2017

Voir sur GitHub
 (9 commentaires) (0 réactions) (0 assignés)Rust (1 391 forks)batch import
A-lintL-correctnessS-needs-discussionT-middlegood first issue

Métriques du dépôt

Stars
 (10 406 stars)
Métriques de merge PR
 (Merge moyen 19j 22h) (113 PRs mergées en 30 j)

Description

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"
}

Guide contributeur