Fix ICE in deny_equality_constraints with bare qualified self types#152344
Fix ICE in deny_equality_constraints with bare qualified self types#152344lapla-cogito wants to merge 1 commit intorust-lang:mainfrom
deny_equality_constraints with bare qualified self types#152344Conversation
|
r? @mati865 rustbot has assigned @mati865. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
|
||
| // Given `<A as Foo>::Bar = RhsTy`, suggest `A: Foo<Bar = RhsTy>`. | ||
| if let TyKind::Path(Some(qself), full_path) = &predicate.lhs_ty.kind | ||
| && qself.position > 0 |
There was a problem hiding this comment.
For T: Trait, <T>::AssocTy = () we should be able to yield the same suggestion as for T: Trait, T::AssocTy = (). So, instead of bailing out you could handle the case if you want to.
There was a problem hiding this comment.
Neat, thanks for the suggestion! Implemented in here: fd7cadd .
|
Reminder, once the PR becomes ready for a review, use |
|
What’s the background leading to this PR? I’m worried that it’s a machine-generated change, with little or no human understanding behind it. |
|
@Zalathar Do you believe this modification is inappropriate? (If so, I apologize—it simply reflects my incomplete understanding.) Regardless, IIUC, the background for this ICE is as follows: (This expands on the information provided in the PR's description.) In cases like |
|
However, I'm not very experienced in creating proper suggestions as mentioned above, so I may need some time to verify my implementation works well, which might delay when I can push a new version. |
cda81fd to
fd7cadd
Compare
|
@rustbot ready |
close #152338
When processing equality constraints in where clauses like
<T>::Item = T, the compiler would panic with an index underflow. This occurred becausedeny_equality_constraintsassumed that qualified paths always include a trait (e.g.,<T as Foo>::Bar), but<T>::Itemhas no trait part (qself.position == 0). After removing the associated type segment, the path becomes empty, causing underflow insegments.len()-1in here.I think this can be prevented by checking the value of
qself.position, similar to how it's handled inrustc_resolve/src/late.rs:rust/compiler/rustc_resolve/src/late.rs
Lines 4748 to 4750 in be4794c