File tree Expand file tree Collapse file tree 1 file changed +17
-13
lines changed
src/librustc_error_codes/error_codes Expand file tree Collapse file tree 1 file changed +17
-13
lines changed Original file line number Diff line number Diff line change 1+ A type or lifetime parameter that is specified for ` impl ` is not constrained.
2+
3+ Erroneous code example:
4+
5+ ``` compile_fail,E0207
6+ struct Foo;
7+
8+ impl<T: Default> Foo {
9+ // error: the type parameter `T` is not constrained by the impl trait, self
10+ // type, or predicates [E0207]
11+ fn get(&self) -> T {
12+ <T as Default>::default()
13+ }
14+ }
15+ ```
16+
117Any type parameter or lifetime parameter of an ` impl ` must meet at least one of
218the following criteria:
319
@@ -10,19 +26,7 @@ the following criteria:
1026### Error example 1
1127
1228Suppose we have a struct ` Foo ` and we would like to define some methods for it.
13- The following definition leads to a compiler error:
14-
15- ``` compile_fail,E0207
16- struct Foo;
17-
18- impl<T: Default> Foo {
19- // error: the type parameter `T` is not constrained by the impl trait, self
20- // type, or predicates [E0207]
21- fn get(&self) -> T {
22- <T as Default>::default()
23- }
24- }
25- ```
29+ The previous code example has a definition which leads to a compiler error:
2630
2731The problem is that the parameter ` T ` does not appear in the implementing type
2832(` Foo ` ) of the impl. In this case, we can fix the error by moving the type
You can’t perform that action at this time.
0 commit comments