Closed
Description
I tried this code:
#![feature(stmt_expr_attributes)]
pub fn foo() {
let f = #[target_feature(enable="magic")] || {};
// f();
}
I expected to see this happen: error because the target feature does not exist and the closure is not unsafe
.
Instead, this happened: the errors does not happen unless the closure is called in foo
and foo
is codegen'd. That is, I can get the expected errors by uncommenting the f();
line and running e.g. cargo build
. but cargo check
/ rustc --emit metadata
doesn't give any error, nor does cargo build
give errors if foo
is not codegen'd for other reasons (e.g., not pub
in a library, or #[inline]
).
Meta
rustc --version --verbose
:
rustc 1.44.0-nightly (f509b26a7 2020-03-18)
binary: rustc
commit-hash: f509b26a7730d721ef87423a72b3fdf8724b4afa
commit-date: 2020-03-18
host: x86_64-unknown-linux-gnu
release: 1.44.0-nightly
LLVM version: 9.0