Skip to content

Commit

Permalink
Auto merge of #65234 - GuillaumeGomez:long-err-explanation-E0573, r=k…
Browse files Browse the repository at this point in the history
…innison

Add long error explanation for E0573

Part of #61137.
  • Loading branch information
bors committed Oct 17, 2019
2 parents c8fa82c + 7d357fb commit 7e49800
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 5 deletions.
75 changes: 74 additions & 1 deletion src/librustc_resolve/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,80 @@ fn print_on_failure(state: &State) {
```
"##,

E0573: r##"
Something other than a type has been used when one was expected.
Erroneous code examples:
```compile_fail,E0573
enum Dragon {
Born,
}
fn oblivion() -> Dragon::Born { // error!
Dragon::Born
}
const HOBBIT: u32 = 2;
impl HOBBIT {} // error!
enum Wizard {
Gandalf,
Saruman,
}
trait Isengard {
fn wizard(_: Wizard::Saruman); // error!
}
```
In all these errors, a type was expected. For example, in the first error, if
we want to return the `Born` variant from the `Dragon` enum, we must set the
function to return the enum and not its variant:
```
enum Dragon {
Born,
}
fn oblivion() -> Dragon { // ok!
Dragon::Born
}
```
In the second error, you can't implement something on an item, only on types.
We would need to create a new type if we wanted to do something similar:
```
struct Hobbit(u32); // we create a new type
const HOBBIT: Hobbit = Hobbit(2);
impl Hobbit {} // ok!
```
In the third case, we tried to only expect one variant of the `Wizard` enum,
which is not possible. To make this work, we need to using pattern matching
over the `Wizard` enum:
```
enum Wizard {
Gandalf,
Saruman,
}
trait Isengard {
fn wizard(w: Wizard) { // error!
match w {
Wizard::Saruman => {
// do something
}
_ => {} // ignore everything else
}
}
}
```
"##,

E0574: r##"
Something other than a struct, variant or union has been used when one was
expected.
Expand Down Expand Up @@ -1788,7 +1862,6 @@ struct Foo<X = Box<Self>> {
// E0427, merged into 530
// E0467, removed
// E0470, removed
E0573,
E0575,
E0576,
E0577,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ LL | #![feature(const_generics)]

error: aborting due to previous error

For more information about this error, try `rustc --explain E0573`.
1 change: 1 addition & 0 deletions src/test/ui/enum/enum-variant-type-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ LL | fn foo(x: Foo::Bar) {}

error: aborting due to previous error

For more information about this error, try `rustc --explain E0573`.
1 change: 1 addition & 0 deletions src/test/ui/issues/issue-17546.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ LL | fn newer() -> Result<foo::MyEnum, String> {

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0573`.
1 change: 1 addition & 0 deletions src/test/ui/issues/issue-18119.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ LL | impl foo {}

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0573`.
1 change: 1 addition & 0 deletions src/test/ui/issues/issue-30535.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ LL | _: foo::Foo::FooV

error: aborting due to previous error

For more information about this error, try `rustc --explain E0573`.
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-35675.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ LL | fn qux() -> Some {

error: aborting due to 7 previous errors

Some errors have detailed explanations: E0412, E0425.
Some errors have detailed explanations: E0412, E0425, E0573.
For more information about an error, try `rustc --explain E0412`.
2 changes: 1 addition & 1 deletion src/test/ui/privacy/privacy-ns1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,5 @@ LL | use foo3::Bar;

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0412, E0423, E0425.
Some errors have detailed explanations: E0412, E0423, E0425, E0573.
For more information about an error, try `rustc --explain E0412`.
2 changes: 1 addition & 1 deletion src/test/ui/privacy/privacy-ns2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,5 @@ LL | use foo3::{Bar,Baz};

error: aborting due to 7 previous errors

Some errors have detailed explanations: E0423, E0603.
Some errors have detailed explanations: E0423, E0573, E0603.
For more information about an error, try `rustc --explain E0423`.
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ LL | rustfmt::skip;

error: aborting due to 7 previous errors

For more information about this error, try `rustc --explain E0423`.
Some errors have detailed explanations: E0423, E0573.
For more information about an error, try `rustc --explain E0423`.
1 change: 1 addition & 0 deletions src/test/ui/traits/trait-impl-for-module.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ LL | impl A for a {

error: aborting due to previous error

For more information about this error, try `rustc --explain E0573`.
1 change: 1 addition & 0 deletions src/test/ui/type/type-ascription-with-fn-call.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ LL | f();

error: aborting due to previous error

For more information about this error, try `rustc --explain E0573`.
1 change: 1 addition & 0 deletions src/test/ui/variants/variant-used-as-type.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ LL | impl Ty {}

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0573`.

0 comments on commit 7e49800

Please sign in to comment.