Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit dc75ed4

Browse files
committedApr 17, 2024·
change diag references from once_cell crate to LazyLock
1 parent c52a252 commit dc75ed4

12 files changed

+21
-25
lines changed
 

‎compiler/rustc_const_eval/src/transform/check_consts/ops.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
306306
}
307307

308308
if let ConstContext::Static(_) = ccx.const_kind() {
309-
err.note("consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell");
309+
err.note("consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`");
310310
}
311311

312312
err

‎compiler/rustc_lint_defs/src/builtin.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1315,9 +1315,7 @@ declare_lint! {
13151315
/// * If the value can be computed at compile-time, consider using
13161316
/// const-compatible values (see [Constant Evaluation]).
13171317
/// * For more complex single-initialization cases, consider using a
1318-
/// third-party crate, such as [`lazy_static`] or [`once_cell`].
1319-
/// * If you are using the [nightly channel], consider the new
1320-
/// [`lazy`] module in the standard library.
1318+
/// [`std::sync::LazyLock`].
13211319
/// * If you truly need a mutable global, consider using a [`static`],
13221320
/// which has a variety of options:
13231321
/// * Simple data types can be directly defined and mutated with an
@@ -1332,9 +1330,7 @@ declare_lint! {
13321330
/// [Constant Evaluation]: https://doc.rust-lang.org/reference/const_eval.html
13331331
/// [`static`]: https://doc.rust-lang.org/reference/items/static-items.html
13341332
/// [mutable `static`]: https://doc.rust-lang.org/reference/items/static-items.html#mutable-statics
1335-
/// [`lazy`]: https://doc.rust-lang.org/nightly/std/lazy/index.html
1336-
/// [`lazy_static`]: https://crates.io/crates/lazy_static
1337-
/// [`once_cell`]: https://crates.io/crates/once_cell
1333+
/// [`std::sync::LazyLock`]: https://doc.rust-lang.org/stable/std/sync/struct.LazyLock.html
13381334
/// [`atomic`]: https://doc.rust-lang.org/std/sync/atomic/index.html
13391335
/// [`Mutex`]: https://doc.rust-lang.org/std/sync/struct.Mutex.html
13401336
pub CONST_ITEM_MUTATION,

‎tests/ui/borrowck/issue-64453.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ LL | static settings_dir: String = format!("");
1414
| ^^^^^^^^^^^
1515
|
1616
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
17-
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
17+
= note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
1818
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
1919

2020
error[E0507]: cannot move out of static item `settings_dir`

‎tests/ui/check-static-values-constraints.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ LL | static STATIC11: Vec<MyOwned> = vec![MyOwned];
2626
| ^^^^^^^^^^^^^
2727
|
2828
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
29-
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
29+
= note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
3030
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
3131

3232
error[E0015]: cannot call non-const fn `<str as ToString>::to_string` in statics
@@ -36,7 +36,7 @@ LL | field2: SafeEnum::Variant4("str".to_string()),
3636
| ^^^^^^^^^^^
3737
|
3838
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
39-
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
39+
= note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
4040
help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
4141
|
4242
LL + #![feature(const_trait_impl)]
@@ -57,7 +57,7 @@ LL | vec![MyOwned],
5757
| ^^^^^^^^^^^^^
5858
|
5959
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
60-
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
60+
= note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
6161
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
6262

6363
error[E0010]: allocations are not allowed in statics
@@ -75,7 +75,7 @@ LL | vec![MyOwned],
7575
| ^^^^^^^^^^^^^
7676
|
7777
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
78-
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
78+
= note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
7979
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
8080

8181
error[E0010]: allocations are not allowed in statics
@@ -93,7 +93,7 @@ LL | &vec![MyOwned],
9393
| ^^^^^^^^^^^^^
9494
|
9595
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
96-
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
96+
= note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
9797
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
9898

9999
error[E0010]: allocations are not allowed in statics
@@ -111,7 +111,7 @@ LL | &vec![MyOwned],
111111
| ^^^^^^^^^^^^^
112112
|
113113
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
114-
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
114+
= note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
115115
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
116116

117117
error[E0010]: allocations are not allowed in statics
@@ -129,7 +129,7 @@ LL | static STATIC19: Vec<isize> = vec![3];
129129
| ^^^^^^^
130130
|
131131
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
132-
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
132+
= note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
133133
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
134134

135135
error[E0010]: allocations are not allowed in statics
@@ -147,7 +147,7 @@ LL | static x: Vec<isize> = vec![3];
147147
| ^^^^^^^
148148
|
149149
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
150-
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
150+
= note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
151151
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
152152

153153
error[E0507]: cannot move out of static item `x`

‎tests/ui/consts/issue-16538.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
8-
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
8+
= note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
99

1010
error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block
1111
--> $DIR/issue-16538.rs:11:22

‎tests/ui/consts/issue-32829-2.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ LL | invalid();
1313
| ^^^^^^^^^
1414
|
1515
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
16-
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
16+
= note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
1717

1818
error[E0015]: cannot call non-const fn `invalid` in statics
1919
--> $DIR/issue-32829-2.rs:54:9
@@ -22,7 +22,7 @@ LL | invalid();
2222
| ^^^^^^^^^
2323
|
2424
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
25-
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
25+
= note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
2626

2727
error: aborting due to 3 previous errors
2828

‎tests/ui/consts/mir_check_nonconst.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | static foo: Foo = bar();
55
| ^^^^^
66
|
77
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
8-
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
8+
= note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
99

1010
error: aborting due to 1 previous error
1111

‎tests/ui/issues/issue-25901.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ note: impl defined here, but it is not `const`
1616
LL | impl Deref for A {
1717
| ^^^^^^^^^^^^^^^^
1818
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
19-
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
19+
= note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
2020
help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
2121
|
2222
LL + #![feature(const_trait_impl)]

‎tests/ui/issues/issue-7364.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ LL | static boxed: Box<RefCell<isize>> = Box::new(RefCell::new(0));
1818
| ^^^^^^^^^^^^^^^^^^^^^^^^^
1919
|
2020
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
21-
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
21+
= note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
2222

2323
error: aborting due to 2 previous errors
2424

‎tests/ui/parser/issues/issue-35813-postfix-after-cast.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ LL | static bar: &[i32] = &(&[1,2,3] as &[i32][0..1]);
352352
| ^^^^^^
353353
|
354354
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
355-
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
355+
= note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
356356
help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
357357
|
358358
LL + #![feature(const_trait_impl)]

‎tests/ui/static/static-mut-not-constant.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | static mut a: Box<isize> = Box::new(3);
55
| ^^^^^^^^^^^
66
|
77
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
8-
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
8+
= note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
99

1010
error: aborting due to 1 previous error
1111

‎tests/ui/static/static-vec-repeat-not-constant.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | static a: [isize; 2] = [foo(); 2];
55
| ^^^^^
66
|
77
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
8-
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
8+
= note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
99

1010
error: aborting due to 1 previous error
1111

0 commit comments

Comments
 (0)
Please sign in to comment.