-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
fix(forge bind
): prefix keyword mod names with r#
#9761
Conversation
forge bind
): prefix keyword mod names with r#forge bind
): prefix keyword mod names with r#
|
||
fn write_mod_name(contents: &mut String, name: &str) -> Result<()> { | ||
if syn::parse_str::<syn::File>(&format!("pub mod {name};")) | ||
.is_err_and(|e| e.to_string().contains("expected identifier, found keyword")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should do it, alternatively we could try to parse name as Ident perhaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be syn::parse_str::<Ident>().is_ok()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
fn write_mod_name(contents: &mut String, name: &str) -> Result<()> { | ||
if syn::parse_str::<syn::File>(&format!("pub mod {name};")) | ||
.is_err_and(|e| e.to_string().contains("expected identifier, found keyword")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be syn::parse_str::<Ident>().is_ok()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense!
Motivation
Closes #5847
Solution
Prefix keyword module names with
r#
.E.g.