File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
compiler/rustc_error_codes/src Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,7 @@ E0206: include_str!("./error_codes/E0206.md"),
111111E0207 : include_str!( "./error_codes/E0207.md" ) ,
112112E0210 : include_str!( "./error_codes/E0210.md" ) ,
113113E0211 : include_str!( "./error_codes/E0211.md" ) ,
114+ E0212 : include_str!( "./error_codes/E0212.md" ) ,
114115E0214 : include_str!( "./error_codes/E0214.md" ) ,
115116E0220 : include_str!( "./error_codes/E0220.md" ) ,
116117E0221 : include_str!( "./error_codes/E0221.md" ) ,
@@ -503,7 +504,6 @@ E0779: include_str!("./error_codes/E0779.md"),
503504// E0196, // cannot determine a type for this closure
504505 E0208 ,
505506// E0209, // builtin traits can only be implemented on structs or enums
506- E0212 , // cannot extract an associated type from a higher-ranked trait bound
507507// E0213, // associated types are not accepted in this context
508508// E0215, // angle-bracket notation is not stable with `Fn`
509509// E0216, // parenthetical notation is only stable with `Fn`
Original file line number Diff line number Diff line change 1+ Cannot use the associated type of
2+ a trait with uninferred generic parameters.
3+
4+ Erroneous code example:
5+
6+ ``` compile_fail,E0212
7+ pub trait Foo<T> {
8+ type A;
9+
10+ fn get(&self, t: T) -> Self::A;
11+ }
12+
13+ fn foo2<I : for<'x> Foo<&'x isize>>(
14+ field: I::A) {} // error!
15+ ```
16+
17+ In this example, we have to instantiate ` 'x ` , and
18+ we don't know what lifetime to instantiate it with.
19+ To fix this, spell out the precise lifetimes involved.
20+ Example:
21+
22+ ```
23+ pub trait Foo<T> {
24+ type A;
25+
26+ fn get(&self, t: T) -> Self::A;
27+ }
28+
29+ fn foo3<I : for<'x> Foo<&'x isize>>(
30+ x: <I as Foo<&isize>>::A) {} // ok!
31+
32+
33+ fn foo4<'a, I : for<'x> Foo<&'x isize>>(
34+ x: <I as Foo<&'a isize>>::A) {} // ok!
35+ ```
You can’t perform that action at this time.
0 commit comments