@@ -3,15 +3,15 @@ use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then};
33use clippy_utils:: msrvs:: { self , Msrv } ;
44use clippy_utils:: sugg:: { Sugg , make_binop} ;
55use 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 ,
77} ;
88use rustc_ast:: ast:: LitKind ;
99use rustc_data_structures:: packed:: Pu128 ;
1010use rustc_errors:: Applicability ;
1111use rustc_hir:: { AssignOpKind , BinOp , BinOpKind , Expr , ExprKind , QPath } ;
1212use rustc_lint:: { LateContext , LateLintPass } ;
1313use rustc_session:: impl_lint_pass;
14- use rustc_span:: Span ;
14+ use rustc_span:: { Span , Symbol } ;
1515
1616declare_clippy_lint ! {
1717 /// ### What it does
@@ -325,7 +325,7 @@ fn check_with_condition<'tcx>(
325325 }
326326
327327 // 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 ;
329329 match cond_num_val. kind {
330330 ExprKind :: Lit ( cond_lit) => {
331331 // Check if the constant is zero
@@ -337,7 +337,7 @@ fn check_with_condition<'tcx>(
337337 }
338338 } ,
339339 ExprKind :: Path ( QPath :: TypeRelative ( _, name) ) => {
340- if name. ident . as_str ( ) == " MIN"
340+ if name. ident . name == sym :: MIN
341341 && let Some ( const_id) = cx. typeck_results ( ) . type_dependent_def_id ( cond_num_val. hir_id )
342342 && let Some ( impl_id) = cx. tcx . impl_of_method ( const_id)
343343 && let None = cx. tcx . impl_trait_ref ( impl_id) // An inherent impl
@@ -348,7 +348,7 @@ fn check_with_condition<'tcx>(
348348 } ,
349349 ExprKind :: Call ( func, [ ] ) => {
350350 if let ExprKind :: Path ( QPath :: TypeRelative ( _, name) ) = func. kind
351- && name. ident . as_str ( ) == " min_value"
351+ && name. ident . name == sym :: min_value
352352 && let Some ( func_id) = cx. typeck_results ( ) . type_dependent_def_id ( func. hir_id )
353353 && let Some ( impl_id) = cx. tcx . impl_of_method ( func_id)
354354 && 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
383383 }
384384}
385385
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 < ' _ > ) {
387387 span_lint_and_sugg (
388388 cx,
389389 IMPLICIT_SATURATING_SUB ,
0 commit comments