fix cast_lossless with macro call

This commit is contained in:
mojave2 2023-09-16 23:17:47 +08:00
parent f54275f20f
commit af2a8478ba
No known key found for this signature in database
4 changed files with 43 additions and 2 deletions

View file

@ -25,7 +25,14 @@ pub(super) fn check(
// The suggestion is to use a function call, so if the original expression
// has parens on the outside, they are no longer needed.
let mut applicability = Applicability::MachineApplicable;
let opt = snippet_opt(cx, cast_op.span);
let opt = snippet_opt(
cx,
if cast_op.span.from_expansion() {
cast_op.span.source_callsite()
} else {
cast_op.span
},
);
let sugg = opt.as_ref().map_or_else(
|| {
applicability = Applicability::HasPlaceholders;