Skip to content

Commit 17b5402

Browse files
committed
Add def_id() method to ty::Binder<.., ExistentialPredicate>
1 parent 4a00305 commit 17b5402

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

compiler/rustc_type_ir/src/predicate.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,13 @@ pub enum ExistentialPredicate<I: Interner> {
275275
}
276276

277277
impl<I: Interner> ty::Binder<I, ExistentialPredicate<I>> {
278+
pub fn def_id(&self) -> I::DefId {
279+
match self.skip_binder() {
280+
ExistentialPredicate::Trait(tr) => tr.def_id,
281+
ExistentialPredicate::Projection(p) => p.def_id,
282+
ExistentialPredicate::AutoTrait(did) => did,
283+
}
284+
}
278285
/// Given an existential predicate like `?Self: PartialEq<u32>` (e.g., derived from `dyn PartialEq<u32>`),
279286
/// and a concrete type `self_ty`, returns a full predicate where the existentially quantified variable `?Self`
280287
/// has been replaced with `self_ty` (e.g., `self_ty: PartialEq<u32>`, in our example).

0 commit comments

Comments
 (0)