|
| 1 | +warning: mutation of an interior mutable `const` item with call to `get` |
| 2 | + --> $DIR/const-item-interior-mutations-const-deref.rs:26:17 |
| 3 | + | |
| 4 | +LL | let count = LOCAL_COUNT.get(); |
| 5 | + | -----------^^^^^^ |
| 6 | + | | |
| 7 | + | `LOCAL_COUNT` is a interior mutable `const` item of type `LocalKey<Cell<usize>>` |
| 8 | + | |
| 9 | + = note: each usage of a `const` item creates a new temporary |
| 10 | + = note: only the temporaries and never the original `const LOCAL_COUNT` will be modified |
| 11 | + = help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html> |
| 12 | + = note: `#[warn(const_item_interior_mutations)]` on by default |
| 13 | +help: for a shared instance of `LOCAL_COUNT`, consider making it a `static` item instead |
| 14 | + | |
| 15 | +LL - const LOCAL_COUNT: LocalKey<Cell<usize>> = LocalKey { inner: Cell::new(8) }; |
| 16 | +LL + static LOCAL_COUNT: LocalKey<Cell<usize>> = LocalKey { inner: Cell::new(8) }; |
| 17 | + | |
| 18 | + |
| 19 | +warning: mutation of an interior mutable `const` item with call to `set` |
| 20 | + --> $DIR/const-item-interior-mutations-const-deref.rs:28:5 |
| 21 | + | |
| 22 | +LL | LOCAL_COUNT.set(count); |
| 23 | + | -----------^^^^^^^^^^^ |
| 24 | + | | |
| 25 | + | `LOCAL_COUNT` is a interior mutable `const` item of type `LocalKey<Cell<usize>>` |
| 26 | + | |
| 27 | + = note: each usage of a `const` item creates a new temporary |
| 28 | + = note: only the temporaries and never the original `const LOCAL_COUNT` will be modified |
| 29 | + = help: for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html> |
| 30 | +help: for a shared instance of `LOCAL_COUNT`, consider making it a `static` item instead |
| 31 | + | |
| 32 | +LL - const LOCAL_COUNT: LocalKey<Cell<usize>> = LocalKey { inner: Cell::new(8) }; |
| 33 | +LL + static LOCAL_COUNT: LocalKey<Cell<usize>> = LocalKey { inner: Cell::new(8) }; |
| 34 | + | |
| 35 | + |
| 36 | +warning: 2 warnings emitted |
| 37 | + |
0 commit comments