Closed
Description
The code:
struct S;
#[static_assert]
static FOO: S = S;
fn main() {}
results in:
issue-13951.rs:1:1: 1:10 warning: struct is never used: `S`, #[warn(dead_code)] on by default
issue-13951.rs:1 struct S;
^~~~~~~~~
issue-13951.rs:4:1: 4:19 warning: static item is never used: `FOO`, #[warn(dead_code)] on by default
issue-13951.rs:4 static FOO: S = S;
^~~~~~~~~~~~~~~~~~
rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/include/llvm/Support/Casting.h:237: typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = llvm::ConstantInt; Y = llvm::Value; typename llvm::cast_retty<X, Y*>::ret_type = llvm::ConstantInt*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
This has no meaning and should be at least warned about. Putting #[static_assert]
on non-static items (like struct definitions... ) is silently ignored.
I think that we should restrict #[static_assert]
to boolean statics, and emit a warning or an error in the other cases.