-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
warn on strings that look like inline format strings but aren't #10195
Comments
I've noticed myself running into this a fair bit with the new format syntax, especially when refactoring code. Before, |
I just found an even more interesting case IRL in kani, where it looks like pub fn main() {
let mut x = Some(3);
let y = "aaa";
x = None.expect("hello {y}");
} will print literally |
Found some code in my crate that did the same thing:
Could we get a comment on if this would be a reasonable lint or not? |
This is an easy mistake when using UI toolkits: let x = 42;
ui.label("The value is {x}"); // oops! |
@GuillaumeGomez wdyt? It requires some thought on exactly what patterns to look for, and I'm sure there will be false positives (so this should probably be an opt-in lint). But at looking for the regex |
I think it's common enough to definitely deserve a lint. I'm at rustconf currently but I'm putting it in my todo list for next week when I'm back. EDIT: as for the "level" of check, I'll give a try at different approaches but I think a global regex that then is checked individually (to see if it's actually valid rust syntax and not |
I opened #13410. Don't hesitate to give it a try as I'm interested to find out cases I might have missed. :) |
What it does
Lint Name
No response
Category
No response
Advantage
No response
Drawbacks
No response
Example
Could be written as:
The text was updated successfully, but these errors were encountered: