1
Fork 0

FIx ICE on wf check for foreign fns

This commit is contained in:
Yuki Okushi 2020-12-31 11:25:53 +09:00
parent 507bff92fa
commit 7008911080
4 changed files with 50 additions and 1 deletions

View file

@ -153,6 +153,7 @@ fn msg_span_from_early_bound_and_free_regions(
Some(Node::Item(it)) => item_scope_tag(&it),
Some(Node::TraitItem(it)) => trait_item_scope_tag(&it),
Some(Node::ImplItem(it)) => impl_item_scope_tag(&it),
Some(Node::ForeignItem(it)) => foreign_item_scope_tag(&it),
_ => unreachable!(),
};
let (prefix, span) = match *region {
@ -233,6 +234,13 @@ fn impl_item_scope_tag(item: &hir::ImplItem<'_>) -> &'static str {
}
}
fn foreign_item_scope_tag(item: &hir::ForeignItem<'_>) -> &'static str {
match item.kind {
hir::ForeignItemKind::Fn(..) => "method body",
hir::ForeignItemKind::Static(..) | hir::ForeignItemKind::Type => "associated item",
}
}
fn explain_span(tcx: TyCtxt<'tcx>, heading: &str, span: Span) -> (String, Option<Span>) {
let lo = tcx.sess.source_map().lookup_char_pos(span.lo());
(format!("the {} at {}:{}", heading, lo.line, lo.col.to_usize() + 1), Some(span))