Skip to content

incremental compilation flags #[rustc_layout_scalar_valid_range_*] as an unused attribute #59524

Description

@pnkfelix

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-incr-compArea: Incremental compilationA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions