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

@ -276,7 +276,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
sym::target_feature => {
if !tcx.is_closure_like(did.to_def_id())
&& let Some(fn_sig) = fn_sig()
&& fn_sig.skip_binder().unsafety() == hir::Unsafety::Normal
&& fn_sig.skip_binder().safety() == hir::Safety::Safe
{
if tcx.sess.target.is_like_wasm || tcx.sess.opts.actually_rustdoc {
// The `#[target_feature]` attribute is allowed on

View file

@ -365,7 +365,7 @@ fn push_debuginfo_type_name<'tcx>(
}
output.push_str(" (*)(");
} else {
output.push_str(sig.unsafety.prefix_str());
output.push_str(sig.safety.prefix_str());
if sig.abi != rustc_target::spec::abi::Abi::Rust {
output.push_str("extern \"");