5

Extend `result_map_or_into_option` lint to handle `Result::map_or_else(|_| None,...

 9 months ago
source link: https://github.com/rust-lang/rust-clippy/pull/11845
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Conversation

Fixes #10365.

As indicated in the title, it extends the result_map_or_into_option lint to handle Result::map_or_else(|_| None, Some).

changelog: extension of the result_map_or_into_option lint to handle Result::map_or_else(|_| None, Some)

r? @blyxyas

KisaragiEffective reacted with thumbs up emoji

rustbot

added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label

Nov 20, 2023

Member

Author

Re-assigning to someone else as @blyxyas is busy IRL.

r? @flip1995

GuillaumeGomez

force-pushed the result_map_or_into_option-extension

branch 2 times, most recently from f4815ed to 773db59 Compare

November 22, 2023 15:56

Member

Author

I added the None check and extended UI test a bit to ensure it is checked.

GuillaumeGomez

force-pushed the result_map_or_into_option-extension

branch 2 times, most recently from a60fd9a to 1b17a5b Compare

November 22, 2023 20:45

Member

Author

Applied your suggestions, the code is much shorter now. :)

Member

LGTM. r=me with above comment addressed

@bors delegate+

Contributor

✌️ @GuillaumeGomez, you can now approve this pull request!

If @flip1995 told you to "r=me" after making some further change, please make that change, then do @bors r=@flip1995

Member

Author

Contributor

📌 Commit 1384ebe has been approved by flip1995

It is now in the queue for this repository.

Contributor

⌛ Testing commit 1384ebe with merge 6411456...

Contributor

💔 Test failed - checks-action_test

Member

Author

Failed because of:

 error: actual output differed from expected
Execute `cargo uibless` to update `tests/ui/manual_main_separator_str.stderr` to the actual output
--- tests/ui/manual_main_separator_str.stderr
+++ <stderr output>
-error: taking a reference on `std::path::MAIN_SEPARATOR` conversion to `String`
-  --> $DIR/manual_main_separator_str.rs:21:19
-   |
-LL |     let _: &str = &MAIN_SEPARATOR.to_string();
-   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `std::path::MAIN_SEPARATOR_STR`
-   |
-   = note: `-D clippy::manual-main-separator-str` implied by `-D warnings`
-   = help: to override `-D warnings` add `#[allow(clippy::manual_main_separator_str)]`
-
-error: taking a reference on `std::path::MAIN_SEPARATOR` conversion to `String`
-  --> $DIR/manual_main_separator_str.rs:22:17
-   |
-LL |     let _ = len(&MAIN_SEPARATOR.to_string());
-   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `std::path::MAIN_SEPARATOR_STR`
-
-error: taking a reference on `std::path::MAIN_SEPARATOR` conversion to `String`
-  --> $DIR/manual_main_separator_str.rs:23:23
-   |
-LL |     let _: Vec<u16> = MAIN_SEPARATOR.to_string().encode_utf16().collect();
-   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `std::path::MAIN_SEPARATOR_STR`
-
-error: taking a reference on `std::path::MAIN_SEPARATOR` conversion to `String`
-  --> $DIR/manual_main_separator_str.rs:27:12
-   |
-LL |         f: &MAIN_SEPARATOR.to_string(),
-   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `std::path::MAIN_SEPARATOR_STR`
-
-error: aborting due to 4 previous errors
-

Not related to this PR but just in case I'll rebase.

Member

Author

Ok, let's try again.

@bors r=@flip1995

Contributor

📌 Commit 5d330d0 has been approved by flip1995

It is now in the queue for this repository.

Contributor

⌛ Testing commit 5d330d0 with merge 840e227...

bors

merged commit 840e227 into

rust-lang:master

Nov 23, 2023

5 checks passed

GuillaumeGomez

deleted the result_map_or_into_option-extension branch

November 23, 2023 10:28

Member

Author

The rebase fixed it. Oh well. Dark magic.

flip1995 and KisaragiEffective reacted with rocket emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Back to tour

flip1995

flip1995 approved these changes
Assignees

flip1995

Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Suggest Result::ok() for result.map_or_else(|_| None, Some)

5 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK