-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ICE when accessing externed DST #36122
Comments
@nikomatsakis @arielb1 Why didn't WF catch this? |
That's because e85adff only checks statics/constants. |
Still reproducible with |
This ought to be a mostly easy fix. The problem is that the well formedness check, which ought to be rejected this code, is ignoring things in an rust/src/librustc_typeck/check/wfcheck.rs Line 86 in a04b88d
They fall through to this rust/src/librustc_typeck/check/wfcheck.rs Line 160 in a04b88d
We would need to add support for the Lines 2034 to 2035 in a04b88d
which in turn has a number of items: Lines 1832 to 1836 in a04b88d
which are defined here: Lines 2143 to 2163 in a04b88d
presumably we want the to check that the types of rust/src/librustc_typeck/check/wfcheck.rs Lines 130 to 132 in a04b88d
(We probably want similar checks on foreign item fns, though?) One tricky part might be compatibility, we may need to turn this into a compatibility lint in case there is lots of broken code in the wild. |
I am trying to fix this bug, and need help moving forward.
Test file: fn main() {
extern "C" {
static symbol: [usize];
}
unsafe {
println!("{}", symbol[0]);
}
} Commit: krk@aaa0ce7 @nikomatsakis Should I create a pull request or is it too early? |
@krk Looks like @nikomatsakis' suggestions are incomplete ( I suspect the only reason regular error[E0308]: mismatched types
--> src/main.rs:1:21
|
1 | static FOO: [u32] = [0, 1, 2];
| ^^^^^^^^^ expected slice, found array of 3 elements
|
= note: expected type `[u32]`
found type `[u32; 3]`
error[E0277]: the trait bound `[u32]: std::marker::Sized` is not satisfied
--> src/main.rs:1:21
|
1 | static FOO: [u32] = [0, 1, 2];
| ^^^^^^^^^ `[u32]` does not have a constant size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `[u32]`
= note: constant expressions must have a statically known size |
Require type is sized in wfcheck.check_item_type for externed DSTs, c… …loses rust-lang#36122 Continuing rust-lang#50126.
I'm going to assume this was fixed. Tagging as E-needstest, but if someone wants to take the time, it'd be even better to bisect to where this was fixed, and see if a regression test for this was added at that time. |
Compiler no longer panics, tested with |
Add more tests for fixed ICEs Closes rust-lang#36122 (fixed in 1.20.0) Closes rust-lang#58094 (fixed in rust-lang#66054) Also, fix mistaken test case, from rust-lang#30904 to rust-lang#30906 (cc @eddyb) r? @Centril
Add more tests for fixed ICEs Closes rust-lang#36122 (fixed in 1.20.0) Closes rust-lang#58094 (fixed in rust-lang#66054) Also, fix mistaken test case, from rust-lang#30904 to rust-lang#30906 (cc @eddyb) r? @Centril
I realize it's kinda nonsensical, but here:
The text was updated successfully, but these errors were encountered: