diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 034d3ee1604a0..4673169a7de3e 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -360,6 +360,40 @@ integer type: http://doc.rust-lang.org/reference.html#ffi-attributes "##, +E0109: r##" +You tried to give a 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 that you used the correct type and recheck its definition, +perhaps it doesn't need the lifetime parameter. 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,8 +1089,6 @@ register_diagnostics! { E0017, E0022, E0038, - E0109, - E0110, E0134, E0135, E0136, diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 5a7f3026ee0dc..d4977c5d3941c 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: @@ -959,6 +1004,24 @@ fn main() { ``` "##, +E0091: r##" +You gave an unnecessary type parameter in a type alias. Erroneous code +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! +``` +"##, + 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 @@ -1585,9 +1648,7 @@ register_diagnostics! { E0077, E0085, E0086, - E0088, E0090, - E0091, E0092, E0093, E0094,