Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace some guess_head_span with def_span #98519

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add Node::Variant to Map::opt_span
TaKO8Ki committed Jul 6, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 3d1b679a3c3e4b5b0a408e3ba59549bd6c182b1b
8 changes: 7 additions & 1 deletion compiler/rustc_middle/src/hir/map/mod.rs
Original file line number Diff line number Diff line change
@@ -1012,12 +1012,18 @@ impl<'hir> Map<'hir> {
ItemKind::Use(path, _) => path.span,
_ => named_span(item.span, item.ident, item.kind.generics()),
},
Node::Variant(variant) => match variant.data {
VariantData::Struct(..) | VariantData::Unit(..) => {
named_span(variant.span, variant.ident, None)
}
VariantData::Tuple(..) => variant.span,
},
Node::ImplItem(item) => named_span(item.span, item.ident, Some(item.generics)),
Node::ForeignItem(item) => match item.kind {
ForeignItemKind::Fn(decl, _, _) => until_within(item.span, decl.output.span()),
_ => named_span(item.span, item.ident, None),
},
Node::Ctor(..) => return self.opt_span(self.get_parent_node(hir_id)),
Node::Ctor(_) => return self.opt_span(self.get_parent_node(hir_id)),
_ => self.span_with_body(hir_id),
};
Some(span)