rust/tests/ui/rust-2024
bors 37d56daac6 Auto merge of #128771 - carbotaniuman:stabilize_unsafe_attr, r=nnethercote
Stabilize `unsafe_attributes`

# Stabilization report

## Summary

This is a tracking issue for the RFC 3325: unsafe attributes

We are stabilizing `#![feature(unsafe_attributes)]`,  which makes certain attributes considered 'unsafe', meaning that they must be surrounded by an `unsafe(...)`, as in `#[unsafe(no_mangle)]`.

RFC: rust-lang/rfcs#3325
Tracking issue: #123757

## What is stabilized

### Summary of stabilization

Certain attributes will now be designated as unsafe attributes, namely, `no_mangle`, `export_name`, and `link_section` (stable only), and these attributes will need to be called by surrounding them in `unsafe(...)` syntax. On editions prior to 2024, this is simply an edition lint, but it will become a hard error in 2024. This also works in `cfg_attr`, but `unsafe` is not allowed for any other attributes, including proc-macros ones.

```rust
#[unsafe(no_mangle)]
fn a() {}

#[cfg_attr(any(), unsafe(export_name = "c"))]
fn b() {}
```

For a table showing the attributes that were considered to be included in the list to require unsafe, and subsequent reasoning about why each such attribute was or was not included, see [this comment here](https://github.com/rust-lang/rust/pull/124214#issuecomment-2124753464)

## Tests

The relevant tests are in `tests/ui/rust-2024/unsafe-attributes` and `tests/ui/attributes/unsafe`.
2024-08-17 22:48:42 +00:00
..
prelude-migration Add migration lint for 2024 prelude additions 2024-07-28 11:44:03 +02:00
unsafe-attributes Stabilize unsafe_attributes 2024-08-07 03:12:13 -05:00
unsafe-extern-blocks Stabilize unsafe extern blocks (RFC 3484) 2024-07-23 00:29:39 -03:00
box-slice-into-iter-ambiguous.fixed Adjust the method ambiguity lint too 2024-05-20 19:21:38 -04:00
box-slice-into-iter-ambiguous.rs Adjust the method ambiguity lint too 2024-05-20 19:21:38 -04:00
box-slice-into-iter-ambiguous.stderr Adjust the method ambiguity lint too 2024-05-20 19:21:38 -04:00
gen-kw-in-macro.rs Make sure we don't deny macro vars w keyword names 2024-05-07 19:13:33 -04:00
gen-kw.e2015.stderr Make sure we don't deny macro vars w keyword names 2024-05-07 19:13:33 -04:00
gen-kw.e2018.stderr Make sure we don't deny macro vars w keyword names 2024-05-07 19:13:33 -04:00
gen-kw.rs Make sure we don't deny macro vars w keyword names 2024-05-07 19:13:33 -04:00
prelude2024.rs
safe-outside-extern.gated.stderr Don't allow unsafe statics outside of extern blocks 2024-07-18 18:02:29 -04:00
safe-outside-extern.rs Stabilize unsafe extern blocks (RFC 3484) 2024-07-23 00:29:39 -03:00
safe-outside-extern.stderr Stabilize unsafe extern blocks (RFC 3484) 2024-07-23 00:29:39 -03:00
safe-outside-extern.ungated.stderr Don't allow unsafe statics outside of extern blocks 2024-07-18 18:02:29 -04:00
unsafe-before_exec.e2024.stderr CommandExt::before_exec: deprecate safety in edition 2024 2024-08-14 14:04:11 +02:00
unsafe-before_exec.rs CommandExt::before_exec: deprecate safety in edition 2024 2024-08-14 14:04:11 +02:00
unsafe-env-suggestion.fixed Rename deprecated_safe lint to deprecated_safe_2024 2024-07-17 14:39:56 +02:00
unsafe-env-suggestion.rs Rename deprecated_safe lint to deprecated_safe_2024 2024-07-17 14:39:56 +02:00
unsafe-env-suggestion.stderr #[deprecated_safe_2024]: Also use the // TODO: hint in the compiler error 2024-08-13 11:32:47 +02:00
unsafe-env.e2021.stderr Don't trigger unsafe_op_in_unsafe_fn for deprecated safe fns 2024-06-05 23:44:59 +02:00
unsafe-env.e2024.stderr Don't trigger unsafe_op_in_unsafe_fn for deprecated safe fns 2024-06-05 23:44:59 +02:00
unsafe-env.rs Don't trigger unsafe_op_in_unsafe_fn for deprecated safe fns 2024-06-05 23:44:59 +02:00