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§
Provided Methods§
Sourcefn name(&self) -> Symbol
fn name(&self) -> Symbol
Return the fully qualified name of the current definition.
See DefId::name
for more details
Sourcefn trimmed_name(&self) -> Symbol
fn trimmed_name(&self) -> Symbol
Return a trimmed name of this definition.
See DefId::trimmed_name
for more details
Sourcefn krate(&self) -> Crate
fn krate(&self) -> Crate
Return information about the crate where this definition is declared.
This will return the crate number and its name.
Sourcefn tool_attrs(&self, attr: &[Symbol]) -> Vec<Attribute>
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()]
.
Sourcefn all_tool_attrs(&self) -> Vec<Attribute>
fn all_tool_attrs(&self) -> Vec<Attribute>
Return all tool attributes of this definition.