Trait 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 tool_attrs(&self, attr: &[Symbol]) -> Vec<Attribute> { ... }
    fn all_tool_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.

See DefId::name for more details

Source

fn trimmed_name(&self) -> Symbol

Return a trimmed name of this definition.

See DefId::trimmed_name for more details

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 tool_attrs(&self, attr: &[Symbol]) -> Vec<Attribute>

Return registered tool attributes with the given attribute name.

FIXME(jdonszelmann): may panic on non-tool attributes. After more attribute work, non-tool attributes will simply return an empty list.

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

Source

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

Return all tool attributes of this definition.

Implementors§