@@ -317,10 +317,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
317
317
}
318
318
319
319
// Prohibit explicit lifetime arguments if late-bound lifetime parameters are present.
320
- let mut reported_late_bound_region_err = false ;
320
+ let mut explicit_lifetimes = Ok ( ( ) ) ;
321
321
if !infer_lifetimes {
322
322
if let Some ( span_late) = def. has_late_bound_regions {
323
- reported_late_bound_region_err = true ;
323
+ explicit_lifetimes = Err ( GenericArgCountMismatch ) ;
324
324
let msg = "cannot specify lifetime arguments explicitly \
325
325
if late bound lifetime parameters are present";
326
326
let note = "the late bound lifetime parameter is introduced here" ;
@@ -354,7 +354,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
354
354
// For kinds without defaults (e.g.., lifetimes), `required == permitted`.
355
355
// For other kinds (i.e., types), `permitted` may be greater than `required`.
356
356
if required <= provided && provided <= permitted {
357
- return false ;
357
+ return Ok ( ( ) ) ;
358
358
}
359
359
360
360
// Unfortunately lifetime and type parameter mismatches are typically styled
@@ -405,49 +405,49 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
405
405
}
406
406
err. emit ( ) ;
407
407
408
- true
408
+ Err ( GenericArgCountMismatch )
409
409
} ;
410
410
411
- let mut arg_count_mismatch = reported_late_bound_region_err ;
411
+ let mut arg_count_correct = explicit_lifetimes ;
412
412
let mut unexpected_spans = vec ! [ ] ;
413
413
414
- if !reported_late_bound_region_err
414
+ if arg_count_correct . is_ok ( )
415
415
&& ( !infer_lifetimes || arg_counts. lifetimes > param_counts. lifetimes )
416
416
{
417
- arg_count_mismatch |= check_kind_count (
417
+ arg_count_correct = arg_count_correct . and ( check_kind_count (
418
418
"lifetime" ,
419
419
param_counts. lifetimes ,
420
420
param_counts. lifetimes ,
421
421
arg_counts. lifetimes ,
422
422
0 ,
423
423
& mut unexpected_spans,
424
- ) ;
424
+ ) ) ;
425
425
}
426
426
// FIXME(const_generics:defaults)
427
427
if !infer_args || arg_counts. consts > param_counts. consts {
428
- arg_count_mismatch |= check_kind_count (
428
+ arg_count_correct = arg_count_correct . and ( check_kind_count (
429
429
"const" ,
430
430
param_counts. consts ,
431
431
param_counts. consts ,
432
432
arg_counts. consts ,
433
433
arg_counts. lifetimes + arg_counts. types ,
434
434
& mut unexpected_spans,
435
- ) ;
435
+ ) ) ;
436
436
}
437
437
// Note that type errors are currently be emitted *after* const errors.
438
438
if !infer_args || arg_counts. types > param_counts. types - defaults. types - has_self as usize
439
439
{
440
- arg_count_mismatch |= check_kind_count (
440
+ arg_count_correct = arg_count_correct . and ( check_kind_count (
441
441
"type" ,
442
442
param_counts. types - defaults. types - has_self as usize ,
443
443
param_counts. types - has_self as usize ,
444
444
arg_counts. types ,
445
445
arg_counts. lifetimes ,
446
446
& mut unexpected_spans,
447
- ) ;
447
+ ) ) ;
448
448
}
449
449
450
- ( if arg_count_mismatch { Err ( GenericArgCountMismatch ) } else { Ok ( ( ) ) } , unexpected_spans)
450
+ ( arg_count_correct , unexpected_spans)
451
451
}
452
452
453
453
/// Report an error that a generic argument did not match the generic parameter that was
0 commit comments