Skip to content

Commit 60de331

Browse files
authored
Merge pull request #1907 from dtolnay/forconst
Allow const parameters in for<>
2 parents 11934e5 + 2aac6d7 commit 60de331

File tree

2 files changed

+6
-21
lines changed

2 files changed

+6
-21
lines changed

src/generics.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -671,23 +671,7 @@ pub(crate) mod parsing {
671671
lifetimes: {
672672
let mut lifetimes = Punctuated::new();
673673
while !input.peek(Token![>]) {
674-
let attrs = input.call(Attribute::parse_outer)?;
675-
676-
let lookahead = input.lookahead1();
677-
if lookahead.peek(Lifetime) {
678-
lifetimes.push_value(GenericParam::Lifetime(LifetimeParam {
679-
attrs,
680-
..input.parse()?
681-
}));
682-
} else if cfg!(feature = "full") && lookahead.peek(Ident) {
683-
lifetimes.push_value(GenericParam::Type(TypeParam {
684-
attrs,
685-
..input.parse()?
686-
}));
687-
} else {
688-
return Err(lookahead.error());
689-
}
690-
674+
lifetimes.push_value(input.parse()?);
691675
if input.peek(Token![>]) {
692676
break;
693677
}

tests/repo/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ const REVISION: &str = "3672a55b7cfd0a12e7097197b6242872473ffaa7";
2020

2121
#[rustfmt::skip]
2222
static EXCLUDE_FILES: &[&str] = &[
23+
// TODO: non-lifetime binders on closures: `let _ = for<T> || {}`
24+
// https://github.com/dtolnay/syn/issues/1906
25+
"src/tools/rustfmt/tests/target/non-lifetime-binders.rs",
26+
"src/tools/rustfmt/tests/source/non-lifetime-binders.rs",
27+
2328
// TODO: const traits: `pub const trait Trait {}`
2429
// https://github.com/dtolnay/syn/issues/1887
2530
"src/tools/clippy/tests/ui/assign_ops.rs",
@@ -308,10 +313,6 @@ static EXCLUDE_FILES: &[&str] = &[
308313
// Lifetimes and types out of order in angle bracketed path arguments
309314
"tests/ui/parser/constraints-before-generic-args-syntactic-pass.rs",
310315

311-
// Const parameter in lifetime binder: `for<const C: usize> [T; C]: Sized`
312-
"src/tools/rustfmt/tests/target/non-lifetime-binders.rs",
313-
"src/tools/rustfmt/tests/source/non-lifetime-binders.rs",
314-
315316
// Deprecated anonymous parameter syntax in traits
316317
"src/tools/rustfmt/tests/source/trait.rs",
317318
"src/tools/rustfmt/tests/target/trait.rs",

0 commit comments

Comments
 (0)