1
Fork 0

Make MISSING_UNSAFE_ON_EXTERN lint emit future compat info with suggestion to prepend unsafe

This commit is contained in:
Santiago Pastorino 2024-06-03 22:27:57 -03:00
parent 0380321e78
commit 1afc7d716c
No known key found for this signature in database
GPG key ID: 8131A24E0C79EFAF
10 changed files with 40 additions and 16 deletions

View file

@ -1044,12 +1044,19 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
if this.features.unsafe_extern_blocks {
if &Safety::Default == safety {
this.lint_buffer.buffer_lint(
MISSING_UNSAFE_ON_EXTERN,
item.id,
item.span,
BuiltinLintDiag::MissingUnsafeOnExtern,
);
if item.span.at_least_rust_2024() {
this.dcx()
.emit_err(errors::MissingUnsafeOnExtern { span: item.span });
} else {
this.lint_buffer.buffer_lint(
MISSING_UNSAFE_ON_EXTERN,
item.id,
item.span,
BuiltinLintDiag::MissingUnsafeOnExtern {
suggestion: item.span.shrink_to_lo(),
},
);
}
}
} else if let &Safety::Unsafe(span) = safety {
this.dcx().emit_err(errors::UnsafeItem { span, kind: "extern block" });