Skip to content

Commit c69663c

Browse files
committed
Rollup merge of rust-lang#26742 - GuillaumeGomez:patch-2, r=arielb1
Part of rust-lang#24407. r? @Manishearth
2 parents ed14593 + 5460650 commit c69663c

File tree

1 file changed

+80
-3
lines changed

1 file changed

+80
-3
lines changed

src/librustc_typeck/diagnostics.rs

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,62 @@ struct Foo {
13681368
```
13691369
"##,
13701370

1371+
E0128: r##"
1372+
Type parameter defaults can only use parameters that occur before them.
1373+
Erroneous code example:
1374+
1375+
```
1376+
pub struct Foo<T=U, U=()> {
1377+
field1: T,
1378+
filed2: U,
1379+
}
1380+
// error: type parameters with a default cannot use forward declared
1381+
// identifiers
1382+
```
1383+
1384+
Since type parameters are evaluated in-order, you may be able to fix this issue
1385+
by doing:
1386+
1387+
```
1388+
pub struct Foo<U=(), T=U> {
1389+
field1: T,
1390+
filed2: U,
1391+
}
1392+
```
1393+
1394+
Please also verify that this wasn't because of a name-clash and rename the type
1395+
parameter if so.
1396+
"##,
1397+
1398+
E0130: r##"
1399+
You declared a pattern as an argument in a foreign function declaration.
1400+
Erroneous code example:
1401+
1402+
```
1403+
extern {
1404+
fn foo((a, b): (u32, u32)); // error: patterns aren't allowed in foreign
1405+
// function declarations
1406+
}
1407+
```
1408+
1409+
Please replace the pattern argument with a regular one. Example:
1410+
1411+
```
1412+
struct SomeStruct {
1413+
a: u32,
1414+
b: u32,
1415+
}
1416+
1417+
extern {
1418+
fn foo(s: SomeStruct); // ok!
1419+
}
1420+
// or
1421+
extern {
1422+
fn foo(a: (u32, u32)); // ok!
1423+
}
1424+
```
1425+
"##,
1426+
13711427
E0131: r##"
13721428
It is not possible to define `main` with type parameters, or even with function
13731429
parameters. When `main` is present, it must take no arguments and return `()`.
@@ -1382,6 +1438,30 @@ fn(isize, *const *const u8) -> isize
13821438
```
13831439
"##,
13841440

1441+
E0159: r##"
1442+
You tried to use a trait as a struct constructor. Erroneous code example:
1443+
1444+
```
1445+
trait TraitNotAStruct {}
1446+
1447+
TraitNotAStruct{ value: 0 }; // error: use of trait `TraitNotAStruct` as a
1448+
// struct constructor
1449+
```
1450+
1451+
Please verify you used the correct type name or please implement the trait
1452+
on a struct and use this struct constructor. Example:
1453+
1454+
```
1455+
trait TraitNotAStruct {}
1456+
1457+
struct Foo {
1458+
value: i32
1459+
}
1460+
1461+
Foo{ value: 0 }; // ok!
1462+
```
1463+
"##,
1464+
13851465
E0166: r##"
13861466
This error means that the compiler found a return expression in a function
13871467
marked as diverging. A function diverges if it has `!` in the place of the
@@ -1978,11 +2058,8 @@ register_diagnostics! {
19782058
E0122,
19792059
E0123,
19802060
E0127,
1981-
E0128,
19822061
E0129,
1983-
E0130,
19842062
E0141,
1985-
E0159,
19862063
E0163,
19872064
E0164,
19882065
E0167,

0 commit comments

Comments
 (0)