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:
// 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
.