@@ -1126,7 +1126,7 @@ impl<'a> Parser<'a> {
1126
1126
p. parse_arg_general ( false )
1127
1127
} ) ;
1128
1128
1129
- p. parse_where_clause ( & mut generics ) ;
1129
+ generics . where_clause = p. parse_where_clause ( ) ;
1130
1130
let sig = ast:: MethodSig {
1131
1131
unsafety : style,
1132
1132
decl : d,
@@ -3932,9 +3932,14 @@ impl<'a> Parser<'a> {
3932
3932
/// ```
3933
3933
/// where T : Trait<U, V> + 'b, 'a : 'b
3934
3934
/// ```
3935
- fn parse_where_clause ( & mut self , generics : & mut ast:: Generics ) {
3935
+ fn parse_where_clause ( & mut self ) -> ast:: WhereClause {
3936
+ let mut where_clause = WhereClause {
3937
+ id : ast:: DUMMY_NODE_ID ,
3938
+ predicates : Vec :: new ( ) ,
3939
+ } ;
3940
+
3936
3941
if !self . eat_keyword ( keywords:: Where ) {
3937
- return
3942
+ return where_clause ;
3938
3943
}
3939
3944
3940
3945
let mut parsed_something = false ;
@@ -3957,7 +3962,7 @@ impl<'a> Parser<'a> {
3957
3962
let hi = self . span . hi ;
3958
3963
let span = mk_sp ( lo, hi) ;
3959
3964
3960
- generics . where_clause . predicates . push ( ast:: WherePredicate :: RegionPredicate (
3965
+ where_clause. predicates . push ( ast:: WherePredicate :: RegionPredicate (
3961
3966
ast:: WhereRegionPredicate {
3962
3967
span : span,
3963
3968
lifetime : bounded_lifetime,
@@ -3992,7 +3997,7 @@ impl<'a> Parser<'a> {
3992
3997
at least one bound in it") ;
3993
3998
}
3994
3999
3995
- generics . where_clause . predicates . push ( ast:: WherePredicate :: BoundPredicate (
4000
+ where_clause. predicates . push ( ast:: WherePredicate :: BoundPredicate (
3996
4001
ast:: WhereBoundPredicate {
3997
4002
span : span,
3998
4003
bound_lifetimes : bound_lifetimes,
@@ -4005,7 +4010,7 @@ impl<'a> Parser<'a> {
4005
4010
// let ty = self.parse_ty();
4006
4011
let hi = self . span . hi ;
4007
4012
let span = mk_sp ( lo, hi) ;
4008
- // generics. where_clause.predicates.push(
4013
+ // where_clause.predicates.push(
4009
4014
// ast::WherePredicate::EqPredicate(ast::WhereEqPredicate {
4010
4015
// id: ast::DUMMY_NODE_ID,
4011
4016
// span: span,
@@ -4036,6 +4041,8 @@ impl<'a> Parser<'a> {
4036
4041
"a `where` clause must have at least one predicate \
4037
4042
in it") ;
4038
4043
}
4044
+
4045
+ where_clause
4039
4046
}
4040
4047
4041
4048
fn parse_fn_args ( & mut self , named_args : bool , allow_variadic : bool )
@@ -4354,7 +4361,7 @@ impl<'a> Parser<'a> {
4354
4361
fn parse_item_fn ( & mut self , unsafety : Unsafety , abi : abi:: Abi ) -> ItemInfo {
4355
4362
let ( ident, mut generics) = self . parse_fn_header ( ) ;
4356
4363
let decl = self . parse_fn_decl ( false ) ;
4357
- self . parse_where_clause ( & mut generics ) ;
4364
+ generics . where_clause = self . parse_where_clause ( ) ;
4358
4365
let ( inner_attrs, body) = self . parse_inner_attrs_and_block ( ) ;
4359
4366
( ident, ItemFn ( decl, unsafety, abi, generics, body) , Some ( inner_attrs) )
4360
4367
}
@@ -4439,7 +4446,7 @@ impl<'a> Parser<'a> {
4439
4446
let ( explicit_self, decl) = self . parse_fn_decl_with_self ( |p| {
4440
4447
p. parse_arg ( )
4441
4448
} ) ;
4442
- self . parse_where_clause ( & mut generics ) ;
4449
+ generics . where_clause = self . parse_where_clause ( ) ;
4443
4450
let ( inner_attrs, body) = self . parse_inner_attrs_and_block ( ) ;
4444
4451
( ident, inner_attrs, MethodImplItem ( ast:: MethodSig {
4445
4452
generics : generics,
@@ -4460,7 +4467,7 @@ impl<'a> Parser<'a> {
4460
4467
// Parse supertrait bounds.
4461
4468
let bounds = self . parse_colon_then_ty_param_bounds ( BoundParsingMode :: Bare ) ;
4462
4469
4463
- self . parse_where_clause ( & mut tps ) ;
4470
+ tps . where_clause = self . parse_where_clause ( ) ;
4464
4471
4465
4472
let meths = self . parse_trait_items ( ) ;
4466
4473
( ident, ItemTrait ( unsafety, tps, bounds, meths) , None )
@@ -4531,7 +4538,7 @@ impl<'a> Parser<'a> {
4531
4538
if opt_trait. is_some ( ) {
4532
4539
ty = self . parse_ty_sum ( ) ;
4533
4540
}
4534
- self . parse_where_clause ( & mut generics ) ;
4541
+ generics . where_clause = self . parse_where_clause ( ) ;
4535
4542
4536
4543
self . expect ( & token:: OpenDelim ( token:: Brace ) ) ;
4537
4544
let attrs = self . parse_inner_attributes ( ) ;
@@ -4603,7 +4610,7 @@ impl<'a> Parser<'a> {
4603
4610
// struct.
4604
4611
4605
4612
let ( fields, ctor_id) = if self . token . is_keyword ( keywords:: Where ) {
4606
- self . parse_where_clause ( & mut generics ) ;
4613
+ generics . where_clause = self . parse_where_clause ( ) ;
4607
4614
if self . eat ( & token:: Semi ) {
4608
4615
// If we see a: `struct Foo<T> where T: Copy;` style decl.
4609
4616
( Vec :: new ( ) , Some ( ast:: DUMMY_NODE_ID ) )
@@ -4684,12 +4691,12 @@ impl<'a> Parser<'a> {
4684
4691
token:: get_ident( class_name. clone( ) ) ) ) ;
4685
4692
}
4686
4693
4687
- self . parse_where_clause ( generics ) ;
4694
+ generics . where_clause = self . parse_where_clause ( ) ;
4688
4695
self . expect ( & token:: Semi ) ;
4689
4696
fields
4690
4697
// This is the case where we just see struct Foo<T> where T: Copy;
4691
4698
} else if self . token . is_keyword ( keywords:: Where ) {
4692
- self . parse_where_clause ( generics ) ;
4699
+ generics . where_clause = self . parse_where_clause ( ) ;
4693
4700
self . expect ( & token:: Semi ) ;
4694
4701
Vec :: new ( )
4695
4702
// This case is where we see: `struct Foo<T>;`
@@ -4937,7 +4944,7 @@ impl<'a> Parser<'a> {
4937
4944
4938
4945
let ( ident, mut generics) = self . parse_fn_header ( ) ;
4939
4946
let decl = self . parse_fn_decl ( true ) ;
4940
- self . parse_where_clause ( & mut generics ) ;
4947
+ generics . where_clause = self . parse_where_clause ( ) ;
4941
4948
let hi = self . span . hi ;
4942
4949
self . expect ( & token:: Semi ) ;
4943
4950
P ( ast:: ForeignItem {
@@ -5082,7 +5089,7 @@ impl<'a> Parser<'a> {
5082
5089
fn parse_item_type ( & mut self ) -> ItemInfo {
5083
5090
let ident = self . parse_ident ( ) ;
5084
5091
let mut tps = self . parse_generics ( ) ;
5085
- self . parse_where_clause ( & mut tps ) ;
5092
+ tps . where_clause = self . parse_where_clause ( ) ;
5086
5093
self . expect ( & token:: Eq ) ;
5087
5094
let ty = self . parse_ty_sum ( ) ;
5088
5095
self . expect ( & token:: Semi ) ;
@@ -5182,7 +5189,7 @@ impl<'a> Parser<'a> {
5182
5189
fn parse_item_enum ( & mut self ) -> ItemInfo {
5183
5190
let id = self . parse_ident ( ) ;
5184
5191
let mut generics = self . parse_generics ( ) ;
5185
- self . parse_where_clause ( & mut generics ) ;
5192
+ generics . where_clause = self . parse_where_clause ( ) ;
5186
5193
self . expect ( & token:: OpenDelim ( token:: Brace ) ) ;
5187
5194
5188
5195
let enum_definition = self . parse_enum_def ( & generics) ;
0 commit comments