safe
keyword is allowed in all function contexts #126749
Closed
Description
opened on Jun 20, 2024
The safe
keyword appears to be allowed in all function contexts. However, the RFC explicitly says it should only be allowed in extern
blocks:
The safe keyword is contextual and is currently allowed only within extern blocks.
#![feature(unsafe_extern_blocks)]
safe fn foo() {}
I expected to see this happen: Compile error
Instead, this happened: Compile success
cc @spastorino FYI
macro fragment
Additionally, it looks like safe fn foo();
is accepted in $item
macro fragment specifier. I think there are different decisions to make here:
Should$item
allowsafe
functions at all? (I think "yes", since it already accepts extern-block items.)Should that be split out into a separate fragment, such as$item_2021
does not allowsafe
, and$item
does in 2024? See Tracking Issue for updatingexpr
macro fragment specifier for Rust 2024 #123742.
EDIT: Concluded below this should not be an issue.
Meta
rustc 1.81.0-nightly (59e2c01c2 2024-06-17)
binary: rustc
commit-hash: 59e2c01c2217a01546222e4d9ff4e6695ee8a1db
commit-date: 2024-06-17
host: aarch64-apple-darwin
release: 1.81.0-nightly
LLVM version: 18.1.7
Tracking:
Activity