Skip to content

Commit 3678dbc

Browse files
committed
Add explicit_predicates_of to SMIR
1 parent 55e5c9d commit 3678dbc

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

compiler/rustc_smir/src/rustc_smir/mod.rs

+17
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,23 @@ impl<'tcx> Context for Tables<'tcx> {
135135
.collect(),
136136
}
137137
}
138+
139+
fn explicit_predicates_of(
140+
&mut self,
141+
def_id: stable_mir::DefId,
142+
) -> stable_mir::ty::GenericPredicates {
143+
let def_id = self[def_id];
144+
let ty::GenericPredicates { parent, predicates } = self.tcx.explicit_predicates_of(def_id);
145+
stable_mir::ty::GenericPredicates {
146+
parent: parent.map(|did| self.trait_def(did)),
147+
predicates: predicates
148+
.iter()
149+
.map(|(clause, span)| {
150+
(clause.as_predicate().kind().skip_binder().stable(self), span.stable(self))
151+
})
152+
.collect(),
153+
}
154+
}
138155
}
139156

140157
#[derive(Clone)]

compiler/rustc_smir/src/stable_mir/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ pub trait Context {
149149
fn trait_impl(&mut self, trait_impl: &ImplDef) -> ImplTrait;
150150
fn generics_of(&mut self, def_id: DefId) -> Generics;
151151
fn predicates_of(&mut self, def_id: DefId) -> GenericPredicates;
152+
fn explicit_predicates_of(&mut self, def_id: DefId) -> GenericPredicates;
152153
/// Get information about the local crate.
153154
fn local_crate(&self) -> Crate;
154155
/// Retrieve a list of all external crates.

compiler/rustc_smir/src/stable_mir/ty.rs

+4
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,10 @@ impl TraitDecl {
395395
pub fn predicates_of(&self) -> GenericPredicates {
396396
with(|cx| cx.predicates_of(self.def_id.0))
397397
}
398+
399+
pub fn explicit_predicates_of(&self) -> GenericPredicates {
400+
with(|cx| cx.explicit_predicates_of(self.def_id.0))
401+
}
398402
}
399403

400404
pub type ImplTrait = EarlyBinder<TraitRef>;

0 commit comments

Comments
 (0)