@@ -4580,7 +4580,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
45804580 // Check provided lifetime parameters.
45814581 let lifetime_defs = segment. map_or ( & [ ] [ ..] , |( _, generics) | & generics. regions ) ;
45824582 if lifetimes. len ( ) > lifetime_defs. len ( ) {
4583- let span = lifetimes[ lifetime_defs. len ( ) ] . span ;
45844583 struct_span_err ! ( self . tcx. sess, span, E0088 ,
45854584 "too many lifetime parameters provided: \
45864585 expected {}, found {}",
@@ -4589,6 +4588,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
45894588 . span_label ( span, & format ! ( "unexpected lifetime parameter{}" ,
45904589 match lifetimes. len( ) { 1 => "" , _ => "s" } ) )
45914590 . emit ( ) ;
4591+ } else if lifetimes. len ( ) > 0 && lifetimes. len ( ) < lifetime_defs. len ( ) {
4592+ struct_span_err ! ( self . tcx. sess, span, E0090 ,
4593+ "too few lifetime parameters provided: \
4594+ expected {}, found {}",
4595+ count( lifetime_defs. len( ) ) ,
4596+ count( lifetimes. len( ) ) )
4597+ . span_label ( span, & format ! ( "too few lifetime parameters" ) )
4598+ . emit ( ) ;
45924599 }
45934600
45944601 // The case where there is not enough lifetime parameters is not checked,
0 commit comments