0

Remove `unwrap` from `match_trait_method` by m-rph · Pull Request #12540 · rust-...

 4 weeks ago
source link: https://github.com/rust-lang/rust-clippy/pull/12540
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.

Remove unwrap from match_trait_method #12540

Merged

Conversation

Contributor

@m-rph m-rph

commented

Mar 23, 2024

edited by blyxyas

Unused_IO_amount relies on match_trait_method in order to match trait methods that exist in Tokio traits as the corresponding symbols don't exist.

With this commit we remove the unwrap that caused #12366.
Note: author (@m-rph) and @GuillaumeGomez couldn't replicate #12366.

changelog:none

r? @blyxyas

rustbot

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

Mar 23, 2024

Contributor

Author

m-rph

commented

Mar 23, 2024

edited

I don't think this is enough to close #12366, I'd like to make sure there isn't some bad assumption in the lint implementation. As a follow-up, I'd probably look for other calls to match_trait_method and see what can be replaced with sym!

This (unused_io) is the only lint that relies on match_trait_method. Maybe there's an alternative and we could remove the function completely?

m-rph

marked this pull request as ready for review

March 23, 2024 12:19

Removing this function if it doesn't do what's expected of it seems like the way forward indeed.

As for the change, looks good to me. 👍

Contributor

Author

m-rph

commented

Mar 23, 2024

edited

Removing it most likely requires adding a diag symbols for tokio (is that even possible?). Maybe there's an alternative?

Member

If it's deprecated with only one use remaining it could be moved out of clippy utils

Contributor

Author

m-rph

commented

Mar 23, 2024

edited

Should I move it to unused_io_amount then and remove it from the following?

book/src/development/trait_checking.md
tests/ui-internal/unnecessary_def_path.*
clippy_utils/src/lib.rs
clippy_lints/src/utils/internal_lints/unnecessary_def_path.rs

Member

Ah it's documented as a fallback. Could leave it, I don't feel too strongly either way

m-rph reacted with thumbs up emoji

Contributor

This doesn't need to change. #12366 is a rustc issue since lints shouldn't have been running after an error.

Contributor

Author

As is it can still fail, but I don't feel particularly strongly about this.

Member

@blyxyas blyxyas

left a comment

LGTM, thanks! ❤️
I'm not sure if this is what caused the original issue, or even if it should be handled within Clippy (it seems to be an issue in the compiler), but I'll still merge this because an unwrap less in the codebase is still a win!

"Better that then false positives, than that ICE propagates."
William Blackstone.

Member

If it's already documented in the book as a fallback, I would keep it, just another option for contributors.

Also, adding a diagnostic item for tokio (or any external crate) would not be a wise decision. Philipp talked against it for future lints (we have some lints based on futures I think, and those were a mistake), so yeah :/

@bors r+

Collaborator

📌 Commit 94fe2fa has been approved by blyxyas

It is now in the queue for this repository.

Collaborator

⌛ Testing commit 94fe2fa with merge d8d0018...

Collaborator

💔 Test failed - checks-action_test

Member

Changelog failure.
@bors r+

Collaborator

💡 This pull request was already approved, no need to approve it again.

  • This pull request previously failed. You should add more commits to fix the bug, or use retry to trigger a build again.

Collaborator

📌 Commit 94fe2fa has been approved by blyxyas

It is now in the queue for this repository.

Collaborator

⌛ Testing commit 94fe2fa with merge 805ef35...

bors

merged commit 805ef35 into

rust-lang:master

Mar 25, 2024

5 checks passed

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

Reviewers

GuillaumeGomez

GuillaumeGomez approved these changes

blyxyas

blyxyas approved these changes
Assignees

blyxyas

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.

None yet

7 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK