-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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: unwrap none error in compiler\rustc_mir\src\monomorphize\collector.rs #85447
Comments
Bisecting points to #81172 as the culprit. cc @SimonSapin searched nightlies: from nightly-2021-02-14 to nightly-2021-05-03 bisected with cargo-bisect-rustc v0.6.0Host triple: x86_64-unknown-linux-gnu cargo bisect-rustc --start=2021-02-14 --end=2021-05-03 |
Reducing a bit more: #![crate_type = "lib"]
use std::{collections::HashMap, hash::Hash};
struct C;
trait Ctx {
type BindGroupId;
}
impl Ctx for C {
type BindGroupId = u32;
}
pub struct BindGroup {
_id: <C as Ctx>::BindGroupId,
}
pub fn insert(map: &mut HashMap<*const BindGroup, u32>, bind_group: *const BindGroup) {
map.insert(bind_group, 1);
} However, if I remove pub fn hash(bind_group: *const BindGroup, state: &mut impl std::hash::Hasher) {
bind_group.hash(state)
} The panic message points to the second
… which means that Because #81172 and a rust/library/core/src/hash/mod.rs Lines 691 to 698 in 9bc8c42
However my failed reduction says that might not be it. I’m not sure what to try next. Maybe someone more familiar with compiler internals can comment on how |
Nominating for discussion during T-compiler meeting to get more eyes on this (cc: @SimonSapin feel free to jump in) |
The code is taken from a minimization. Issue: rust-lang/rust#85447
Some more reduced code examples can be found in this related/duplicate issue. #86469 There’s also a case of hitting a slightly different ICE
here: #86469 (comment) |
Ouch, I forgot about this and the regression has reached Stable :/ However I still don’t know how to proceed as I’m not at all familiar with these compiler internals. Any help would be appreciated. The slightly different ICE points to:
I think this file is about some other kind of metadata, not #81513 pointer metadata? But the underlying issue seems to be similar: some code receives a |
Hey @SimonSapin , I self-assigned this and then didn't follow up. I'm looking at it more carefully now. |
Looking at the reduction from #85447 (comment), I added a bit of instrumentation to the compiler to see which
If nothing else, this lends evidence to @SimonSapin 's notes above: we're trying to resolve a trait method, So my current guess is that we're missing some extra resolution path somewhere to convert the Update: I mostly added this note because of something that I didn't mention in the text above: The presence of the higher-kinded type |
Hmm, no, this doesn't seem like a sufficient explanation, at least not in this trivialized form. Here's why: I took a whirl at running the same test case on a build immediately prior to PR #81172, and in the debug output from that run, I see successful
Update: Of course the ty is not "the exact" one of interest. The whole point is that after this PR, we are seeing attempts to resolve like: I'm just restating that the HKT alone isn't the reason for the resolution .unwrap().unwrap() failure. (Its entirely possible that the HKT is an issue somewhere upstream. Or maybe the construction from PR #81172 is just not quite right.) |
@pnkfelix and I dug into this. The problem is exactly this FIXME here:
In particular, the pub struct BindGroup {
_id: <C as Ctx>::BindGroupId,
} The Fixing this is not entirely trivial, I am debating the best approach. The problem is that the "assemble candidates" logic isn't really meant to normalize, which is kind of a side-effecting operation that produces subobligations. But it should be possible to do -- I suppose we could look at what (Egads I would like to convert this code to use chalk!) |
When writing this comment as part of #81172 I remember feeling very much feeling like the "no idea what I’m doing" meme. I mostly imitated what the compiler already did for the Does |
I think I can remove the @rustbot label -I-nominated |
Fixed by #92248 |
Code
Meta
rustc --version --verbose
:This error also occurs on nightly, that last version that it worked on was 1.51.
It seems that this only occurs if the crate-type is lib. Even if I remove a
pub
, it can compile successfully.Error output
The text was updated successfully, but these errors were encountered: