@@ -37,6 +37,7 @@ pub(crate) fn validate(root: &SyntaxNode, errors: &mut Vec<SyntaxError>) {
37
37
ast:: FnPtrType ( it) => validate_trait_object_fn_ptr_ret_ty( it, errors) ,
38
38
ast:: MacroRules ( it) => validate_macro_rules( it, errors) ,
39
39
ast:: LetExpr ( it) => validate_let_expr( it, errors) ,
40
+ ast:: ImplTraitType ( it) => validate_impl_object_ty( it, errors) ,
40
41
_ => ( ) ,
41
42
}
42
43
}
@@ -315,21 +316,10 @@ fn validate_path_keywords(segment: ast::PathSegment, errors: &mut Vec<SyntaxErro
315
316
}
316
317
317
318
fn validate_trait_object_ref_ty ( ty : ast:: RefType , errors : & mut Vec < SyntaxError > ) {
318
- match ty. ty ( ) {
319
- Some ( ast:: Type :: DynTraitType ( ty) ) => {
320
- if let Some ( err) = validate_trait_object_ty ( ty) {
321
- errors. push ( err) ;
322
- }
323
- }
324
- Some ( ast:: Type :: ImplTraitType ( ty) ) => {
325
- if ty. type_bound_list ( ) . map_or ( 0 , |tbl| tbl. bounds ( ) . count ( ) ) == 0 {
326
- errors. push ( SyntaxError :: new (
327
- "At least one trait must be specified" ,
328
- ty. syntax ( ) . text_range ( ) ,
329
- ) ) ;
330
- }
319
+ if let Some ( ast:: Type :: DynTraitType ( ty) ) = ty. ty ( ) {
320
+ if let Some ( err) = validate_trait_object_ty ( ty) {
321
+ errors. push ( err) ;
331
322
}
332
- _ => { }
333
323
}
334
324
}
335
325
@@ -372,6 +362,15 @@ fn validate_trait_object_ty(ty: ast::DynTraitType) -> Option<SyntaxError> {
372
362
}
373
363
}
374
364
365
+ fn validate_impl_object_ty ( ty : ast:: ImplTraitType , errors : & mut Vec < SyntaxError > ) {
366
+ if ty. type_bound_list ( ) . map_or ( 0 , |tbl| tbl. bounds ( ) . count ( ) ) == 0 {
367
+ errors. push ( SyntaxError :: new (
368
+ "At least one trait must be specified" ,
369
+ ty. syntax ( ) . text_range ( ) ,
370
+ ) ) ;
371
+ }
372
+ }
373
+
375
374
fn validate_macro_rules ( mac : ast:: MacroRules , errors : & mut Vec < SyntaxError > ) {
376
375
if let Some ( vis) = mac. visibility ( ) {
377
376
errors. push ( SyntaxError :: new (
0 commit comments