@@ -3,15 +3,15 @@ use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then};
3
3
use clippy_utils:: msrvs:: { self , Msrv } ;
4
4
use clippy_utils:: sugg:: { Sugg , make_binop} ;
5
5
use clippy_utils:: {
6
- SpanlessEq , eq_expr_value, higher, is_in_const_context, is_integer_literal, peel_blocks, peel_blocks_with_stmt,
6
+ SpanlessEq , eq_expr_value, higher, is_in_const_context, is_integer_literal, peel_blocks, peel_blocks_with_stmt, sym ,
7
7
} ;
8
8
use rustc_ast:: ast:: LitKind ;
9
9
use rustc_data_structures:: packed:: Pu128 ;
10
10
use rustc_errors:: Applicability ;
11
11
use rustc_hir:: { AssignOpKind , BinOp , BinOpKind , Expr , ExprKind , QPath } ;
12
12
use rustc_lint:: { LateContext , LateLintPass } ;
13
13
use rustc_session:: impl_lint_pass;
14
- use rustc_span:: Span ;
14
+ use rustc_span:: { Span , Symbol } ;
15
15
16
16
declare_clippy_lint ! {
17
17
/// ### What it does
@@ -325,7 +325,7 @@ fn check_with_condition<'tcx>(
325
325
}
326
326
327
327
// Get the variable name
328
- let var_name = ares_path. segments [ 0 ] . ident . name . as_str ( ) ;
328
+ let var_name = ares_path. segments [ 0 ] . ident . name ;
329
329
match cond_num_val. kind {
330
330
ExprKind :: Lit ( cond_lit) => {
331
331
// Check if the constant is zero
@@ -337,7 +337,7 @@ fn check_with_condition<'tcx>(
337
337
}
338
338
} ,
339
339
ExprKind :: Path ( QPath :: TypeRelative ( _, name) ) => {
340
- if name. ident . as_str ( ) == " MIN"
340
+ if name. ident . name == sym :: MIN
341
341
&& let Some ( const_id) = cx. typeck_results ( ) . type_dependent_def_id ( cond_num_val. hir_id )
342
342
&& let Some ( impl_id) = cx. tcx . impl_of_method ( const_id)
343
343
&& let None = cx. tcx . impl_trait_ref ( impl_id) // An inherent impl
@@ -348,7 +348,7 @@ fn check_with_condition<'tcx>(
348
348
} ,
349
349
ExprKind :: Call ( func, [ ] ) => {
350
350
if let ExprKind :: Path ( QPath :: TypeRelative ( _, name) ) = func. kind
351
- && name. ident . as_str ( ) == " min_value"
351
+ && name. ident . name == sym :: min_value
352
352
&& let Some ( func_id) = cx. typeck_results ( ) . type_dependent_def_id ( func. hir_id )
353
353
&& let Some ( impl_id) = cx. tcx . impl_of_method ( func_id)
354
354
&& let None = cx. tcx . impl_trait_ref ( impl_id) // An inherent impl
@@ -383,7 +383,7 @@ fn subtracts_one<'a>(cx: &LateContext<'_>, expr: &'a Expr<'a>) -> Option<&'a Exp
383
383
}
384
384
}
385
385
386
- fn print_lint_and_sugg ( cx : & LateContext < ' _ > , var_name : & str , expr : & Expr < ' _ > ) {
386
+ fn print_lint_and_sugg ( cx : & LateContext < ' _ > , var_name : Symbol , expr : & Expr < ' _ > ) {
387
387
span_lint_and_sugg (
388
388
cx,
389
389
IMPLICIT_SATURATING_SUB ,
0 commit comments