Skip to content

Commit 0d1deb5

Browse files
Add E0159 error explanation
1 parent 05fcb2e commit 0d1deb5

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/librustc_typeck/diagnostics.rs

+24-1
Original file line numberDiff line numberDiff line change
@@ -1431,6 +1431,30 @@ fn(isize, *const *const u8) -> isize
14311431
```
14321432
"##,
14331433

1434+
E0159: r##"
1435+
You tried to use a trait as a struct constructor. Erroneous code example:
1436+
1437+
```
1438+
trait TraitNotAStruct {}
1439+
1440+
TraitNotAStruct{ value: 0 }; // error: use of trait `TraitNotAStruct` as a
1441+
// struct constructor
1442+
```
1443+
1444+
Please verify you used the correct type name or please implement the trait
1445+
on a struct and use this struct constructor. Example:
1446+
1447+
```
1448+
trait TraitNotAStruct {}
1449+
1450+
struct Foo {
1451+
value: i32
1452+
}
1453+
1454+
Foo{ value: 0 }; // ok!
1455+
```
1456+
"##,
1457+
14341458
E0166: r##"
14351459
This error means that the compiler found a return expression in a function
14361460
marked as diverging. A function diverges if it has `!` in the place of the
@@ -2029,7 +2053,6 @@ register_diagnostics! {
20292053
E0127,
20302054
E0129,
20312055
E0141,
2032-
E0159,
20332056
E0163,
20342057
E0164,
20352058
E0167,

0 commit comments

Comments
 (0)