@@ -3,7 +3,7 @@ use crate::astconv::{
33 AstConv , CreateSubstsForGenericArgsCtxt , ExplicitLateBound , GenericArgCountMismatch ,
44 GenericArgCountResult , GenericArgPosition ,
55} ;
6- use crate :: errors:: { AssocTypeBindingNotAllowed , ExplicitGenericArgsWithImplTrait } ;
6+ use crate :: errors:: AssocTypeBindingNotAllowed ;
77use crate :: structured_errors:: { GenericArgsInfo , StructuredDiagnostic , WrongNumberOfGenericArgs } ;
88use rustc_ast:: ast:: ParamKindOrd ;
99use rustc_errors:: { struct_span_err, Applicability , Diagnostic , MultiSpan } ;
@@ -397,19 +397,24 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
397397 is_method_call : IsMethodCall ,
398398 ) -> GenericArgCountResult {
399399 let empty_args = hir:: GenericArgs :: none ( ) ;
400- let suppress_mismatch = Self :: check_impl_trait ( tcx, seg, generics) ;
401-
402400 let gen_args = seg. args . unwrap_or ( & empty_args) ;
403401 let gen_pos = if is_method_call == IsMethodCall :: Yes {
404402 GenericArgPosition :: MethodCall
405403 } else {
406404 GenericArgPosition :: Value
407405 } ;
408406 let has_self = generics. parent . is_none ( ) && generics. has_self ;
409- let infer_args = seg. infer_args || suppress_mismatch;
410407
411408 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 ,
413418 )
414419 }
415420
@@ -431,19 +436,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
431436 let param_counts = gen_params. own_counts ( ) ;
432437
433438 // 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 ( ) ;
447447 let named_type_param_count =
448448 param_counts. types - has_self as usize - synth_type_param_count;
449449 let infer_lifetimes =
@@ -611,40 +611,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
611611 }
612612 }
613613
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-
648614 /// Emits an error regarding forbidden type binding associations
649615 pub fn prohibit_assoc_ty_binding ( tcx : TyCtxt < ' _ > , span : Span ) {
650616 tcx. sess . emit_err ( AssocTypeBindingNotAllowed { span } ) ;
0 commit comments