@@ -1434,6 +1434,7 @@ impl InvalidAtomicOrdering {
1434
1434
fn inherent_atomic_method_call < ' hir > (
1435
1435
cx : & LateContext < ' _ > ,
1436
1436
expr : & Expr < ' hir > ,
1437
+ recognized_names : & [ Symbol ] , // used for fast path calculation
1437
1438
) -> Option < ( Symbol , & ' hir [ Expr < ' hir > ] ) > {
1438
1439
const ATOMIC_TYPES : & [ Symbol ] = & [
1439
1440
sym:: AtomicBool ,
@@ -1453,6 +1454,7 @@ impl InvalidAtomicOrdering {
1453
1454
] ;
1454
1455
if_chain ! {
1455
1456
if let ExprKind :: MethodCall ( ref method_path, _, args, _) = & expr. kind;
1457
+ if recognized_names. contains( & method_path. ident. name) ;
1456
1458
if let Some ( m_def_id) = cx. typeck_results( ) . type_dependent_def_id( expr. hir_id) ;
1457
1459
if let Some ( impl_did) = cx. tcx. impl_of_method( m_def_id) ;
1458
1460
if let Some ( adt) = cx. tcx. type_of( impl_did) . ty_adt_def( ) ;
@@ -1494,7 +1496,7 @@ impl InvalidAtomicOrdering {
1494
1496
use rustc_hir:: def:: { DefKind , Res } ;
1495
1497
use rustc_hir:: QPath ;
1496
1498
if_chain ! {
1497
- if let Some ( ( method, args) ) = Self :: inherent_atomic_method_call( cx, expr) ;
1499
+ if let Some ( ( method, args) ) = Self :: inherent_atomic_method_call( cx, expr, & [ sym :: load , sym :: store ] ) ;
1498
1500
if let Some ( ( ordering_arg, invalid_ordering) ) = match method {
1499
1501
sym:: load => Some ( ( & args[ 1 ] , sym:: Release ) ) ,
1500
1502
sym:: store => Some ( ( & args[ 2 ] , sym:: Acquire ) ) ,
@@ -1543,7 +1545,7 @@ impl InvalidAtomicOrdering {
1543
1545
1544
1546
fn check_atomic_compare_exchange ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > ) {
1545
1547
if_chain ! {
1546
- if let Some ( ( method, args) ) = Self :: inherent_atomic_method_call( cx, expr) ;
1548
+ if let Some ( ( method, args) ) = Self :: inherent_atomic_method_call( cx, expr, & [ sym :: fetch_update , sym :: compare_exchange , sym :: compare_exchange_weak ] ) ;
1547
1549
if let Some ( ( success_order_arg, failure_order_arg) ) = match method {
1548
1550
sym:: fetch_update => Some ( ( & args[ 1 ] , & args[ 2 ] ) ) ,
1549
1551
sym:: compare_exchange | sym:: compare_exchange_weak => Some ( ( & args[ 3 ] , & args[ 4 ] ) ) ,
0 commit comments