- span_lint_and_sugg(
- cx,
- MANUAL_INSTANT_ELAPSED,
- expr.span,
- "manual implementation of `Instant::elapsed`",
- "try",
- format!("{}.elapsed()", sugg.maybe_par()),
- Applicability::MachineApplicable,
- );
- }
-
- if expr.span.from_expansion() || !meets_msrv(self.msrv, msrvs::TRY_FROM) {
- return;
- }
-
- if_chain! {
- if let ExprKind::Binary(op, lhs, rhs) = expr.kind;
-
- if let BinOpKind::Sub = op.node;
-
- // get types of left and right side
- if is_an_instant(cx, lhs);
- if is_a_duration(cx, rhs);
-
- then {
- print_lint_and_sugg(cx, lhs, rhs, expr)
+ if_chain! {
+ if is_instant_now_call(cx, lhs);
+
+ if is_an_instant(cx, rhs);
+ if let Some(sugg) = Sugg::hir_opt(cx, rhs);
+
+ then {
+ print_manual_instant_elapsed_sugg(cx, expr, sugg)
+ } else {
+ if_chain! {
+ if !expr.span.from_expansion();
+ if meets_msrv(self.msrv, msrvs::TRY_FROM);
+
+ if is_an_instant(cx, lhs);
+ if is_a_duration(cx, rhs);
+
+ then {
+ print_unchecked_duration_subtraction_sugg(cx, lhs, rhs, expr)
+ }
+ }
+ }