@@ -1512,13 +1512,13 @@ impl InvalidAtomicOrdering {
1512
1512
{
1513
1513
cx. struct_span_lint ( INVALID_ATOMIC_ORDERING , ordering_arg. span , |diag| {
1514
1514
if method == sym:: load {
1515
- diag. build ( "atomic loads cannot have `Release` or `AcqRel` ordering" )
1516
- . help ( "consider using ordering modes `Acquire`, `SeqCst` or `Relaxed`" )
1515
+ diag. build ( fluent :: lint :: atomic_ordering_load )
1516
+ . help ( fluent :: lint :: help )
1517
1517
. emit ( )
1518
1518
} else {
1519
1519
debug_assert_eq ! ( method, sym:: store) ;
1520
- diag. build ( "atomic stores cannot have `Acquire` or `AcqRel` ordering" )
1521
- . help ( "consider using ordering modes `Release`, `SeqCst` or `Relaxed`" )
1520
+ diag. build ( fluent :: lint :: atomic_ordering_store )
1521
+ . help ( fluent :: lint :: help )
1522
1522
. emit ( ) ;
1523
1523
}
1524
1524
} ) ;
@@ -1533,8 +1533,8 @@ impl InvalidAtomicOrdering {
1533
1533
&& Self :: match_ordering ( cx, & args[ 0 ] ) == Some ( sym:: Relaxed )
1534
1534
{
1535
1535
cx. struct_span_lint ( INVALID_ATOMIC_ORDERING , args[ 0 ] . span , |diag| {
1536
- diag. build ( "memory fences cannot have `Relaxed` ordering" )
1537
- . help ( "consider using ordering modes `Acquire`, `Release`, `AcqRel` or `SeqCst`" )
1536
+ diag. build ( fluent :: lint :: atomic_ordering_fence )
1537
+ . help ( fluent :: lint :: help )
1538
1538
. emit ( ) ;
1539
1539
} ) ;
1540
1540
}
@@ -1554,13 +1554,11 @@ impl InvalidAtomicOrdering {
1554
1554
1555
1555
if matches ! ( fail_ordering, sym:: Release | sym:: AcqRel ) {
1556
1556
cx. struct_span_lint ( INVALID_ATOMIC_ORDERING , fail_order_arg. span , |diag| {
1557
- diag. build ( & format ! (
1558
- "`{method}`'s failure ordering may not be `Release` or `AcqRel`, \
1559
- since a failed `{method}` does not result in a write",
1560
- ) )
1561
- . span_label ( fail_order_arg. span , "invalid failure ordering" )
1562
- . help ( "consider using `Acquire` or `Relaxed` failure ordering instead" )
1563
- . emit ( ) ;
1557
+ diag. build ( fluent:: lint:: atomic_ordering_invalid)
1558
+ . set_arg ( "method" , method)
1559
+ . span_label ( fail_order_arg. span , fluent:: lint:: label)
1560
+ . help ( fluent:: lint:: help)
1561
+ . emit ( ) ;
1564
1562
} ) ;
1565
1563
}
1566
1564
@@ -1578,18 +1576,20 @@ impl InvalidAtomicOrdering {
1578
1576
fail_ordering
1579
1577
} ;
1580
1578
cx. struct_span_lint ( INVALID_ATOMIC_ORDERING , success_order_arg. span , |diag| {
1581
- diag. build ( & format ! (
1582
- "`{method}`'s success ordering must be at least as strong as its failure ordering"
1583
- ) )
1584
- . span_label ( fail_order_arg. span , format ! ( "`{fail_ordering}` failure ordering" ) )
1585
- . span_label ( success_order_arg. span , format ! ( "`{success_ordering}` success ordering" ) )
1586
- . span_suggestion_short (
1587
- success_order_arg. span ,
1588
- format ! ( "consider using `{success_suggestion}` success ordering instead" ) ,
1589
- format ! ( "std::sync::atomic::Ordering::{success_suggestion}" ) ,
1590
- Applicability :: MaybeIncorrect ,
1591
- )
1592
- . emit ( ) ;
1579
+ diag. build ( fluent:: lint:: atomic_ordering_invalid_fail_success)
1580
+ . set_arg ( "method" , method)
1581
+ . set_arg ( "fail_ordering" , fail_ordering)
1582
+ . set_arg ( "success_ordering" , success_ordering)
1583
+ . set_arg ( "success_suggestion" , success_suggestion)
1584
+ . span_label ( fail_order_arg. span , fluent:: lint:: fail_label)
1585
+ . span_label ( success_order_arg. span , fluent:: lint:: success_label)
1586
+ . span_suggestion_short (
1587
+ success_order_arg. span ,
1588
+ fluent:: lint:: suggestion,
1589
+ format ! ( "std::sync::atomic::Ordering::{success_suggestion}" ) ,
1590
+ Applicability :: MaybeIncorrect ,
1591
+ )
1592
+ . emit ( ) ;
1593
1593
} ) ;
1594
1594
}
1595
1595
}
0 commit comments