Skip to content

Commit 0e69a8a

Browse files
committed
Add all_trait_decls to SMIR
1 parent 496faa8 commit 0e69a8a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Diff for: compiler/rustc_smir/src/rustc_smir/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ impl<'tcx> Context for Tables<'tcx> {
4242
Some(self.crate_item(self.tcx.entry_fn(())?.0))
4343
}
4444

45+
fn all_trait_decls(&mut self) -> stable_mir::TraitDecls {
46+
self.tcx
47+
.traits(LOCAL_CRATE)
48+
.iter()
49+
.map(|trait_def_id| self.trait_def(*trait_def_id))
50+
.collect()
51+
}
52+
4553
fn trait_decl(&mut self, trait_def: &stable_mir::ty::TraitDef) -> stable_mir::ty::TraitDecl {
4654
let def_id = self.trait_def_id(trait_def);
4755
let trait_def = self.tcx.trait_def(def_id);

Diff for: compiler/rustc_smir/src/stable_mir/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ pub type DefId = usize;
3232
/// A list of crate items.
3333
pub type CrateItems = Vec<CrateItem>;
3434

35+
/// A list of crate items.
36+
pub type TraitDecls = Vec<TraitDef>;
37+
3538
/// Holds information about a crate.
3639
#[derive(Clone, PartialEq, Eq, Debug)]
3740
pub struct Crate {
@@ -84,6 +87,7 @@ pub trait Context {
8487
/// Retrieve all items of the local crate that have a MIR associated with them.
8588
fn all_local_items(&mut self) -> CrateItems;
8689
fn mir_body(&mut self, item: &CrateItem) -> mir::Body;
90+
fn all_trait_decls(&mut self) -> TraitDecls;
8791
fn trait_decl(&mut self, trait_def: &TraitDef) -> TraitDecl;
8892
/// Get information about the local crate.
8993
fn local_crate(&self) -> Crate;

0 commit comments

Comments
 (0)