-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Panic with Layout mismatch when copying!
from macro
#61663
Comments
cc @oli-obk |
🤣 this is a sanity check ensuring that const eval's type caching is sane. If there's a type mismatch, it won't be though. The trivial fix would be to use cc @RalfJung I am also wondering how this came to happen, const eval should not actually do anything if the typecktables of something has had errors. Or should we change this, in the spirit of not aborting compilation early, and try to evaluate things with broken types? |
This reminds me of #61598. Looks like we execute CTFE on all sorts of invalid MIR? I guess that's the disadvantage of being so tightly integrated into the compiler. :/ A minimized examples that doesn't use macros would help me understand what that code even does. |
Reduced: struct F;
struct T;
impl F {
const V: i32 = 0;
}
impl T {
const V: i32 = 0;
}
macro_rules! mac {
($( $v: ident = $s: ident,)*) => {
enum E {
$( $v = $s::V, )*
}
}
}
mac! {
A = F,
B = T,
} |
@RalfJung The macro seems to be important somehow; I cannot seem to get rid of it. |
That is odd, to me that makes it sound like a bug in macro expansion instead of something we should fix in the Miri engine? |
Yeah that's plausible. If you change both |
triage: P-high. Leaving nominated and unassigned. |
Bisected a bit. This was injected between rustc 1.36.0-nightly (e305df1 2019-04-24) and rustc 1.36.0-nightly (3991285 2019-04-25). Then I bisected the git log between those commits. Unfortunately
|
Bisection of the rollup indicates that the problem was injected by PR #59560. |
Further bisection points to ff4d4b2 as the first bad commit |
(surely subtyping requires that the layouts be compatible ... ?) |
Assigning to @matthewjasper for initial investigation of a fix. (The commit in question is also fixing an ICE, so I'm not currently suggesting that we back it out. But I do find the whole matter pretty curious, especially given the earlier comments saying that macros are somehow involved here...?) Also assigning to self to make sure I don't lose track of this. Removing nomination tag. |
Relevant code: rust/src/librustc/infer/mod.rs Lines 1148 to 1161 in 38cd948
This is broken because we de-duplicate identical errors. It seems like this should be exploitable in lots of other places. |
…=pnkfelix Fix error counting Count duplicate errors for `track_errors` and other error counting checks. Add FIXMEs to make it clear that we should be moving away from this kind of logic. Closes rust-lang#61663
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…=pnkfelix Fix error counting Count duplicate errors for `track_errors` and other error counting checks. Add FIXMEs to make it clear that we should be moving away from this kind of logic. Closes rust-lang#61663
The following code has the compiler (correctly) emit an error about how explicit enum tags with the default representation need to be of type
isize
. The compiler panics afterwards.Output:
I tried to reduce the code more but this code does not cause a panic:
I will happily move on after correcting my mistake but I thought I'd at least report this panic.
Meta
rustc --version --verbose
:Backtrace:
The text was updated successfully, but these errors were encountered: