Fix handling of item names for HIR
- Handle variants, fields, macros in `Node::ident()` - Handle the crate root in `opt_item_name` - Factor out `item_name_from_def_id` to reduce duplication - Look at HIR before the DefId for `opt_item_name` This gives accurate spans, which are not available from serialized metadata. - Don't panic on the crate root in `opt_item_name` - Add comments
This commit is contained in:
@@ -2677,6 +2677,9 @@ impl<'hir> Node<'hir> {
|
||||
Node::TraitItem(TraitItem { ident, .. })
|
||||
| Node::ImplItem(ImplItem { ident, .. })
|
||||
| Node::ForeignItem(ForeignItem { ident, .. })
|
||||
| Node::Field(StructField { ident, .. })
|
||||
| Node::Variant(Variant { ident, .. })
|
||||
| Node::MacroDef(MacroDef { ident, .. })
|
||||
| Node::Item(Item { ident, .. }) => Some(*ident),
|
||||
_ => None,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user