Add all_trait_decls to SMIR
This commit is contained in:
parent
496faa857c
commit
0e69a8ad20
@ -42,6 +42,14 @@ fn entry_fn(&mut self) -> Option<stable_mir::CrateItem> {
|
||||
Some(self.crate_item(self.tcx.entry_fn(())?.0))
|
||||
}
|
||||
|
||||
fn all_trait_decls(&mut self) -> stable_mir::TraitDecls {
|
||||
self.tcx
|
||||
.traits(LOCAL_CRATE)
|
||||
.iter()
|
||||
.map(|trait_def_id| self.trait_def(*trait_def_id))
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn trait_decl(&mut self, trait_def: &stable_mir::ty::TraitDef) -> stable_mir::ty::TraitDecl {
|
||||
let def_id = self.trait_def_id(trait_def);
|
||||
let trait_def = self.tcx.trait_def(def_id);
|
||||
|
@ -32,6 +32,9 @@
|
||||
/// A list of crate items.
|
||||
pub type CrateItems = Vec<CrateItem>;
|
||||
|
||||
/// A list of crate items.
|
||||
pub type TraitDecls = Vec<TraitDef>;
|
||||
|
||||
/// Holds information about a crate.
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct Crate {
|
||||
@ -84,6 +87,7 @@ pub trait Context {
|
||||
/// Retrieve all items of the local crate that have a MIR associated with them.
|
||||
fn all_local_items(&mut self) -> CrateItems;
|
||||
fn mir_body(&mut self, item: &CrateItem) -> mir::Body;
|
||||
fn all_trait_decls(&mut self) -> TraitDecls;
|
||||
fn trait_decl(&mut self, trait_def: &TraitDef) -> TraitDecl;
|
||||
/// Get information about the local crate.
|
||||
fn local_crate(&self) -> Crate;
|
||||
|
Loading…
Reference in New Issue
Block a user