Skip to content
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

error on empty precision #136638

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

error on empty precision #136638

wants to merge 1 commit into from

Conversation

hkBst
Copy link
Member

@hkBst hkBst commented Feb 6, 2025

Fixes #131159 by erroring 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
Contributor

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
Contributor

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
hkBst added a commit to hkBst/kryl_04 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/math-algorithm-book 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/polars 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/srgb.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
mina86 pushed a commit to mina86/srgb.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
Copy link
Member Author

hkBst commented Feb 8, 2025

@Noratrieb
Copy link
Member

Given the large amount of regressions, it does not appear appropriate to make this an error. Documenting the behavior seems good (and potentially emit a lint that it's useless).

laggui pushed a commit to tracel-ai/burn that referenced this pull request Feb 10, 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
Copy link
Member Author

hkBst commented Feb 14, 2025

I agree that a warning would be better, but I'm not sure how to turn this error into one yet. Any pointers would be welcome, otherwise I'm not sure when I'll get to this.

@petrochenkov
Copy link
Contributor

petrochenkov commented Feb 19, 2025

Ah, this is not about lexer, then r? compiler
(I have too many assigned PRs)

@rustbot rustbot assigned oli-obk and unassigned petrochenkov Feb 19, 2025
@petrochenkov
Copy link
Contributor

This is sort of a library issue too (a built-in proc macro).
cc @m-ou-se in case you have an opinion on this.

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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