-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Closed
Labels
C-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Description
rust/compiler/rustc_trait_selection/src/traits/select/mod.rs
Lines 2117 to 2144 in f90a4ff
| fn rematch_impl( | |
| &mut self, | |
| impl_def_id: DefId, | |
| obligation: &TraitObligation<'tcx>, | |
| ) -> Normalized<'tcx, SubstsRef<'tcx>> { | |
| let impl_trait_ref = self.tcx().bound_impl_trait_ref(impl_def_id).unwrap(); | |
| match self.match_impl(impl_def_id, impl_trait_ref, obligation) { | |
| Ok(substs) => substs, | |
| Err(()) => { | |
| self.infcx.tcx.sess.delay_span_bug( | |
| obligation.cause.span, | |
| &format!( | |
| "Impl {:?} was matchable against {:?} but now is not", | |
| impl_def_id, obligation | |
| ), | |
| ); | |
| let value = self.infcx.fresh_substs_for_item(obligation.cause.span, impl_def_id); | |
| let err = self.tcx().ty_error(); | |
| let value = value.fold_with(&mut BottomUpFolder { | |
| tcx: self.tcx(), | |
| ty_op: |_| err, | |
| lt_op: |l| l, | |
| ct_op: |c| c, | |
| }); | |
| Normalized { value, obligations: vec![] } | |
| } | |
| } | |
| } |
We currently emit a delay_span_bug if match_impl in rematch_impl fails. Considering that we should only call rematch_impl for impls for which we've already called match_impl before, rematch_impl should always succeed.
There are currently 2 tests which hit that error case:
src/test/ui/impl-trait/issues/issue-62742.rs
src/test/ui/impl-trait/issues/issue-84073.rsWe should figure out why they fail and either fix that, or add a comment to rematch_impl explaining what's going on.
Metadata
Metadata
Assignees
Labels
C-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.