-
Notifications
You must be signed in to change notification settings - Fork 1.7k
missing_asserts_for_indexing
: consider assert_eq!()
as well
#14258
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
} else if let Some((macro_call, bin_op)) = | ||
first_node_macro_backtrace(cx, expr).find_map(|macro_call| match cx.tcx.item_name(macro_call.def_id).as_str() { | ||
"assert_eq" => Some((macro_call, BinOpKind::Eq)), | ||
"assert_ne" => Some((macro_call, BinOpKind::Ne)), |
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 think you can use the symbols directly here (for example https://doc.rust-lang.org/nightly/nightly-rustc/rustc_span/symbol/sym/constant.assert_ne_macro.html) instead of matching on strings.
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.
Good point. Updated.
97ea9f9
to
0d65456
Compare
0d65456
to
e4d2a23
Compare
This comment has been minimized.
This comment has been minimized.
`assert_eq!()` and `assert_ne!()` are not expanded the same way as `assert!()` (they use a `match` instead of a `if`). This makes them being recognized as well.
e4d2a23
to
d1c315a
Compare
Rebased |
Looks like it was closed by mistake, reopening. |
r? clippy |
r? clippy |
assert_eq!()
andassert_ne!()
are not expanded the same way asassert!()
(they use amatch
instead of aif
). This makes them being recognized as well.Fix #14255
changelog: [
missing_asserts_for_indexing
]: considerassert_eq!()
as well