From 481b18acd09b480cc1ca50ea726cf91847f928f1 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 30 Nov 2019 13:28:53 +0100 Subject: [PATCH 1/2] Small error codes explanation cleanup (E0092, E0093 and E0094) --- src/librustc_error_codes/error_codes/E0092.md | 7 ++++--- src/librustc_error_codes/error_codes/E0093.md | 8 +++++--- src/librustc_error_codes/error_codes/E0094.md | 3 ++- src/librustc_error_codes/error_codes/E0106.md | 4 ++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0092.md b/src/librustc_error_codes/error_codes/E0092.md index 2750a7d45b48e..e289534bf7abd 100644 --- a/src/librustc_error_codes/error_codes/E0092.md +++ b/src/librustc_error_codes/error_codes/E0092.md @@ -1,4 +1,5 @@ -You tried to declare an undefined atomic operation function. +An undefined atomic operation function was declared. + Erroneous code example: ```compile_fail,E0092 @@ -11,8 +12,8 @@ extern "rust-intrinsic" { ``` Please check you didn't make a mistake in the function's name. All intrinsic -functions are defined in librustc_codegen_llvm/intrinsic.rs and in -libcore/intrinsics.rs in the Rust source code. Example: +functions are defined in `librustc_codegen_llvm/intrinsic.rs` and in +`libcore/intrinsics.rs` in the Rust source code. Example: ``` #![feature(intrinsics)] diff --git a/src/librustc_error_codes/error_codes/E0093.md b/src/librustc_error_codes/error_codes/E0093.md index 9633f794d8bb7..8e7de1a9d37b3 100644 --- a/src/librustc_error_codes/error_codes/E0093.md +++ b/src/librustc_error_codes/error_codes/E0093.md @@ -1,4 +1,6 @@ -You declared an unknown intrinsic function. Erroneous code example: +An unknown intrinsic function was declared. + +Erroneous code example: ```compile_fail,E0093 #![feature(intrinsics)] @@ -15,8 +17,8 @@ fn main() { ``` Please check you didn't make a mistake in the function's name. All intrinsic -functions are defined in librustc_codegen_llvm/intrinsic.rs and in -libcore/intrinsics.rs in the Rust source code. Example: +functions are defined in `librustc_codegen_llvm/intrinsic.rs` and in +`libcore/intrinsics.rs` in the Rust source code. Example: ``` #![feature(intrinsics)] diff --git a/src/librustc_error_codes/error_codes/E0094.md b/src/librustc_error_codes/error_codes/E0094.md index 4d27f616d2d84..42baa65bf9faf 100644 --- a/src/librustc_error_codes/error_codes/E0094.md +++ b/src/librustc_error_codes/error_codes/E0094.md @@ -1,4 +1,5 @@ -You gave an invalid number of type parameters to an intrinsic function. +An invalid number of type parameters was given to an intrinsic function. + Erroneous code example: ```compile_fail,E0094 diff --git a/src/librustc_error_codes/error_codes/E0106.md b/src/librustc_error_codes/error_codes/E0106.md index 8a49c1f79e475..60ca1ddc2830c 100644 --- a/src/librustc_error_codes/error_codes/E0106.md +++ b/src/librustc_error_codes/error_codes/E0106.md @@ -2,7 +2,7 @@ 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 lifetime elision rules (see below). -Here are some simple examples of where you'll run into this error: +Erroneous code examples: ```compile_fail,E0106 struct Foo1 { x: &bool } @@ -27,7 +27,7 @@ function signatures which allows you to leave out lifetimes in certain cases. For more background on lifetime elision see [the book][book-le]. The lifetime elision rules require that any function signature with an elided -output lifetime must either have +output lifetime must either have: - exactly one input lifetime - or, multiple input lifetimes, but the function must also be a method with a From c911bb1a2e5efc35a8e76bfe6e2581f4a9dfc20b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 30 Nov 2019 13:42:50 +0100 Subject: [PATCH 2/2] clean up E0107 error explanation --- src/librustc_error_codes/error_codes/E0107.md | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0107.md b/src/librustc_error_codes/error_codes/E0107.md index bfe0d21f3129b..4d22b17fe1016 100644 --- a/src/librustc_error_codes/error_codes/E0107.md +++ b/src/librustc_error_codes/error_codes/E0107.md @@ -1,4 +1,6 @@ -This error means that an incorrect number of generic arguments were provided: +An incorrect number of generic arguments were provided. + +Erroneous code example: ```compile_fail,E0107 struct Foo { x: T } @@ -9,6 +11,7 @@ struct Baz { x: Foo } // error: wrong number of type arguments: // expected 1, found 2 fn foo(x: T, y: U) {} +fn f() {} fn main() { let x: bool = true; @@ -16,12 +19,26 @@ fn main() { // expected 2, found 1 foo::(x, 2, 4); // error: wrong number of type arguments: // expected 2, found 3 + f::<'static>(); // error: wrong number of lifetime arguments + // expected 0, found 1 } +``` + +When using/declaring an item with generic arguments, you must provide the exact +same number: + +``` +struct Foo { x: T } + +struct Bar { x: Foo } // ok! +struct Baz { x: Foo, y: Foo } // ok! +fn foo(x: T, y: U) {} fn f() {} fn main() { - f::<'static>(); // error: wrong number of lifetime arguments: - // expected 0, found 1 + let x: bool = true; + foo::(x, 12); // ok! + f(); // ok! } ```