fixed generics of crate node ICE#153615
Conversation
|
r? @fee1-dead rustbot has assigned @fee1-dead. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
948df5b to
8aec809
Compare
There was a problem hiding this comment.
I think overall this is not pretty fool-proof (what if someone else decides to call tcx.generics_of(body_owner_def_id) down the line, in the function or somewhere else?) and also requires quite some involved changes for an ICE that doesn't happen quite often.
I wonder whether we should simply return and not attempt to add additional information if the obligation cause is dummy.
I wonder whether we can try to make the original obligation cause not dummy.
| if !tcx.is_impl_trait_in_trait(proj.def_id) && body_generics.is_some() => | ||
| { | ||
| let param = tcx.generics_of(body_owner_def_id).type_param(p, tcx); | ||
| let param = body_generics.unwrap().type_param(p, tcx); |
There was a problem hiding this comment.
| if !tcx.is_impl_trait_in_trait(proj.def_id) && body_generics.is_some() => | |
| { | |
| let param = tcx.generics_of(body_owner_def_id).type_param(p, tcx); | |
| let param = body_generics.unwrap().type_param(p, tcx); | |
| if !tcx.is_impl_trait_in_trait(proj.def_id) && let Some(body_generics) = body_generics => | |
| { | |
| let param = body_generics.type_param(p, tcx); |
| }; | ||
| if !sp.contains(p_span) { | ||
| diag.span_label(p_span, format!("{expected}this type parameter")); | ||
| if let Some(generics) = body_generics { |
There was a problem hiding this comment.
This should be (ty::Param(p), _) | (_, ty::Param(p)) if let Some(generics) = body_generics =>
|
Reminder, once the PR becomes ready for a review, use |
8aec809 to
7e8b18f
Compare
|
ok so my first uproach won't work, i went with guarding regarding making the obligation cause non-dummy: |
This comment has been minimized.
This comment has been minimized.
7e8b18f to
0d9419c
Compare
This comment has been minimized.
This comment has been minimized.
0d9419c to
3917a5e
Compare
This comment has been minimized.
This comment has been minimized.
3917a5e to
4651565
Compare
|
Some changes occurred in src/tools/compiletest cc @jieyouxu
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
4651565 to
4931206
Compare
This comment has been minimized.
This comment has been minimized.
4931206 to
f1a4ae0
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
ok so, i completely changed approach. |
|
@rustbot ready |
|
@bors r+ |
Rollup merge of #153615 - enthropy7:fix-ice-generics-of-crate-node, r=fee1-dead fixed generics of crate node ICE when `note_and_explain_type_err` is called during dyn-compatibility checking, the `body_owner_def_id` can be `CRATE_DEF_ID` because `ObligationCause::dummy()` uses it as a placeholder when there is no real body owner. calling `generics_of `on `CRATE_DEF_ID `caused an ICE because the crate root is a module and modules don't have generics. the fix guards all `generics_of` call sites by checking whether `body_owner_def_id` is `CRATE_DEF_ID` before attempting to look up generics, and skips the type parameter span labeling in that case. i also added regression test with original ice reproduce fixes #152335
Rollup of 4 pull requests Successful merges: - rust-lang/rust#152853 (deny-by-default & report in deps `uninhabited_static`) - rust-lang/rust#153615 (fixed generics of crate node ICE) - rust-lang/rust#154744 (Remove `Clone` impl for `StableHashingContext`.) - rust-lang/rust#154841 (add regression test for Redundant memory strores with mut parameters …)
when
note_and_explain_type_erris called during dyn-compatibility checking, thebody_owner_def_idcan beCRATE_DEF_IDbecauseObligationCause::dummy()uses it as a placeholder when there is no real body owner. callinggenerics_ofonCRATE_DEF_IDcaused an ICE because the crate root is a module and modules don't have generics. the fix guards allgenerics_ofcall sites by checking whetherbody_owner_def_idisCRATE_DEF_IDbefore attempting to look up generics, and skips the type parameter span labeling in that case.i also added regression test with original ice reproduce
fixes #152335