Skip to content

Stop emitting double to_string()#639

Merged
ltratt merged 1 commit into
softdevteam:masterfrom
hseg:remove-double-tostring
May 13, 2026
Merged

Stop emitting double to_string()#639
ltratt merged 1 commit into
softdevteam:masterfrom
hseg:remove-double-tostring

Conversation

@hseg
Copy link
Copy Markdown
Contributor

@hseg hseg commented May 13, 2026

d70b294 wrapped regex in a QuoteToString whose ToTokens implementation nominally handles the necessary to_string() invocation prior to splicing. However, it didn't make the parallel change to drop the call to to_string from the splice. This results in a redundant regex.to_string().to_string() in the generated code.
A minor tweak, with potentially negligible but positive impact if the compiler isn't clever enough. Mostly motivated on my part because the import model for the generated parsers (include!ing them directly in the code) makes it impossible to get Clippy to shut up about this.

d70b294 wrapped regex in a QuoteToString whose ToTokens implementation
nominally handles the necessary to_string() invocation prior to
splicing.
However, it didn't make the parallel change to drop the call to
to_string from the splice.
This results in a redundant regex.to_string().to_string() in the
generated code.
@ltratt ltratt added this pull request to the merge queue May 13, 2026
hseg added a commit to hseg/pizauth that referenced this pull request May 13, 2026
Also remove unnecessary clones (Instant impls Copy)

Cannot enable lints until [grmtools#639] is merged since the generated
code for the lexer will cause these to unblockably complain.

When it is, re-enable implicit_clone and redundant_clone

[grmtools#639]: softdevteam/grmtools#639
Merged via the queue into softdevteam:master with commit 3fef8c5 May 13, 2026
1 check passed
hseg added a commit to hseg/pizauth that referenced this pull request May 13, 2026
Also remove unnecessary clones (Instant impls Copy)

Cannot enable lints until [grmtools#639] is merged since the generated
code for the lexer will cause these to unblockably complain.

When it is, re-enable implicit_clone and redundant_clone

[grmtools#639]: softdevteam/grmtools#639
hseg added a commit to hseg/pizauth that referenced this pull request May 13, 2026
Also remove unnecessary clones (Instant impls Copy)

Cannot enable lints until [grmtools#639] is merged since the generated
code for the lexer will cause these to unblockably complain.

When it is, re-enable implicit_clone and redundant_clone

[grmtools#639]: softdevteam/grmtools#639
hseg added a commit to hseg/pizauth that referenced this pull request May 13, 2026
Also remove unnecessary clones (Instant impls Copy)

Cannot enable lints until [grmtools#639] is merged since the generated
code for the lexer will cause these to unblockably complain.

When it is, re-enable implicit_clone and redundant_clone

[grmtools#639]: softdevteam/grmtools#639
@ratmice
Copy link
Copy Markdown
Collaborator

ratmice commented May 14, 2026

Thanks, good catch!

Mostly motivated on my part because the import model for the generated parsers (include!ing them directly in the code) makes it impossible to get Clippy to shut up about this.

I just wanted to note that I've also run into this sort of problem in the past, at that time it was possible to work around with the following kind of mod/use workaround code, I haven't tested this in a long time though.

mod __foo__ {
  #![allow(clippy::...)]
  include!(...)
}
use __foo__::*;

@hseg
Copy link
Copy Markdown
Contributor Author

hseg commented May 14, 2026 via email

@ratmice
Copy link
Copy Markdown
Collaborator

ratmice commented May 14, 2026

Oh, indeed I think it would be pub use __foo__::*; but as I said I haven't tested this in a long long time I could see some visibility lint getting in the way perhaps.

hseg added a commit to hseg/pizauth that referenced this pull request May 15, 2026
Also remove unnecessary clones (Instant impls Copy)

Cannot enable lints until [grmtools#639] is merged since the generated
code for the lexer will cause these to unblockably complain.

When it is, re-enable implicit_clone and redundant_clone

[grmtools#639]: softdevteam/grmtools#639
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants