1
Fork 0

Rollup merge of #88123 - camelid:tup-pat-precise-spans, r=estebank

Make spans for tuple patterns in E0023 more precise

As suggested in #86307. Closes #86307.

r? ````@estebank````
This commit is contained in:
Manish Goregaokar 2021-08-26 12:38:06 -07:00 committed by GitHub
commit 8aa46e51df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 1165 additions and 77 deletions

View file

@ -223,7 +223,18 @@ fn associated_items(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AssocItems<'_> {
}
fn def_ident_span(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Span> {
tcx.hir().get_if_local(def_id).and_then(|node| node.ident()).map(|ident| ident.span)
tcx.hir()
.get_if_local(def_id)
.and_then(|node| match node {
// A `Ctor` doesn't have an identifier itself, but its parent
// struct/variant does. Compare with `hir::Map::opt_span`.
hir::Node::Ctor(ctor) => ctor
.ctor_hir_id()
.and_then(|ctor_id| tcx.hir().find(tcx.hir().get_parent_node(ctor_id)))
.and_then(|parent| parent.ident()),
_ => node.ident(),
})
.map(|ident| ident.span)
}
/// If the given `DefId` describes an item belonging to a trait,