From 6c88a2833d6982b1632b623901e3c30245377550 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 26 Jun 2015 13:39:39 +0200 Subject: [PATCH 1/6] Add E0091 error explanation Part of #24407. cc @michaelsproul --- src/librustc_typeck/diagnostics.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 5a7f3026ee0dc..829909db6d686 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -959,6 +959,20 @@ fn main() { ``` "##, +E0091: r##" +You gave an unnecessary type parameter. Erroneous code example: + +``` +type Foo = u32; // error: type parameter `T` is unused +``` + +Please check you didn't write to many type parameter. Example: + +``` +type Foo = u32; // ok! +``` +"##, + E0106: r##" This error indicates that a lifetime is missing from a type. If it is an error inside a function signature, the problem may be with failing to adhere to the @@ -1587,7 +1601,6 @@ register_diagnostics! { E0086, E0088, E0090, - E0091, E0092, E0093, E0094, From 0d74311e2baa73d883aec065dd300d48d34a0158 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 26 Jun 2015 13:53:01 +0200 Subject: [PATCH 2/6] Add E0088 error explanation --- src/librustc_typeck/diagnostics.rs | 51 ++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 829909db6d686..bf2913c83a152 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -934,6 +934,51 @@ The number of supplied parameters much exactly match the number of defined type parameters. "##, +E0088: r##" +You gave too many lifetime parameters. Erroneous code example: + +``` +fn f() {} + +fn main() { + f::<'static>() // error: too many lifetime parameters provided +} +``` + +Please check you give the right number of lifetime parameters. Example: + +``` +fn f() {} + +fn main() { + f() // ok! +} +``` + +It's also important to note that the Rust compiler can generally +determine the lifetime by itself. Example: + +``` +struct Foo { + value: String +} + +impl Foo { + // it can be written like this + fn get_value<'a>(&'a self) -> &'a str { &self.value } + // but the compiler works fine with this too: + fn without_lifetime(&self) -> &str { &self.value } +} + +fn main() { + let f = Foo { value: "hello".to_owned() }; + + println!("{}", f.get_value()); + println!("{}", f.without_lifetime()); +} +``` +"##, + E0089: r##" Not enough type parameters were supplied for a function. For example: @@ -960,13 +1005,14 @@ fn main() { "##, E0091: r##" -You gave an unnecessary type parameter. Erroneous code example: +You gave an unnecessary type parameter in a type alias. Erroneous code +example: ``` type Foo = u32; // error: type parameter `T` is unused ``` -Please check you didn't write to many type parameter. Example: +Please check you didn't write too many type parameters. Example: ``` type Foo = u32; // ok! @@ -1599,7 +1645,6 @@ register_diagnostics! { E0077, E0085, E0086, - E0088, E0090, E0092, E0093, From d73cc565656c76cb5270934caaafa78760cc565b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 27 Jun 2015 14:23:53 +0200 Subject: [PATCH 3/6] Add E0109 error explanation --- src/librustc/diagnostics.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 034d3ee1604a0..b15bcb7b75862 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -360,6 +360,22 @@ integer type: http://doc.rust-lang.org/reference.html#ffi-attributes "##, +E0109: r##" +You tried to give type parameter to a type which doesn't need it. Erroneous +code example: + +``` +type X = u32; // error: type parameters are not allowed on this type +``` + +Please check you actually used the good type or check again its definition. +Example: + +``` +type X = u32; // ok! +``` +"##, + E0133: r##" Using unsafe functionality, such as dereferencing raw pointers and calling functions via FFI or marked as unsafe, is potentially dangerous and disallowed @@ -1055,7 +1071,6 @@ register_diagnostics! { E0017, E0022, E0038, - E0109, E0110, E0134, E0135, From 14e3d26b8a19c56c2c2b2b99ee870a9002bb70e0 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 28 Jun 2015 00:20:59 +0200 Subject: [PATCH 4/6] Add E0110 error explanation --- src/librustc/diagnostics.rs | 21 +++++++++++++++++++-- src/librustc_typeck/diagnostics.rs | 3 +++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index b15bcb7b75862..8d51674ab13e5 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -361,13 +361,31 @@ http://doc.rust-lang.org/reference.html#ffi-attributes "##, E0109: r##" -You tried to give type parameter to a type which doesn't need it. Erroneous +You tried to give type parameter to a type which doesn't need it. Erroneous code example: ``` type X = u32; // error: type parameters are not allowed on this type ``` +Please check that you used the correct type and recheck its definition. Perhaps +it doesn't need the type parameter. +Example: + +``` +type X = u32; // ok! +``` +"##, + +E0110: r##" +You tried to give a lifetime parameter to a type which doesn't need it. +Erroneous code example: + +``` +type X = u32<'static>; // error: lifetime parameters are not allowed on + // this type +``` + Please check you actually used the good type or check again its definition. Example: @@ -1071,7 +1089,6 @@ register_diagnostics! { E0017, E0022, E0038, - E0110, E0134, E0135, E0136, diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index bf2913c83a152..d4977c5d3941c 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -1010,12 +1010,15 @@ example: ``` type Foo = u32; // error: type parameter `T` is unused +// or: +type Foo = Box; // error: type parameter `B` is unused ``` Please check you didn't write too many type parameters. Example: ``` type Foo = u32; // ok! +type Foo = Box; // ok! ``` "##, From b44253067165949d0d70db95c21771a6aeac718f Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 29 Jun 2015 10:03:02 +0200 Subject: [PATCH 5/6] Add more details in error explanation --- src/librustc/diagnostics.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 8d51674ab13e5..36ec48633dcf1 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -386,8 +386,8 @@ type X = u32<'static>; // error: lifetime parameters are not allowed on // this type ``` -Please check you actually used the good type or check again its definition. -Example: +Please check that you used the correct type and recheck its definition, +perhaps it doesn't need the lifetime parameter. Example: ``` type X = u32; // ok! From 7f830a874ccea9cf0ebfe88fa4074d5c5e9c53b4 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 29 Jun 2015 10:21:39 +0200 Subject: [PATCH 6/6] The come back of the "a" eaten by the void --- src/librustc/diagnostics.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 36ec48633dcf1..4673169a7de3e 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -361,7 +361,7 @@ http://doc.rust-lang.org/reference.html#ffi-attributes "##, E0109: r##" -You tried to give type parameter to a type which doesn't need it. Erroneous +You tried to give a type parameter to a type which doesn't need it. Erroneous code example: ```