@@ -39,11 +39,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
3939 ) ;
4040
4141 if let GenericParamDefKind :: Const { .. } = param. kind {
42- if matches ! (
43- arg,
44- GenericArg :: Type ( hir:: Ty { kind: hir:: TyKind :: Infer , .. } ) | GenericArg :: Infer ( _)
45- ) {
42+ if matches ! ( arg, GenericArg :: Type ( hir:: Ty { kind: hir:: TyKind :: Infer , .. } ) ) {
4643 err. help ( "const arguments cannot yet be inferred with `_`" ) ;
44+ if sess. is_nightly_build ( ) {
45+ err. help (
46+ "add `#![feature(generic_arg_infer)]` to the crate attributes to enable" ,
47+ ) ;
48+ }
4749 }
4850 }
4951
@@ -458,8 +460,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
458460 let default_counts = gen_params. own_defaults ( ) ;
459461 let param_counts = gen_params. own_counts ( ) ;
460462 let named_type_param_count = param_counts. types - has_self as usize ;
461- let arg_counts = gen_args . own_counts ( ) ;
462- let infer_lifetimes = gen_pos != GenericArgPosition :: Type && arg_counts . lifetimes == 0 ;
463+ let infer_lifetimes =
464+ gen_pos != GenericArgPosition :: Type && !gen_args . has_lifetime_params ( ) ;
463465
464466 if gen_pos != GenericArgPosition :: Type && !gen_args. bindings . is_empty ( ) {
465467 Self :: prohibit_assoc_ty_binding ( tcx, gen_args. bindings [ 0 ] . span ) ;
@@ -517,7 +519,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
517519
518520 let min_expected_lifetime_args = if infer_lifetimes { 0 } else { param_counts. lifetimes } ;
519521 let max_expected_lifetime_args = param_counts. lifetimes ;
520- let num_provided_lifetime_args = arg_counts . lifetimes ;
522+ let num_provided_lifetime_args = gen_args . num_lifetime_params ( ) ;
521523
522524 let lifetimes_correct = check_lifetime_args (
523525 min_expected_lifetime_args,
@@ -588,14 +590,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
588590 - default_counts. consts
589591 } ;
590592 debug ! ( "expected_min: {:?}" , expected_min) ;
591- debug ! ( "arg_counts.lifetimes: {:?}" , arg_counts . lifetimes ) ;
593+ debug ! ( "arg_counts.lifetimes: {:?}" , gen_args . num_lifetime_params ( ) ) ;
592594
593595 check_types_and_consts (
594596 expected_min,
595597 param_counts. consts + named_type_param_count,
596- arg_counts . consts + arg_counts . types + arg_counts . infer ,
598+ gen_args . num_generic_params ( ) ,
597599 param_counts. lifetimes + has_self as usize ,
598- arg_counts . lifetimes ,
600+ gen_args . num_lifetime_params ( ) ,
599601 )
600602 } ;
601603
@@ -673,8 +675,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
673675 position : GenericArgPosition ,
674676 ) -> ExplicitLateBound {
675677 let param_counts = def. own_counts ( ) ;
676- let arg_counts = args. own_counts ( ) ;
677- let infer_lifetimes = position != GenericArgPosition :: Type && arg_counts. lifetimes == 0 ;
678+ let infer_lifetimes = position != GenericArgPosition :: Type && !args. has_lifetime_params ( ) ;
678679
679680 if infer_lifetimes {
680681 return ExplicitLateBound :: No ;
@@ -687,7 +688,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
687688 let span = args. args [ 0 ] . span ( ) ;
688689
689690 if position == GenericArgPosition :: Value
690- && arg_counts . lifetimes != param_counts. lifetimes
691+ && args . num_lifetime_params ( ) != param_counts. lifetimes
691692 {
692693 let mut err = tcx. sess . struct_span_err ( span, msg) ;
693694 err. span_note ( span_late, note) ;
0 commit comments