parser: tweak item kind wording
This commit is contained in:
parent
ab84914fe4
commit
b01c1e2092
12 changed files with 115 additions and 112 deletions
|
|
@ -661,12 +661,7 @@ impl<'a> Parser<'a> {
|
|||
self.struct_span_err(span, "associated `static` items are not allowed").emit();
|
||||
AssocItemKind::Const(a, b)
|
||||
}
|
||||
_ => {
|
||||
let span = self.sess.source_map().def_span(span);
|
||||
self.struct_span_err(span, "item kind not supported in `trait` or `impl`")
|
||||
.emit();
|
||||
return None;
|
||||
}
|
||||
_ => return self.error_bad_item_kind(span, &kind, "`trait` or `impl`"),
|
||||
};
|
||||
Some(P(Item { attrs, id, span, vis, ident, defaultness, kind, tokens }))
|
||||
}))
|
||||
|
|
@ -858,16 +853,19 @@ impl<'a> Parser<'a> {
|
|||
self.error_on_foreign_const(span, ident);
|
||||
ForeignItemKind::Static(a, Mutability::Not, b)
|
||||
}
|
||||
_ => {
|
||||
let span = self.sess.source_map().def_span(span);
|
||||
self.struct_span_err(span, "item kind not supported in `extern` block").emit();
|
||||
return None;
|
||||
}
|
||||
_ => return self.error_bad_item_kind(span, &kind, "`extern` block"),
|
||||
};
|
||||
Some(P(Item { attrs, id, span, vis, ident, defaultness, kind, tokens }))
|
||||
}))
|
||||
}
|
||||
|
||||
fn error_bad_item_kind<T>(&self, span: Span, kind: &ItemKind, ctx: &str) -> Option<T> {
|
||||
let span = self.sess.source_map().def_span(span);
|
||||
let msg = format!("{} not supported in {}", kind.descr(), ctx);
|
||||
self.struct_span_err(span, &msg).emit();
|
||||
return None;
|
||||
}
|
||||
|
||||
fn error_on_foreign_const(&self, span: Span, ident: Ident) {
|
||||
self.struct_span_err(ident.span, "extern items cannot be `const`")
|
||||
.span_suggestion(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue