Introduce get_diagnostic_name
This commit is contained in:
parent
d7539a6af0
commit
33b9b95305
9 changed files with 59 additions and 34 deletions
|
@ -1636,12 +1636,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
|
||||
// Special case the primary error message when send or sync is the trait that was
|
||||
// not implemented.
|
||||
let is_send = self.tcx.is_diagnostic_item(sym::Send, trait_ref.def_id);
|
||||
let is_sync = self.tcx.is_diagnostic_item(sym::Sync, trait_ref.def_id);
|
||||
let hir = self.tcx.hir();
|
||||
let trait_explanation = if is_send || is_sync {
|
||||
let trait_explanation = if let Some(name @ (sym::Send | sym::Sync)) =
|
||||
self.tcx.get_diagnostic_name(trait_ref.def_id)
|
||||
{
|
||||
let (trait_name, trait_verb) =
|
||||
if is_send { ("`Send`", "sent") } else { ("`Sync`", "shared") };
|
||||
if name == sym::Send { ("`Send`", "sent") } else { ("`Sync`", "shared") };
|
||||
|
||||
err.clear_code();
|
||||
err.set_primary_message(format!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue