mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 15:14:29 +00:00
Split up non_copy_const
ui test
This commit is contained in:
parent
4f65bec39a
commit
314f438ab4
5 changed files with 335 additions and 300 deletions
|
@ -1,4 +1,5 @@
|
|||
#![allow(clippy::ref_in_deref, dead_code)]
|
||||
#![warn(clippy::borrow_interior_mutable_const)]
|
||||
#![allow(clippy::declare_interior_mutable_const, clippy::ref_in_deref)]
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::cell::Cell;
|
||||
|
@ -6,88 +7,27 @@ use std::fmt::Display;
|
|||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::sync::Once;
|
||||
|
||||
const ATOMIC: AtomicUsize = AtomicUsize::new(5); //~ ERROR interior mutable
|
||||
const CELL: Cell<usize> = Cell::new(6); //~ ERROR interior mutable
|
||||
const ATOMIC: AtomicUsize = AtomicUsize::new(5);
|
||||
const CELL: Cell<usize> = Cell::new(6);
|
||||
const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec<AtomicUsize>, u8) = ([ATOMIC], Vec::new(), 7);
|
||||
//~^ ERROR interior mutable
|
||||
|
||||
macro_rules! declare_const {
|
||||
($name:ident: $ty:ty = $e:expr) => {
|
||||
const $name: $ty = $e;
|
||||
};
|
||||
}
|
||||
declare_const!(_ONCE: Once = Once::new()); //~ ERROR interior mutable
|
||||
|
||||
// const ATOMIC_REF: &AtomicUsize = &AtomicUsize::new(7); // This will simply trigger E0492.
|
||||
|
||||
const INTEGER: u8 = 8;
|
||||
const STRING: String = String::new();
|
||||
const STR: &str = "012345";
|
||||
const COW: Cow<str> = Cow::Borrowed("abcdef");
|
||||
//^ note: a const item of Cow is used in the `postgres` package.
|
||||
|
||||
const NO_ANN: &dyn Display = &70;
|
||||
|
||||
static STATIC_TUPLE: (AtomicUsize, String) = (ATOMIC, STRING);
|
||||
//^ there should be no lints on this line
|
||||
|
||||
#[allow(clippy::declare_interior_mutable_const)]
|
||||
const ONCE_INIT: Once = Once::new();
|
||||
|
||||
trait Trait<T>: Copy {
|
||||
type NonCopyType;
|
||||
|
||||
const ATOMIC: AtomicUsize; //~ ERROR interior mutable
|
||||
const INTEGER: u64;
|
||||
const STRING: String;
|
||||
const SELF: Self; // (no error)
|
||||
const INPUT: T;
|
||||
//~^ ERROR interior mutable
|
||||
//~| HELP consider requiring `T` to be `Copy`
|
||||
const ASSOC: Self::NonCopyType;
|
||||
//~^ ERROR interior mutable
|
||||
//~| HELP consider requiring `<Self as Trait<T>>::NonCopyType` to be `Copy`
|
||||
|
||||
const AN_INPUT: T = Self::INPUT;
|
||||
//~^ ERROR interior mutable
|
||||
//~| ERROR consider requiring `T` to be `Copy`
|
||||
declare_const!(ANOTHER_INPUT: T = Self::INPUT); //~ ERROR interior mutable
|
||||
const ATOMIC: AtomicUsize;
|
||||
}
|
||||
|
||||
trait Trait2 {
|
||||
type CopyType: Copy;
|
||||
|
||||
const SELF_2: Self;
|
||||
//~^ ERROR interior mutable
|
||||
//~| HELP consider requiring `Self` to be `Copy`
|
||||
const ASSOC_2: Self::CopyType; // (no error)
|
||||
}
|
||||
|
||||
// we don't lint impl of traits, because an impl has no power to change the interface.
|
||||
impl Trait<u32> for u64 {
|
||||
type NonCopyType = u16;
|
||||
|
||||
const ATOMIC: AtomicUsize = AtomicUsize::new(9);
|
||||
const INTEGER: u64 = 10;
|
||||
const STRING: String = String::new();
|
||||
const SELF: Self = 11;
|
||||
const INPUT: u32 = 12;
|
||||
const ASSOC: Self::NonCopyType = 13;
|
||||
}
|
||||
|
||||
struct Local<T, U>(T, U);
|
||||
|
||||
impl<T: Trait2 + Trait<u32>, U: Trait2> Local<T, U> {
|
||||
const ASSOC_3: AtomicUsize = AtomicUsize::new(14); //~ ERROR interior mutable
|
||||
const COW: Cow<'static, str> = Cow::Borrowed("tuvwxy");
|
||||
const T_SELF: T = T::SELF_2;
|
||||
const U_SELF: U = U::SELF_2;
|
||||
//~^ ERROR interior mutable
|
||||
//~| HELP consider requiring `U` to be `Copy`
|
||||
const T_ASSOC: T::NonCopyType = T::ASSOC;
|
||||
//~^ ERROR interior mutable
|
||||
//~| HELP consider requiring `<T as Trait<u32>>::NonCopyType` to be `Copy`
|
||||
const U_ASSOC: U::CopyType = U::ASSOC_2;
|
||||
}
|
||||
|
||||
fn main() {
|
131
tests/ui/borrow_interior_mutable_const.stderr
Normal file
131
tests/ui/borrow_interior_mutable_const.stderr
Normal file
|
@ -0,0 +1,131 @@
|
|||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> $DIR/borrow_interior_mutable_const.rs:34: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:35: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:38: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:39: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:40: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:41: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:52: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:53: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:54: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:55: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:56: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:62: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:67: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:68: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:81: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:82: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
|
||||
|
93
tests/ui/declare_interior_mutable_const.rs
Normal file
93
tests/ui/declare_interior_mutable_const.rs
Normal file
|
@ -0,0 +1,93 @@
|
|||
#![warn(clippy::declare_interior_mutable_const)]
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::cell::Cell;
|
||||
use std::fmt::Display;
|
||||
use std::sync::atomic::AtomicUsize;
|
||||
use std::sync::Once;
|
||||
|
||||
const ATOMIC: AtomicUsize = AtomicUsize::new(5); //~ ERROR interior mutable
|
||||
const CELL: Cell<usize> = Cell::new(6); //~ ERROR interior mutable
|
||||
const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec<AtomicUsize>, u8) = ([ATOMIC], Vec::new(), 7);
|
||||
//~^ ERROR interior mutable
|
||||
|
||||
macro_rules! declare_const {
|
||||
($name:ident: $ty:ty = $e:expr) => {
|
||||
const $name: $ty = $e;
|
||||
};
|
||||
}
|
||||
declare_const!(_ONCE: Once = Once::new()); //~ ERROR interior mutable
|
||||
|
||||
// const ATOMIC_REF: &AtomicUsize = &AtomicUsize::new(7); // This will simply trigger E0492.
|
||||
|
||||
const INTEGER: u8 = 8;
|
||||
const STRING: String = String::new();
|
||||
const STR: &str = "012345";
|
||||
const COW: Cow<str> = Cow::Borrowed("abcdef");
|
||||
//^ note: a const item of Cow is used in the `postgres` package.
|
||||
|
||||
const NO_ANN: &dyn Display = &70;
|
||||
|
||||
static STATIC_TUPLE: (AtomicUsize, String) = (ATOMIC, STRING);
|
||||
//^ there should be no lints on this line
|
||||
|
||||
#[allow(clippy::declare_interior_mutable_const)]
|
||||
const ONCE_INIT: Once = Once::new();
|
||||
|
||||
trait Trait<T>: Copy {
|
||||
type NonCopyType;
|
||||
|
||||
const ATOMIC: AtomicUsize; //~ ERROR interior mutable
|
||||
const INTEGER: u64;
|
||||
const STRING: String;
|
||||
const SELF: Self; // (no error)
|
||||
const INPUT: T;
|
||||
//~^ ERROR interior mutable
|
||||
//~| HELP consider requiring `T` to be `Copy`
|
||||
const ASSOC: Self::NonCopyType;
|
||||
//~^ ERROR interior mutable
|
||||
//~| HELP consider requiring `<Self as Trait<T>>::NonCopyType` to be `Copy`
|
||||
|
||||
const AN_INPUT: T = Self::INPUT;
|
||||
//~^ ERROR interior mutable
|
||||
//~| ERROR consider requiring `T` to be `Copy`
|
||||
declare_const!(ANOTHER_INPUT: T = Self::INPUT); //~ ERROR interior mutable
|
||||
}
|
||||
|
||||
trait Trait2 {
|
||||
type CopyType: Copy;
|
||||
|
||||
const SELF_2: Self;
|
||||
//~^ ERROR interior mutable
|
||||
//~| HELP consider requiring `Self` to be `Copy`
|
||||
const ASSOC_2: Self::CopyType; // (no error)
|
||||
}
|
||||
|
||||
// we don't lint impl of traits, because an impl has no power to change the interface.
|
||||
impl Trait<u32> for u64 {
|
||||
type NonCopyType = u16;
|
||||
|
||||
const ATOMIC: AtomicUsize = AtomicUsize::new(9);
|
||||
const INTEGER: u64 = 10;
|
||||
const STRING: String = String::new();
|
||||
const SELF: Self = 11;
|
||||
const INPUT: u32 = 12;
|
||||
const ASSOC: Self::NonCopyType = 13;
|
||||
}
|
||||
|
||||
struct Local<T, U>(T, U);
|
||||
|
||||
impl<T: Trait2 + Trait<u32>, U: Trait2> Local<T, U> {
|
||||
const ASSOC_3: AtomicUsize = AtomicUsize::new(14); //~ ERROR interior mutable
|
||||
const COW: Cow<'static, str> = Cow::Borrowed("tuvwxy");
|
||||
const T_SELF: T = T::SELF_2;
|
||||
const U_SELF: U = U::SELF_2;
|
||||
//~^ ERROR interior mutable
|
||||
//~| HELP consider requiring `U` to be `Copy`
|
||||
const T_ASSOC: T::NonCopyType = T::ASSOC;
|
||||
//~^ ERROR interior mutable
|
||||
//~| HELP consider requiring `<T as Trait<u32>>::NonCopyType` to be `Copy`
|
||||
const U_ASSOC: U::CopyType = U::ASSOC_2;
|
||||
}
|
||||
|
||||
fn main() {}
|
106
tests/ui/declare_interior_mutable_const.stderr
Normal file
106
tests/ui/declare_interior_mutable_const.stderr
Normal file
|
@ -0,0 +1,106 @@
|
|||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/declare_interior_mutable_const.rs:9:1
|
||||
|
|
||||
LL | const ATOMIC: AtomicUsize = AtomicUsize::new(5); //~ ERROR interior mutable
|
||||
| -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| make this a static item (maybe with lazy_static)
|
||||
|
|
||||
= note: `-D clippy::declare-interior-mutable-const` implied by `-D warnings`
|
||||
|
||||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/declare_interior_mutable_const.rs:10:1
|
||||
|
|
||||
LL | const CELL: Cell<usize> = Cell::new(6); //~ ERROR interior mutable
|
||||
| -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| make this a static item (maybe with lazy_static)
|
||||
|
||||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/declare_interior_mutable_const.rs:11:1
|
||||
|
|
||||
LL | const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec<AtomicUsize>, u8) = ([ATOMIC], Vec::new(), 7);
|
||||
| -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| make this a static item (maybe with lazy_static)
|
||||
|
||||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/declare_interior_mutable_const.rs:16:9
|
||||
|
|
||||
LL | const $name: $ty = $e;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | declare_const!(_ONCE: Once = Once::new()); //~ ERROR interior mutable
|
||||
| ------------------------------------------ in this macro invocation
|
||||
|
||||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/declare_interior_mutable_const.rs:40:5
|
||||
|
|
||||
LL | const ATOMIC: AtomicUsize; //~ ERROR interior mutable
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/declare_interior_mutable_const.rs:44:5
|
||||
|
|
||||
LL | const INPUT: T;
|
||||
| ^^^^^^^^^^^^^-^
|
||||
| |
|
||||
| consider requiring `T` to be `Copy`
|
||||
|
||||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/declare_interior_mutable_const.rs:47:5
|
||||
|
|
||||
LL | const ASSOC: Self::NonCopyType;
|
||||
| ^^^^^^^^^^^^^-----------------^
|
||||
| |
|
||||
| consider requiring `<Self as Trait<T>>::NonCopyType` to be `Copy`
|
||||
|
||||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/declare_interior_mutable_const.rs:51:5
|
||||
|
|
||||
LL | const AN_INPUT: T = Self::INPUT;
|
||||
| ^^^^^^^^^^^^^^^^-^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| consider requiring `T` to be `Copy`
|
||||
|
||||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/declare_interior_mutable_const.rs:16:9
|
||||
|
|
||||
LL | const $name: $ty = $e;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | declare_const!(ANOTHER_INPUT: T = Self::INPUT); //~ ERROR interior mutable
|
||||
| ----------------------------------------------- in this macro invocation
|
||||
|
||||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/declare_interior_mutable_const.rs:60:5
|
||||
|
|
||||
LL | const SELF_2: Self;
|
||||
| ^^^^^^^^^^^^^^----^
|
||||
| |
|
||||
| consider requiring `Self` to be `Copy`
|
||||
|
||||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/declare_interior_mutable_const.rs:81:5
|
||||
|
|
||||
LL | const ASSOC_3: AtomicUsize = AtomicUsize::new(14); //~ ERROR interior mutable
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/declare_interior_mutable_const.rs:84:5
|
||||
|
|
||||
LL | const U_SELF: U = U::SELF_2;
|
||||
| ^^^^^^^^^^^^^^-^^^^^^^^^^^^^
|
||||
| |
|
||||
| consider requiring `U` to be `Copy`
|
||||
|
||||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/declare_interior_mutable_const.rs:87:5
|
||||
|
|
||||
LL | const T_ASSOC: T::NonCopyType = T::ASSOC;
|
||||
| ^^^^^^^^^^^^^^^--------------^^^^^^^^^^^^
|
||||
| |
|
||||
| consider requiring `<T as Trait<u32>>::NonCopyType` to be `Copy`
|
||||
|
||||
error: aborting due to 13 previous errors
|
||||
|
|
@ -1,235 +0,0 @@
|
|||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/non_copy_const.rs:9:1
|
||||
|
|
||||
LL | const ATOMIC: AtomicUsize = AtomicUsize::new(5); //~ ERROR interior mutable
|
||||
| -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| make this a static item (maybe with lazy_static)
|
||||
|
|
||||
= note: `#[deny(clippy::declare_interior_mutable_const)]` on by default
|
||||
|
||||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/non_copy_const.rs:10:1
|
||||
|
|
||||
LL | const CELL: Cell<usize> = Cell::new(6); //~ ERROR interior mutable
|
||||
| -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| make this a static item (maybe with lazy_static)
|
||||
|
||||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/non_copy_const.rs:11:1
|
||||
|
|
||||
LL | const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec<AtomicUsize>, u8) = ([ATOMIC], Vec::new(), 7);
|
||||
| -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| make this a static item (maybe with lazy_static)
|
||||
|
||||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/non_copy_const.rs:16:9
|
||||
|
|
||||
LL | const $name: $ty = $e;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | declare_const!(_ONCE: Once = Once::new()); //~ ERROR interior mutable
|
||||
| ------------------------------------------ in this macro invocation
|
||||
|
||||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/non_copy_const.rs:40:5
|
||||
|
|
||||
LL | const ATOMIC: AtomicUsize; //~ ERROR interior mutable
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/non_copy_const.rs:44:5
|
||||
|
|
||||
LL | const INPUT: T;
|
||||
| ^^^^^^^^^^^^^-^
|
||||
| |
|
||||
| consider requiring `T` to be `Copy`
|
||||
|
||||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/non_copy_const.rs:47:5
|
||||
|
|
||||
LL | const ASSOC: Self::NonCopyType;
|
||||
| ^^^^^^^^^^^^^-----------------^
|
||||
| |
|
||||
| consider requiring `<Self as Trait<T>>::NonCopyType` to be `Copy`
|
||||
|
||||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/non_copy_const.rs:51:5
|
||||
|
|
||||
LL | const AN_INPUT: T = Self::INPUT;
|
||||
| ^^^^^^^^^^^^^^^^-^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| consider requiring `T` to be `Copy`
|
||||
|
||||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/non_copy_const.rs:16:9
|
||||
|
|
||||
LL | const $name: $ty = $e;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | declare_const!(ANOTHER_INPUT: T = Self::INPUT); //~ ERROR interior mutable
|
||||
| ----------------------------------------------- in this macro invocation
|
||||
|
||||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/non_copy_const.rs:60:5
|
||||
|
|
||||
LL | const SELF_2: Self;
|
||||
| ^^^^^^^^^^^^^^----^
|
||||
| |
|
||||
| consider requiring `Self` to be `Copy`
|
||||
|
||||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/non_copy_const.rs:81:5
|
||||
|
|
||||
LL | const ASSOC_3: AtomicUsize = AtomicUsize::new(14); //~ ERROR interior mutable
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/non_copy_const.rs:84:5
|
||||
|
|
||||
LL | const U_SELF: U = U::SELF_2;
|
||||
| ^^^^^^^^^^^^^^-^^^^^^^^^^^^^
|
||||
| |
|
||||
| consider requiring `U` to be `Copy`
|
||||
|
||||
error: a `const` item should never be interior mutable
|
||||
--> $DIR/non_copy_const.rs:87:5
|
||||
|
|
||||
LL | const T_ASSOC: T::NonCopyType = T::ASSOC;
|
||||
| ^^^^^^^^^^^^^^^--------------^^^^^^^^^^^^
|
||||
| |
|
||||
| consider requiring `<T as Trait<u32>>::NonCopyType` to be `Copy`
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> $DIR/non_copy_const.rs:94:5
|
||||
|
|
||||
LL | ATOMIC.store(1, Ordering::SeqCst); //~ ERROR interior mutability
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: `#[deny(clippy::borrow_interior_mutable_const)]` on by default
|
||||
= 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/non_copy_const.rs:95: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/non_copy_const.rs:98: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/non_copy_const.rs:99: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/non_copy_const.rs:100: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/non_copy_const.rs:101: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/non_copy_const.rs:112: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/non_copy_const.rs:113: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/non_copy_const.rs:114: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/non_copy_const.rs:115: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/non_copy_const.rs:116: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/non_copy_const.rs:122: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/non_copy_const.rs:127: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/non_copy_const.rs:128: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/non_copy_const.rs:141: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/non_copy_const.rs:142: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 29 previous errors
|
||||
|
Loading…
Reference in a new issue