diff options
| author | Michael Goulet <michael@errs.io> | 2022-07-24 19:33:26 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-07-24 19:35:53 +0000 |
| commit | 3bbe95ca0cb50260aa23a507642af05a83652a4e (patch) | |
| tree | a55a19954a66b17b824c769d45fa704ed84b5d65 /compiler/rustc_trait_selection/src | |
| parent | 2bbcdc73339c2b7c3e57c2fc0d3bc574945c0023 (diff) | |
| download | rust-3bbe95ca0cb50260aa23a507642af05a83652a4e.tar.gz rust-3bbe95ca0cb50260aa23a507642af05a83652a4e.zip | |
Combine redundant obligation cause codes
Diffstat (limited to 'compiler/rustc_trait_selection/src')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs | 40 |
2 files changed, 6 insertions, 41 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index 2f92a77a795..41c5087c43d 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -301,13 +301,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { span = obligation.cause.span; } } - if let ObligationCauseCode::CompareImplMethodObligation { - impl_item_def_id, - trait_item_def_id, - } - | ObligationCauseCode::CompareImplTypeObligation { + if let ObligationCauseCode::CompareImplItemObligation { impl_item_def_id, trait_item_def_id, + kind: _, } = *obligation.cause.code() { self.report_extra_impl_obligation( diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 7ab85e7fa66..89d7c050c40 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -2682,11 +2682,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { ) }); } - ObligationCauseCode::CompareImplMethodObligation { trait_item_def_id, .. } => { + ObligationCauseCode::CompareImplItemObligation { trait_item_def_id, kind, .. } => { let item_name = self.tcx.item_name(trait_item_def_id); let msg = format!( - "the requirement `{}` appears on the impl method `{}` but not on the \ - corresponding trait method", + "the requirement `{}` appears on the `impl`'s {kind} `{}` but not on the \ + corresponding trait's {kind}", predicate, item_name, ); let sp = self @@ -2697,7 +2697,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { let mut assoc_span: MultiSpan = sp.into(); assoc_span.push_span_label( sp, - format!("this trait method doesn't have the requirement `{}`", predicate), + format!("this trait's {kind} doesn't have the requirement `{}`", predicate), ); if let Some(ident) = self .tcx @@ -2708,38 +2708,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { } err.span_note(assoc_span, &msg); } - ObligationCauseCode::CompareImplTypeObligation { trait_item_def_id, .. } => { - let item_name = self.tcx.item_name(trait_item_def_id); - let msg = format!( - "the requirement `{}` appears on the associated impl type `{}` but not on the \ - corresponding associated trait type", - predicate, item_name, - ); - let sp = self.tcx.def_span(trait_item_def_id); - let mut assoc_span: MultiSpan = sp.into(); - assoc_span.push_span_label( - sp, - format!( - "this trait associated type doesn't have the requirement `{}`", - predicate, - ), - ); - if let Some(ident) = self - .tcx - .opt_associated_item(trait_item_def_id) - .and_then(|i| self.tcx.opt_item_ident(i.container.id())) - { - assoc_span.push_span_label(ident.span, "in this trait"); - } - err.span_note(assoc_span, &msg); - } - ObligationCauseCode::CompareImplConstObligation => { - err.note(&format!( - "the requirement `{}` appears on the associated impl constant \ - but not on the corresponding associated trait constant", - predicate - )); - } ObligationCauseCode::TrivialBound => { err.help("see issue #48214"); if tcx.sess.opts.unstable_features.is_nightly_build() { |
