forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#123675 - oli-obk:static_wf_ice, r=compiler-errors Taint const qualifs if a static is referenced that didn't pass wfcheck It is correct to only check the signature here, as the ICE is caused by `USE_WITH_ERROR` trying to allocate memory to store the result of `WITH_ERROR` before evaluating it. fixes rust-lang#123153
- Loading branch information
Showing
4 changed files
with
63 additions
and
17 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 was deleted.
Oops, something went wrong.
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,21 @@ | ||
//! This test used to actually start evaluating the static even though | ||
//! there were errors in typeck. | ||
//! issue: rust-lang/rust#123153 | ||
pub struct Foo { | ||
pub version: str, | ||
} | ||
|
||
pub struct Bar { | ||
pub ok: &'static [&'static Bar], | ||
pub bad: &'static Foo, | ||
} | ||
|
||
pub static WITH_ERROR: Foo = Foo { version: 0 }; | ||
//~^ ERROR the size for values of type `str` cannot be known at compilation time | ||
//~| ERROR the size for values of type `str` cannot be known at compilation time | ||
//~| ERROR mismatched types | ||
|
||
pub static USE_WITH_ERROR: Bar = Bar { ok: &[], bad: &WITH_ERROR }; | ||
|
||
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,37 @@ | ||
error[E0277]: the size for values of type `str` cannot be known at compilation time | ||
--> $DIR/unsized_type2.rs:14:24 | ||
| | ||
LL | pub static WITH_ERROR: Foo = Foo { version: 0 }; | ||
| ^^^ doesn't have a size known at compile-time | ||
| | ||
= help: within `Foo`, the trait `Sized` is not implemented for `str`, which is required by `Foo: Sized` | ||
note: required because it appears within the type `Foo` | ||
--> $DIR/unsized_type2.rs:5:12 | ||
| | ||
LL | pub struct Foo { | ||
| ^^^ | ||
|
||
error[E0277]: the size for values of type `str` cannot be known at compilation time | ||
--> $DIR/unsized_type2.rs:14:30 | ||
| | ||
LL | pub static WITH_ERROR: Foo = Foo { version: 0 }; | ||
| ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | ||
| | ||
= help: within `Foo`, the trait `Sized` is not implemented for `str`, which is required by `Foo: Sized` | ||
note: required because it appears within the type `Foo` | ||
--> $DIR/unsized_type2.rs:5:12 | ||
| | ||
LL | pub struct Foo { | ||
| ^^^ | ||
= note: constant expressions must have a statically known size | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/unsized_type2.rs:14:45 | ||
| | ||
LL | pub static WITH_ERROR: Foo = Foo { version: 0 }; | ||
| ^ expected `str`, found integer | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0277, E0308. | ||
For more information about an error, try `rustc --explain E0277`. |