1
Fork 0

Rollup merge of #98519 - TaKO8Ki:add-head-span-field-to-item-and-impl-item, r=cjgillot

Replace some `guess_head_span` with `def_span`

This patch fixes a part of #97417.
r? `@cjgillot`
This commit is contained in:
Guillaume Gomez 2022-07-06 20:43:24 +02:00 committed by GitHub
commit d712f67897
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 154 additions and 223 deletions

View file

@ -1013,12 +1013,13 @@ impl<'hir> Map<'hir> {
ItemKind::Use(path, _) => path.span,
_ => named_span(item.span, item.ident, item.kind.generics()),
},
Node::Variant(variant) => named_span(variant.span, variant.ident, None),
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)

View file

@ -795,7 +795,7 @@ fn foo(&self) -> Self::T { String::new() }
if item_def_id == proj_ty_item_def_id =>
{
Some((
self.sess.source_map().guess_head_span(self.def_span(item.def_id)),
self.def_span(item.def_id),
format!("consider calling `{}`", self.def_path_str(item.def_id)),
))
}