Skip to content

Commit b76f301

Browse files
thomccjyn514
authored andcommitted
Uplift the invalid_atomic_ordering lint from clippy to rustc
- Deprecate clippy::invalid_atomic_ordering - Use rustc_diagnostic_item for the orderings in the invalid_atomic_ordering lint - Reduce code duplication - Give up on making enum variants diagnostic items and just look for `Ordering` instead I ran into tons of trouble with this because apparently the change to store HIR attrs in a side table also gave the DefIds of the constructor instead of the variant itself. So I had to change `matches_ordering` to also check the grandparent of the defid as well. - Rename `atomic_ordering_x` symbols to just the name of the variant - Fix typos in checks - there were a few places that said "may not be Release" in the diagnostic but actually checked for SeqCst in the lint. - Make constant items const - Use fewer diagnostic items - Only look at arguments after making sure the method matches This prevents an ICE when there aren't enough arguments. - Ignore trait methods - Only check Ctors instead of going through `qpath_res` The functions take values, so this couldn't ever be anything else. - Add if_chain to allowed dependencies - Fix grammar - Remove unnecessary allow
1 parent 094f5cd commit b76f301

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

core/src/sync/atomic.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
#![stable(feature = "rust1", since = "1.0.0")]
114114
#![cfg_attr(not(target_has_atomic_load_store = "8"), allow(dead_code))]
115115
#![cfg_attr(not(target_has_atomic_load_store = "8"), allow(unused_imports))]
116+
#![rustc_diagnostic_item = "atomic_mod"]
116117

117118
use self::Ordering::*;
118119

@@ -198,6 +199,7 @@ unsafe impl<T> Sync for AtomicPtr<T> {}
198199
#[stable(feature = "rust1", since = "1.0.0")]
199200
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
200201
#[non_exhaustive]
202+
#[rustc_diagnostic_item = "Ordering"]
201203
pub enum Ordering {
202204
/// No ordering constraints, only atomic operations.
203205
///
@@ -2664,6 +2666,7 @@ unsafe fn atomic_umin<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
26642666
/// ```
26652667
#[inline]
26662668
#[stable(feature = "rust1", since = "1.0.0")]
2669+
#[rustc_diagnostic_item = "fence"]
26672670
pub fn fence(order: Ordering) {
26682671
// SAFETY: using an atomic fence is safe.
26692672
unsafe {
@@ -2745,6 +2748,7 @@ pub fn fence(order: Ordering) {
27452748
/// [memory barriers]: https://www.kernel.org/doc/Documentation/memory-barriers.txt
27462749
#[inline]
27472750
#[stable(feature = "compiler_fences", since = "1.21.0")]
2751+
#[rustc_diagnostic_item = "compiler_fence"]
27482752
pub fn compiler_fence(order: Ordering) {
27492753
// SAFETY: using an atomic fence is safe.
27502754
unsafe {

0 commit comments

Comments
 (0)