Skip to content

Commit 34deda3

Browse files
committed
With the revert of PR 83091, swap is not a const fn anymore.
(for the short term, that is; see issue 84297.)
1 parent a5cb9af commit 34deda3

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/test/ui/thread-local-static.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const fn g(x: &mut [u32; 8]) {
1111
//~| ERROR mutable references are not allowed
1212
//~| ERROR use of mutable static is unsafe
1313
//~| constant functions cannot refer to statics
14+
//~| ERROR calls in constant functions are limited to constant functions
1415
}
1516

1617
fn main() {}

src/test/ui/thread-local-static.stderr

+8-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ LL | std::mem::swap(x, &mut STATIC_VAR_2)
3030
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
3131
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
3232

33+
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
34+
--> $DIR/thread-local-static.rs:9:5
35+
|
36+
LL | std::mem::swap(x, &mut STATIC_VAR_2)
37+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
38+
3339
error[E0133]: use of mutable static is unsafe and requires unsafe function or block
3440
--> $DIR/thread-local-static.rs:9:23
3541
|
@@ -38,7 +44,7 @@ LL | std::mem::swap(x, &mut STATIC_VAR_2)
3844
|
3945
= note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
4046

41-
error: aborting due to 5 previous errors
47+
error: aborting due to 6 previous errors
4248

43-
Some errors have detailed explanations: E0013, E0133, E0658.
49+
Some errors have detailed explanations: E0013, E0015, E0133, E0658.
4450
For more information about an error, try `rustc --explain E0013`.

0 commit comments

Comments
 (0)