Skip to content

Commit c9bdfac

Browse files
committed
Tweak parsing logic for TypeParamBound
1 parent fcdba50 commit c9bdfac

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/generics.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -801,25 +801,23 @@ pub(crate) mod parsing {
801801
let mut params = Punctuated::new();
802802
loop {
803803
let lookahead = input.lookahead1();
804-
let capture = if lookahead.peek(Lifetime) {
805-
input.parse().map(CapturedParam::Lifetime)
804+
params.push_value(if lookahead.peek(Lifetime) {
805+
input.parse().map(CapturedParam::Lifetime)?
806806
} else if lookahead.peek(Ident) {
807-
input.parse().map(CapturedParam::Ident)
807+
input.parse().map(CapturedParam::Ident)?
808808
} else if lookahead.peek(Token![>]) {
809809
break;
810810
} else {
811811
return Err(lookahead.error());
812-
}?;
813-
params.push_value(capture);
812+
});
814813
let lookahead = input.lookahead1();
815-
let comma = if lookahead.peek(Token![,]) {
816-
input.parse::<Token![,]>()
814+
params.push_punct(if lookahead.peek(Token![,]) {
815+
input.parse::<Token![,]>()?
817816
} else if lookahead.peek(Token![>]) {
818817
break;
819818
} else {
820819
return Err(lookahead.error());
821-
}?;
822-
params.push_punct(comma);
820+
});
823821
}
824822
let gt_token: Token![>] = input.parse()?;
825823
return if allow_precise_capture {

0 commit comments

Comments
 (0)