1
Fork 0

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
This commit is contained in:
Thom Chiovoloni 2020-12-02 15:16:12 -08:00 committed by Joshua Nelson
parent 7069a8c2b7
commit 402a9c9f5e
28 changed files with 655 additions and 455 deletions

View file

@ -121,6 +121,8 @@ symbols! {
// There is currently no checking that all symbols are used; that would be
// nice to have.
Symbols {
AcqRel,
Acquire,
Alignment,
Any,
Arc,
@ -129,6 +131,20 @@ symbols! {
Arguments,
AsMut,
AsRef,
AtomicBool,
AtomicI128,
AtomicI16,
AtomicI32,
AtomicI64,
AtomicI8,
AtomicIsize,
AtomicPtr,
AtomicU128,
AtomicU16,
AtomicU32,
AtomicU64,
AtomicU8,
AtomicUsize,
BTreeEntry,
BTreeMap,
BTreeSet,
@ -215,12 +231,15 @@ symbols! {
Rc,
Ready,
Receiver,
Relaxed,
Release,
Result,
Return,
Right,
RustcDecodable,
RustcEncodable,
Send,
SeqCst,
Some,
StructuralEq,
StructuralPartialEq,
@ -311,6 +330,8 @@ symbols! {
assume_init,
async_await,
async_closure,
atomic,
atomic_mod,
atomics,
att_syntax,
attr,
@ -390,8 +411,12 @@ symbols! {
coerce_unsized,
cold,
column,
compare_and_swap,
compare_exchange,
compare_exchange_weak,
compile_error,
compiler_builtins,
compiler_fence,
concat,
concat_idents,
conservative_impl_trait,
@ -575,6 +600,8 @@ symbols! {
fadd_fast,
fdiv_fast,
feature,
fence,
fetch_update,
ffi,
ffi_const,
ffi_pure,
@ -728,6 +755,7 @@ symbols! {
lint_reasons,
literal,
llvm_asm,
load,
local,
local_inner_macros,
log10f32,
@ -1217,6 +1245,7 @@ symbols! {
stmt,
stmt_expr_attributes,
stop_after_dataflow,
store,
str,
str_alloc,
string_type,