Skip to content

Commit

Permalink
Merge pull request #927 from dtolnay/const
Browse files Browse the repository at this point in the history
Allow lifetime params to parse after const params
  • Loading branch information
dtolnay committed Nov 23, 2020
2 parents c8719be + 4703c2f commit 11091fa
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
5 changes: 1 addition & 4 deletions src/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -610,27 +610,24 @@ pub mod parsing {
let lt_token: Token![<] = input.parse()?;

let mut params = Punctuated::new();
let mut allow_lifetime_param = true;
loop {
if input.peek(Token![>]) {
break;
}

let attrs = input.call(Attribute::parse_outer)?;
let lookahead = input.lookahead1();
if allow_lifetime_param && lookahead.peek(Lifetime) {
if lookahead.peek(Lifetime) {
params.push_value(GenericParam::Lifetime(LifetimeDef {
attrs,
..input.parse()?
}));
} else if lookahead.peek(Ident) {
allow_lifetime_param = false;
params.push_value(GenericParam::Type(TypeParam {
attrs,
..input.parse()?
}));
} else if lookahead.peek(Token![const]) {
allow_lifetime_param = false;
params.push_value(GenericParam::Const(ConstParam {
attrs,
..input.parse()?
Expand Down
5 changes: 0 additions & 5 deletions tests/repo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ const REVISION: &str = "9d78d1d02761b906038ba4d54c5f3427f920f5fb";

#[rustfmt::skip]
static EXCLUDE: &[&str] = &[
// TODO: const parameter before lifetime parameter (#920)
"src/test/ui/const-generics/argument_order.rs",
"src/test/ui/const-generics/const-param-before-other-params.rs",
"src/test/ui/const-generics/defaults/intermixed-lifetime.rs",

// TODO: const block (#921)
"src/test/ui/inline-const/const-expr-array-init.rs",
"src/test/ui/inline-const/const-expr-basic.rs",
Expand Down

0 comments on commit 11091fa

Please sign in to comment.