Skip to content

Conversation

samueltardieu
Copy link
Member

Fixes #10480

changelog: [manual_main_separator_str] new lint

@rustbot
Copy link
Collaborator

rustbot commented Mar 11, 2023

r? @flip1995

(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 Mar 11, 2023
@samueltardieu
Copy link
Member Author

r? @llogiq

@rustbot rustbot assigned llogiq and unassigned flip1995 Mar 11, 2023
@samueltardieu samueltardieu force-pushed the issue-10480 branch 2 times, most recently from ec11bb6 to 81a4f6b Compare March 11, 2023 11:57
@llogiq
Copy link
Contributor

llogiq commented Mar 11, 2023

I wonder if we could extend the unnecessary_to_owned lint instead of creating a new one. Also doesn't that work with all &str constants? Why single out MAIN_SEPARATOR?

@samueltardieu
Copy link
Member Author

I wonder if we could extend the unnecessary_to_owned lint instead of creating a new one. Also doesn't that work with all &str constants? Why single out MAIN_SEPARATOR?

It depends on the existence of a &str constant (std::path::MAIN_SEPARATOR_STR) with the same content as the char constant (std::path::MAIN_SEPARATOR).

Copy link
Contributor

@llogiq llogiq left a comment

Choose a reason for hiding this comment

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

Ah, I hadn't noticed the difference here.

I'd like to see some more tests, otherwise this looks good.


use std::path::MAIN_SEPARATOR;

fn main() {
Copy link
Contributor

Choose a reason for hiding this comment

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

What about lets without a given type? Or other expressions that are not direct local bindings?

Copy link
Member Author

Choose a reason for hiding this comment

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

I have added new tests, such as initializing a struct field with this expression or passing it as a function argument.

I've also made it work when it is a method receiver (see the test with encode_utf16()), without an explicit &.

@samueltardieu
Copy link
Member Author

@llogiq Is there anything more you'd like me to do on this one?

@bors
Copy link
Contributor

bors commented Mar 16, 2023

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

@llogiq
Copy link
Contributor

llogiq commented Mar 17, 2023

Thank you!

@bors r+

@bors
Copy link
Contributor

bors commented Mar 17, 2023

📌 Commit ffabdab has been approved by llogiq

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Mar 17, 2023

⌛ Testing commit ffabdab with merge d3c8442...

@bors
Copy link
Contributor

bors commented Mar 17, 2023

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

1 similar comment
@bors
Copy link
Contributor

bors commented Mar 17, 2023

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

@bors bors merged commit d3c8442 into rust-lang:master Mar 17, 2023
@samueltardieu samueltardieu deleted the issue-10480 branch March 24, 2023 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suggest std::path::MAIN_SEPARATOR_STR
5 participants