Skip to content

Commit

Permalink
all variants
Browse files Browse the repository at this point in the history
  • Loading branch information
jdonszelmann authored and WaffleLapkin committed Jun 24, 2024
1 parent db13fa8 commit c73fce2
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 27 deletions.
26 changes: 16 additions & 10 deletions code/examples/misc_9.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
struct A;
struct B();
struct C {}
struct Unit;
struct Tuple();
struct Struct {}

fn main() {
A {};
A { .. } = A { ..A };
Unit {};
Tuple {};
Struct {};

B {};
C {};
Unit();
Tuple();
Struct();

A;
B;
C;
Unit;
Tuple;
Struct;

Unit { .. } = Unit { ..Unit };
Tuple { .. } = Tuple { ..Tuple() };
Struct { .. } = Struct { ..Struct {} };
}
49 changes: 32 additions & 17 deletions code/examples/stderr/misc_9.stderr
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
error[E0423]: expected value, found struct `C`
--> examples/misc_9.rs:14:5
error[E0423]: expected value, found struct `Struct`
--> examples/misc_9.rs:16:5
|
1 | struct A;
| --------- similarly named unit struct `A` defined here
2 | struct B();
3 | struct C {}
| ----------- `C` defined here
3 | struct Struct {}
| ---------------- `Struct` defined here
...
14 | C;
| ^
16 | Struct;
| ^^^^^^ help: use struct literal syntax instead: `Struct {}`

error[E0618]: expected function, found struct `Unit`
--> examples/misc_9.rs:10:5
|
1 | struct Unit;
| ----------- struct `Unit` defined here
...
10 | Unit();
| ^^^^--
| |
| call expression requires function
|
help: use struct literal syntax instead
help: `Unit` is a unit struct, and does not take parentheses to be constructed
|
14 | C {};
| ~~~~
help: a unit struct with a similar name exists
10 - Unit();
10 + Unit;
|
14 | A;
| ~

For more information about this error, try `rustc --explain E0423`.
error: could not compile `code` (example "misc_9") due to 1 previous error
error[E0423]: expected function, tuple struct or tuple variant, found struct `Struct`
--> examples/misc_9.rs:12:5
|
3 | struct Struct {}
| ---------------- `Struct` defined here
...
12 | Struct();
| ^^^^^^^^ help: use struct literal syntax instead: `Struct {}`

Some errors have detailed explanations: E0423, E0618.
For more information about an error, try `rustc --explain E0423`.
error: could not compile `code` (example "misc_9") due to 3 previous errors

0 comments on commit c73fce2

Please sign in to comment.