diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-04-14 21:55:39 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-14 21:55:39 +0200 |
| commit | 1bceed826e9a8452716cb8aaa78b98f2aa669dfc (patch) | |
| tree | dc78d7bc99b50b72104b3537d25107351dc894a9 /compiler/rustc_parse/src | |
| parent | 6b3531e915179bf52962881bdb0f7ac7de293031 (diff) | |
| parent | cb22c1d5e949b64aafb99994befde4bd25a421e9 (diff) | |
| download | rust-1bceed826e9a8452716cb8aaa78b98f2aa669dfc.tar.gz rust-1bceed826e9a8452716cb8aaa78b98f2aa669dfc.zip | |
Rollup merge of #139797 - folkertdev:naked-allow-unsafe, r=tgross35
Allow (but don't require) `#[unsafe(naked)]` so that `compiler-builtins` can upgrade to it tracking issue: https://github.com/rust-lang/rust/issues/138997 Per https://github.com/rust-lang/rust/pull/134213#issuecomment-2755984503, we want to make the `#[naked]` attribute an unsafe attribute. Making that change runs into a cyclic dependency with `compiler-builtins` which uses `#[naked]`, where `rustc` needs an updated `compiler-builtins` and vice versa. So based on https://github.com/rust-lang/rust/pull/139753 and [#t-compiler/help > updating `compiler-builtins` and `rustc`](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/updating.20.60compiler-builtins.60.20and.20.60rustc.60), this PR allows, but does not require `#[unsafe(naked)]`, and makes that change for some of the tests to check that both `#[naked]` and `#[unsafe(naked)]` are accepted. Then we can upgrade and synchronize `compiler-builtins`, and then make `#[naked]` (without `unsafe`) invalid. r? `@traviscross` (or someone from t-compiler if you're faster and this look allright)
Diffstat (limited to 'compiler/rustc_parse/src')
| -rw-r--r-- | compiler/rustc_parse/src/validate_attr.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/rustc_parse/src/validate_attr.rs b/compiler/rustc_parse/src/validate_attr.rs index 6a1c2af48ed..b518fca7a65 100644 --- a/compiler/rustc_parse/src/validate_attr.rs +++ b/compiler/rustc_parse/src/validate_attr.rs @@ -194,6 +194,12 @@ pub fn check_attribute_safety(psess: &ParseSess, safety: AttributeSafety, attr: } } } else if let Safety::Unsafe(unsafe_span) = attr_item.unsafety { + // Allow (but don't require) `#[unsafe(naked)]` so that compiler-builtins can upgrade to it. + // FIXME(#139797): remove this special case when compiler-builtins has upgraded. + if attr.has_name(sym::naked) { + return; + } + psess.dcx().emit_err(errors::InvalidAttrUnsafe { span: unsafe_span, name: attr_item.path.clone(), |
