@@ -623,14 +623,15 @@ fn parse_extras(cursor: &mut Cursor) -> Result<Vec<ExtraName>, Pep508Error> {
623
623
loop {
624
624
cursor. eat_whitespace ( ) ;
625
625
626
- // end of the extras section
626
+ // End of the extras section
627
627
if let Some ( ']' ) = cursor. peek_char ( ) {
628
628
cursor. next ( ) ;
629
629
break ;
630
630
}
631
631
632
- // comma separator, except for the first iteration
632
+ // Comma separator
633
633
match ( cursor. peek ( ) , is_first_iteration) {
634
+ // For the first iteration, we don't expect a comma
634
635
( Some ( ( pos, ',' ) ) , true ) => {
635
636
return Err ( Pep508Error {
636
637
message : Pep508ErrorSource :: String (
@@ -641,6 +642,7 @@ fn parse_extras(cursor: &mut Cursor) -> Result<Vec<ExtraName>, Pep508Error> {
641
642
input : cursor. to_string ( ) ,
642
643
} ) ;
643
644
}
645
+ // For the other iterations, the comma is required
644
646
( Some ( ( _, ',' ) ) , false ) => {
645
647
cursor. next ( ) ;
646
648
}
@@ -708,8 +710,9 @@ fn parse_extras(cursor: &mut Cursor) -> Result<Vec<ExtraName>, Pep508Error> {
708
710
}
709
711
_ => { }
710
712
} ;
711
- cursor. eat_whitespace ( ) ;
712
713
// wsp* after the identifier
714
+ cursor. eat_whitespace ( ) ;
715
+ // Add the parsed extra
713
716
extras. push (
714
717
ExtraName :: new ( buffer) . expect ( "`ExtraName` validation should match PEP 508 parsing" ) ,
715
718
) ;
0 commit comments