You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Look for curly braces in string literals and warn that the user may be missing a format! call.
Advantage
I have several times forgotten to call format!, leading to subtle bugs. For instance:
on_error("There was an error: {error}");
Drawbacks
There may be legitimate uses of curly-braces in strings, so there will likely be a lot of false positives. This should therefor be a suspicious lint, that is opt-in.
Example
on_error("There was an error: {error}");
Could be written as:
on_error(format!("There was an error: {error}"));
The text was updated successfully, but these errors were encountered:
cc #10195
It seems like it'd have FPs for JSON-like strings, but maybe we could try to parse the literal as a format string to see if it is one instead of only looking for just { .. } (not sure if that ends up being too expensive) since most JSON is most likely not valid format syntax.
This should therefor be a suspicious lint, that is opt-in.
I'm not sure if thats possible. Suspicious is warn by default and afaik needs to be opt out of manually by the user. Pedantic and restriction are allow by default (opt in)
What it does
Look for curly braces in string literals and warn that the user may be missing a
format!
call.Advantage
I have several times forgotten to call
format!
, leading to subtle bugs. For instance:Drawbacks
There may be legitimate uses of curly-braces in strings, so there will likely be a lot of false positives. This should therefor be a suspicious lint, that is opt-in.
Example
Could be written as:
The text was updated successfully, but these errors were encountered: