diff --git a/src/generics.rs b/src/generics.rs index 746184826..1e8fccf03 100644 --- a/src/generics.rs +++ b/src/generics.rs @@ -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::()? - } 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::()? + } else if lookahead.peek(Token![>]) { + break; + } else { + return Err(lookahead.error()); + }, + ); let lookahead = input.lookahead1(); params.push_punct(if lookahead.peek(Token![,]) { input.parse::()? @@ -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()) } diff --git a/tests/repo/mod.rs b/tests/repo/mod.rs index 93f0c32ea..96f039cb3 100644 --- a/tests/repo/mod.rs +++ b/tests/repo/mod.rs @@ -19,9 +19,6 @@ const REVISION: &str = "86d69c705a552236a622eee3fdea94bf13c5f102"; #[rustfmt::skip] static EXCLUDE_FILES: &[&str] = &[ - // TODO: self capture: `impl Sized + use` - "tests/ui/impl-trait/precise-capturing/self-capture.rs", - // TODO: non-lifetime binders: `where for<'a, T> &'a Struct: Trait` // https://github.com/dtolnay/syn/issues/1435 "src/tools/rustfmt/tests/source/issue_5721.rs",