Closed
Description
Spawned off of #58633
The following code will compile successfully the first time you build it with -C incremental=dir
, then will fail the second time (again with -C incremental=dir
).
Code:
#![feature(rustc_attrs)]
#![deny(unused_attributes)]
#[rustc_layout_scalar_valid_range_start(10)]
#[rustc_layout_scalar_valid_range_end(30)]
struct RestrictedRange(u32);
const OKAY_RANGE: RestrictedRange = unsafe { RestrictedRange(20) };
fn main() {
OKAY_RANGE.0;
}
Demonstration:
% rustc -C incremental=dir ub-nonnull-works.rs
% rustc -C incremental=dir ub-nonnull-works.rs
error: unused attribute
--> ub-nonnull-works.rs:4:1
|
4 | #[rustc_layout_scalar_valid_range_start(10)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> ub-nonnull-works.rs:2:9
|
2 | #![deny(unused_attributes)]
| ^^^^^^^^^^^^^^^^^
error: unused attribute
--> ub-nonnull-works.rs:5:1
|
5 | #[rustc_layout_scalar_valid_range_end(30)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
This may seem like a low priority item since it is using an unstable feature; but we use that feature in libcore
itself, so this problem is causing issues for people who want to use incremental compilation when making their locally bootstrapped build, which defaults to -D warnings
.