Skip to content

Add E0128, E0130, E0134, E0135 and E0159 error explanation #26742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 8, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 80 additions & 3 deletions src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,62 @@ struct Foo {
```
"##,

E0128: r##"
Type parameter defaults can only use parameters that occur before them.
Erroneous code example:

```
pub struct Foo<T=U, U=()> {
field1: T,
filed2: U,
}
// error: type parameters with a default cannot use forward declared
// identifiers
```

Since type parameters are evaluated in-order, you may be able to fix this issue
by doing:

```
pub struct Foo<U=(), T=U> {
field1: T,
filed2: U,
}
```

Please also verify that this wasn't because of a name-clash and rename the type
parameter if so.
"##,

E0130: r##"
You declared a pattern as an argument in a foreign function declaration.
Erroneous code example:

```
extern {
fn foo((a, b): (u32, u32)); // error: patterns aren't allowed in foreign
// function declarations
}
```

Please replace the pattern argument with a regular one. Example:

```
struct SomeStruct {
a: u32,
b: u32,
}

extern {
fn foo(s: SomeStruct); // ok!
}
// or
extern {
fn foo(a: (u32, u32)); // ok!
}
```
"##,

E0131: r##"
It is not possible to define `main` with type parameters, or even with function
parameters. When `main` is present, it must take no arguments and return `()`.
Expand All @@ -1382,6 +1438,30 @@ fn(isize, *const *const u8) -> isize
```
"##,

E0159: r##"
You tried to use a trait as a struct constructor. Erroneous code example:

```
trait TraitNotAStruct {}

TraitNotAStruct{ value: 0 }; // error: use of trait `TraitNotAStruct` as a
// struct constructor
```

Please verify you used the correct type name or please implement the trait
on a struct and use this struct constructor. Example:

```
trait TraitNotAStruct {}

struct Foo {
value: i32
}

Foo{ value: 0 }; // ok!
```
"##,

E0166: r##"
This error means that the compiler found a return expression in a function
marked as diverging. A function diverges if it has `!` in the place of the
Expand Down Expand Up @@ -1978,11 +2058,8 @@ register_diagnostics! {
E0122,
E0123,
E0127,
E0128,
E0129,
E0130,
E0141,
E0159,
E0163,
E0164,
E0167,
Expand Down