@@ -145,25 +145,24 @@ impl<'a> AstValidator<'a> {
145145 & mut self ,
146146 ty_alias : & TyAlias ,
147147 ) -> Result < ( ) , errors:: WhereClauseBeforeTypeAlias > {
148- if ty_alias. ty . is_none ( ) || !ty_alias. where_clauses . before . has_where_token {
148+ if ty_alias. ty . is_none ( ) || !ty_alias. generics . where_clause . has_where_token {
149149 return Ok ( ( ) ) ;
150150 }
151151
152- let ( before_predicates, after_predicates) =
153- ty_alias. generics . where_clause . predicates . split_at ( ty_alias. where_clauses . split ) ;
154- let span = ty_alias. where_clauses . before . span ;
152+ let span = ty_alias. generics . where_clause . span ;
155153
156- let sugg = if !before_predicates. is_empty ( ) || !ty_alias. where_clauses . after . has_where_token
154+ let sugg = if !ty_alias. generics . where_clause . predicates . is_empty ( )
155+ || !ty_alias. after_where_clause . has_where_token
157156 {
158157 let mut state = State :: new ( ) ;
159158
160- if !ty_alias. where_clauses . after . has_where_token {
159+ if !ty_alias. after_where_clause . has_where_token {
161160 state. space ( ) ;
162161 state. word_space ( "where" ) ;
163162 }
164163
165- let mut first = after_predicates . is_empty ( ) ;
166- for p in before_predicates {
164+ let mut first = ty_alias . after_where_clause . predicates . is_empty ( ) ;
165+ for p in & ty_alias . generics . where_clause . predicates {
167166 if !first {
168167 state. word_space ( "," ) ;
169168 }
@@ -174,7 +173,7 @@ impl<'a> AstValidator<'a> {
174173 errors:: WhereClauseBeforeTypeAliasSugg :: Move {
175174 left : span,
176175 snippet : state. s . eof ( ) ,
177- right : ty_alias. where_clauses . after . span . shrink_to_hi ( ) ,
176+ right : ty_alias. after_where_clause . span . shrink_to_hi ( ) ,
178177 }
179178 } else {
180179 errors:: WhereClauseBeforeTypeAliasSugg :: Remove { span }
@@ -566,11 +565,7 @@ impl<'a> AstValidator<'a> {
566565 self . dcx ( ) . emit_err ( errors:: BoundInContext { span, ctx } ) ;
567566 }
568567
569- fn check_foreign_ty_genericless (
570- & self ,
571- generics : & Generics ,
572- where_clauses : & TyAliasWhereClauses ,
573- ) {
568+ fn check_foreign_ty_genericless ( & self , generics : & Generics , after_where_clause : & WhereClause ) {
574569 let cannot_have = |span, descr, remove_descr| {
575570 self . dcx ( ) . emit_err ( errors:: ExternTypesCannotHave {
576571 span,
@@ -584,14 +579,14 @@ impl<'a> AstValidator<'a> {
584579 cannot_have ( generics. span , "generic parameters" , "generic parameters" ) ;
585580 }
586581
587- let check_where_clause = |where_clause : TyAliasWhereClause | {
582+ let check_where_clause = |where_clause : & WhereClause | {
588583 if where_clause. has_where_token {
589584 cannot_have ( where_clause. span , "`where` clauses" , "`where` clause" ) ;
590585 }
591586 } ;
592587
593- check_where_clause ( where_clauses . before ) ;
594- check_where_clause ( where_clauses . after ) ;
588+ check_where_clause ( & generics . where_clause ) ;
589+ check_where_clause ( & after_where_clause ) ;
595590 }
596591
597592 fn check_foreign_kind_bodyless ( & self , ident : Ident , kind : & str , body_span : Option < Span > ) {
@@ -1261,7 +1256,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
12611256 visit:: walk_item ( self , item) ;
12621257 }
12631258 ItemKind :: TyAlias (
1264- ty_alias @ box TyAlias { defaultness, bounds, where_clauses , ty, .. } ,
1259+ ty_alias @ box TyAlias { defaultness, bounds, after_where_clause , ty, .. } ,
12651260 ) => {
12661261 self . check_defaultness ( item. span , * defaultness) ;
12671262 if ty. is_none ( ) {
@@ -1276,9 +1271,9 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
12761271 if let Err ( err) = self . check_type_alias_where_clause_location ( ty_alias) {
12771272 self . dcx ( ) . emit_err ( err) ;
12781273 }
1279- } else if where_clauses . after . has_where_token {
1274+ } else if after_where_clause . has_where_token {
12801275 self . dcx ( ) . emit_err ( errors:: WhereClauseAfterTypeAlias {
1281- span : where_clauses . after . span ,
1276+ span : after_where_clause . span ,
12821277 help : self . sess . is_nightly_build ( ) ,
12831278 } ) ;
12841279 }
@@ -1308,15 +1303,15 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
13081303 defaultness,
13091304 ident,
13101305 generics,
1311- where_clauses ,
1306+ after_where_clause ,
13121307 bounds,
13131308 ty,
13141309 ..
13151310 } ) => {
13161311 self . check_defaultness ( fi. span , * defaultness) ;
13171312 self . check_foreign_kind_bodyless ( * ident, "type" , ty. as_ref ( ) . map ( |b| b. span ) ) ;
13181313 self . check_type_no_bounds ( bounds, "`extern` blocks" ) ;
1319- self . check_foreign_ty_genericless ( generics, where_clauses ) ;
1314+ self . check_foreign_ty_genericless ( generics, after_where_clause ) ;
13201315 self . check_foreign_item_ascii_only ( * ident) ;
13211316 }
13221317 ForeignItemKind :: Static ( box StaticItem { ident, safety, expr, .. } ) => {
0 commit comments