Skip to content

Commit 4adcc78

Browse files
committed
Rollup merge of #26593 - GuillaumeGomez:patch-2, r=Manishearth
Part of #24407. cc @michaelsproul
2 parents a973e4c + 7f830a8 commit 4adcc78

File tree

2 files changed

+97
-4
lines changed

2 files changed

+97
-4
lines changed

src/librustc/diagnostics.rs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,40 @@ integer type:
360360
http://doc.rust-lang.org/reference.html#ffi-attributes
361361
"##,
362362

363+
E0109: r##"
364+
You tried to give a type parameter to a type which doesn't need it. Erroneous
365+
code example:
366+
367+
```
368+
type X = u32<i32>; // error: type parameters are not allowed on this type
369+
```
370+
371+
Please check that you used the correct type and recheck its definition. Perhaps
372+
it doesn't need the type parameter.
373+
Example:
374+
375+
```
376+
type X = u32; // ok!
377+
```
378+
"##,
379+
380+
E0110: r##"
381+
You tried to give a lifetime parameter to a type which doesn't need it.
382+
Erroneous code example:
383+
384+
```
385+
type X = u32<'static>; // error: lifetime parameters are not allowed on
386+
// this type
387+
```
388+
389+
Please check that you used the correct type and recheck its definition,
390+
perhaps it doesn't need the lifetime parameter. Example:
391+
392+
```
393+
type X = u32; // ok!
394+
```
395+
"##,
396+
363397
E0133: r##"
364398
Using unsafe functionality, such as dereferencing raw pointers and calling
365399
functions via FFI or marked as unsafe, is potentially dangerous and disallowed
@@ -1055,8 +1089,6 @@ register_diagnostics! {
10551089
E0017,
10561090
E0022,
10571091
E0038,
1058-
E0109,
1059-
E0110,
10601092
E0134,
10611093
E0135,
10621094
E0136,

src/librustc_typeck/diagnostics.rs

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,51 @@ The number of supplied parameters much exactly match the number of defined type
934934
parameters.
935935
"##,
936936

937+
E0088: r##"
938+
You gave too many lifetime parameters. Erroneous code example:
939+
940+
```
941+
fn f() {}
942+
943+
fn main() {
944+
f::<'static>() // error: too many lifetime parameters provided
945+
}
946+
```
947+
948+
Please check you give the right number of lifetime parameters. Example:
949+
950+
```
951+
fn f() {}
952+
953+
fn main() {
954+
f() // ok!
955+
}
956+
```
957+
958+
It's also important to note that the Rust compiler can generally
959+
determine the lifetime by itself. Example:
960+
961+
```
962+
struct Foo {
963+
value: String
964+
}
965+
966+
impl Foo {
967+
// it can be written like this
968+
fn get_value<'a>(&'a self) -> &'a str { &self.value }
969+
// but the compiler works fine with this too:
970+
fn without_lifetime(&self) -> &str { &self.value }
971+
}
972+
973+
fn main() {
974+
let f = Foo { value: "hello".to_owned() };
975+
976+
println!("{}", f.get_value());
977+
println!("{}", f.without_lifetime());
978+
}
979+
```
980+
"##,
981+
937982
E0089: r##"
938983
Not enough type parameters were supplied for a function. For example:
939984
@@ -959,6 +1004,24 @@ fn main() {
9591004
```
9601005
"##,
9611006

1007+
E0091: r##"
1008+
You gave an unnecessary type parameter in a type alias. Erroneous code
1009+
example:
1010+
1011+
```
1012+
type Foo<T> = u32; // error: type parameter `T` is unused
1013+
// or:
1014+
type Foo<A,B> = Box<A>; // error: type parameter `B` is unused
1015+
```
1016+
1017+
Please check you didn't write too many type parameters. Example:
1018+
1019+
```
1020+
type Foo = u32; // ok!
1021+
type Foo<A> = Box<A>; // ok!
1022+
```
1023+
"##,
1024+
9621025
E0106: r##"
9631026
This error indicates that a lifetime is missing from a type. If it is an error
9641027
inside a function signature, the problem may be with failing to adhere to the
@@ -1585,9 +1648,7 @@ register_diagnostics! {
15851648
E0077,
15861649
E0085,
15871650
E0086,
1588-
E0088,
15891651
E0090,
1590-
E0091,
15911652
E0092,
15921653
E0093,
15931654
E0094,

0 commit comments

Comments
 (0)