|
| 1 | +error[E0423]: expected function, tuple struct or tuple variant, found struct `PersonOnlyName` |
| 2 | + --> $DIR/struct-construct-with-call-issue-138931.rs:14:19 |
| 3 | + | |
| 4 | +LL | / struct PersonOnlyName { |
| 5 | +LL | | name: String |
| 6 | +LL | | } |
| 7 | + | |_- `PersonOnlyName` defined here |
| 8 | +... |
| 9 | +LL | let wilfred = PersonOnlyName("Name1".to_owned()); |
| 10 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 11 | + | |
| 12 | +help: use struct literal syntax instead of calling |
| 13 | + | |
| 14 | +LL - let wilfred = PersonOnlyName("Name1".to_owned()); |
| 15 | +LL + let wilfred = PersonOnlyName{name: "Name1".to_owned()}; |
| 16 | + | |
| 17 | + |
| 18 | +error[E0423]: expected function, tuple struct or tuple variant, found struct `PersonWithAge` |
| 19 | + --> $DIR/struct-construct-with-call-issue-138931.rs:17:16 |
| 20 | + | |
| 21 | +LL | / struct PersonWithAge { |
| 22 | +LL | | name: String, |
| 23 | +LL | | age: u8, |
| 24 | +LL | | height: u8, |
| 25 | +LL | | } |
| 26 | + | |_- `PersonWithAge` defined here |
| 27 | +... |
| 28 | +LL | let bill = PersonWithAge( |
| 29 | + | ________________^ |
| 30 | +LL | | "Name2".to_owned(), |
| 31 | +LL | | 20, |
| 32 | +LL | | 180, |
| 33 | +LL | | ); |
| 34 | + | |_____^ |
| 35 | + | |
| 36 | +help: use struct literal syntax instead of calling |
| 37 | + | |
| 38 | +LL ~ let bill = PersonWithAge{ |
| 39 | +LL ~ name: "Name2".to_owned(), |
| 40 | +LL ~ age: 20, |
| 41 | +LL ~ height: 180, |
| 42 | +LL ~ }; |
| 43 | + | |
| 44 | + |
| 45 | +error[E0423]: expected function, tuple struct or tuple variant, found struct `PersonWithAge` |
| 46 | + --> $DIR/struct-construct-with-call-issue-138931.rs:23:18 |
| 47 | + | |
| 48 | +LL | / struct PersonWithAge { |
| 49 | +LL | | name: String, |
| 50 | +LL | | age: u8, |
| 51 | +LL | | height: u8, |
| 52 | +LL | | } |
| 53 | + | |_- `PersonWithAge` defined here |
| 54 | +... |
| 55 | +LL | let person = PersonWithAge("Name3".to_owned()); |
| 56 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `PersonWithAge { name: val, age: val, height: val }` |
| 57 | + |
| 58 | +error: aborting due to 3 previous errors |
| 59 | + |
| 60 | +For more information about this error, try `rustc --explain E0423`. |
0 commit comments