summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/librustc_error_codes/error_codes/E0107.md23
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 bfe0d21..4d22b17 100644
--- a/src/librustc_error_codes/error_codes/E0107.md
+++ b/src/librustc_error_codes/error_codes/E0107.md
@@ -1,4 +1,6 @@
1This error means that an incorrect number of generic arguments were provided: 1An incorrect number of generic arguments were provided.
2
3Erroneous code example:
2 4
3```compile_fail,E0107 5```compile_fail,E0107
4struct Foo<T> { x: T } 6struct Foo<T> { x: T }
@@ -9,6 +11,7 @@ struct Baz<S, T> { x: Foo<S, T> } // error: wrong number of type arguments:
9 // expected 1, found 2 11 // expected 1, found 2
10 12
11fn foo<T, U>(x: T, y: U) {} 13fn foo<T, U>(x: T, y: U) {}
14fn f() {}
12 15
13fn main() { 16fn main() {
14 let x: bool = true; 17 let x: bool = true;
@@ -16,12 +19,26 @@ fn main() {
16 // expected 2, found 1 19 // expected 2, found 1
17 foo::<bool, i32, i32>(x, 2, 4); // error: wrong number of type arguments: 20 foo::<bool, i32, i32>(x, 2, 4); // error: wrong number of type arguments:
18 // expected 2, found 3 21 // expected 2, found 3
22 f::<'static>(); // error: wrong number of lifetime arguments
23 // expected 0, found 1
19} 24}
25```
26
27When using/declaring an item with generic arguments, you must provide the exact
28same number:
29
30```
31struct Foo<T> { x: T }
32
33struct Bar<T> { x: Foo<T> } // ok!
34struct Baz<S, T> { x: Foo<S>, y: Foo<T> } // ok!
20 35
36fn foo<T, U>(x: T, y: U) {}
21fn f() {} 37fn f() {}
22 38
23fn main() { 39fn main() {
24 f::<'static>(); // error: wrong number of lifetime arguments: 40 let x: bool = true;
25 // expected 0, found 1 41 foo::<bool, u32>(x, 12); // ok!
42 f(); // ok!
26} 43}
27``` 44```