Skip to content

Conversation

hkBst
Copy link
Member

@hkBst hkBst commented Feb 6, 2025

Fixes #131159 by erroring warning on missing precision. Alternatively we could document current behavior.

@rustbot
Copy link
Collaborator

rustbot commented Feb 6, 2025

r? @petrochenkov

rustbot has assigned @petrochenkov.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 6, 2025
@rust-log-analyzer

This comment has been minimized.

@oli-obk
Copy link
Contributor

oli-obk commented Feb 6, 2025

@bors try

@oli-obk
Copy link
Contributor

oli-obk commented Feb 6, 2025

Please add a ui test for this

@bors
Copy link
Collaborator

bors commented Feb 6, 2025

⌛ Trying commit ef04c64 with merge 77e9660...

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 6, 2025
error on empty precision

Fixes rust-lang#131159 by erroring on missing precision. Alternatively we could document current behavior.
@bors
Copy link
Collaborator

bors commented Feb 6, 2025

☀️ Try build successful - checks-actions
Build commit: 77e9660 (77e966048a5976133ba6b8f26d38d558f2a84355)

@oli-obk
Copy link
Contributor

oli-obk commented Feb 6, 2025

@craterbot check

@craterbot
Copy link
Collaborator

👌 Experiment pr-136638 created and queued.
🤖 Automatically detected try build 77e9660
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 6, 2025
@craterbot
Copy link
Collaborator

🚧 Experiment pr-136638 is now running

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🎉 Experiment pr-136638 is completed!
📊 365 regressed and 5 fixed (578841 total)
📰 Open the full report.

⚠️ If you notice any spurious failure please add them to the denylist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Feb 7, 2025
hkBst added a commit to hkBst/burn that referenced this pull request Feb 8, 2025
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
hkBst added a commit to hkBst/polyfit-residuals that referenced this pull request Feb 8, 2025
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
hkBst added a commit to hkBst/rano that referenced this pull request Feb 8, 2025
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
hkBst added a commit to hkBst/simple_optimization that referenced this pull request Feb 8, 2025
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
hkBst added a commit to hkBst/xxd-rs that referenced this pull request Feb 8, 2025
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
hkBst added a commit to hkBst/yaxpeax-arm that referenced this pull request Feb 8, 2025
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
@m-ou-se
Copy link
Member

m-ou-se commented Feb 19, 2025

Given how many crates were broken in the crater run, I don't think we should change this. (See all the PRs referenced above.)

Perhaps a warning is better. Or we can just document it.

@m-ou-se m-ou-se added I-libs-api-nominated Nominated for discussion during a libs-api team meeting. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 19, 2025
@Amanieu Amanieu removed the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Feb 25, 2025
@Amanieu
Copy link
Member

Amanieu commented Feb 25, 2025

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.

@traviscross
Copy link
Contributor

Probably this FCW should go ahead and just start by linting in deps.

@m-ou-se
Copy link
Member

m-ou-se commented Feb 26, 2025

I'm not convinced that this needs a (forward-compatibility) warning.

A default placeholder can be written as {} or {:} or {:.}. Should we also warn about {:}? I don't think we should. But then I'm not sure why we would warn about {:.}.

It seems that in every single occurence of {:.}, the author got exactly what they wanted: a placeholder with default settings. A warning would make sense if it is an easy mistake that looks very similar to something with a different meaning, but that's not the case here.

@Noratrieb
Copy link
Member

I think a clippy lint would be reasonable, it's a needlessly complicated way to write {}. But I agree that we shouldn't be emitting future compat warnings for it, especially not in deps.

@traviscross
Copy link
Contributor

traviscross commented Feb 26, 2025

The other option, of course, is to document the current behavior. We do get this right for {:}, because we document:

format := '{' [ argument ] [ ':' format_spec ] [ ws ] * '}'
format_spec := [[fill]align][sign]['#']['0'][width]['.' precision]type
type := '' | '?' | 'x?' | 'X?' | identifier

So since type includes '', we must accept {:}. But, for {:.}, we'd look at:

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. {:.x}, that seems right. Or alternatively, and maybe more directly, we could say:

format_spec := [[fill]align][sign]['#']['0'][width]['.' [precision]]type

@oli-obk oli-obk added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 20, 2025
@Dylan-DPC
Copy link
Member

@hkBst any updates on this? thanks

@rustbot
Copy link
Collaborator

rustbot commented Aug 26, 2025

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.

@hkBst hkBst changed the title error on empty precision <del>error</del> warn on empty precision Aug 26, 2025
@hkBst hkBst changed the title <del>error</del> warn on empty precision warn on empty precision Aug 26, 2025
@rust-log-analyzer

This comment has been minimized.

@m-ou-se
Copy link
Member

m-ou-se commented Aug 26, 2025

I don't think we should merge this, as I mentioned above:

A default placeholder can be written as {} or {:} or {:.}. Should we also warn about {:}? I don't think we should. But then I'm not sure why we would warn about {:.}.

It seems that in every single occurence of {:.}, the author got exactly what they wanted: a placeholder with default settings. A warning would make sense if it is an easy mistake that looks very similar to something with a different meaning, but that's not the case here.

I think instead we should fix the reference, as mentioned by @traviscross above: #136638 (comment)

@rfcbot close

@rfcbot
Copy link

rfcbot commented Aug 26, 2025

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.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-close This PR / issue is in PFCP or FCP with a disposition to close it. labels Aug 26, 2025
@hkBst
Copy link
Member Author

hkBst commented Aug 26, 2025

It seems that in every single occurence of {:.}, the author got exactly what they wanted: a placeholder with default settings. A warning would make sense if it is an easy mistake that looks very similar to something with a different meaning, but that's not the case here.

This actually caught a bug, as I previously mentioned here: #136638 (comment)

@m-ou-se
Copy link
Member

m-ou-se commented Aug 26, 2025

I think a clippy lint would be more appropriate.

@hkBst
Copy link
Member Author

hkBst commented Aug 26, 2025

A default placeholder can be written as {} or {:} or {:.}. Should we also warn about {:}? I don't think we should. But then I'm not sure why we would warn about {:.}.

{:.} is merely a degenerate special case. In general {var:stuff.} will be warned against.

@hkBst
Copy link
Member Author

hkBst commented Aug 26, 2025

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-close This PR / issue is in PFCP or FCP with a disposition to close it. proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

absent precision parameter for floating point format string is undocumented