1
Fork 0

Handle safety keyword for extern block inner items

This commit is contained in:
Santiago Pastorino 2024-05-23 10:01:05 -03:00
parent bbddc9b58f
commit 2a377122dd
No known key found for this signature in database
GPG key ID: 8131A24E0C79EFAF
52 changed files with 168 additions and 84 deletions

View file

@ -1321,9 +1321,11 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_, ty::PolyFn
icx.lowerer().lower_fn_ty(hir_id, header.safety, header.abi, decl, Some(generics), None)
}
ForeignItem(&hir::ForeignItem { kind: ForeignItemKind::Fn(fn_decl, _, _), .. }) => {
ForeignItem(&hir::ForeignItem {
kind: ForeignItemKind::Fn(fn_decl, _, _, safety), ..
}) => {
let abi = tcx.hir().get_foreign_abi(hir_id);
compute_sig_of_foreign_fn_decl(tcx, def_id, fn_decl, abi)
compute_sig_of_foreign_fn_decl(tcx, def_id, fn_decl, abi, safety)
}
Ctor(data) | Variant(hir::Variant { data, .. }) if data.ctor().is_some() => {
@ -1695,11 +1697,12 @@ fn compute_sig_of_foreign_fn_decl<'tcx>(
def_id: LocalDefId,
decl: &'tcx hir::FnDecl<'tcx>,
abi: abi::Abi,
safety: hir::Safety,
) -> ty::PolyFnSig<'tcx> {
let safety = if abi == abi::Abi::RustIntrinsic {
intrinsic_operation_unsafety(tcx, def_id)
} else {
hir::Safety::Unsafe
safety
};
let hir_id = tcx.local_def_id_to_hir_id(def_id);
let fty =