-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[map_entry
]: Check insert expression for map use
#12362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good. Adding new docs is very appreciated! :)
clippy_lints/src/entry.rs
Outdated
/// Details on an expression checking whether a map contains a key. | ||
/// | ||
/// For instance, with the following: | ||
/// ```no_run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to mark it as ignore
, otherwise the doctest will fail.
/// | ||
/// For instance, on the following: | ||
/// ```no_run | ||
/// self.the_map.insert("the_key", 3 + 4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
Thank you! @bors r+ |
[`map_entry`]: Check insert expression for map use The lint makes sure that the map is not used (borrowed) before the call to `insert`. Since the lint creates a mutable borrow on the map with the `Entry`, it wouldn't be possible to replace such code with `Entry`. However, expressions up to the `insert` call are checked, but not expressions for the arguments of the `insert` call itself. This commit fixes that. Fixes #11935 *Please write a short comment explaining your change (or "none" for internal only changes)* changelog: [`map_entry`]: Fix false positive when borrowing the map in the `insert` call
💔 Test failed - checks-action_test |
@bors retry |
@Ethiraric: 🔑 Insufficient privileges: not in try users |
@bors retry |
[`map_entry`]: Check insert expression for map use The lint makes sure that the map is not used (borrowed) before the call to `insert`. Since the lint creates a mutable borrow on the map with the `Entry`, it wouldn't be possible to replace such code with `Entry`. However, expressions up to the `insert` call are checked, but not expressions for the arguments of the `insert` call itself. This commit fixes that. Fixes #11935 ---- changelog: [`map_entry`]: Fix false positive when borrowing the map in the `insert` call
💔 Test failed - checks-action_test |
The errors do not happen near the code I have changed. I have no MacOS computer to test that locally. If this is linked to the code I wrote, do you have any hint for me regarding a way of debugging this? |
Random SIGABRT in an unrelated test on a macOS runner, definitely looks spurious |
[`map_entry`]: Check insert expression for map use The lint makes sure that the map is not used (borrowed) before the call to `insert`. Since the lint creates a mutable borrow on the map with the `Entry`, it wouldn't be possible to replace such code with `Entry`. However, expressions up to the `insert` call are checked, but not expressions for the arguments of the `insert` call itself. This commit fixes that. Fixes #11935 ---- changelog: [`map_entry`]: Fix false positive when borrowing the map in the `insert` call
💔 Test failed - checks-action_test |
This failure looks less 'spurious' (as in, I can at least repro it locally after I wonder if this has something to do with the new version of uitest published 40 minutes ago that might've broken clippy? cc @oli-obk ? |
Ah, I just saw #12363, which looks like it fixed these failing tests. Probably just needs a rebase then |
The lint makes sure that the map is not used (borrowed) before the call to `insert`. Since the lint creates a mutable borrow on the map with the `Entry`, it wouldn't be possible to replace such code with `Entry`. However, expressions up to the `insert` call are checked, but not expressions for the arguments of the `insert` call itself. This commit fixes that. Fixes rust-lang#11935
Hurray! 🎉 Thanks for digging into this @y21! |
@bors retry |
ah oops |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
The lint makes sure that the map is not used (borrowed) before the call to
insert
. Since the lint creates a mutable borrow on the map with theEntry
, it wouldn't be possible to replace such code withEntry
. However, expressions up to theinsert
call are checked, but not expressions for the arguments of theinsert
call itself. This commit fixes that.Fixes #11935
changelog: [
map_entry
]: Fix false positive when borrowing the map in theinsert
call