1
Fork 0

Auto merge of #125077 - spastorino:add-new-fnsafety-enum2, r=jackh726

Rename Unsafe to Safety

Alternative to #124455, which is to just have one Safety enum to use everywhere, this opens the posibility of adding `ast::Safety::Safe` that's useful for unsafe extern blocks.

This leaves us today with:

```rust
enum ast::Safety {
    Unsafe(Span),
    Default,
    // Safe (going to be added for unsafe extern blocks)
}

enum hir::Safety {
    Unsafe,
    Safe,
}
```

We would convert from `ast::Safety::Default` into the right Safety level according the context.
This commit is contained in:
bors 2024-05-18 19:35:24 +00:00
commit eb1a5c9bb3
115 changed files with 460 additions and 494 deletions

View file

@ -37,7 +37,7 @@ fn fn_sig_for_fn_abi<'tcx>(
[],
tcx.thread_local_ptr_ty(instance.def_id()),
false,
hir::Unsafety::Normal,
hir::Safety::Safe,
rustc_target::spec::abi::Abi::Unadjusted,
));
}
@ -96,7 +96,7 @@ fn fn_sig_for_fn_abi<'tcx>(
iter::once(env_ty).chain(sig.inputs().iter().cloned()),
sig.output(),
sig.c_variadic,
sig.unsafety,
sig.safety,
sig.abi,
),
bound_vars,
@ -150,7 +150,7 @@ fn fn_sig_for_fn_abi<'tcx>(
args.as_coroutine_closure().coroutine_captures_by_ref_ty(),
),
sig.c_variadic,
sig.unsafety,
sig.safety,
sig.abi,
),
bound_vars,
@ -301,7 +301,7 @@ fn fn_sig_for_fn_abi<'tcx>(
[env_ty, resume_ty],
ret_ty,
false,
hir::Unsafety::Normal,
hir::Safety::Safe,
rustc_target::spec::abi::Abi::Rust,
)
} else {
@ -310,7 +310,7 @@ fn fn_sig_for_fn_abi<'tcx>(
[env_ty],
ret_ty,
false,
hir::Unsafety::Normal,
hir::Safety::Safe,
rustc_target::spec::abi::Abi::Rust,
)
};