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

[RFC-3086] Restrict the parsing of count #111908

Merged
merged 1 commit into from
Aug 18, 2023
Merged

Conversation

c410-f3r
Copy link
Contributor

Fix #111904

The original RFC didn't mention the possibility of using ${count(t,)} and such thing isn't very semantically accurate which can lead to confusion.

@rustbot
Copy link
Collaborator

rustbot commented May 24, 2023

r? @davidtwco

(rustbot has picked a reviewer for you, use r? to override)

@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 May 24, 2023
@PatchMixolydic
Copy link
Contributor

This change seems to be inconsistent with other comma separated lists in the language, which permit trailing commas. I believe ${count(t,)} should be allowed and should behave identically to ${count(t)} if at all possible.

@c410-f3r
Copy link
Contributor Author

c410-f3r commented Jun 6, 2023

r? compiler

@rustbot rustbot assigned TaKO8Ki and unassigned davidtwco Jun 6, 2023
@compiler-errors
Copy link
Member

Yeah, I agree with @PatchMixolydic here. Why is count(t,) being recovered to count(t, 0)? Is there a way we could get it to just act like count(t) and have this incongruency?

@c410-f3r
Copy link
Contributor Author

AFAICT, count(t,) is being banned although it is possible to recover to count(t) which points to the outermost index that is equal or greater than 0 (#83527 (comment)).

There isn't a personal preference so, if desired, feel free to close this PR and #111904 to stick with the current behavior :)

@compiler-errors
Copy link
Member

I may be misremembering, but I think petrochenkov reviewed previous RFC3086 work? Maybe you have more opinions about how to handle this and whether to error here.

r? petrochenkov

@petrochenkov
Copy link
Contributor

This change seems to be inconsistent with other comma separated lists in the language, which permit trailing commas.

At which points something becomes a list though?
Standard library macros take it to absurd and consider even mac!(single_argument) a list, and therefore accept mac!(single_argument,) as well.

Neither ${count(t)}/${count(t, N)}, nor ${index(N)} or ${length(N)} are convincingly lists, so for now I think it's fine to report this as error instead of accepting things like ${count(t,)}, ${count(t, N,)}, ${index(N,)} and ${length(N,)}.

(But we could accept all the commas here too, just need to do it consistently.)

@petrochenkov petrochenkov 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 Jun 29, 2023
@Dylan-DPC
Copy link
Member

@c410-f3r any updates on this?

@c410-f3r
Copy link
Contributor Author

Sorry, life happened. I will return to this PR tomorrow.

@c410-f3r
Copy link
Contributor Author

A little late but here it is

@petrochenkov petrochenkov 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 17, 2023
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Aug 18, 2023

📌 Commit 6395dc2 has been approved by petrochenkov

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 18, 2023
@bors
Copy link
Contributor

bors commented Aug 18, 2023

⌛ Testing commit 6395dc2 with merge b9177c0...

@bors
Copy link
Contributor

bors commented Aug 18, 2023

☀️ Test successful - checks-actions
Approved by: petrochenkov
Pushing b9177c0 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 18, 2023
@bors bors merged commit b9177c0 into rust-lang:master Aug 18, 2023
@rustbot rustbot added this to the 1.73.0 milestone Aug 18, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b9177c0): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.9% [0.8%, 2.9%] 2
Regressions ❌
(secondary)
2.3% [2.0%, 2.6%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.1% [-3.1%, -3.1%] 1
All ❌✅ (primary) 1.9% [0.8%, 2.9%] 2

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.4% [-1.4%, -1.4%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.4% [-1.4%, -1.4%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 634.503s -> 633.83s (-0.11%)
Artifact size: 346.93 MiB -> 347.06 MiB (0.04%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

${count(t,)} is interpreted as ${count(t, 0)}
10 participants