Skip to content

Commit

Permalink
Fix on_unimplemented_note for RPITITs
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Mar 16, 2023
1 parent ff7c3b8 commit 8d922eb
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,22 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
trait_ref: ty::PolyTraitRef<'tcx>,
obligation: &PredicateObligation<'tcx>,
) -> OnUnimplementedNote {
if self.tcx.opt_rpitit_info(obligation.cause.body_id.to_def_id()).is_some() {
return OnUnimplementedNote::default();
}

let (def_id, substs) = self
.impl_similar_to(trait_ref, obligation)
.unwrap_or_else(|| (trait_ref.def_id(), trait_ref.skip_binder().substs));
let trait_ref = trait_ref.skip_binder();

let body_hir = self.tcx.hir().local_def_id_to_hir_id(obligation.cause.body_id);
let mut flags =
vec![(sym::ItemContext, self.describe_enclosure(body_hir).map(|s| s.to_owned()))];
let mut flags = vec![];
// FIXME(-Zlower-impl-trait-in-trait-to-assoc-ty): HIR is not present for RPITITs,
// but I guess we could synthesize one here. We don't see any errors that rely on
// that yet, though.
let enclosure =
if let Some(body_hir) = self.tcx.opt_local_def_id_to_hir_id(obligation.cause.body_id) {
self.describe_enclosure(body_hir).map(|s| s.to_owned())
} else {
None
};
flags.push((sym::ItemContext, enclosure));

match obligation.cause.code() {
ObligationCauseCode::BuiltinDerivedObligation(..)
Expand Down

0 comments on commit 8d922eb

Please sign in to comment.