@@ -2,9 +2,10 @@ use clippy_utils::consts::{constant, Constant};
2
2
use clippy_utils:: diagnostics:: span_lint_and_then;
3
3
use clippy_utils:: sugg:: Sugg ;
4
4
use 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 } ;
6
6
use core:: ops:: ControlFlow ;
7
7
use rustc_errors:: Applicability ;
8
+ use rustc_hir:: def:: Res ;
8
9
use rustc_hir:: { BinOpKind , BorrowKind , Expr , ExprKind , UnOp , Unsafety } ;
9
10
use rustc_lint:: LateContext ;
10
11
use rustc_middle:: ty:: { self , Ty , TypeFlags , TypeVisitableExt } ;
@@ -32,6 +33,10 @@ pub(crate) fn check<'tcx>(
32
33
&& !( matches ! ( left_red. kind, ExprKind :: Lit ( _) ) && matches ! ( right_red. kind, ExprKind :: Lit ( _) ) )
33
34
// Allow comparing the results of signum()
34
35
&& !( 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
+ }
35
40
{
36
41
let left_c = constant ( cx, cx. typeck_results ( ) , left_red) ;
37
42
let is_left_const = left_c. is_some ( ) ;
@@ -64,7 +69,7 @@ pub(crate) fn check<'tcx>(
64
69
65
70
if let Some ( name) = get_item_name ( cx, expr) {
66
71
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" ) {
68
73
return ;
69
74
}
70
75
}
0 commit comments