Rollup merge of #131550 - compiler-errors:extern-diags, r=spastorino
Make some tweaks to extern block diagnostics Self-explanatory. See the diagnostic changes; I hope they make them a bit more descriptive. r? spastorino
This commit is contained in:
commit
b8cdca8cce
16 changed files with 62 additions and 58 deletions
|
@ -62,12 +62,12 @@ ast_passes_equality_in_where = equality constraints are not yet supported in `wh
|
|||
|
||||
ast_passes_extern_block_suggestion = if you meant to declare an externally defined function, use an `extern` block
|
||||
|
||||
ast_passes_extern_fn_qualifiers = functions in `extern` blocks cannot have qualifiers
|
||||
ast_passes_extern_fn_qualifiers = functions in `extern` blocks cannot have `{$kw}` qualifier
|
||||
.label = in this `extern` block
|
||||
.suggestion = remove this qualifier
|
||||
.suggestion = remove the `{$kw}` qualifier
|
||||
|
||||
ast_passes_extern_invalid_safety = items in unadorned `extern` blocks cannot have safety qualifiers
|
||||
.suggestion = add unsafe to this `extern` block
|
||||
ast_passes_extern_invalid_safety = items in `extern` blocks without an `unsafe` qualifier cannot have safety qualifiers
|
||||
.suggestion = add `unsafe` to this `extern` block
|
||||
|
||||
ast_passes_extern_item_ascii = items in `extern` blocks cannot use non-ascii identifiers
|
||||
.label = in this `extern` block
|
||||
|
|
|
@ -524,21 +524,24 @@ impl<'a> AstValidator<'a> {
|
|||
// Deconstruct to ensure exhaustiveness
|
||||
FnHeader { safety: _, coroutine_kind, constness, ext }: FnHeader,
|
||||
) {
|
||||
let report_err = |span| {
|
||||
self.dcx()
|
||||
.emit_err(errors::FnQualifierInExtern { span, block: self.current_extern_span() });
|
||||
let report_err = |span, kw| {
|
||||
self.dcx().emit_err(errors::FnQualifierInExtern {
|
||||
span,
|
||||
kw,
|
||||
block: self.current_extern_span(),
|
||||
});
|
||||
};
|
||||
match coroutine_kind {
|
||||
Some(knd) => report_err(knd.span()),
|
||||
Some(kind) => report_err(kind.span(), kind.as_str()),
|
||||
None => (),
|
||||
}
|
||||
match constness {
|
||||
Const::Yes(span) => report_err(span),
|
||||
Const::Yes(span) => report_err(span, "const"),
|
||||
Const::No => (),
|
||||
}
|
||||
match ext {
|
||||
Extern::None => (),
|
||||
Extern::Implicit(span) | Extern::Explicit(_, span) => report_err(span),
|
||||
Extern::Implicit(span) | Extern::Explicit(_, span) => report_err(span, "extern"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -295,6 +295,7 @@ pub(crate) struct FnQualifierInExtern {
|
|||
pub span: Span,
|
||||
#[label]
|
||||
pub block: Span,
|
||||
pub kw: &'static str,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue