@@ -3,7 +3,7 @@ use crate::astconv::{
3
3
AstConv , CreateSubstsForGenericArgsCtxt , ExplicitLateBound , GenericArgCountMismatch ,
4
4
GenericArgCountResult , GenericArgPosition ,
5
5
} ;
6
- use crate :: errors:: { AssocTypeBindingNotAllowed , ExplicitGenericArgsWithImplTrait } ;
6
+ use crate :: errors:: AssocTypeBindingNotAllowed ;
7
7
use crate :: structured_errors:: { GenericArgsInfo , StructuredDiagnostic , WrongNumberOfGenericArgs } ;
8
8
use rustc_ast:: ast:: ParamKindOrd ;
9
9
use rustc_errors:: { struct_span_err, Applicability , Diagnostic , MultiSpan } ;
@@ -397,19 +397,24 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
397
397
is_method_call : IsMethodCall ,
398
398
) -> GenericArgCountResult {
399
399
let empty_args = hir:: GenericArgs :: none ( ) ;
400
- let suppress_mismatch = Self :: check_impl_trait ( tcx, seg, generics) ;
401
-
402
400
let gen_args = seg. args . unwrap_or ( & empty_args) ;
403
401
let gen_pos = if is_method_call == IsMethodCall :: Yes {
404
402
GenericArgPosition :: MethodCall
405
403
} else {
406
404
GenericArgPosition :: Value
407
405
} ;
408
406
let has_self = generics. parent . is_none ( ) && generics. has_self ;
409
- let infer_args = seg. infer_args || suppress_mismatch;
410
407
411
408
Self :: check_generic_arg_count (
412
- tcx, span, def_id, seg, generics, gen_args, gen_pos, has_self, infer_args,
409
+ tcx,
410
+ span,
411
+ def_id,
412
+ seg,
413
+ generics,
414
+ gen_args,
415
+ gen_pos,
416
+ has_self,
417
+ seg. infer_args ,
413
418
)
414
419
}
415
420
@@ -431,19 +436,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
431
436
let param_counts = gen_params. own_counts ( ) ;
432
437
433
438
// Subtracting from param count to ensure type params synthesized from `impl Trait`
434
- // cannot be explicitly specified even with `explicit_generic_args_with_impl_trait`
435
- // feature enabled.
436
- let synth_type_param_count = if tcx. features ( ) . explicit_generic_args_with_impl_trait {
437
- gen_params
438
- . params
439
- . iter ( )
440
- . filter ( |param| {
441
- matches ! ( param. kind, ty:: GenericParamDefKind :: Type { synthetic: true , .. } )
442
- } )
443
- . count ( )
444
- } else {
445
- 0
446
- } ;
439
+ // cannot be explicitly specified.
440
+ let synth_type_param_count = gen_params
441
+ . params
442
+ . iter ( )
443
+ . filter ( |param| {
444
+ matches ! ( param. kind, ty:: GenericParamDefKind :: Type { synthetic: true , .. } )
445
+ } )
446
+ . count ( ) ;
447
447
let named_type_param_count =
448
448
param_counts. types - has_self as usize - synth_type_param_count;
449
449
let infer_lifetimes =
@@ -611,40 +611,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
611
611
}
612
612
}
613
613
614
- /// Report error if there is an explicit type parameter when using `impl Trait`.
615
- pub ( crate ) fn check_impl_trait (
616
- tcx : TyCtxt < ' _ > ,
617
- seg : & hir:: PathSegment < ' _ > ,
618
- generics : & ty:: Generics ,
619
- ) -> bool {
620
- if seg. infer_args || tcx. features ( ) . explicit_generic_args_with_impl_trait {
621
- return false ;
622
- }
623
-
624
- let impl_trait = generics. has_impl_trait ( ) ;
625
-
626
- if impl_trait {
627
- let spans = seg
628
- . args ( )
629
- . args
630
- . iter ( )
631
- . filter_map ( |arg| match arg {
632
- GenericArg :: Infer ( _) | GenericArg :: Type ( _) | GenericArg :: Const ( _) => {
633
- Some ( arg. span ( ) )
634
- }
635
- _ => None ,
636
- } )
637
- . collect :: < Vec < _ > > ( ) ;
638
-
639
- tcx. sess . emit_err ( ExplicitGenericArgsWithImplTrait {
640
- spans,
641
- is_nightly_build : tcx. sess . is_nightly_build ( ) . then_some ( ( ) ) ,
642
- } ) ;
643
- }
644
-
645
- impl_trait
646
- }
647
-
648
614
/// Emits an error regarding forbidden type binding associations
649
615
pub fn prohibit_assoc_ty_binding ( tcx : TyCtxt < ' _ > , span : Span ) {
650
616
tcx. sess . emit_err ( AssocTypeBindingNotAllowed { span } ) ;
0 commit comments