File tree 2 files changed +33
-1
lines changed
compiler/rustc_error_codes/src
2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -157,6 +157,7 @@ E0308: include_str!("./error_codes/E0308.md"),
157
157
E0309 : include_str!( "./error_codes/E0309.md" ) ,
158
158
E0310 : include_str!( "./error_codes/E0310.md" ) ,
159
159
E0312 : include_str!( "./error_codes/E0312.md" ) ,
160
+ E0316 : include_str!( "./error_codes/E0316.md" ) ,
160
161
E0317 : include_str!( "./error_codes/E0317.md" ) ,
161
162
E0321 : include_str!( "./error_codes/E0321.md" ) ,
162
163
E0322 : include_str!( "./error_codes/E0322.md" ) ,
@@ -555,7 +556,6 @@ E0783: include_str!("./error_codes/E0783.md"),
555
556
// variable
556
557
// E0314, // closure outlives stack frame
557
558
// E0315, // cannot invoke closure outside of its lifetime
558
- E0316 , // nested quantification of lifetimes
559
559
// E0319, // trait impls for defaulted traits allowed just for structs/enums
560
560
E0320 , // recursive overflow during dropck
561
561
// E0372, // coherence not object safe
Original file line number Diff line number Diff line change
1
+ A ` where ` clause contains a nested quantification over lifetimes.
2
+
3
+ Erroneous code example:
4
+
5
+ ``` compile_fail,E0316
6
+ trait Tr<'a, 'b> {}
7
+
8
+ fn foo<T>(t: T)
9
+ where
10
+ for<'a> &'a T: for<'b> Tr<'a, 'b>, // error: nested quantification
11
+ {
12
+ }
13
+ ```
14
+
15
+ Rust 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
19
+ leads to a nested lifetime quantification, which is not supported.
20
+
21
+ The following example compiles, because the clause with the nested
22
+ quantification has been rewritten to use only one ` for<> ` :
23
+
24
+ ```
25
+ trait Tr<'a, 'b> {}
26
+
27
+ fn foo<T>(t: T)
28
+ where
29
+ for<'a, 'b> &'a T: Tr<'a, 'b>, // ok
30
+ {
31
+ }
32
+ ```
You can’t perform that action at this time.
0 commit comments