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 { ... }
}
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.

Implementors§