Skip to content

Commit 4ee19bf

Browse files
committed
Remove lazy_static mention
1 parent 5aae5f6 commit 4ee19bf

File tree

5 files changed

+20
-59
lines changed

5 files changed

+20
-59
lines changed

clippy_lints/src/non_copy_const.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc_middle::mir::interpret::{ErrorHandled, EvalToValTreeResult, GlobalId};
1818
use rustc_middle::ty::adjustment::Adjust;
1919
use rustc_middle::ty::{self, Ty, TyCtxt};
2020
use rustc_session::impl_lint_pass;
21-
use rustc_span::{sym, InnerSpan, Span, DUMMY_SP};
21+
use rustc_span::{sym, Span, DUMMY_SP};
2222
use rustc_target::abi::VariantIdx;
2323

2424
// FIXME: this is a correctness problem but there's no suitable
@@ -159,8 +159,7 @@ fn lint(cx: &LateContext<'_>, source: Source) {
159159
}
160160
match source {
161161
Source::Item { .. } => {
162-
let const_kw_span = span.from_inner(InnerSpan::new(0, 5));
163-
diag.span_label(const_kw_span, "make this a static item (maybe with lazy_static)");
162+
diag.help("consider making this a static item or a `thread_local`");
164163
},
165164
Source::Assoc { .. } => (),
166165
Source::Expr { .. } => {

tests/ui/crashes/ice-9445.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ error: a `const` item should never be interior mutable
22
--> tests/ui/crashes/ice-9445.rs:1:1
33
|
44
LL | const UNINIT: core::mem::MaybeUninit<core::cell::Cell<&'static ()>> = core::mem::MaybeUninit::uninit();
5-
| -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6-
| |
7-
| make this a static item (maybe with lazy_static)
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
86
|
7+
= help: consider making this a static item or a `thread_local`
98
= note: `-D clippy::declare-interior-mutable-const` implied by `-D warnings`
109
= help: to override `-D warnings` add `#[allow(clippy::declare_interior_mutable_const)]`
1110

tests/ui/crashes/mut_mut_macro.rs

Lines changed: 0 additions & 33 deletions
This file was deleted.

tests/ui/declare_interior_mutable_const/enums.stderr

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,32 @@ error: a `const` item should never be interior mutable
22
--> tests/ui/declare_interior_mutable_const/enums.rs:12:1
33
|
44
LL | const UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(true));
5-
| -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6-
| |
7-
| make this a static item (maybe with lazy_static)
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
86
|
7+
= help: consider making this a static item or a `thread_local`
98
= note: `-D clippy::declare-interior-mutable-const` implied by `-D warnings`
109
= help: to override `-D warnings` add `#[allow(clippy::declare_interior_mutable_const)]`
1110

1211
error: a `const` item should never be interior mutable
1312
--> tests/ui/declare_interior_mutable_const/enums.rs:23:1
1413
|
1514
LL | const UNFROZEN_VARIANT_FROM_FN: OptionalCell = unfrozen_variant();
16-
| -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17-
| |
18-
| make this a static item (maybe with lazy_static)
15+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16+
|
17+
= help: consider making this a static item or a `thread_local`
1918

2019
error: a `const` item should never be interior mutable
2120
--> tests/ui/declare_interior_mutable_const/enums.rs:45:1
2221
|
23-
LL | const NESTED_UNFROZEN_VARIANT: NestedOutermost = NestedOutermost {
24-
| ^----
25-
| |
26-
| _make this a static item (maybe with lazy_static)
27-
| |
22+
LL | / const NESTED_UNFROZEN_VARIANT: NestedOutermost = NestedOutermost {
2823
LL | |
2924
LL | | outer: NestedOuter::NestedInner(NestedInner {
3025
LL | | inner: NestedInnermost::Unfrozen(AtomicUsize::new(2)),
3126
LL | | }),
3227
LL | | };
3328
| |__^
29+
|
30+
= help: consider making this a static item or a `thread_local`
3431

3532
error: a `const` item should never be interior mutable
3633
--> tests/ui/declare_interior_mutable_const/enums.rs:60:5

tests/ui/declare_interior_mutable_const/others.stderr

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,27 @@ error: a `const` item should never be interior mutable
22
--> tests/ui/declare_interior_mutable_const/others.rs:9:1
33
|
44
LL | const ATOMIC: AtomicUsize = AtomicUsize::new(5);
5-
| -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6-
| |
7-
| make this a static item (maybe with lazy_static)
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
86
|
7+
= help: consider making this a static item or a `thread_local`
98
= note: `-D clippy::declare-interior-mutable-const` implied by `-D warnings`
109
= help: to override `-D warnings` add `#[allow(clippy::declare_interior_mutable_const)]`
1110

1211
error: a `const` item should never be interior mutable
1312
--> tests/ui/declare_interior_mutable_const/others.rs:10:1
1413
|
1514
LL | const CELL: Cell<usize> = Cell::new(6);
16-
| -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17-
| |
18-
| make this a static item (maybe with lazy_static)
15+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16+
|
17+
= help: consider making this a static item or a `thread_local`
1918

2019
error: a `const` item should never be interior mutable
2120
--> tests/ui/declare_interior_mutable_const/others.rs:11:1
2221
|
2322
LL | const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec<AtomicUsize>, u8) = ([ATOMIC], Vec::new(), 7);
24-
| -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
25-
| |
26-
| make this a static item (maybe with lazy_static)
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24+
|
25+
= help: consider making this a static item or a `thread_local`
2726

2827
error: a `const` item should never be interior mutable
2928
--> tests/ui/declare_interior_mutable_const/others.rs:16:9

0 commit comments

Comments
 (0)