mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
fix: don't emit E0711
if staged_api
not enabled
This commit is contained in:
parent
e9e0908367
commit
be1a6db9f8
@ -137,6 +137,12 @@ impl<'tcx> Visitor<'tcx> for LibFeatureCollector<'tcx> {
|
||||
}
|
||||
|
||||
fn lib_features(tcx: TyCtxt<'_>, (): ()) -> LibFeatures {
|
||||
// If `staged_api` is not enabled then we aren't allowed to define lib
|
||||
// features; there is no point collecting them.
|
||||
if !tcx.features().staged_api {
|
||||
return new_lib_features();
|
||||
}
|
||||
|
||||
let mut collector = LibFeatureCollector::new(tcx);
|
||||
tcx.hir().walk_attributes(&mut collector);
|
||||
collector.lib_features
|
||||
|
10
tests/ui/stability-attribute/issue-106589.rs
Normal file
10
tests/ui/stability-attribute/issue-106589.rs
Normal file
@ -0,0 +1,10 @@
|
||||
// #![feature(staged_api)] // note: `staged_api` not enabled
|
||||
|
||||
#![stable(feature = "foo", since = "1.0.0")]
|
||||
//~^ ERROR stability attributes may not be used outside of the standard library
|
||||
|
||||
#[unstable(feature = "foo", issue = "none")]
|
||||
//~^ ERROR stability attributes may not be used outside of the standard library
|
||||
fn foo_unstable() {}
|
||||
|
||||
fn main() {}
|
15
tests/ui/stability-attribute/issue-106589.stderr
Normal file
15
tests/ui/stability-attribute/issue-106589.stderr
Normal file
@ -0,0 +1,15 @@
|
||||
error[E0734]: stability attributes may not be used outside of the standard library
|
||||
--> $DIR/issue-106589.rs:6:1
|
||||
|
|
||||
LL | #[unstable(feature = "foo", issue = "none")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0734]: stability attributes may not be used outside of the standard library
|
||||
--> $DIR/issue-106589.rs:3:1
|
||||
|
|
||||
LL | #![stable(feature = "foo", since = "1.0.0")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0734`.
|
Loading…
Reference in New Issue
Block a user