Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse self captures: impl Sized + use<Self> #1772

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading