Trait stable_mir::crate_def::CrateDef

source ·
pub trait CrateDef {
    // Required method
    fn def_id(&self) -> DefId;

    // Provided methods
    fn name(&self) -> Symbol { ... }
    fn trimmed_name(&self) -> Symbol { ... }
    fn krate(&self) -> Crate { ... }
    fn span(&self) -> Span { ... }
    fn attrs_by_path(&self, attr: &[Symbol]) -> Vec<Attribute> { ... }
    fn all_attrs(&self) -> Vec<Attribute> { ... }
}
Expand description

A trait for retrieving information about a particular definition.

Implementors must provide the implementation of def_id which will be used to retrieve information about a crate’s definition.

Required Methods§

source

fn def_id(&self) -> DefId

Retrieve the unique identifier for the current definition.

Provided Methods§

source

fn name(&self) -> Symbol

Return the fully qualified name of the current definition.

source

fn trimmed_name(&self) -> Symbol

Return a trimmed name of this definition.

This can be used to print more user friendly diagnostic messages.

If a symbol name can only be imported from one place for a type, and as long as it was not glob-imported anywhere in the current crate, we trim its path and print only the name.

For example, this function may shorten std::vec::Vec to just Vec, as long as there is no other Vec importable anywhere.

source

fn krate(&self) -> Crate

Return information about the crate where this definition is declared.

This will return the crate number and its name.

source

fn span(&self) -> Span

Return the span of this definition.

source

fn attrs_by_path(&self, attr: &[Symbol]) -> Vec<Attribute>

Return attributes with the given attribute name.

Single segmented name like #[inline] is specified as &["inline".to_string()]. Multi-segmented name like #[rustfmt::skip] is specified as &["rustfmt".to_string(), "skip".to_string()].

source

fn all_attrs(&self) -> Vec<Attribute>

Return all attributes of this definition.

Implementors§