@@ -39,11 +39,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
39
39
) ;
40
40
41
41
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 , .. } ) ) {
46
43
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
+ }
47
49
}
48
50
}
49
51
@@ -458,8 +460,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
458
460
let default_counts = gen_params. own_defaults ( ) ;
459
461
let param_counts = gen_params. own_counts ( ) ;
460
462
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 ( ) ;
463
465
464
466
if gen_pos != GenericArgPosition :: Type && !gen_args. bindings . is_empty ( ) {
465
467
Self :: prohibit_assoc_ty_binding ( tcx, gen_args. bindings [ 0 ] . span ) ;
@@ -517,7 +519,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
517
519
518
520
let min_expected_lifetime_args = if infer_lifetimes { 0 } else { param_counts. lifetimes } ;
519
521
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 ( ) ;
521
523
522
524
let lifetimes_correct = check_lifetime_args (
523
525
min_expected_lifetime_args,
@@ -588,14 +590,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
588
590
- default_counts. consts
589
591
} ;
590
592
debug ! ( "expected_min: {:?}" , expected_min) ;
591
- debug ! ( "arg_counts.lifetimes: {:?}" , arg_counts . lifetimes ) ;
593
+ debug ! ( "arg_counts.lifetimes: {:?}" , gen_args . num_lifetime_params ( ) ) ;
592
594
593
595
check_types_and_consts (
594
596
expected_min,
595
597
param_counts. consts + named_type_param_count,
596
- arg_counts . consts + arg_counts . types + arg_counts . infer ,
598
+ gen_args . num_generic_params ( ) ,
597
599
param_counts. lifetimes + has_self as usize ,
598
- arg_counts . lifetimes ,
600
+ gen_args . num_lifetime_params ( ) ,
599
601
)
600
602
} ;
601
603
@@ -673,8 +675,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
673
675
position : GenericArgPosition ,
674
676
) -> ExplicitLateBound {
675
677
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 ( ) ;
678
679
679
680
if infer_lifetimes {
680
681
return ExplicitLateBound :: No ;
@@ -687,7 +688,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
687
688
let span = args. args [ 0 ] . span ( ) ;
688
689
689
690
if position == GenericArgPosition :: Value
690
- && arg_counts . lifetimes != param_counts. lifetimes
691
+ && args . num_lifetime_params ( ) != param_counts. lifetimes
691
692
{
692
693
let mut err = tcx. sess . struct_span_err ( span, msg) ;
693
694
err. span_note ( span_late, note) ;
0 commit comments