File tree 3 files changed +53
-3
lines changed
3 files changed +53
-3
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ pub struct TraitFlags {
54
54
pub struct AssocTyDefn {
55
55
pub name : Identifier ,
56
56
pub parameter_kinds : Vec < ParameterKind > ,
57
+ pub bound : Option < TraitRef > ,
58
+ pub where_clauses : Vec < QuantifiedWhereClause > ,
57
59
}
58
60
59
61
pub enum ParameterKind {
Original file line number Diff line number Diff line change @@ -72,9 +72,26 @@ TraitDefn: TraitDefn = {
72
72
};
73
73
74
74
AssocTyDefn: AssocTyDefn = {
75
- "type" <name:Id> <p:Angle<ParameterKind>> ";" => AssocTyDefn {
76
- name: name,
77
- parameter_kinds: p
75
+ "type" <name:Id> <p:Angle<ParameterKind>> <b:(":" <Id> <Angle<Parameter>>)?>
76
+ <w:QuantifiedWhereClauses> ";" =>
77
+ {
78
+ let bound = match b {
79
+ Some((t, a)) => {
80
+ let mut args = vec![Parameter::Ty(Ty::Id{ name })];
81
+ args.extend(a);
82
+ Some(TraitRef {
83
+ trait_name: t,
84
+ args: args,
85
+ })
86
+ }
87
+ None => None
88
+ };
89
+ AssocTyDefn {
90
+ name: name,
91
+ parameter_kinds: p,
92
+ where_clauses: w,
93
+ bound,
94
+ }
78
95
}
79
96
};
80
97
Original file line number Diff line number Diff line change @@ -302,3 +302,34 @@ fn check_parameter_kinds() {
302
302
}
303
303
}
304
304
}
305
+
306
+ #[ test]
307
+ fn gat_parse ( ) {
308
+ let program = Arc :: new (
309
+ parse_and_lower_program (
310
+ "
311
+ trait Sized {}
312
+
313
+ trait Foo {
314
+ type Item<'a, T>: Clone where Self: Sized;
315
+ }
316
+
317
+ trait Bar {
318
+ type Item<'a, T> where Self: Sized;
319
+ }
320
+
321
+ trait Baz {
322
+ type Item<'a, T>: Clone;
323
+ }
324
+
325
+ trait Quux {
326
+ type Item<'a, T>;
327
+ }
328
+ " ,
329
+ SolverChoice :: slg ( )
330
+ ) . unwrap ( )
331
+ ) ;
332
+ tls:: set_current_program ( & program, || {
333
+ println ! ( "{:#?}" , program. associated_ty_data. values( ) ) ;
334
+ } ) ;
335
+ }
You can’t perform that action at this time.
0 commit comments