rust/compiler/rustc_builtin_macros/src
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
..
assert Reformat use declarations. 2024-07-29 08:26:52 +10:00
deriving Use more slice patterns inside the compiler 2024-08-07 13:37:52 +02:00
format_foreign Use as_deref in compiler (but only where it makes sense) 2022-11-16 21:58:58 +00:00
alloc_error_handler.rs chore: use shorthand initializer 2024-08-02 13:22:28 -04:00
asm.rs Use impl PartialEq<TokenKind> for Token more. 2024-08-14 16:37:09 +10:00
assert.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
cfg_accessible.rs Stabilize unsafe_attributes 2024-08-07 03:12:13 -05:00
cfg_eval.rs Distinguish the two kinds of token range. 2024-08-01 19:30:40 +10:00
cfg.rs Add toggle for parse_meta_item unsafe parsing 2024-07-30 18:28:43 -05:00
cmdline_attrs.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
compile_error.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
concat_bytes.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
concat_idents.rs Adjust some pubs. 2024-04-26 13:29:20 +10:00
concat.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
derive.rs Stabilize unsafe_attributes 2024-08-07 03:12:13 -05:00
edition_panic.rs Adjust some pubs. 2024-04-26 13:29:20 +10:00
env.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
errors.rs Rollup merge of #128305 - folkertdev:asm-parser-unsupported-operand, r=Amanieu 2024-08-04 11:32:33 +02:00
format_foreign.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
format.rs Rollup merge of #128762 - fmease:use-more-slice-pats, r=compiler-errors 2024-08-11 07:51:51 +02:00
global_allocator.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
lib.rs Auto merge of #128083 - Mark-Simulacrum:bump-bootstrap, r=albertlarsan68 2024-07-30 17:49:08 +00:00
log_syntax.rs Adjust some pubs. 2024-04-26 13:29:20 +10:00
pattern_type.rs Mark Parser::eat/check methods as must_use 2024-07-29 21:29:08 -04:00
proc_macro_harness.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
source_util.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
standard_library_imports.rs Rename all ParseSess variables/fields/lifetimes as psess. 2024-03-05 08:11:45 +11:00
test_harness.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
test.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
trace_macros.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
util.rs Stabilize unsafe_attributes 2024-08-07 03:12:13 -05:00