Skip to content

Commit 11e1b3e

Browse files
authored
Rollup merge of rust-lang#59525 - pnkfelix:whitelist-some-rustc-attrs, 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
2 parents 1b1b864 + cbbd4d5 commit 11e1b3e

3 files changed

+61
-1
lines changed

src/libsyntax/feature_gate.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ pub const BUILTIN_ATTRIBUTES: &[(&str, AttributeType, AttributeTemplate, Attribu
906906
not currently handle destructors.",
907907
cfg_fn!(thread_local))),
908908

909-
("rustc_on_unimplemented", Normal, template!(List:
909+
("rustc_on_unimplemented", Whitelisted, template!(List:
910910
r#"/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...""#,
911911
NameValueStr: "message"),
912912
Gated(Stability::Unstable,
@@ -962,6 +962,20 @@ pub const BUILTIN_ATTRIBUTES: &[(&str, AttributeType, AttributeTemplate, Attribu
962962
is just used for rustc unit tests \
963963
and will never be stable",
964964
cfg_fn!(rustc_attrs))),
965+
("rustc_layout_scalar_valid_range_start", Whitelisted, template!(List: "value"),
966+
Gated(Stability::Unstable,
967+
"rustc_attrs",
968+
"the `#[rustc_layout_scalar_valid_range_start]` attribute \
969+
is just used to enable niche optimizations in libcore \
970+
and will never be stable",
971+
cfg_fn!(rustc_attrs))),
972+
("rustc_layout_scalar_valid_range_end", Whitelisted, template!(List: "value"),
973+
Gated(Stability::Unstable,
974+
"rustc_attrs",
975+
"the `#[rustc_layout_scalar_valid_range_end]` attribute \
976+
is just used to enable niche optimizations in libcore \
977+
and will never be stable",
978+
cfg_fn!(rustc_attrs))),
965979
("rustc_regions", Normal, template!(Word), Gated(Stability::Unstable,
966980
"rustc_attrs",
967981
"the `#[rustc_regions]` attribute \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// We should not see the unused_attributes lint fire for
2+
// rustc_on_unimplemented, but with this bug we are seeing it fire (on
3+
// subsequent runs) if incremental compilation is enabled.
4+
5+
// revisions: rpass1 rpass2
6+
// compile-pass
7+
8+
#![feature(on_unimplemented)]
9+
#![deny(unused_attributes)]
10+
11+
#[rustc_on_unimplemented = "invalid"]
12+
trait Index<Idx: ?Sized> {
13+
type Output: ?Sized;
14+
fn index(&self, index: Idx) -> &Self::Output;
15+
}
16+
17+
#[rustc_on_unimplemented = "a usize is required to index into a slice"]
18+
impl Index<usize> for [i32] {
19+
type Output = i32;
20+
fn index(&self, index: usize) -> &i32 {
21+
&self[index]
22+
}
23+
}
24+
25+
fn main() {
26+
Index::<usize>::index(&[1, 2, 3] as &[i32], 2);
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// We should not see the unused_attributes lint fire for
2+
// rustc_layout_scalar_valid_range_start, but with this bug we are
3+
// seeing it fire (on subsequent runs) if incremental compilation is
4+
// enabled.
5+
6+
// revisions: rpass1 rpass2
7+
// compile-pass
8+
9+
#![feature(rustc_attrs)]
10+
#![deny(unused_attributes)]
11+
12+
#[rustc_layout_scalar_valid_range_start(10)]
13+
#[rustc_layout_scalar_valid_range_end(30)]
14+
struct RestrictedRange(u32);
15+
const OKAY_RANGE: RestrictedRange = unsafe { RestrictedRange(20) };
16+
17+
fn main() {
18+
OKAY_RANGE.0;
19+
}

0 commit comments

Comments
 (0)