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

Make fields public for syn::Visibility #1595

Closed
StackOverflowExcept1on opened this issue Mar 10, 2024 · 1 comment
Closed

Make fields public for syn::Visibility #1595

StackOverflowExcept1on opened this issue Mar 10, 2024 · 1 comment

Comments

@StackOverflowExcept1on
Copy link

StackOverflowExcept1on commented Mar 10, 2024

for example I want to make the visibility of each field public but the creation of syn::Visibility::Public(_) is not allowed

for field in fields.named.iter_mut() {
    field.vis = syn::Visibility::Public(syn::Token![pub]);
}
   --> utils/weight-diff/src/main.rs:251:33
    |
251 |                     field.vis = syn::Visibility::Public;
    |                     ---------   ^^^^^^^^^^^^^^^^^^^^^^^ expected `Visibility`, found enum constructor

instead you need to do it like this:

field.vis = syn::parse2(quote! { pub }).unwrap();
@dtolnay
Copy link
Owner

dtolnay commented Apr 17, 2024

The code you wrote works, and is different from the code in the error message you pasted. I think this is most likely a case of you confusing yourself with 2 different copies of your own code, but if not, please take your questions to any of the resources shown in https://www.rust-lang.org/community and someone should be able to help you figure things out.

@dtolnay dtolnay closed this as completed Apr 17, 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

No branches or pull requests

2 participants