Skip to content

Conversation

Centri3
Copy link
Member

@Centri3 Centri3 commented Jun 3, 2023

Emits a warning when there are an extraneous number of hashes(?) around a raw string literal, for example r##"I'm a "raw string literal"!"## or cr#"crunb"#

Closes #10882

I think this could also fit in style as well, rather than complexity.

changelog: Add [needless_raw_string_hashes] and [needless_raw_string] lints

@rustbot
Copy link
Collaborator

rustbot commented Jun 3, 2023

r? @dswij

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

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jun 3, 2023
@Centri3
Copy link
Member Author

Centri3 commented Jun 4, 2023

Seems the only instance of this from running lintcheck is in anyhow's build.rs, which is very similar to clippy's CARGO_CLIPPY_HELP so maybe this can ignore r#?

@y21
Copy link
Member

y21 commented Jun 7, 2023

Looks like there's also an open PR to add the same lint to rustc itself: rust-lang/rust#112373 (though it seems to be waiting on T-lang approval)

@Centri3 Centri3 force-pushed the needless_raw_string_hashes branch from d6b7b06 to 6c2ef3d Compare June 10, 2023 13:14
@dswij
Copy link
Member

dswij commented Jun 15, 2023

I think this could also fit in style as well, rather than complexity

I think this fit in style more. WDYT? @Centri3

@dswij dswij added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Jun 15, 2023
@Centri3
Copy link
Member Author

Centri3 commented Jun 15, 2023

style's fine by me

@Centri3
Copy link
Member Author

Centri3 commented Jun 15, 2023

Now that I think about it, maybe needless_raw_strings should be pedantic or restriction? There are many cases where you may want a raw string even if it's unnecessary (regexes are a good example).

@Centri3 Centri3 force-pushed the needless_raw_string_hashes branch from 4258597 to 2e47438 Compare June 15, 2023 19:18
@Centri3 Centri3 force-pushed the needless_raw_string_hashes branch from 2e47438 to d215098 Compare June 16, 2023 00:09
@bors
Copy link
Contributor

bors commented Jun 16, 2023

☔ The latest upstream changes (presumably #10925) made this pull request unmergeable. Please resolve the merge conflicts.

@Centri3 Centri3 force-pushed the needless_raw_string_hashes branch 4 times, most recently from ec4e194 to c28deba Compare June 16, 2023 15:52
@Centri3
Copy link
Member Author

Centri3 commented Jun 16, 2023

Pushed to the wrong branch :D

@bors
Copy link
Contributor

bors commented Jun 17, 2023

☔ The latest upstream changes (presumably #10886) made this pull request unmergeable. Please resolve the merge conflicts.

@bors
Copy link
Contributor

bors commented Jun 19, 2023

☔ The latest upstream changes (presumably #10951) made this pull request unmergeable. Please resolve the merge conflicts.

@Centri3 Centri3 force-pushed the needless_raw_string_hashes branch from 196993e to f5cfac0 Compare June 19, 2023 03:45
@Centri3 Centri3 force-pushed the needless_raw_string_hashes branch from 995585a to 34bb0cb Compare June 20, 2023 17:32
Copy link
Member

@dswij dswij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this!

@dswij
Copy link
Member

dswij commented Jun 27, 2023

@bors r+

@bors
Copy link
Contributor

bors commented Jun 27, 2023

📌 Commit 34bb0cb has been approved by dswij

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jun 27, 2023

⌛ Testing commit 34bb0cb with merge 8c07cea...

bors added a commit that referenced this pull request Jun 27, 2023
New lint [`needless_raw_string_hashes`]

Emits a warning when there are an extraneous number of hashes(?) around a raw string literal, for example `r##"I'm a "raw string literal"!"##` or `cr#"crunb"#`

Closes #10882

I think this could also fit in `style` as well, rather than `complexity`.

changelog: Add [`needless_raw_string_hashes`] and [`needless_raw_string`] lints
@bors
Copy link
Contributor

bors commented Jun 27, 2023

💔 Test failed - checks-action_test

Centri3 added 5 commits June 27, 2023 05:12
add semicolon in doctest
Thanks, #112373, for the snippet at line 75!
Update raw_strings.rs

Revert "new lints for visibility"

This reverts commit 0e5a537.

new lints for visibility
@Centri3
Copy link
Member Author

Centri3 commented Jun 27, 2023

dogfood failed, seems to pass now @dswij

@Centri3 Centri3 force-pushed the needless_raw_string_hashes branch from 34bb0cb to 8cb6c86 Compare June 27, 2023 10:16
@dswij
Copy link
Member

dswij commented Jun 27, 2023

@bors r+

@bors
Copy link
Contributor

bors commented Jun 27, 2023

📌 Commit 8cb6c86 has been approved by dswij

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jun 27, 2023

⌛ Testing commit 8cb6c86 with merge c710b48...

@bors
Copy link
Contributor

bors commented Jun 27, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: dswij
Pushing c710b48 to master...

@bors bors merged commit c710b48 into rust-lang:master Jun 27, 2023
@Centri3 Centri3 deleted the needless_raw_string_hashes branch June 27, 2023 18:21
github-merge-queue bot pushed a commit that referenced this pull request Feb 10, 2025
The `needless_raw_string_hashes` lint was implemented in #10884.
However, the name originally considered might have been
`unnecessary_raw_string_hashes`, so this part refers to a non-existent
lint.

r? flip1995

changelog: none
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 from the author. (Use `@rustbot ready` to update this status)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lint to warn against unnecessary extra hashes in raw string literals
7 participants