Skip to content

Commit

Permalink
Parse self captures: impl Sized + use<Self>
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Oct 23, 2024
1 parent e478e03 commit 2a9e9fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
21 changes: 12 additions & 9 deletions src/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,13 +1046,16 @@ pub(crate) mod parsing {
let mut params = Punctuated::new();
loop {
let lookahead = input.lookahead1();
params.push_value(if lookahead.peek(Lifetime) || lookahead.peek(Ident) {
input.parse::<CapturedParam>()?
} else if lookahead.peek(Token![>]) {
break;
} else {
return Err(lookahead.error());
});
params.push_value(
if lookahead.peek(Lifetime) || lookahead.peek(Ident) || input.peek(Token![Self])
{
input.parse::<CapturedParam>()?
} else if lookahead.peek(Token![>]) {
break;
} else {
return Err(lookahead.error());
},
);
let lookahead = input.lookahead1();
params.push_punct(if lookahead.peek(Token![,]) {
input.parse::<Token![,]>()?
Expand All @@ -1079,8 +1082,8 @@ pub(crate) mod parsing {
let lookahead = input.lookahead1();
if lookahead.peek(Lifetime) {
input.parse().map(CapturedParam::Lifetime)
} else if lookahead.peek(Ident) {
input.parse().map(CapturedParam::Ident)
} else if lookahead.peek(Ident) || input.peek(Token![Self]) {
input.call(Ident::parse_any).map(CapturedParam::Ident)
} else {
Err(lookahead.error())
}
Expand Down
3 changes: 0 additions & 3 deletions tests/repo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ const REVISION: &str = "86d69c705a552236a622eee3fdea94bf13c5f102";

#[rustfmt::skip]
static EXCLUDE_FILES: &[&str] = &[
// TODO: self capture: `impl Sized + use<Self>`
"tests/ui/impl-trait/precise-capturing/self-capture.rs",

// TODO: non-lifetime binders: `where for<'a, T> &'a Struct<T>: Trait`
// https://github.com/dtolnay/syn/issues/1435
"src/tools/rustfmt/tests/source/issue_5721.rs",
Expand Down

0 comments on commit 2a9e9fb

Please sign in to comment.