Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/ui/statics/unsized-static-without-body-index-141804.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Regression test for <https://github.com/rust-lang/rust/issues/141804>.
// Indexing an unsized `static` declared without a body used to ICE in const eval
// with "primitive read not possible for type".

fn foo() {
static symbol: [u32];
//~^ ERROR free static item without body
//~| ERROR the size for values of type `[u32]` cannot be known at compilation time
symbol[0];
}

fn main() {}
20 changes: 20 additions & 0 deletions tests/ui/statics/unsized-static-without-body-index-141804.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
error: free static item without body
--> $DIR/unsized-static-without-body-index-141804.rs:6:5
|
LL | static symbol: [u32];
| ^^^^^^^^^^^^^^^^^^^^-
| |
| help: provide a definition for the static: `= <expr>;`

error[E0277]: the size for values of type `[u32]` cannot be known at compilation time
--> $DIR/unsized-static-without-body-index-141804.rs:6:5
|
LL | static symbol: [u32];
| ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[u32]`
= note: statics and constants must have a statically known size

error: aborting due to 2 previous errors

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