Fix all_trait* methods to return all trait available
Also provide a mechanism to retrieve traits and implementations for a given crate.
This commit is contained in:
@@ -31,7 +31,7 @@ pub use crate::error::*;
|
||||
use crate::mir::pretty::function_name;
|
||||
use crate::mir::Body;
|
||||
use crate::mir::Mutability;
|
||||
use crate::ty::{ImplDef, ImplTrait, IndexedVal, Span, TraitDecl, TraitDef, Ty};
|
||||
use crate::ty::{ImplDef, IndexedVal, Span, TraitDef, Ty};
|
||||
|
||||
pub mod abi;
|
||||
#[macro_use]
|
||||
@@ -86,6 +86,18 @@ pub struct Crate {
|
||||
pub is_local: bool,
|
||||
}
|
||||
|
||||
impl Crate {
|
||||
/// The list of traits declared in this crate.
|
||||
pub fn trait_decls(&self) -> TraitDecls {
|
||||
with(|cx| cx.trait_decls(self.id))
|
||||
}
|
||||
|
||||
/// The list of trait implementations in this crate.
|
||||
pub fn trait_impls(&self) -> ImplTraitDecls {
|
||||
with(|cx| cx.trait_impls(self.id))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
|
||||
pub enum ItemKind {
|
||||
Fn,
|
||||
@@ -169,18 +181,10 @@ pub fn all_trait_decls() -> TraitDecls {
|
||||
with(|cx| cx.all_trait_decls())
|
||||
}
|
||||
|
||||
pub fn trait_decl(trait_def: &TraitDef) -> TraitDecl {
|
||||
with(|cx| cx.trait_decl(trait_def))
|
||||
}
|
||||
|
||||
pub fn all_trait_impls() -> ImplTraitDecls {
|
||||
with(|cx| cx.all_trait_impls())
|
||||
}
|
||||
|
||||
pub fn trait_impl(trait_impl: &ImplDef) -> ImplTrait {
|
||||
with(|cx| cx.trait_impl(trait_impl))
|
||||
}
|
||||
|
||||
/// A type that provides internal information but that can still be used for debug purpose.
|
||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Opaque(String);
|
||||
|
||||
Reference in New Issue
Block a user