-
Notifications
You must be signed in to change notification settings - Fork 1.7k
check f16 and f128 in float_equality_without_abs #15054
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
base: master
Are you sure you want to change the base?
Conversation
&& let ExprKind::Path(ref epsilon_path) = rhs.kind | ||
&& let Res::Def(DefKind::AssocConst, def_id) = cx.qpath_res(epsilon_path, rhs.hir_id) | ||
&& ([sym::f32_epsilon, sym::f64_epsilon].into_iter().any(|sym| cx.tcx.is_diagnostic_item(sym, def_id))) | ||
&& (sym_epsilon.into_iter().any(|sym| cx.tcx.is_diagnostic_item(sym, def_id))) |
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.
Suggestion: you can use get_diagnostic_item
to avoid a bunch of query overhead, something like
&& (sym_epsilon.into_iter().any(|sym| cx.tcx.is_diagnostic_item(sym, def_id))) | |
&& matches!(cx.tcx.get_diagnostic_name(def_id), Some(sym::f16_epsilon | sym::f32_epsilon | sym::f64_epsilon | sym::f128_epsilon)) |
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.
It's too long so rustfmt complains error[internal]: line formatted, but exceeded maximum width
.
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 can split the line by hand and make rustfmt
happy.
Can you also add tests for this? It seems like there's also a f16_f128 FIXME in the code that could easily be resolved in the same PR here:
|
Added. |
followup of rust-lang/rust#141874
changelog: check f16 and f128 in float_equality_without_abs