Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incremental compilation flags #[rustc_on_unimplemented] as an unused attribute #59523

Closed
pnkfelix opened this issue Mar 29, 2019 · 2 comments
Closed
Labels
A-incr-comp Area: Incremental compilation A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@pnkfelix
Copy link
Member

pnkfelix commented Mar 29, 2019

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:

// This is a case where we should not see the lint, but we are seeing
// it if incremental compilation is enabled.

#![feature(on_unimplemented)]
#![deny(unused_attributes)]

#[rustc_on_unimplemented = "invalid"]
trait Index<Idx: ?Sized> {
    type Output: ?Sized;
    fn index(&self, index: Idx) -> &Self::Output;
}

#[rustc_on_unimplemented = "a usize is required to index into a slice"]
impl Index<usize> for [i32] {
    type Output = i32;
    fn index(&self, index: usize) -> &i32 {
        &self[index]
    }
}

fn main() {
    Index::<usize>::index(&[1, 2, 3] as &[i32], 2);
}

Demonstration:

% rustc +nightly -C incremental=dir on-impl-works.rs
% rustc +nightly -C incremental=dir on-impl-works.rs
error: unused attribute
 --> on-impl-works.rs:7:1
  |
7 | #[rustc_on_unimplemented = "invalid"]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
note: lint level defined here
 --> on-impl-works.rs:5:9
  |
5 | #![deny(unused_attributes)]
  |         ^^^^^^^^^^^^^^^^^

error: unused attribute
  --> on-impl-works.rs:13:1
   |
13 | #[rustc_on_unimplemented = "a usize is required to index into a slice"]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

This may seem like a low priority item since it is using #![feature(on_unimplemented)]; 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.

@pnkfelix
Copy link
Member Author

Probably the easiest short-term answer is just do something analogous to 81a6437 but for on_unimplemented.

@pnkfelix pnkfelix added the A-incr-comp Area: Incremental compilation label Mar 29, 2019
@pnkfelix
Copy link
Member Author

pnkfelix commented Mar 29, 2019

For the long term, I am vaguely worried that this may be an instance of a class of bugs with the interaction between lints and incremental compilation that we should be tracking.

For example, see also #52387

@pnkfelix pnkfelix added A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 29, 2019
Centril added a commit to Centril/rust that referenced this issue Mar 29, 2019
…, r=petrochenkov

Whitelist some rustc attrs

These rustc attrs are used within libcore, and were causing failures when one mixed incremental compilation with bootstrapping (due to a default of `-D warnings` when bootstrapping).

Fix rust-lang#59523
Fix rust-lang#59524

Cc rust-lang#58633
Centril added a commit to Centril/rust that referenced this issue Mar 30, 2019
…, r=petrochenkov

Whitelist some rustc attrs

These rustc attrs are used within libcore, and were causing failures when one mixed incremental compilation with bootstrapping (due to a default of `-D warnings` when bootstrapping).

Fix rust-lang#59523
Fix rust-lang#59524

Cc rust-lang#58633
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-incr-comp Area: Incremental compilation A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

1 participant