accidentally cause an ICE by putting the TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS handling after the match

The reason I did this in the first place was to try and figure out why I don't see my expected 7 error messages
This commit is contained in:
Ryan1729 2020-08-03 00:16:11 -06:00
parent 7061b1c093
commit b4ecee9ede

View File

@ -626,21 +626,25 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
);
}
},
(_, _) if can_be_expressed_as_pointer_cast(cx, e, from_ty, to_ty) => {
span_lint(
cx,
TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS,
e.span,
&format!(
"transmute from `{}` to `{}` which could be expressed as a pointer cast instead",
from_ty,
to_ty
)
);
},
_ => {
return
},
_ => {},
}
if can_be_expressed_as_pointer_cast(cx, e, from_ty, to_ty) {
span_lint_and_then(
cx,
TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS,
e.span,
&format!(
"transmute from `{}` to `{}` which could be expressed as a pointer cast instead",
from_ty,
to_ty
),
|diag| {
if let Some(arg) = sugg::Sugg::hir_opt(cx, &args[0]) {
let sugg = format!("{} as {}", arg, to_ty);
diag.span_suggestion(e.span, "try", sugg, Applicability::Unspecified);
}
}
)
}
}
}