]> git.proxmox.com Git - rustc.git/blame - compiler/rustc_error_codes/src/error_codes/E0316.md
New upstream version 1.54.0+dfsg1
[rustc.git] / compiler / rustc_error_codes / src / error_codes / E0316.md
CommitLineData
17df50a5
XL
1A `where` clause contains a nested quantification over lifetimes.
2
3Erroneous code example:
4
5```compile_fail,E0316
6trait Tr<'a, 'b> {}
7
8fn foo<T>(t: T)
9where
10 for<'a> &'a T: for<'b> Tr<'a, 'b>, // error: nested quantification
11{
12}
13```
14
15Rust syntax allows lifetime quantifications in two places within
16`where` clauses: Quantifying over the trait bound only (as in
17`Ty: for<'l> Trait<'l>`) and quantifying over the whole clause
18(as in `for<'l> &'l Ty: Trait<'l>`). Using both in the same clause
19leads to a nested lifetime quantification, which is not supported.
20
21The following example compiles, because the clause with the nested
22quantification has been rewritten to use only one `for<>`:
23
24```
25trait Tr<'a, 'b> {}
26
27fn foo<T>(t: T)
28where
29 for<'a, 'b> &'a T: Tr<'a, 'b>, // ok
30{
31}
32```