Skip to content

Commit

Permalink
Also test projections
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Dec 17, 2018
1 parent b31a1f7 commit 7e2e489
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/test/ui/consts/static_mut_containing_mut_ref2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
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
//~^ ERROR references in statics may only refer to immutable values

fn main() {}
8 changes: 8 additions & 0 deletions src/test/ui/consts/static_mut_containing_mut_ref3.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#![feature(const_let)]

static mut FOO: (u8, u8) = (42, 43);

static mut BAR: () = unsafe { FOO.0 = 99; };
//~^ ERROR could not evaluate static initializer

fn main() {}
9 changes: 9 additions & 0 deletions src/test/ui/consts/static_mut_containing_mut_ref3.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0080]: could not evaluate static initializer
--> $DIR/static_mut_containing_mut_ref3.rs:5:31
|
LL | static mut BAR: () = unsafe { FOO.0 = 99; };
| ^^^^^^^^^^ tried to modify a static's initial value from another static's initializer

error: aborting due to previous error

For more information about this error, try `rustc --explain E0080`.

0 comments on commit 7e2e489

Please sign in to comment.