Note what qualifier
This commit is contained in:
parent
c085071631
commit
d6391d5d4d
9 changed files with 39 additions and 35 deletions
|
@ -66,9 +66,9 @@ 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 `extern` blocks without an `unsafe` qualifier cannot have safety qualifiers
|
||||
.suggestion = add `unsafe` to this `extern` block
|
||||
|
|
|
@ -561,21 +561,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