Skip to content

Commit 77f529b

Browse files
authored
Rollup merge of #106614 - Ezrashaw:ui-test-fixups-2, r=GuillaumeGomez
error-code docs improvements (No. 2) - Added empty error-code docs for `E0208`, `E0640` and `E0717` with the "internal" header as discussed on Discord. - Wrote docs and UI test for `E0711`, again with the header. - `tidy` changes are common-sense and make everything pass, `style.rs` hack is annoying though. r? ```@GuillaumeGomez```
2 parents 99529b0 + 2c92c72 commit 77f529b

20 files changed

+88
-6
lines changed

compiler/rustc_error_codes/src/error_codes.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ E0204: include_str!("./error_codes/E0204.md"),
110110
E0205: include_str!("./error_codes/E0205.md"),
111111
E0206: include_str!("./error_codes/E0206.md"),
112112
E0207: include_str!("./error_codes/E0207.md"),
113+
E0208: include_str!("./error_codes/E0208.md"),
113114
E0210: include_str!("./error_codes/E0210.md"),
114115
E0211: include_str!("./error_codes/E0211.md"),
115116
E0212: include_str!("./error_codes/E0212.md"),
@@ -387,6 +388,7 @@ E0636: include_str!("./error_codes/E0636.md"),
387388
E0637: include_str!("./error_codes/E0637.md"),
388389
E0638: include_str!("./error_codes/E0638.md"),
389390
E0639: include_str!("./error_codes/E0639.md"),
391+
E0640: include_str!("./error_codes/E0640.md"),
390392
E0641: include_str!("./error_codes/E0641.md"),
391393
E0642: include_str!("./error_codes/E0642.md"),
392394
E0643: include_str!("./error_codes/E0643.md"),
@@ -434,6 +436,8 @@ E0713: include_str!("./error_codes/E0713.md"),
434436
E0714: include_str!("./error_codes/E0714.md"),
435437
E0715: include_str!("./error_codes/E0715.md"),
436438
E0716: include_str!("./error_codes/E0716.md"),
439+
E0711: include_str!("./error_codes/E0711.md"),
440+
E0717: include_str!("./error_codes/E0717.md"),
437441
E0718: include_str!("./error_codes/E0718.md"),
438442
E0719: include_str!("./error_codes/E0719.md"),
439443
E0720: include_str!("./error_codes/E0720.md"),
@@ -540,7 +544,6 @@ E0791: include_str!("./error_codes/E0791.md"),
540544
// E0190, // deprecated: can only cast a &-pointer to an &-object
541545
// E0194, // merged into E0403
542546
// E0196, // cannot determine a type for this closure
543-
E0208, // internal error code
544547
// E0209, // builtin traits can only be implemented on structs or enums
545548
// E0213, // associated types are not accepted in this context
546549
// E0215, // angle-bracket notation is not stable with `Fn`
@@ -633,14 +636,11 @@ E0791: include_str!("./error_codes/E0791.md"),
633636
// E0629, // missing 'feature' (rustc_const_unstable)
634637
// E0630, // rustc_const_unstable attribute must be paired with stable/unstable
635638
// attribute
636-
E0640, // infer outlives requirements, internal error code
637639
// E0645, // trait aliases not finished
638640
// E0694, // an unknown tool name found in scoped attributes
639641
// E0702, // replaced with a generic attribute input check
640642
// E0707, // multiple elided lifetimes used in arguments of `async fn`
641643
// E0709, // multiple different lifetimes used in arguments of `async fn`
642-
E0711, // a feature has been declared with conflicting stability attributes, internal error code
643-
E0717, // rustc_promotable without stability attribute, internal error code
644644
// E0721, // `await` keyword
645645
// E0723, // unstable feature in `const` context
646646
// E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#### This error code is internal to the compiler and will not be emitted with normal Rust code.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#### This error code is internal to the compiler and will not be emitted with normal Rust code.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#### This error code is internal to the compiler and will not be emitted with normal Rust code.
2+
3+
Feature declared with conflicting stability requirements.
4+
5+
```compile_fail,E0711
6+
// NOTE: this attribute is perma-unstable and should *never* be used outside of
7+
// stdlib and the compiler.
8+
#![feature(staged_api)]
9+
10+
#![stable(feature = "...", since = "1.0.0")]
11+
12+
#[stable(feature = "foo", since = "1.0.0")]
13+
fn foo_stable_1_0_0() {}
14+
15+
// error: feature `foo` is declared stable since 1.29.0
16+
#[stable(feature = "foo", since = "1.29.0")]
17+
fn foo_stable_1_29_0() {}
18+
19+
// error: feature `foo` is declared unstable
20+
#[unstable(feature = "foo", issue = "none")]
21+
fn foo_unstable() {}
22+
```
23+
24+
In the above example, the `foo` feature is first defined to be stable since
25+
1.0.0, but is then re-declared stable since 1.29.0. This discrepancy in
26+
versions causes an error. Furthermore, `foo` is then re-declared as unstable,
27+
again the conflict causes an error.
28+
29+
This error can be fixed by splitting the feature, this allows any
30+
stability requirements and removes any possibility of conflict.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#### This error code is internal to the compiler and will not be emitted with normal Rust code.

src/test/ui/error-codes/E0711.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// copied from: src/test/ui/feature-gates/stability-attribute-consistency.rs
2+
3+
#![feature(staged_api)]
4+
5+
#![stable(feature = "stable_test_feature", since = "1.0.0")]
6+
7+
#[stable(feature = "foo", since = "1.0.0")]
8+
fn foo_stable_1_0_0() {}
9+
10+
#[stable(feature = "foo", since = "1.29.0")]
11+
//~^ ERROR feature `foo` is declared stable since 1.29.0
12+
fn foo_stable_1_29_0() {}
13+
14+
#[unstable(feature = "foo", issue = "none")]
15+
//~^ ERROR feature `foo` is declared unstable
16+
fn foo_unstable() {}
17+
18+
fn main() {}

src/test/ui/error-codes/E0711.stderr

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0711]: feature `foo` is declared stable since 1.29.0, but was previously declared stable since 1.0.0
2+
--> $DIR/E0711.rs:10:1
3+
|
4+
LL | #[stable(feature = "foo", since = "1.29.0")]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error[E0711]: feature `foo` is declared unstable, but was previously declared stable
8+
--> $DIR/E0711.rs:14:1
9+
|
10+
LL | #[unstable(feature = "foo", issue = "none")]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
error: aborting due to 2 previous errors
14+
15+
For more information about this error, try `rustc --explain E0711`.

src/test/ui/feature-gates/stability-attribute-consistency.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ LL | #[unstable(feature = "foo", issue = "none")]
1212

1313
error: aborting due to 2 previous errors
1414

15+
For more information about this error, try `rustc --explain E0711`.

src/test/ui/stability-attribute/stability-attribute-sanity.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,5 @@ LL | #[stable(feature = "a", since = "1.0.0")]
132132

133133
error: aborting due to 20 previous errors
134134

135-
Some errors have detailed explanations: E0539, E0541, E0542, E0543, E0544, E0546, E0547, E0549.
135+
Some errors have detailed explanations: E0539, E0541, E0542, E0543, E0544, E0546, E0547, E0549, E0711.
136136
For more information about an error, try `rustc --explain E0539`.

src/test/ui/variance/variance-associated-consts.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ LL | struct Foo<T: Trait> {
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0208`.

src/test/ui/variance/variance-associated-types.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ LL | struct Bar<'a, T : Trait<'a>> {
1212

1313
error: aborting due to 2 previous errors
1414

15+
For more information about this error, try `rustc --explain E0208`.

src/test/ui/variance/variance-object-types.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ LL | struct Foo<'a> {
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0208`.

src/test/ui/variance/variance-regions-direct.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@ LL | enum Test8<'a, 'b, 'c:'b> {
4242

4343
error: aborting due to 7 previous errors
4444

45+
For more information about this error, try `rustc --explain E0208`.

src/test/ui/variance/variance-regions-indirect.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ LL | struct Derived4<'a, 'b, 'c:'b> {
3030

3131
error: aborting due to 5 previous errors
3232

33+
For more information about this error, try `rustc --explain E0208`.

src/test/ui/variance/variance-trait-bounds.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ LL | struct TestBox<U,T:Getter<U>+Setter<U>> {
2424

2525
error: aborting due to 4 previous errors
2626

27+
For more information about this error, try `rustc --explain E0208`.

src/test/ui/variance/variance-trait-object-bound.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ LL | struct TOption<'a> {
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0208`.

src/test/ui/variance/variance-types-bounds.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ LL | struct TestObject<A, R> {
3030

3131
error: aborting due to 5 previous errors
3232

33+
For more information about this error, try `rustc --explain E0208`.

src/test/ui/variance/variance-types.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ LL | enum Enum<A,B,C> {
3636

3737
error: aborting due to 6 previous errors
3838

39+
For more information about this error, try `rustc --explain E0208`.

src/tools/tidy/src/error_codes.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ const ERROR_DOCS_PATH: &str = "compiler/rustc_error_codes/src/error_codes/";
2727
const ERROR_TESTS_PATH: &str = "src/test/ui/error-codes/";
2828

2929
// Error codes that (for some reason) can't have a doctest in their explanation. Error codes are still expected to provide a code example, even if untested.
30-
const IGNORE_DOCTEST_CHECK: &[&str] = &["E0464", "E0570", "E0601", "E0602"];
30+
const IGNORE_DOCTEST_CHECK: &[&str] =
31+
&["E0208", "E0464", "E0570", "E0601", "E0602", "E0640", "E0717"];
3132

3233
// Error codes that don't yet have a UI test. This list will eventually be removed.
3334
const IGNORE_UI_TEST_CHECK: &[&str] = &[
@@ -193,6 +194,7 @@ fn check_error_codes_docs(
193194
"warning: Error code `{err_code}` doesn't have a code example, all error codes are expected to have one \
194195
(even if untested)."
195196
);
197+
return;
196198
}
197199

198200
let test_ignored = IGNORE_DOCTEST_CHECK.contains(&&err_code);

src/tools/tidy/src/style.rs

+4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ const PROBLEMATIC_CONSTS: &[u32] = &[
6565
3735927486, 3735932941, 4027431614, 4276992702,
6666
];
6767

68+
const INTERNAL_COMPILER_DOCS_LINE: &str = "#### This error code is internal to the compiler and will not be emitted with normal Rust code.";
69+
6870
/// Parser states for `line_is_url`.
6971
#[derive(Clone, Copy, PartialEq)]
7072
#[allow(non_camel_case_types)]
@@ -133,6 +135,8 @@ fn long_line_is_ok(extension: &str, is_error_code: bool, max_columns: usize, lin
133135
"ftl" => true,
134136
// non-error code markdown is allowed to be any length
135137
"md" if !is_error_code => true,
138+
// HACK(Ezrashaw): there is no way to split a markdown header over multiple lines
139+
"md" if line == INTERNAL_COMPILER_DOCS_LINE => true,
136140
_ => line_is_url(is_error_code, max_columns, line) || should_ignore(line),
137141
}
138142
}

0 commit comments

Comments
 (0)