New by_ref_peekable_peek lint#17042
Conversation
|
r? @Jarcho rustbot has assigned @Jarcho. Use Why was this reviewer chosen?The reviewer was selected based on:
|
274ead3 to
bad070b
Compare
| use super::BY_REF_PEEKABLE_PEEK; | ||
|
|
||
| pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>) { | ||
| if let Some(recvs) = method_chain_args(recv, &[sym::by_ref, sym::peekable]) |
There was a problem hiding this comment.
Can we not use method_chain_args. It's only mildly shorter to write, but it's notably slower and does a hidden from_expansion check on everything.
| && cx | ||
| .typeck_results() | ||
| .expr_ty(recv) | ||
| .peel_refs() | ||
| .is_diag_item(cx, sym::IterPeekable) |
There was a problem hiding this comment.
This doesn't check that we called the correct peekable function.
| && let Some(def_id) = cx.typeck_results().type_dependent_def_id(recvs[1].0.hir_id) | ||
| && paths::ITERATOR_BY_REF.matches(cx, def_id) |
There was a problem hiding this comment.
cx.ty_based_def(recvs[1].0).opt_parent().is_diag_item(sym::Iterator)
|
@rustbot label lint-nominated |
|
This lint has been nominated for inclusion. |
bad070b to
1eb259c
Compare
|
I've changed the code to not use |
1eb259c to
c6e0832
Compare
c6e0832 to
59f63dd
Compare
changelog: [
by_ref_peekable_peek]: new lintCloses #17020