@@ -8,14 +8,18 @@ use rustc_ast::{
8
8
AssocItemConstraintKind , BlockCheckMode , GenericArg , GenericArgs , Generics , ParenthesizedArgs ,
9
9
Path , PathSegment , QSelf ,
10
10
} ;
11
- use rustc_errors:: { Applicability , Diag , PResult } ;
11
+ use rustc_errors:: { Applicability , Diag , DiagCtxtHandle , PResult } ;
12
12
use rustc_span:: { BytePos , Ident , Span , kw, sym} ;
13
13
use thin_vec:: ThinVec ;
14
14
use tracing:: debug;
15
15
16
16
use super :: ty:: { AllowPlus , RecoverQPath , RecoverReturnSign } ;
17
17
use super :: { Parser , Restrictions , TokenType } ;
18
- use crate :: errors:: { self , FnPathFoundNamedParams , PathSingleColon , PathTripleColon } ;
18
+ use crate :: ast:: { PatKind , Ty , TyKind } ;
19
+ use crate :: errors:: {
20
+ self , FnPathFoundNamedParams , PathFoundAttributeInParams , PathFoundCVariadicParams ,
21
+ PathSingleColon , PathTripleColon ,
22
+ } ;
19
23
use crate :: exp;
20
24
use crate :: parser:: { CommaRecoveryMode , RecoverColon , RecoverComma } ;
21
25
@@ -396,21 +400,32 @@ impl<'a> Parser<'a> {
396
400
snapshot = Some ( self . create_snapshot_for_diagnostic ( ) ) ;
397
401
}
398
402
399
- let dcx = self . dcx ( ) ;
400
- let ( inputs, _) = match self . parse_paren_comma_seq ( |p| {
401
- if p. is_named_param ( ) {
402
- let param = p. parse_param_general ( |_| false , false ) ;
403
- if let Ok ( ref param) = param {
404
- dcx. emit_err ( FnPathFoundNamedParams {
405
- named_param_span : param. pat . span ,
406
- } ) ;
407
- }
408
- param. map ( |param| param. ty )
409
- } else {
410
- p. parse_ty ( )
411
- }
412
- } ) {
413
- Ok ( ( output, trailing) ) => ( output, trailing) ,
403
+ let parse_type_params =
404
+ |p : & mut Parser < ' a > , dcx : & mut DiagCtxtHandle < ' a > | -> PResult < ' a , P < Ty > > {
405
+ let param = p. parse_param_general ( |_| false , false , false ) ;
406
+ param. map ( move |param| {
407
+ if !matches ! ( param. pat. kind, PatKind :: Missing ) {
408
+ dcx. emit_err ( FnPathFoundNamedParams {
409
+ named_param_span : param. pat . span ,
410
+ } ) ;
411
+ }
412
+ if matches ! ( param. ty. kind, TyKind :: CVarArgs ) {
413
+ dcx. emit_err ( PathFoundCVariadicParams { span : param. pat . span } ) ;
414
+ }
415
+ if !param. attrs . is_empty ( ) {
416
+ dcx. emit_err ( PathFoundAttributeInParams {
417
+ span : param. attrs [ 0 ] . span ,
418
+ } ) ;
419
+ }
420
+ param. ty
421
+ } )
422
+ } ;
423
+
424
+ let mut dcx = self . dcx ( ) ;
425
+ let ( inputs, _) = match self
426
+ . parse_paren_comma_seq ( |p| parse_type_params ( p, & mut dcx) )
427
+ {
428
+ Ok ( output) => output,
414
429
Err ( mut error) if prev_token_before_parsing == token:: PathSep => {
415
430
error. span_label (
416
431
prev_token_before_parsing. span . to ( token_before_parsing. span ) ,
0 commit comments