Conversation
|
rustbot has assigned @petrochenkov. Use |
This comment has been minimized.
This comment has been minimized.
|
@bors try |
|
Please add a ui test for this |
error on empty precision Fixes rust-lang#131159 by erroring on missing precision. Alternatively we could document current behavior.
|
☀️ Try build successful - checks-actions |
|
@craterbot check |
|
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
|
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
|
🎉 Experiment
|
A format precision specifier consisting of a dot and no number actually does nothing and has no specified meaning. Currently this is silently ignored, but it may turn into a warning or error. See rust-lang/rust#136638
A format precision specifier consisting of a dot and no number actually does nothing and has no specified meaning. Currently this is silently ignored, but it may turn into a warning or error. See rust-lang/rust#131159 and rust-lang/rust#136638
A format precision specifier consisting of a dot and no number actually does nothing and has no specified meaning. Currently this is silently ignored, but it may turn into a warning or error. See rust-lang/rust#131159 and rust-lang/rust#136638
A format precision specifier consisting of a dot and no number actually does nothing and has no specified meaning. Currently this is silently ignored, but it may turn into a warning or error. See rust-lang/rust#131159 and rust-lang/rust#136638
A format precision specifier consisting of a dot and no number actually does nothing and has no specified meaning. Currently this is silently ignored, but it may turn into a warning or error. See rust-lang/rust#131159 and rust-lang/rust#136638
A format precision specifier consisting of a dot and no number actually does nothing and has no specified meaning. Currently this is silently ignored, but it may turn into a warning or error. See rust-lang/rust#131159 and rust-lang/rust#136638
|
We discussed this in the libs-api meeting and decided that the best path forward would be a forward-compatibility warning which will give us the possibility of making this a hard error in the future. We definitely shouldn't make it an error immediately due to the widespread potential breakage. |
|
Probably this FCW should go ahead and just start by linting in deps. |
|
I'm not convinced that this needs a (forward-compatibility) warning. A default placeholder can be written as It seems that in every single occurence of |
|
I think a clippy lint would be reasonable, it's a needlessly complicated way to write |
|
The other option, of course, is to document the current behavior. We do get this right for format := '{' [ argument ] [ ':' format_spec ] [ ws ] * '}'
format_spec := [[fill]align][sign]['#']['0'][width]['.' precision]type
type := '' | '?' | 'x?' | 'X?' | identifierSo since format := '{' [ argument ] [ ':' format_spec ] [ ws ] * '}'
argument := integer | identifier
format_spec := [[fill]align][sign]['#']['0'][width]['.' precision]type
precision := count | '*'
count := parameter | integer
parameter := argument '$'Here, this bottoms out at requiring something after the dot. We could say, instead, if we want, e.g.: precision := count | '*' | ''Since we do also accept today, e.g. format_spec := [[fill]align][sign]['#']['0'][width]['.' [precision]]type |
|
@hkBst any updates on this? thanks |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I don't think we should merge this, as I mentioned above:
I think instead we should fix the reference, as mentioned by @traviscross above: #136638 (comment) @rfcbot close |
|
Team member @m-ou-se has proposed to close this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
This actually caught a bug, as I previously mentioned here: #136638 (comment) |
|
I think a clippy lint would be more appropriate. |
|
|
@rustbot ready |
|
@rustbot label +A-fmt |
|
@samueltardieu: could you explain whether it is feasible to lint format macro syntax (like in this PR) within clippy? |
We can do this as we have access to the parsed format specifier as well as the original source code. However, unless I'm mistaken, this might require an error-prone reparsing because:
This would be easier if the span of the precision was available outside the precision (so that we can get a |
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Perhaps an exception for "{:.}" (which would disable the warning) can help land this? Some options are (see latest commit):
|
|
@m-ou-se I think I've addressed all your concerns, but if you're not convinced yet, would a clean crater run convince you? |
|
@dtolnay @joshtriplett I think I've addressed all @m-ou-se's concerns. Perhaps you'd like to take another look? |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
|
@rfcbot concern I've addressed previously listed concerns with this implementation (such that the most common occurrence ("{:.}") is now not warned against any more) but have seen nothing to indicate anyone took this into consideration. It is also false that this does not catch bugs, as a bug was caught during the initial crater run. My correction of this statement also seems not to have gotten any attention. Given these facts, I cannot shake the feeling that some votes might be based on outdated or wrong information... Of course it is possible that even with a full picture this solution is not preferred, but the alternatives do seem objectively worse:
|
Or as I wrote in this comment provide Clippy with some extra information to do the job efficiently. |
|
r? @m-ou-se |
|
@hkBst I still think the best course of action is to add this lint to Clippy first. |
View all comments
Fixes #131159 by
erroringwarning on missing precision.Alternatively we could document current behavior.EDIT: Warnings for common case of "{:.}" are now disabled, so this should have a clean crater run.