2

Fix `needless_borrow` causing mutable borrows to be moved by Jarcho · Pull Reque...

 2 years ago
source link: https://github.com/rust-lang/rust-clippy/pull/8217
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

Copy link

Contributor

Jarcho commented 26 days ago

edited

fixes #8191

changelog: Fix needless_borrow causing mutable borrows to be moved
changelog: Rename ref_in_deref to needless_borrow
changelog: Suggest removing the borrow on method call receivers in needless_borrow

Copy link

Collaborator

rust-highfive commented 26 days ago

r? @camsteffen

(rust-highfive has picked a reviewer for you, use r? to override)

Copy link

Contributor

Author

Jarcho commented 18 days ago

This now includes all cases covered by ref_in_deref, which lints (&_).field. The description for both would lead one to believe they lint the same thing. Should I just rename it?

Copy link

Collaborator

camsteffen commented 18 days ago

I think we can remove/deprecate ref_in_deref then?

Tangentially, I noticed the other day that we don't lint (*x).y. I wonder where that could fit.

Copy link

Contributor

Author

Jarcho commented 18 days ago

I'm (very slowly) working on an explicit deref lint. It would fit in there whenever that's done.

Copy link

Contributor

Author

Jarcho commented 18 days ago

That successfully broke the changelog... Not really sure what to change there.

Copy link

Collaborator

camsteffen commented 15 days ago

You need to add declare_deprecated_lint! in clippy_lints/src/deprecated_lints.rs and also add a deprecation test in tests/ui/deprecated.rs. Then run cargo dev update_lints and it should be good.

Copy link

Contributor

Author

Jarcho commented 14 days ago

That would mean register_renamed can't be used, right?

Copy link

Collaborator

camsteffen commented 14 days ago

register_renamed would make it so any usage of ref_in_deref counts as needless_borrow. That may or may not be a good thing but I think the lints are different enough that we don't want that? In any case the error message should point to needless_borrow.

Copy link

Contributor

Author

Jarcho commented 14 days ago

The description for ref_inderef` is

Checks for references in expressions that use auto dereference.

The description for needless_borrow is

Checks for address of operations (&) that are going to be dereferenced immediately by the compiler.

Those describe exactly the same thing. o the point where anything covered by one and not he other would be a clear false negative. Given that renaming sound like the appropriate thing to do.

Copy link

Collaborator

camsteffen commented 14 days ago

edited

Okay, good point. So I think you can just add register_renamed by hand. To fix the error, change any ref_in_deref links in the changelog to not be links anymore.

Copy link

Contributor

Author

Jarcho commented 14 days ago

I was trying to avoid editing the changelog, but I don't see any other option.

Copy link

Collaborator

camsteffen commented 12 days ago

One idea for the lint message but otherwise looks good. Please update "changelog" to include the lint rename and added functionality.

Copy link

Collaborator

camsteffen commented 7 days ago

Squash some commits then will merge!

Copy link

Collaborator

camsteffen commented 7 days ago

@bors r+

Copy link

Contributor

bors commented 7 days ago

pushpin Commit c615140 has been approved by camsteffen

Copy link

Contributor

bors commented 7 days ago

hourglass Testing commit c615140 with merge 788a8bc...

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

Projects

None yet

Milestone

No milestone

Linked issues

Successfully merging this pull request may close these issues.

4 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK