Skip to content

Commit 8d922eb

Browse files
Fix on_unimplemented_note for RPITITs
1 parent ff7c3b8 commit 8d922eb

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -144,18 +144,22 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
144144
trait_ref: ty::PolyTraitRef<'tcx>,
145145
obligation: &PredicateObligation<'tcx>,
146146
) -> OnUnimplementedNote {
147-
if self.tcx.opt_rpitit_info(obligation.cause.body_id.to_def_id()).is_some() {
148-
return OnUnimplementedNote::default();
149-
}
150-
151147
let (def_id, substs) = self
152148
.impl_similar_to(trait_ref, obligation)
153149
.unwrap_or_else(|| (trait_ref.def_id(), trait_ref.skip_binder().substs));
154150
let trait_ref = trait_ref.skip_binder();
155151

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

160164
match obligation.cause.code() {
161165
ObligationCauseCode::BuiltinDerivedObligation(..)

0 commit comments

Comments
 (0)