rust-lang/rust-clippy

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

Open

#1,874 创建于 2017年7月5日

在 GitHub 查看
 (9 评论) (0 反应) (0 负责人)Rust (1,391 fork)batch import
A-lintL-correctnessS-needs-discussionT-middlegood first issue

仓库指标

Star
 (10,406 star)
PR 合并指标
 (平均合并 19天 22小时) (30 天内合并 113 个 PR)

描述

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

贡献者指南