-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)C-bugCategory: This is a bug.Category: This is a bug.P-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Description
Code
I tried this code:
unsafe extern "C" {
#[deprecated]
static FOO: std::ffi::c_int;
}
fn main() {
dbg!(unsafe { FOO });
}
I expected to see this happen: successful build, with warning about use of deprecated FOO
.
Instead, this happened: build failed, hard error on use of useless_deprecated
.
Note that the hard error seems incorrect to me, the warning works fine and always did. cc @JonathanBrouwer @jdonszelmann it looks to me like #145085 is the likely cause.
warning: use of deprecated static `FOO`
--> src/main.rs:8:19
|
8 | dbg!(unsafe { FOO });
| ^^^
|
= note: `#[warn(deprecated)]` on by default
error: `#[deprecated]` attribute cannot be used on foreign statics
--> src/main.rs:3:5
|
3 | #[deprecated]
| ^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= help: `#[deprecated]` can be applied to functions, data types, modules, unions, constants, statics, macro defs, type aliases, use statements, struct fields, traits, associated types, associated consts, enum variants, inherent impl blocks, crates
= note: `#[deny(useless_deprecated)]` on by default
Version it worked on
It most recently worked on: nightly-2025-08-14, stable 1.89
Version with regression
rustc --version --verbose
:
rustc 1.91.0-nightly (898aff704 2025-08-14)
binary: rustc
commit-hash: 898aff704d6f0d00343f21d31b8b9bfac8e43007
commit-date: 2025-08-14
host: aarch64-apple-darwin
release: 1.91.0-nightly
LLVM version: 21.1.0
@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged
Metadata
Metadata
Assignees
Labels
A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)C-bugCategory: This is a bug.Category: This is a bug.P-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.