Rollup merge of #65308 - GuillaumeGomez:long-err-explanation-E0574, r=matthewjasper

Add long error explanation for E0574

Part of #61137.
This commit is contained in:
Tyler Mandry 2019-10-15 16:07:50 -07:00 committed by GitHub
commit 42b35968fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 62 additions and 2 deletions

View file

@ -1611,6 +1611,56 @@ fn print_on_failure(state: &State) {
``` ```
"##, "##,
E0574: r##"
Something other than a struct, variant or union has been used when one was
expected.
Erroneous code example:
```compile_fail,E0574
mod Mordor {}
let sauron = Mordor { x: () }; // error!
enum Jak {
Daxter { i: isize },
}
let eco = Jak::Daxter { i: 1 };
match eco {
Jak { i } => {} // error!
}
```
In all these errors, a type was expected. For example, in the first error,
we tried to instantiate the `Mordor` module, which is impossible. If you want
to instantiate a type inside a module, you can do it as follow:
```
mod Mordor {
pub struct TheRing {
pub x: usize,
}
}
let sauron = Mordor::TheRing { x: 1 }; // ok!
```
In the second error, we tried to bind the `Jak` enum directly, which is not
possible: you can only bind one of its variants. To do so:
```
enum Jak {
Daxter { i: isize },
}
let eco = Jak::Daxter { i: 1 };
match eco {
Jak::Daxter { i } => {} // ok!
}
```
"##,
E0603: r##" E0603: r##"
A private item was used outside its scope. A private item was used outside its scope.
@ -1739,7 +1789,6 @@ struct Foo<X = Box<Self>> {
// E0467, removed // E0467, removed
// E0470, removed // E0470, removed
E0573, E0573,
E0574,
E0575, E0575,
E0576, E0576,
E0577, E0577,

View file

@ -6,3 +6,4 @@ LL | let p = foo { x: () };
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0574`.

View file

@ -6,3 +6,4 @@ LL | Foo { i } => ()
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0574`.

View file

@ -6,3 +6,4 @@ LL | let myVar = MyMod { T: 0 };
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0574`.

View file

@ -6,3 +6,4 @@ LL | let _ = module { x: 0 };
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0574`.

View file

@ -6,3 +6,4 @@ LL | char{ch} => true
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0574`.

View file

@ -24,3 +24,4 @@ LL | u32 { x: 1 } => {}
error: aborting due to 4 previous errors error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0574`.

View file

@ -16,4 +16,5 @@ LL | Foo::f();
error: aborting due to 2 previous errors error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0599`. Some errors have detailed explanations: E0574, E0599.
For more information about an error, try `rustc --explain E0574`.

View file

@ -14,3 +14,4 @@ LL | use std::thread::Result;
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0574`.

View file

@ -6,3 +6,4 @@ LL | TraitNotAStruct{ value: 0 };
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0574`.

View file

@ -21,3 +21,4 @@ LL | let try_result: Option<_> = try {
error: aborting due to 2 previous errors error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0574`.

View file

@ -6,3 +6,4 @@ LL | Trait { x: 42 } => ()
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0574`.