Skip to content

Update to syn 2.0#56

Open
mre wants to merge 1 commit into
AzureMarker:masterfrom
mre:syn2
Open

Update to syn 2.0#56
mre wants to merge 1 commit into
AzureMarker:masterfrom
mre:syn2

Conversation

@mre
Copy link
Copy Markdown

@mre mre commented May 6, 2025

Summary

It would be great if we could update syn to version 2.0 of the API as using syn 1.0 causes some downstream projects to have multiple versions of syn in the dependency tree at the moment. There have been some breaking API changes in syn 2.0, but nothing out of the ordinary. The only think I'm not 100% sure about is the error message for unknown shaku attributes; I can change that if needed.

Details

Update parse_terminated to include separator token parameter as required by syn 2.0 API changes. Replace Attribute field access with method calls:

  • path -> path()
  • tokens -> meta

Update attribute parsing to handle new Meta structure and provide better error messages based on attribute type (Path, List, NameValue).

These changes were needed to fix compilation errors after dependency update to syn 2.0.101.

Note that the compiler output changed; I updated it accordingly with TRYBUILD=overwrite cargo test -p shaku --test shaku_ui.

Update parse_terminated to include separator token parameter as required
by syn 2.0 API changes. Replace Attribute field access with method calls:
- path -> path()
- tokens -> meta

Update attribute parsing to handle new Meta structure and provide better
error messages based on attribute type (Path, List, NameValue).

These changes were needed to fix compilation errors after dependency update
to syn 2.0.101.
@AzureMarker
Copy link
Copy Markdown
Owner

Thanks for the PR, I will take a closer look when I get some time.

@AzureMarker
Copy link
Copy Markdown
Owner

Using Rust 1.87.0, I see some mismatches in the expected compiler output. You can update rust-toolchain with the new Rust version to see the changes. Interestingly, it now prints an internal compiler error in one of the tests:

error: internal compiler error: compiler/rustc_trait_selection/src/traits/normalize.rs:69:17: deeply_normalize should not be called with pending obligations: [
                                    Obligation(predicate=Binder { value: OutlivesPredicate(TestModule, 'static), bound_vars: [] }, depth=0),
                                ]

} else {
Err(Error::new(
attr.span(),
format!("Unknown attribute: 'shaku{}'", attr.tokens),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I think you could replace the format call with "Unknown attribute" to keep this simple. The span should indicate to the user where the error is.

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