1
Fork 0

Auto merge of #124482 - spastorino:unsafe-extern-blocks, r=oli-obk

Unsafe extern blocks

This implements RFC 3484.

Tracking issue #123743 and RFC https://github.com/rust-lang/rfcs/pull/3484

This is better reviewed commit by commit.
This commit is contained in:
bors 2024-06-06 08:14:58 +00:00
commit 2d28b6384e
93 changed files with 714 additions and 152 deletions

View file

@ -202,6 +202,9 @@ pub(super) fn decorate_lint(sess: &Session, diagnostic: BuiltinLintDiag, diag: &
};
lints::DeprecatedWhereClauseLocation { suggestion }.decorate_lint(diag);
}
BuiltinLintDiag::MissingUnsafeOnExtern { suggestion } => {
lints::MissingUnsafeOnExtern { suggestion }.decorate_lint(diag);
}
BuiltinLintDiag::SingleUseLifetime {
param_span,
use_span: Some((use_span, elide)),

View file

@ -2730,6 +2730,13 @@ pub enum DeprecatedWhereClauseLocationSugg {
},
}
#[derive(LintDiagnostic)]
#[diag(lint_missing_unsafe_on_extern)]
pub struct MissingUnsafeOnExtern {
#[suggestion(code = "unsafe ", applicability = "machine-applicable")]
pub suggestion: Span,
}
#[derive(LintDiagnostic)]
#[diag(lint_single_use_lifetime)]
pub struct SingleUseLifetime {

View file

@ -1741,13 +1741,13 @@ impl<'tcx> LateLintPass<'tcx> for ImproperCTypesDeclarations {
let abi = cx.tcx.hir().get_foreign_abi(it.hir_id());
match it.kind {
hir::ForeignItemKind::Fn(decl, _, _) if !vis.is_internal_abi(abi) => {
hir::ForeignItemKind::Fn(decl, _, _, _) if !vis.is_internal_abi(abi) => {
vis.check_foreign_fn(it.owner_id.def_id, decl);
}
hir::ForeignItemKind::Static(ty, _) if !vis.is_internal_abi(abi) => {
hir::ForeignItemKind::Static(ty, _, _) if !vis.is_internal_abi(abi) => {
vis.check_foreign_static(it.owner_id, ty.span);
}
hir::ForeignItemKind::Fn(decl, _, _) => vis.check_fn(it.owner_id.def_id, decl),
hir::ForeignItemKind::Fn(decl, _, _, _) => vis.check_fn(it.owner_id.def_id, decl),
hir::ForeignItemKind::Static(..) | hir::ForeignItemKind::Type => (),
}
}