Add long explanation for E0212
Update compiler/rustc_error_codes/src/error_codes/E0212.md Co-authored-by: Joshua Nelson <joshua@yottadb.com>
This commit is contained in:
parent
36363e535a
commit
a1e94cdcd5
2 changed files with 36 additions and 1 deletions
|
@ -111,6 +111,7 @@ E0206: include_str!("./error_codes/E0206.md"),
|
||||||
E0207: include_str!("./error_codes/E0207.md"),
|
E0207: include_str!("./error_codes/E0207.md"),
|
||||||
E0210: include_str!("./error_codes/E0210.md"),
|
E0210: include_str!("./error_codes/E0210.md"),
|
||||||
E0211: include_str!("./error_codes/E0211.md"),
|
E0211: include_str!("./error_codes/E0211.md"),
|
||||||
|
E0212: include_str!("./error_codes/E0212.md"),
|
||||||
E0214: include_str!("./error_codes/E0214.md"),
|
E0214: include_str!("./error_codes/E0214.md"),
|
||||||
E0220: include_str!("./error_codes/E0220.md"),
|
E0220: include_str!("./error_codes/E0220.md"),
|
||||||
E0221: include_str!("./error_codes/E0221.md"),
|
E0221: include_str!("./error_codes/E0221.md"),
|
||||||
|
@ -503,7 +504,6 @@ E0779: include_str!("./error_codes/E0779.md"),
|
||||||
// E0196, // cannot determine a type for this closure
|
// E0196, // cannot determine a type for this closure
|
||||||
E0208,
|
E0208,
|
||||||
// E0209, // builtin traits can only be implemented on structs or enums
|
// E0209, // builtin traits can only be implemented on structs or enums
|
||||||
E0212, // cannot extract an associated type from a higher-ranked trait bound
|
|
||||||
// E0213, // associated types are not accepted in this context
|
// E0213, // associated types are not accepted in this context
|
||||||
// E0215, // angle-bracket notation is not stable with `Fn`
|
// E0215, // angle-bracket notation is not stable with `Fn`
|
||||||
// E0216, // parenthetical notation is only stable with `Fn`
|
// E0216, // parenthetical notation is only stable with `Fn`
|
||||||
|
|
35
compiler/rustc_error_codes/src/error_codes/E0212.md
Normal file
35
compiler/rustc_error_codes/src/error_codes/E0212.md
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
Cannot use the associated type of
|
||||||
|
a trait with uninferred generic parameters.
|
||||||
|
|
||||||
|
Erroneous code example:
|
||||||
|
|
||||||
|
```compile_fail,E0212
|
||||||
|
pub trait Foo<T> {
|
||||||
|
type A;
|
||||||
|
|
||||||
|
fn get(&self, t: T) -> Self::A;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn foo2<I : for<'x> Foo<&'x isize>>(
|
||||||
|
field: I::A) {} // error!
|
||||||
|
```
|
||||||
|
|
||||||
|
In this example, we have to instantiate `'x`, and
|
||||||
|
we don't know what lifetime to instantiate it with.
|
||||||
|
To fix this, spell out the precise lifetimes involved.
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```
|
||||||
|
pub trait Foo<T> {
|
||||||
|
type A;
|
||||||
|
|
||||||
|
fn get(&self, t: T) -> Self::A;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn foo3<I : for<'x> Foo<&'x isize>>(
|
||||||
|
x: <I as Foo<&isize>>::A) {} // ok!
|
||||||
|
|
||||||
|
|
||||||
|
fn foo4<'a, I : for<'x> Foo<&'x isize>>(
|
||||||
|
x: <I as Foo<&'a isize>>::A) {} // ok!
|
||||||
|
```
|
Loading…
Add table
Add a link
Reference in a new issue