You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: clippy_lints/src/unnecessary_literal_bound.rs
+59-21Lines changed: 59 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,12 @@
1
1
use clippy_utils::diagnostics::span_lint_and_sugg;
2
-
use clippy_utils::{ReturnType,ReturnVisitor, path_res, visit_returns};
2
+
use clippy_utils::source::snippet_with_applicability;
3
+
use clippy_utils::{ReturnType,ReturnVisitor, visit_returns};
4
+
use rustc_ast::BorrowKind;
3
5
use rustc_ast::ast::LitKind;
4
6
use rustc_errors::Applicability;
5
7
use rustc_hir::def::Res;
6
8
use rustc_hir::intravisit::FnKind;
7
-
use rustc_hir::{Body,ExprKind,FnDecl,FnRetTy,Lit,MutTy,Mutability,PrimTy,Ty,TyKind};
9
+
use rustc_hir::{Body,Expr,ExprKind,FnDecl,FnRetTy,Lit,MutTy,Mutability,PrimTy,Ty,TyKind};
8
10
use rustc_lint::{LateContext,LateLintPass};
9
11
use rustc_session::declare_lint_pass;
10
12
use rustc_span::Span;
@@ -13,11 +15,11 @@ use rustc_span::def_id::LocalDefId;
13
15
declare_clippy_lint!{
14
16
/// ### What it does
15
17
///
16
-
/// Detects functions that are written to return `&str` that could return `&'static str` but instead return a `&'a str`.
18
+
/// Detects functions that are written to return a reference to a literal that could return a static reference but instead return a lifetime-bounded reference.
17
19
///
18
20
/// ### Why is this bad?
19
21
///
20
-
/// This leaves the caller unable to use the `&str` as `&'static str`, causing unneccessary allocations or confusion.
22
+
/// This leaves the caller unable to use the reference as `'static`, causing unneccessary allocations or confusion.
21
23
/// This is also most likely what you meant to write.
0 commit comments