rust-lang/rust-clippy
在 GitHub 查看Lint request: Prevent lifetimes that are only used for function output
Open
#1,874 建立於 2017年7月5日
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"
}