mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 15:01:51 +00:00
docs/test: add error-docs and UI test for E0711
This commit is contained in:
parent
ecc0507fdd
commit
24ce65c8d6
@ -436,6 +436,7 @@ E0713: include_str!("./error_codes/E0713.md"),
|
|||||||
E0714: include_str!("./error_codes/E0714.md"),
|
E0714: include_str!("./error_codes/E0714.md"),
|
||||||
E0715: include_str!("./error_codes/E0715.md"),
|
E0715: include_str!("./error_codes/E0715.md"),
|
||||||
E0716: include_str!("./error_codes/E0716.md"),
|
E0716: include_str!("./error_codes/E0716.md"),
|
||||||
|
E0711: include_str!("./error_codes/E0711.md"),
|
||||||
E0717: include_str!("./error_codes/E0717.md"),
|
E0717: include_str!("./error_codes/E0717.md"),
|
||||||
E0718: include_str!("./error_codes/E0718.md"),
|
E0718: include_str!("./error_codes/E0718.md"),
|
||||||
E0719: include_str!("./error_codes/E0719.md"),
|
E0719: include_str!("./error_codes/E0719.md"),
|
||||||
@ -640,7 +641,6 @@ E0791: include_str!("./error_codes/E0791.md"),
|
|||||||
// E0702, // replaced with a generic attribute input check
|
// E0702, // replaced with a generic attribute input check
|
||||||
// E0707, // multiple elided lifetimes used in arguments of `async fn`
|
// E0707, // multiple elided lifetimes used in arguments of `async fn`
|
||||||
// E0709, // multiple different lifetimes used in arguments of `async fn`
|
// E0709, // multiple different lifetimes used in arguments of `async fn`
|
||||||
E0711, // a feature has been declared with conflicting stability attributes, internal error code
|
|
||||||
// E0721, // `await` keyword
|
// E0721, // `await` keyword
|
||||||
// E0723, // unstable feature in `const` context
|
// E0723, // unstable feature in `const` context
|
||||||
// E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.
|
// E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.
|
||||||
|
30
compiler/rustc_error_codes/src/error_codes/E0711.md
Normal file
30
compiler/rustc_error_codes/src/error_codes/E0711.md
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#### This error code is internal to the compiler and will not be emitted with normal Rust code.
|
||||||
|
|
||||||
|
Feature declared with conflicting stability requirements.
|
||||||
|
|
||||||
|
```compile_fail,E0711
|
||||||
|
// NOTE: this attribute is perma-unstable and should *never* be used outside of
|
||||||
|
// stdlib and the compiler.
|
||||||
|
#![feature(staged_api)]
|
||||||
|
|
||||||
|
#![stable(feature = "...", since = "1.0.0")]
|
||||||
|
|
||||||
|
#[stable(feature = "foo", since = "1.0.0")]
|
||||||
|
fn foo_stable_1_0_0() {}
|
||||||
|
|
||||||
|
// error: feature `foo` is declared stable since 1.29.0
|
||||||
|
#[stable(feature = "foo", since = "1.29.0")]
|
||||||
|
fn foo_stable_1_29_0() {}
|
||||||
|
|
||||||
|
// error: feature `foo` is declared unstable
|
||||||
|
#[unstable(feature = "foo", issue = "none")]
|
||||||
|
fn foo_unstable() {}
|
||||||
|
```
|
||||||
|
|
||||||
|
In the above example, the `foo` feature is first defined to be stable since
|
||||||
|
1.0.0, but is then re-declared stable since 1.29.0. This discrepancy in
|
||||||
|
versions causes an error. Furthermore, `foo` is then re-declared as unstable,
|
||||||
|
again the conflict causes an error.
|
||||||
|
|
||||||
|
This error can be fixed by splitting the feature, this allows any
|
||||||
|
stability requirements and removes any possibility of conflict.
|
18
src/test/ui/error-codes/E0711.rs
Normal file
18
src/test/ui/error-codes/E0711.rs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// copied from: src/test/ui/feature-gates/stability-attribute-consistency.rs
|
||||||
|
|
||||||
|
#![feature(staged_api)]
|
||||||
|
|
||||||
|
#![stable(feature = "stable_test_feature", since = "1.0.0")]
|
||||||
|
|
||||||
|
#[stable(feature = "foo", since = "1.0.0")]
|
||||||
|
fn foo_stable_1_0_0() {}
|
||||||
|
|
||||||
|
#[stable(feature = "foo", since = "1.29.0")]
|
||||||
|
//~^ ERROR feature `foo` is declared stable since 1.29.0
|
||||||
|
fn foo_stable_1_29_0() {}
|
||||||
|
|
||||||
|
#[unstable(feature = "foo", issue = "none")]
|
||||||
|
//~^ ERROR feature `foo` is declared unstable
|
||||||
|
fn foo_unstable() {}
|
||||||
|
|
||||||
|
fn main() {}
|
15
src/test/ui/error-codes/E0711.stderr
Normal file
15
src/test/ui/error-codes/E0711.stderr
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
error[E0711]: feature `foo` is declared stable since 1.29.0, but was previously declared stable since 1.0.0
|
||||||
|
--> $DIR/E0711.rs:10:1
|
||||||
|
|
|
||||||
|
LL | #[stable(feature = "foo", since = "1.29.0")]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error[E0711]: feature `foo` is declared unstable, but was previously declared stable
|
||||||
|
--> $DIR/E0711.rs:14:1
|
||||||
|
|
|
||||||
|
LL | #[unstable(feature = "foo", issue = "none")]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0711`.
|
Loading…
Reference in New Issue
Block a user