forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#6046 - rail-rain:change_criteria_non_copy_con…
…st, r=flip1995 Change the criteria of `interior_mutable_const` This implements my suggestion [here](rust-lang/rust-clippy#5050 (comment)), and so hopefully fixes rust-lang#5050. * stop linting associated types and generic type parameters * start linting ones in trait impls whose corresponding definitions in the traits are generic * remove the `is_copy` check as presumably the only purpose of it is to allow generics with `Copy` bounds as `Freeze` is internal and generics are no longer linted * remove the term 'copy' from the tests as being `Copy` no longer have meaning --- changelog: Change the criteria of `declare_interior_mutable_const` and `borrow_interior_mutable_const` to narrow the lints to only lint things that defenitly is a interior mutable type, not potentially.
- Loading branch information
Showing
5 changed files
with
269 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,131 +1,139 @@ | ||
error: a `const` item with interior mutability should not be borrowed | ||
--> $DIR/borrow_interior_mutable_const.rs:66:5 | ||
--> $DIR/borrow_interior_mutable_const.rs:44:18 | ||
| | ||
LL | let _ = &Self::ASSOC; //~ ERROR interior mutability | ||
| ^^^^^^^^^^^ | ||
| | ||
= note: `-D clippy::borrow-interior-mutable-const` implied by `-D warnings` | ||
= help: assign this const to a local or static variable, and use the variable here | ||
|
||
error: a `const` item with interior mutability should not be borrowed | ||
--> $DIR/borrow_interior_mutable_const.rs:80:5 | ||
| | ||
LL | ATOMIC.store(1, Ordering::SeqCst); //~ ERROR interior mutability | ||
| ^^^^^^ | ||
| | ||
= note: `-D clippy::borrow-interior-mutable-const` implied by `-D warnings` | ||
= help: assign this const to a local or static variable, and use the variable here | ||
|
||
error: a `const` item with interior mutability should not be borrowed | ||
--> $DIR/borrow_interior_mutable_const.rs:67:16 | ||
--> $DIR/borrow_interior_mutable_const.rs:81:16 | ||
| | ||
LL | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ ERROR interior mutability | ||
| ^^^^^^ | ||
| | ||
= help: assign this const to a local or static variable, and use the variable here | ||
|
||
error: a `const` item with interior mutability should not be borrowed | ||
--> $DIR/borrow_interior_mutable_const.rs:70:22 | ||
--> $DIR/borrow_interior_mutable_const.rs:84:22 | ||
| | ||
LL | let _once_ref = &ONCE_INIT; //~ ERROR interior mutability | ||
| ^^^^^^^^^ | ||
| | ||
= help: assign this const to a local or static variable, and use the variable here | ||
|
||
error: a `const` item with interior mutability should not be borrowed | ||
--> $DIR/borrow_interior_mutable_const.rs:71:25 | ||
--> $DIR/borrow_interior_mutable_const.rs:85:25 | ||
| | ||
LL | let _once_ref_2 = &&ONCE_INIT; //~ ERROR interior mutability | ||
| ^^^^^^^^^ | ||
| | ||
= help: assign this const to a local or static variable, and use the variable here | ||
|
||
error: a `const` item with interior mutability should not be borrowed | ||
--> $DIR/borrow_interior_mutable_const.rs:72:27 | ||
--> $DIR/borrow_interior_mutable_const.rs:86:27 | ||
| | ||
LL | let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR interior mutability | ||
| ^^^^^^^^^ | ||
| | ||
= help: assign this const to a local or static variable, and use the variable here | ||
|
||
error: a `const` item with interior mutability should not be borrowed | ||
--> $DIR/borrow_interior_mutable_const.rs:73:26 | ||
--> $DIR/borrow_interior_mutable_const.rs:87:26 | ||
| | ||
LL | let _once_mut = &mut ONCE_INIT; //~ ERROR interior mutability | ||
| ^^^^^^^^^ | ||
| | ||
= help: assign this const to a local or static variable, and use the variable here | ||
|
||
error: a `const` item with interior mutability should not be borrowed | ||
--> $DIR/borrow_interior_mutable_const.rs:84:14 | ||
--> $DIR/borrow_interior_mutable_const.rs:98:14 | ||
| | ||
LL | let _ = &ATOMIC_TUPLE; //~ ERROR interior mutability | ||
| ^^^^^^^^^^^^ | ||
| | ||
= help: assign this const to a local or static variable, and use the variable here | ||
|
||
error: a `const` item with interior mutability should not be borrowed | ||
--> $DIR/borrow_interior_mutable_const.rs:85:14 | ||
--> $DIR/borrow_interior_mutable_const.rs:99:14 | ||
| | ||
LL | let _ = &ATOMIC_TUPLE.0; //~ ERROR interior mutability | ||
| ^^^^^^^^^^^^ | ||
| | ||
= help: assign this const to a local or static variable, and use the variable here | ||
|
||
error: a `const` item with interior mutability should not be borrowed | ||
--> $DIR/borrow_interior_mutable_const.rs:86:19 | ||
--> $DIR/borrow_interior_mutable_const.rs:100:19 | ||
| | ||
LL | let _ = &(&&&&ATOMIC_TUPLE).0; //~ ERROR interior mutability | ||
| ^^^^^^^^^^^^ | ||
| | ||
= help: assign this const to a local or static variable, and use the variable here | ||
|
||
error: a `const` item with interior mutability should not be borrowed | ||
--> $DIR/borrow_interior_mutable_const.rs:87:14 | ||
--> $DIR/borrow_interior_mutable_const.rs:101:14 | ||
| | ||
LL | let _ = &ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability | ||
| ^^^^^^^^^^^^ | ||
| | ||
= help: assign this const to a local or static variable, and use the variable here | ||
|
||
error: a `const` item with interior mutability should not be borrowed | ||
--> $DIR/borrow_interior_mutable_const.rs:88:13 | ||
--> $DIR/borrow_interior_mutable_const.rs:102:13 | ||
| | ||
LL | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); //~ ERROR interior mutability | ||
| ^^^^^^^^^^^^ | ||
| | ||
= help: assign this const to a local or static variable, and use the variable here | ||
|
||
error: a `const` item with interior mutability should not be borrowed | ||
--> $DIR/borrow_interior_mutable_const.rs:94:13 | ||
--> $DIR/borrow_interior_mutable_const.rs:108:13 | ||
| | ||
LL | let _ = ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability | ||
| ^^^^^^^^^^^^ | ||
| | ||
= help: assign this const to a local or static variable, and use the variable here | ||
|
||
error: a `const` item with interior mutability should not be borrowed | ||
--> $DIR/borrow_interior_mutable_const.rs:99:5 | ||
--> $DIR/borrow_interior_mutable_const.rs:113:5 | ||
| | ||
LL | CELL.set(2); //~ ERROR interior mutability | ||
| ^^^^ | ||
| | ||
= help: assign this const to a local or static variable, and use the variable here | ||
|
||
error: a `const` item with interior mutability should not be borrowed | ||
--> $DIR/borrow_interior_mutable_const.rs:100:16 | ||
--> $DIR/borrow_interior_mutable_const.rs:114:16 | ||
| | ||
LL | assert_eq!(CELL.get(), 6); //~ ERROR interior mutability | ||
| ^^^^ | ||
| | ||
= help: assign this const to a local or static variable, and use the variable here | ||
|
||
error: a `const` item with interior mutability should not be borrowed | ||
--> $DIR/borrow_interior_mutable_const.rs:113:5 | ||
--> $DIR/borrow_interior_mutable_const.rs:127:5 | ||
| | ||
LL | u64::ATOMIC.store(5, Ordering::SeqCst); //~ ERROR interior mutability | ||
| ^^^^^^^^^^^ | ||
| | ||
= help: assign this const to a local or static variable, and use the variable here | ||
|
||
error: a `const` item with interior mutability should not be borrowed | ||
--> $DIR/borrow_interior_mutable_const.rs:114:16 | ||
--> $DIR/borrow_interior_mutable_const.rs:128:16 | ||
| | ||
LL | assert_eq!(u64::ATOMIC.load(Ordering::SeqCst), 9); //~ ERROR interior mutability | ||
| ^^^^^^^^^^^ | ||
| | ||
= help: assign this const to a local or static variable, and use the variable here | ||
|
||
error: aborting due to 16 previous errors | ||
error: aborting due to 17 previous errors | ||
|
Oops, something went wrong.