Skip to content

Commit 159ba8a

Browse files
committed
Auto merge of #106627 - Ezrashaw:no-e0711-without-staged-api, r=Mark-Simulacrum
fix: don't emit `E0711` if `staged_api` not enabled Fixes #106589 Simple fix, added UI test. As an aside, it seems a lot of features are susceptible to this, `E0711` stands out to me because it's perma-unstable and we are effectively exposing an implementation detail.
2 parents 85357e3 + be1a6db commit 159ba8a

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

compiler/rustc_passes/src/lib_features.rs

+6
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ impl<'tcx> Visitor<'tcx> for LibFeatureCollector<'tcx> {
137137
}
138138

139139
fn lib_features(tcx: TyCtxt<'_>, (): ()) -> LibFeatures {
140+
// If `staged_api` is not enabled then we aren't allowed to define lib
141+
// features; there is no point collecting them.
142+
if !tcx.features().staged_api {
143+
return new_lib_features();
144+
}
145+
140146
let mut collector = LibFeatureCollector::new(tcx);
141147
tcx.hir().walk_attributes(&mut collector);
142148
collector.lib_features
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// #![feature(staged_api)] // note: `staged_api` not enabled
2+
3+
#![stable(feature = "foo", since = "1.0.0")]
4+
//~^ ERROR stability attributes may not be used outside of the standard library
5+
6+
#[unstable(feature = "foo", issue = "none")]
7+
//~^ ERROR stability attributes may not be used outside of the standard library
8+
fn foo_unstable() {}
9+
10+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0734]: stability attributes may not be used outside of the standard library
2+
--> $DIR/issue-106589.rs:6:1
3+
|
4+
LL | #[unstable(feature = "foo", issue = "none")]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error[E0734]: stability attributes may not be used outside of the standard library
8+
--> $DIR/issue-106589.rs:3:1
9+
|
10+
LL | #![stable(feature = "foo", since = "1.0.0")]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
error: aborting due to 2 previous errors
14+
15+
For more information about this error, try `rustc --explain E0734`.

0 commit comments

Comments
 (0)