Skip to content

Commit 223c298

Browse files
committed
Add explicit_predicates_of to SMIR
1 parent 55e5c9d commit 223c298

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

compiler/rustc_smir/src/rustc_smir/mod.rs

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

140154
#[derive(Clone)]

compiler/rustc_smir/src/stable_mir/mod.rs

Lines changed: 1 addition & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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)