-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fix iter_kv_map false positive into_keys and into_values suggestion #11757
Conversation
r? @Alexendoo (rustbot has picked a reviewer for you, use r? to override) |
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.
This should probably also update the lint documentation:
rust-clippy/clippy_config/src/conf.rs
Line 252 in 902c79c
/// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, OPTION_MAP_UNWRAP_OR, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE, BORROW_AS_PTR, MANUAL_BITS, ERR_EXPECT, CAST_ABS_TO_UNSIGNED, UNINLINED_FORMAT_ARGS, MANUAL_CLAMP, MANUAL_LET_ELSE, UNCHECKED_DURATION_SUBTRACTION, COLLAPSIBLE_STR_REPLACE, SEEK_FROM_CURRENT, SEEK_REWIND, UNNECESSARY_LAZY_EVALUATIONS, TRANSMUTE_PTR_TO_REF, ALMOST_COMPLETE_RANGE, NEEDLESS_BORROW, DERIVABLE_IMPLS, MANUAL_IS_ASCII_CHECK, MANUAL_REM_EUCLID, MANUAL_RETAIN, TYPE_REPETITION_IN_BOUNDS, TUPLE_ARRAY_CONVERSIONS, MANUAL_TRY_FOLD, MANUAL_HASH_ONE. |
Thanks for pointing that out, I updated the documentation |
☔ The latest upstream changes (presumably #11750) made this pull request unmergeable. Please resolve the merge conflicts. |
840481f
to
d77b9be
Compare
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 to me 👍
I have one comment but that's not really concerned with the PR here, rather the lint itself, so feel free to ignore.
) { | ||
if map_type == "into_iter" && !msrv.meets(msrvs::INTO_KEYS) { | ||
return; | ||
} | ||
if !expr.span.from_expansion() | ||
&& let ExprKind::Closure(c) = m_arg.kind |
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.
This lint should probably check that the closure doesn't have parameter- or return type annotations since that can help type inference or make the map
closure act as a coercion site.
Not your problem though, that could be a PR on its own, unless you also want to try to fix that here ^^.
Examples where the machine applicable suggestion breaks: coercions, inference
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.
I will have a try fixing this, but I think I will open a separate PR so this one doesn't get too cluttered ^^
Thanks! @bors r+ |
Fix iter_kv_map false positive into_keys and into_values suggestion fixes: #11752 changelog: [`iter_kv_map`]: fix false positive: Don't suggest `into_keys()` and `into_values()` if the MSRV is to low
💔 Test failed - checks-action_test |
d77b9be
to
a20f61b
Compare
I ran the |
Yeah a note would be good, would be good for us to see if we can make it automatic also |
@bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Add documentation update hint using `cargo collect-metadata` This adds a little reminder to update the documentation in the book using `cargo collect-metadata` after changing the lint configuration since this can easily be missed (been there done that 🙈). > Yeah a note would be good, would be good for us to see if we can make it automatic also _Originally posted by `@Alexendoo` in #11757 (comment) Regarding the automation Im not sure whats the best option here. I thought about a kind of a "semi-automated" way, e.g. a `cargo dev` command which runs the "is the documentation updated" check (and maybe other useful checks) locally and reminds the user of updating the documentation so this gets caught before pushing. changelog: none
fixes: #11752
changelog: [
iter_kv_map
]: fix false positive: Don't suggestinto_keys()
andinto_values()
if the MSRV is to low