-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a recently introduces regression
- Loading branch information
Showing
6 changed files
with
44 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// compile-pass | ||
|
||
static mut STDERR_BUFFER_SPACE: [u8; 42] = [0u8; 42]; | ||
|
||
pub static mut STDERR_BUFFER: *mut [u8] = unsafe { &mut STDERR_BUFFER_SPACE }; | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#![feature(const_let)] | ||
|
||
static mut STDERR_BUFFER_SPACE: u8 = 0; | ||
|
||
pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; }; | ||
//~^ references in statics may only refer to immutable values | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
error[E0017]: references in statics may only refer to immutable values | ||
--> $DIR/static_mut_containing_mut_ref2.rs:5:46 | ||
| | ||
LL | pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ statics require immutable values | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0017`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,28 @@ | ||
error: cannot mutate statics in the initializer of another static | ||
error[E0080]: could not evaluate static initializer | ||
--> $DIR/write-to-static-mut-in-static.rs:14:33 | ||
| | ||
LL | pub static mut B: () = unsafe { A = 1; }; | ||
| ^^^^^ | ||
| ^^^^^ tried to modify a static's initial value from another static's initializer | ||
|
||
error: cannot mutate statics in the initializer of another static | ||
error[E0391]: cycle detected when const-evaluating `C` | ||
--> $DIR/write-to-static-mut-in-static.rs:17:34 | ||
| | ||
LL | pub static mut C: u32 = unsafe { C = 1; 0 }; | ||
| ^^^^^ | ||
| | ||
note: ...which requires const-evaluating `C`... | ||
--> $DIR/write-to-static-mut-in-static.rs:17:1 | ||
| | ||
LL | pub static mut C: u32 = unsafe { C = 1; 0 }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: ...which again requires const-evaluating `C`, completing the cycle | ||
note: cycle used when const-evaluating + checking `C` | ||
--> $DIR/write-to-static-mut-in-static.rs:17:1 | ||
| | ||
LL | pub static mut C: u32 = unsafe { C = 1; 0 }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors occurred: E0080, E0391. | ||
For more information about an error, try `rustc --explain E0080`. |