diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2019-11-30 13:42:50 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2019-12-03 22:25:15 +0100 |
| commit | c911bb1a2e5efc35a8e76bfe6e2581f4a9dfc20b (patch) | |
| tree | 21984b4b1bbb7ee87078d62cc39358ddb758bb12 | |
| parent | 481b18acd09b480cc1ca50ea726cf91847f928f1 (diff) | |
| download | rust-c911bb1a2e5efc35a8e76bfe6e2581f4a9dfc20b.tar.gz rust-c911bb1a2e5efc35a8e76bfe6e2581f4a9dfc20b.zip | |
clean up E0107 error explanation
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0107.md | 23 |
1 files 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 bfe0d21f312..4d22b17fe10 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<T> { x: T } @@ -9,6 +11,7 @@ struct Baz<S, T> { x: Foo<S, T> } // error: wrong number of type arguments: // expected 1, found 2 fn foo<T, U>(x: T, y: U) {} +fn f() {} fn main() { let x: bool = true; @@ -16,12 +19,26 @@ fn main() { // expected 2, found 1 foo::<bool, i32, i32>(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<T> { x: T } + +struct Bar<T> { x: Foo<T> } // ok! +struct Baz<S, T> { x: Foo<S>, y: Foo<T> } // ok! +fn foo<T, U>(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::<bool, u32>(x, 12); // ok! + f(); // ok! } ``` |
