Skip to content

Commit

Permalink
Rollup merge of rust-lang#65308 - GuillaumeGomez:long-err-explanation…
Browse files Browse the repository at this point in the history
…-E0574, r=matthewjasper

Add long error explanation for E0574

Part of rust-lang#61137.
  • Loading branch information
tmandry committed Oct 15, 2019
2 parents ff9b99d + 9f392c4 commit 42b3596
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 2 deletions.
51 changes: 50 additions & 1 deletion src/librustc_resolve/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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##"
A private item was used outside its scope.
Expand Down Expand Up @@ -1739,7 +1789,6 @@ struct Foo<X = Box<Self>> {
// E0467, removed
// E0470, removed
E0573,
E0574,
E0575,
E0576,
E0577,
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/issues/issue-17001.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ LL | let p = foo { x: () };

error: aborting due to previous error

For more information about this error, try `rustc --explain E0574`.
1 change: 1 addition & 0 deletions src/test/ui/issues/issue-17405.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ LL | Foo { i } => ()

error: aborting due to previous error

For more information about this error, try `rustc --explain E0574`.
1 change: 1 addition & 0 deletions src/test/ui/issues/issue-21449.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ LL | let myVar = MyMod { T: 0 };

error: aborting due to previous error

For more information about this error, try `rustc --explain E0574`.
1 change: 1 addition & 0 deletions src/test/ui/issues/issue-23189.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ LL | let _ = module { x: 0 };

error: aborting due to previous error

For more information about this error, try `rustc --explain E0574`.
1 change: 1 addition & 0 deletions src/test/ui/issues/issue-26459.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ LL | char{ch} => true

error: aborting due to previous error

For more information about this error, try `rustc --explain E0574`.
1 change: 1 addition & 0 deletions src/test/ui/issues/issue-27815.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ LL | u32 { x: 1 } => {}

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0574`.
3 changes: 2 additions & 1 deletion src/test/ui/lexical-scopes.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ LL | Foo::f();

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`.
1 change: 1 addition & 0 deletions src/test/ui/resolve/issue-16058.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ LL | use std::thread::Result;

error: aborting due to previous error

For more information about this error, try `rustc --explain E0574`.
1 change: 1 addition & 0 deletions src/test/ui/traits/trait-as-struct-constructor.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ LL | TraitNotAStruct{ value: 0 };

error: aborting due to previous error

For more information about this error, try `rustc --explain E0574`.
1 change: 1 addition & 0 deletions src/test/ui/try-block/try-block-in-edition2015.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ LL | let try_result: Option<_> = try {

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0574`.
1 change: 1 addition & 0 deletions src/test/ui/use/issue-18986.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ LL | Trait { x: 42 } => ()

error: aborting due to previous error

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

0 comments on commit 42b3596

Please sign in to comment.