1
Fork 0

Use get_diagnostic_name more

This commit is contained in:
Cameron Steffen 2021-11-16 13:12:38 -06:00
parent d914f17ca7
commit dec40530f7
6 changed files with 73 additions and 74 deletions

View file

@ -539,11 +539,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
// is otherwise overwhelming and unhelpful (see #85844 for an
// example).
let trait_is_debug =
self.tcx.is_diagnostic_item(sym::Debug, trait_ref.def_id());
let trait_is_display =
self.tcx.is_diagnostic_item(sym::Display, trait_ref.def_id());
let in_std_macro =
match obligation.cause.span.ctxt().outer_expn_data().macro_def_id {
Some(macro_def_id) => {
@ -553,7 +548,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
None => false,
};
if in_std_macro && (trait_is_debug || trait_is_display) {
if in_std_macro
&& matches!(
self.tcx.get_diagnostic_name(trait_ref.def_id()),
Some(sym::Debug | sym::Display)
)
{
err.emit();
return;
}