Rollup merge of #116420 - bvanjoi:fix-116203, r=Nilstrieb
discard invalid spans in external blocks Fixes #116203 This PR has discarded the invalid `const_span`, thereby making the format more neat. r? ``@Nilstrieb``
This commit is contained in:
commit
71a8ca0522
4 changed files with 71 additions and 2 deletions
|
@ -1733,7 +1733,7 @@ pub(crate) struct ExternItemCannotBeConst {
|
|||
#[primary_span]
|
||||
pub ident_span: Span,
|
||||
#[suggestion(code = "static ", applicability = "machine-applicable")]
|
||||
pub const_span: Span,
|
||||
pub const_span: Option<Span>,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
|
|
@ -1139,9 +1139,11 @@ impl<'a> Parser<'a> {
|
|||
Ok(kind) => kind,
|
||||
Err(kind) => match kind {
|
||||
ItemKind::Const(box ConstItem { ty, expr, .. }) => {
|
||||
let const_span = Some(span.with_hi(ident.span.lo()))
|
||||
.filter(|span| span.can_be_used_for_suggestions());
|
||||
self.sess.emit_err(errors::ExternItemCannotBeConst {
|
||||
ident_span: ident.span,
|
||||
const_span: span.with_hi(ident.span.lo()),
|
||||
const_span,
|
||||
});
|
||||
ForeignItemKind::Static(ty, Mutability::Not, expr)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue