-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
does not detect {} not being in quotes when looking for a string literal, instead offers an incorrect solution #130170
Comments
it's worth noting that this is perfectly valid code: fn main() {
println!("{:?}", {});
} minimal repro: fn main() {
println!({});
} |
huh, didn't know that. good to know ig |
I think it is worth special casing this in diagnostics though, if someone wanted to print a unit type (for some reason?) they probably should use the |
@rustbot claim |
… format macro. For example: ```rust let s = "123"; println!({}, "sss", s); ``` Suggest: `println!("{:?} {} {}", {}, "sss", s);` fixes rust-lang#130170
… format macro. For example: ```rust let s = "123"; println!({}, "sss", s); ``` Suggest: `println!("{:?} {} {}", {}, "sss", s);` fixes rust-lang#130170
… format macro. For example: ```rust let s = "123"; println!({}, "sss", s); ``` Suggest: `println!("{:?} {} {}", {}, "sss", s);` fixes rust-lang#130170
Special treatment empty tuple when suggest adding a string literal in format macro. For example: ```rust let s = "123"; println!({}, "sss", s); ``` Suggest: `println!("{:?} {} {}", {}, "sss", s);` fixes rust-lang#130170
Special treatment empty tuple when suggest adding a string literal in format macro. For example: ```rust let s = "123"; println!({}, "sss", s); ``` Suggest: `println!("{:?} {} {}", {}, "sss", s);` fixes rust-lang#130170
Rollup merge of rust-lang#131430 - surechen:fix_130495, r=jieyouxu Special treatment empty tuple when suggest adding a string literal in format macro. For example: ```rust let s = "123"; println!({}, "sss", s); ``` Suggest: `println!("{:?} {} {}", {}, "sss", s);` fixes rust-lang#130170
The PR that closed this doesn't seem to actually apply the wanted fix, this should be reopened. |
Hello, thank you very much for the suggestion. My idea is to find a slightly more general solution instead of special treatment for rare cases. If you think it should be modified as |
Code
Current output
Desired output
Rationale and extra context
Cargo does not seem to be detecting the {} outside brackets and provides an incredibly strange fix instead.
Other cases
No response
Rust Version
Anything else?
the file is from here:
https://github.com/Wynntils/Static-Storage/blob/main/Reference/id_keys.json
You will need serde_json crate.
The text was updated successfully, but these errors were encountered: