rust-lang/rust

Tracking issue for release notes of #128771: Stabilize `unsafe_attributes`

rustbot opened this issue · 2 comments

This issue tracks the release notes text for #128771.

  • Issue is nominated for the responsible team (and T-release nomination is removed).
  • Proposed text is drafted by team responsible for underlying change.
  • Issue is nominated for release team review of clarity for wider audience.
  • Release team includes text in release notes/blog posts.

Release notes text:

The section title will be de-duplicated by the release team with other release notes issues.
Prefer to use the standard titles from previous releases.
More than one section can be included if needed.

# Language
- [Stabilize unsafe attributes](https://github.com/rust-lang/rust/pull/128771)

Release blog section (if any, leave blank if no section is expected):

@RalfJung: Would you like to propose any language here? This is user-facing enough it seems perhaps worth a mention in the blog post.

cc @rust-lang/lang

Here's a sketch, but @carbotaniuman did the implementation and I didn't closely follow that so they are in a better position to refine this.

Unsafe attributes

Some of our attributes, such as no_mangle, can be used to cause Undefined Behavior without any unsafe block. If this was regular code we would require them to be placed in an unsafe {} block, but so far attributes have not had comparable syntax. To reflect the fact that these attributes can undermine Rust's safety guarantees, they are now considered "unsafe" and should be written as follows:

#[unsafe(no_mangle)]
pub fn my_global_function() { }

The old form of the attribute (without unsafe) is currently still accepted, but might be linted against at some point in the future, and will be a hard error in a future edition.

This affects the following attributes:

  • no_mangle
  • link_section
  • export_name