Skip to content

Commit 9594747

Browse files
Suppress suggestions in derive macro
1 parent 3066253 commit 9594747

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2839,13 +2839,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
28392839
let msg =
28402840
format!("{} and panic if the converted value doesn't fit", msg.clone());
28412841
let mut suggestion = sugg.clone();
2842-
suggestion.push((
2843-
expr.span.shrink_to_hi(),
2844-
format!("{close_paren}.try_into().unwrap()"),
2845-
));
2842+
if !expr.span.in_derive_expansion() {
2843+
suggestion.push((
2844+
expr.span.shrink_to_hi(),
2845+
format!("{close_paren}.try_into().unwrap()"),
2846+
));
2847+
}
28462848
(msg, suggestion)
28472849
};
2848-
err.multipart_suggestion_verbose(msg, suggestion, Applicability::MachineApplicable);
2850+
2851+
if !suggestion.is_empty() {
2852+
err.multipart_suggestion_verbose(
2853+
msg,
2854+
suggestion,
2855+
Applicability::MachineApplicable,
2856+
);
2857+
}
28492858
};
28502859

28512860
let suggest_to_change_suffix_or_into =

0 commit comments

Comments
 (0)