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
Code
I tried this code:
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.
Version it worked on
It most recently worked on: nightly-2025-08-14, stable 1.89
Version with regression
rustc --version --verbose:@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged