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

chore(deps): Update to syn 2 #12

Merged
merged 4 commits into from
Oct 24, 2024
Merged

chore(deps): Update to syn 2 #12

merged 4 commits into from
Oct 24, 2024

Conversation

jsdw
Copy link
Contributor

@jsdw jsdw commented Oct 23, 2024

cargo test passes everything and cargo fmt is happy. I added some basic CI to run this automatically but it probably needs enabling :)

@jsdw jsdw marked this pull request as ready for review October 23, 2024 18:01
Comment on lines +112 to +114
fn visit_receiver(&mut self, _: &'ast syn::Receiver) {
// Do nothing: explicitly ignore any receiver type.
}
Copy link
Contributor Author

@jsdw jsdw Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this, the built-in visit_receiver is called which then calls visit_type on the receiver type (leading to unwanted Clone bounds which break some tests). Syn 1.0 didn't call visit_type on receivers (I'm a little confused because the receiver type is implicit, but it seems to be represented as if the type is explicit when parsing).

let (expr, expanded) = self.custom_fold_expr(expr);
Stmt::Expr(expr, if expanded { None } else { semi })
}
Stmt::Macro(macro_stmt) => {
Copy link
Contributor Author

@jsdw jsdw Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stmt::Macro was added in syn 2, so we need to check that too. I turn it into an expr to reuse the above logic but we could try to parse the macro etc directly here too.

};

let input = items.tokens.to_token_stream();
let result = syn::parse2::<syn::TypeTraitObject>(input);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tokens no longer include parens by the looks of it, so can parse directly into the target and remove the BoundsStruct type.

Copy link
Owner

@bkchr bkchr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!!

Cargo.toml Outdated Show resolved Hide resolved
@bkchr bkchr merged commit 1207d23 into bkchr:master Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants