rust/compiler
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
..
rustc Link std statically in rustc_driver 2024-08-11 04:16:53 +02:00
rustc_abi interpret: simplify pointer arithmetic logic 2024-08-01 14:25:19 +02:00
rustc_arena Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_ast Use more slice patterns inside the compiler 2024-08-07 13:37:52 +02:00
rustc_ast_ir Use dep: for crate dependencies 2024-07-15 12:40:10 -04:00
rustc_ast_lowering Use FnSig instead of raw FnDecl for ForeignItemKind::Fn 2024-08-16 14:10:06 -04:00
rustc_ast_passes Stabilize unsafe_attributes 2024-08-07 03:12:13 -05:00
rustc_ast_pretty Use more slice patterns inside the compiler 2024-08-07 13:37:52 +02:00
rustc_attr Rollup merge of #128886 - GrigorenkoPV:untranslatable-diagnostic, r=nnethercote 2024-08-12 17:09:17 +02:00
rustc_baked_icu_data Use tidy to sort crate attributes for all compiler crates. 2024-06-12 15:49:10 +10:00
rustc_borrowck Rollup merge of #129059 - compiler-errors:subtyping-correct-type, r=lcnr 2024-08-14 21:43:08 +08:00
rustc_builtin_macros Auto merge of #128771 - carbotaniuman:stabilize_unsafe_attr, r=nnethercote 2024-08-17 22:48:42 +00:00
rustc_codegen_cranelift Auto merge of #128812 - nnethercote:shrink-TyKind-FnPtr, r=compiler-errors 2024-08-14 00:56:53 +00:00
rustc_codegen_gcc Rollup merge of #128570 - folkertdev:stabilize-asm-const, r=Amanieu 2024-08-14 21:43:07 +08:00
rustc_codegen_llvm Auto merge of #128936 - bjorn3:fix_thin_archive_reading, r=jieyouxu 2024-08-15 14:13:52 +00:00
rustc_codegen_ssa Auto merge of #128936 - bjorn3:fix_thin_archive_reading, r=jieyouxu 2024-08-15 14:13:52 +00:00
rustc_const_eval stabilize is_none_or 2024-08-14 18:28:40 +08:00
rustc_data_structures Update indexmap and use IndexMap::append 2024-08-13 16:16:57 -07:00
rustc_driver Use tidy to sort crate attributes for all compiler crates. 2024-06-12 15:49:10 +10:00
rustc_driver_impl Rollup merge of #128762 - fmease:use-more-slice-pats, r=compiler-errors 2024-08-11 07:51:51 +02:00
rustc_error_codes Update E0517 message to reflect RFC 2195. 2024-08-07 23:11:30 -05:00
rustc_error_messages Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_errors Add | to make the html doc of Level rendered correctly 2024-08-14 13:38:03 +08:00
rustc_expand Auto merge of #128771 - carbotaniuman:stabilize_unsafe_attr, r=nnethercote 2024-08-17 22:48:42 +00:00
rustc_feature Auto merge of #128771 - carbotaniuman:stabilize_unsafe_attr, r=nnethercote 2024-08-17 22:48:42 +00:00
rustc_fluent_macro Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_fs_util Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_graphviz Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_hir Use FnSig instead of raw FnDecl for ForeignItemKind::Fn 2024-08-16 14:10:06 -04:00
rustc_hir_analysis Use FnSig instead of raw FnDecl for ForeignItemKind::Fn 2024-08-16 14:10:06 -04:00
rustc_hir_pretty Use FnSig instead of raw FnDecl for ForeignItemKind::Fn 2024-08-16 14:10:06 -04:00
rustc_hir_typeck Auto merge of #128786 - estebank:multiple-crate-versions, r=fee1-dead 2024-08-17 14:40:04 +00:00
rustc_incremental Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_index Add and use IndexVec::append 2024-08-13 13:40:05 -07:00
rustc_index_macros Remove usage of specialization from newtype_index! 2024-06-30 16:42:53 +00:00
rustc_infer Auto merge of #128812 - nnethercote:shrink-TyKind-FnPtr, r=compiler-errors 2024-08-14 00:56:53 +00:00
rustc_interface Stabilize std:🧵:Builder::spawn_unchecked 2024-08-16 10:43:47 -07:00
rustc_lexer Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_lint Use FnSig instead of raw FnDecl for ForeignItemKind::Fn 2024-08-16 14:10:06 -04:00
rustc_lint_defs Auto merge of #128771 - carbotaniuman:stabilize_unsafe_attr, r=nnethercote 2024-08-17 22:48:42 +00:00
rustc_llvm Auto merge of #128936 - bjorn3:fix_thin_archive_reading, r=jieyouxu 2024-08-15 14:13:52 +00:00
rustc_log Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_macros Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_metadata Rollup merge of #128886 - GrigorenkoPV:untranslatable-diagnostic, r=nnethercote 2024-08-12 17:09:17 +02:00
rustc_middle Auto merge of #128792 - compiler-errors:foreign-sig, r=spastorino 2024-08-17 19:35:01 +00:00
rustc_mir_build Remove a useless ref/id/ref round-trip from pattern_from_hir 2024-08-17 22:18:37 +10:00
rustc_mir_dataflow Auto merge of #128812 - nnethercote:shrink-TyKind-FnPtr, r=compiler-errors 2024-08-14 00:56:53 +00:00
rustc_mir_transform Rollup merge of #129101 - compiler-errors:deref-on-parent-by-ref, r=lcnr 2024-08-15 19:32:37 +02:00
rustc_monomorphize Rollup merge of #129067 - cuviper:append, r=wesleywiser 2024-08-15 00:02:27 +02:00
rustc_next_trait_solver Rollup merge of #128828 - lcnr:search-graph-11, r=compiler-errors 2024-08-14 21:43:07 +08:00
rustc_parse Auto merge of #128771 - carbotaniuman:stabilize_unsafe_attr, r=nnethercote 2024-08-17 22:48:42 +00:00
rustc_parse_format Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_passes Rollup merge of #128989 - s7tya:check-linkage-attribute-pos, r=petrochenkov 2024-08-17 18:18:18 +02:00
rustc_pattern_analysis Rollup merge of #128965 - Zalathar:no-pat, r=Nadrieril 2024-08-15 18:44:16 -07:00
rustc_privacy Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_query_impl Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_query_system Use more slice patterns inside the compiler 2024-08-07 13:37:52 +02:00
rustc_resolve Rollup merge of #128875 - bvanjoi:cleanup-import-used, r=petrochenkov 2024-08-11 07:51:52 +02:00
rustc_sanitizers Shrink TyKind::FnPtr. 2024-08-09 14:33:25 +10:00
rustc_serialize Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_session Rollup merge of #128348 - dingxiangfei2009:allow-shadow-call-stack-sanitizer, r=tmandry 2024-08-15 19:32:35 +02:00
rustc_smir Shrink TyKind::FnPtr. 2024-08-09 14:33:25 +10:00
rustc_span #[deprecated_safe_2024]: Also use the // TODO: hint in the compiler error 2024-08-13 11:32:47 +02:00
rustc_symbol_mangling Shrink TyKind::FnPtr. 2024-08-09 14:33:25 +10:00
rustc_target Rollup merge of #127905 - BKPepe:powerpc-muslspe, r=wesleywiser 2024-08-15 00:02:24 +02:00
rustc_trait_selection Auto merge of #128792 - compiler-errors:foreign-sig, r=spastorino 2024-08-17 19:35:01 +00:00
rustc_traits Remove redundant type ops 2024-08-14 14:18:17 -04:00
rustc_transmute Update std and compiler 2024-08-10 12:07:17 +02:00
rustc_ty_utils Auto merge of #129076 - matthiaskrgr:rollup-rg8mi2x, r=matthiaskrgr 2024-08-14 04:17:13 +00:00
rustc_type_ir Rollup merge of #128828 - lcnr:search-graph-11, r=compiler-errors 2024-08-14 21:43:07 +08:00
rustc_type_ir_macros Reformat use declarations. 2024-07-29 08:26:52 +10:00
stable_mir Reformat use declarations. 2024-07-29 08:26:52 +10:00