rust-lang/rust-clippy

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

Open

#1.874 aberto em 5 de jul. de 2017

Ver no GitHub
 (9 comments) (0 reactions) (0 assignees)Rust (1.391 forks)batch import
A-lintL-correctnessS-needs-discussionT-middlegood first issue

Métricas do repositório

Stars
 (10.406 stars)
Métricas de merge de PR
 (Mesclagem média 19d 22h) (113 fundiu PRs em 30d)

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

Guia do colaborador