@@ -2,9 +2,10 @@ use clippy_utils::consts::{constant, Constant};
22use clippy_utils:: diagnostics:: span_lint_and_then;
33use clippy_utils:: sugg:: Sugg ;
44use clippy_utils:: visitors:: { for_each_expr, is_const_evaluatable} ;
5- use clippy_utils:: { get_item_name, is_expr_named_const, peel_hir_expr_while, SpanlessEq } ;
5+ use clippy_utils:: { get_item_name, is_expr_named_const, path_res , peel_hir_expr_while, SpanlessEq } ;
66use core:: ops:: ControlFlow ;
77use rustc_errors:: Applicability ;
8+ use rustc_hir:: def:: Res ;
89use rustc_hir:: { BinOpKind , BorrowKind , Expr , ExprKind , UnOp , Unsafety } ;
910use rustc_lint:: LateContext ;
1011use rustc_middle:: ty:: { self , Ty , TypeFlags , TypeVisitableExt } ;
@@ -32,6 +33,10 @@ pub(crate) fn check<'tcx>(
3233 && !( matches ! ( left_red. kind, ExprKind :: Lit ( _) ) && matches ! ( right_red. kind, ExprKind :: Lit ( _) ) )
3334 // Allow comparing the results of signum()
3435 && !( is_signum ( cx, left_red) && is_signum ( cx, right_red) )
36+ && match ( path_res ( cx, left_red) , path_res ( cx, right_red) ) {
37+ ( Res :: Err , _) | ( _, Res :: Err ) => true ,
38+ ( left, right) => left != right,
39+ }
3540 {
3641 let left_c = constant ( cx, cx. typeck_results ( ) , left_red) ;
3742 let is_left_const = left_c. is_some ( ) ;
@@ -64,7 +69,7 @@ pub(crate) fn check<'tcx>(
6469
6570 if let Some ( name) = get_item_name ( cx, expr) {
6671 let name = name. as_str ( ) ;
67- if name == "eq" || name == "ne" || name == "is_nan" || name . starts_with ( "eq_" ) || name. ends_with ( "_eq" ) {
72+ if name == "eq" || name == "ne" || name. starts_with ( "eq_" ) || name. ends_with ( "_eq" ) {
6873 return ;
6974 }
7075 }
0 commit comments