Remove some fields from ObligationCauseCode
This commit is contained in:
parent
7276a6a117
commit
9734c03524
9 changed files with 29 additions and 62 deletions
|
@ -2190,14 +2190,12 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
if let Some(SubregionOrigin::CompareImplMethodObligation {
|
if let Some(SubregionOrigin::CompareImplMethodObligation {
|
||||||
span,
|
span,
|
||||||
item_name,
|
|
||||||
impl_item_def_id,
|
impl_item_def_id,
|
||||||
trait_item_def_id,
|
trait_item_def_id,
|
||||||
}) = origin
|
}) = origin
|
||||||
{
|
{
|
||||||
return self.report_extra_impl_obligation(
|
return self.report_extra_impl_obligation(
|
||||||
span,
|
span,
|
||||||
item_name,
|
|
||||||
impl_item_def_id,
|
impl_item_def_id,
|
||||||
trait_item_def_id,
|
trait_item_def_id,
|
||||||
&format!("`{}: {}`", bound_kind, sub),
|
&format!("`{}: {}`", bound_kind, sub),
|
||||||
|
|
|
@ -54,12 +54,16 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||||
{
|
{
|
||||||
if let SubregionOrigin::CompareImplTypeObligation {
|
if let SubregionOrigin::CompareImplTypeObligation {
|
||||||
span,
|
span,
|
||||||
item_name,
|
|
||||||
impl_item_def_id,
|
impl_item_def_id,
|
||||||
trait_item_def_id,
|
trait_item_def_id,
|
||||||
} = origin
|
} = origin
|
||||||
{
|
{
|
||||||
self.emit_associated_type_err(span, item_name, impl_item_def_id, trait_item_def_id);
|
self.emit_associated_type_err(
|
||||||
|
span,
|
||||||
|
self.infcx.tcx.item_name(impl_item_def_id),
|
||||||
|
impl_item_def_id,
|
||||||
|
trait_item_def_id,
|
||||||
|
);
|
||||||
return Some(ErrorReported);
|
return Some(ErrorReported);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -330,30 +330,21 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
);
|
);
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::CompareImplMethodObligation {
|
infer::CompareImplMethodObligation { span, impl_item_def_id, trait_item_def_id } => {
|
||||||
span,
|
self.report_extra_impl_obligation(
|
||||||
item_name,
|
span,
|
||||||
impl_item_def_id,
|
impl_item_def_id,
|
||||||
trait_item_def_id,
|
trait_item_def_id,
|
||||||
} => self.report_extra_impl_obligation(
|
&format!("`{}: {}`", sup, sub),
|
||||||
span,
|
)
|
||||||
item_name,
|
}
|
||||||
impl_item_def_id,
|
infer::CompareImplTypeObligation { span, impl_item_def_id, trait_item_def_id } => self
|
||||||
trait_item_def_id,
|
.report_extra_impl_obligation(
|
||||||
&format!("`{}: {}`", sup, sub),
|
span,
|
||||||
),
|
impl_item_def_id,
|
||||||
infer::CompareImplTypeObligation {
|
trait_item_def_id,
|
||||||
span,
|
&format!("`{}: {}`", sup, sub),
|
||||||
item_name,
|
),
|
||||||
impl_item_def_id,
|
|
||||||
trait_item_def_id,
|
|
||||||
} => self.report_extra_impl_obligation(
|
|
||||||
span,
|
|
||||||
item_name,
|
|
||||||
impl_item_def_id,
|
|
||||||
trait_item_def_id,
|
|
||||||
&format!("`{}: {}`", sup, sub),
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -419,21 +419,11 @@ pub enum SubregionOrigin<'tcx> {
|
||||||
|
|
||||||
/// Comparing the signature and requirements of an impl method against
|
/// Comparing the signature and requirements of an impl method against
|
||||||
/// the containing trait.
|
/// the containing trait.
|
||||||
CompareImplMethodObligation {
|
CompareImplMethodObligation { span: Span, impl_item_def_id: DefId, trait_item_def_id: DefId },
|
||||||
span: Span,
|
|
||||||
item_name: Symbol,
|
|
||||||
impl_item_def_id: DefId,
|
|
||||||
trait_item_def_id: DefId,
|
|
||||||
},
|
|
||||||
|
|
||||||
/// Comparing the signature and requirements of an impl associated type
|
/// Comparing the signature and requirements of an impl associated type
|
||||||
/// against the containing trait
|
/// against the containing trait
|
||||||
CompareImplTypeObligation {
|
CompareImplTypeObligation { span: Span, impl_item_def_id: DefId, trait_item_def_id: DefId },
|
||||||
span: Span,
|
|
||||||
item_name: Symbol,
|
|
||||||
impl_item_def_id: DefId,
|
|
||||||
trait_item_def_id: DefId,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// `SubregionOrigin` is used a lot. Make sure it doesn't unintentionally get bigger.
|
// `SubregionOrigin` is used a lot. Make sure it doesn't unintentionally get bigger.
|
||||||
|
@ -1830,23 +1820,19 @@ impl<'tcx> SubregionOrigin<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
traits::ObligationCauseCode::CompareImplMethodObligation {
|
traits::ObligationCauseCode::CompareImplMethodObligation {
|
||||||
item_name,
|
|
||||||
impl_item_def_id,
|
impl_item_def_id,
|
||||||
trait_item_def_id,
|
trait_item_def_id,
|
||||||
} => SubregionOrigin::CompareImplMethodObligation {
|
} => SubregionOrigin::CompareImplMethodObligation {
|
||||||
span: cause.span,
|
span: cause.span,
|
||||||
item_name,
|
|
||||||
impl_item_def_id,
|
impl_item_def_id,
|
||||||
trait_item_def_id,
|
trait_item_def_id,
|
||||||
},
|
},
|
||||||
|
|
||||||
traits::ObligationCauseCode::CompareImplTypeObligation {
|
traits::ObligationCauseCode::CompareImplTypeObligation {
|
||||||
item_name,
|
|
||||||
impl_item_def_id,
|
impl_item_def_id,
|
||||||
trait_item_def_id,
|
trait_item_def_id,
|
||||||
} => SubregionOrigin::CompareImplTypeObligation {
|
} => SubregionOrigin::CompareImplTypeObligation {
|
||||||
span: cause.span,
|
span: cause.span,
|
||||||
item_name,
|
|
||||||
impl_item_def_id,
|
impl_item_def_id,
|
||||||
trait_item_def_id,
|
trait_item_def_id,
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,7 +6,6 @@ use rustc_errors::{struct_span_err, DiagnosticBuilder};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_span::symbol::Symbol;
|
|
||||||
use rustc_span::{MultiSpan, Span};
|
use rustc_span::{MultiSpan, Span};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
@ -15,8 +14,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
pub fn report_extra_impl_obligation(
|
pub fn report_extra_impl_obligation(
|
||||||
&self,
|
&self,
|
||||||
error_span: Span,
|
error_span: Span,
|
||||||
item_name: Symbol,
|
impl_item_def_id: DefId,
|
||||||
_impl_item_def_id: DefId,
|
|
||||||
trait_item_def_id: DefId,
|
trait_item_def_id: DefId,
|
||||||
requirement: &dyn fmt::Display,
|
requirement: &dyn fmt::Display,
|
||||||
) -> DiagnosticBuilder<'tcx> {
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
|
@ -27,6 +25,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
if let Some(trait_item_span) = self.tcx.hir().span_if_local(trait_item_def_id) {
|
if let Some(trait_item_span) = self.tcx.hir().span_if_local(trait_item_def_id) {
|
||||||
let span = self.tcx.sess.source_map().guess_head_span(trait_item_span);
|
let span = self.tcx.sess.source_map().guess_head_span(trait_item_span);
|
||||||
|
let item_name = self.tcx.item_name(impl_item_def_id);
|
||||||
err.span_label(span, format!("definition of `{}` from trait", item_name));
|
err.span_label(span, format!("definition of `{}` from trait", item_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -267,14 +267,12 @@ pub enum ObligationCauseCode<'tcx> {
|
||||||
|
|
||||||
/// Error derived when matching traits/impls; see ObligationCause for more details
|
/// Error derived when matching traits/impls; see ObligationCause for more details
|
||||||
CompareImplMethodObligation {
|
CompareImplMethodObligation {
|
||||||
item_name: Symbol,
|
|
||||||
impl_item_def_id: DefId,
|
impl_item_def_id: DefId,
|
||||||
trait_item_def_id: DefId,
|
trait_item_def_id: DefId,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Error derived when matching traits/impls; see ObligationCause for more details
|
/// Error derived when matching traits/impls; see ObligationCause for more details
|
||||||
CompareImplTypeObligation {
|
CompareImplTypeObligation {
|
||||||
item_name: Symbol,
|
|
||||||
impl_item_def_id: DefId,
|
impl_item_def_id: DefId,
|
||||||
trait_item_def_id: DefId,
|
trait_item_def_id: DefId,
|
||||||
},
|
},
|
||||||
|
|
|
@ -266,19 +266,16 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let ObligationCauseCode::CompareImplMethodObligation {
|
if let ObligationCauseCode::CompareImplMethodObligation {
|
||||||
item_name,
|
|
||||||
impl_item_def_id,
|
impl_item_def_id,
|
||||||
trait_item_def_id,
|
trait_item_def_id,
|
||||||
}
|
}
|
||||||
| ObligationCauseCode::CompareImplTypeObligation {
|
| ObligationCauseCode::CompareImplTypeObligation {
|
||||||
item_name,
|
|
||||||
impl_item_def_id,
|
impl_item_def_id,
|
||||||
trait_item_def_id,
|
trait_item_def_id,
|
||||||
} = obligation.cause.code
|
} = obligation.cause.code
|
||||||
{
|
{
|
||||||
self.report_extra_impl_obligation(
|
self.report_extra_impl_obligation(
|
||||||
span,
|
span,
|
||||||
item_name,
|
|
||||||
impl_item_def_id,
|
impl_item_def_id,
|
||||||
trait_item_def_id,
|
trait_item_def_id,
|
||||||
&format!("`{}`", obligation.predicate),
|
&format!("`{}`", obligation.predicate),
|
||||||
|
|
|
@ -2354,11 +2354,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
ObligationCauseCode::CompareImplMethodObligation {
|
ObligationCauseCode::CompareImplMethodObligation { trait_item_def_id, .. } => {
|
||||||
item_name,
|
let item_name = self.tcx.item_name(trait_item_def_id);
|
||||||
trait_item_def_id,
|
|
||||||
..
|
|
||||||
} => {
|
|
||||||
let msg = format!(
|
let msg = format!(
|
||||||
"the requirement `{}` appears on the impl method `{}` but not on the \
|
"the requirement `{}` appears on the impl method `{}` but not on the \
|
||||||
corresponding trait method",
|
corresponding trait method",
|
||||||
|
@ -2383,9 +2380,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
err.span_note(assoc_span, &msg);
|
err.span_note(assoc_span, &msg);
|
||||||
}
|
}
|
||||||
ObligationCauseCode::CompareImplTypeObligation {
|
ObligationCauseCode::CompareImplTypeObligation { trait_item_def_id, .. } => {
|
||||||
item_name, trait_item_def_id, ..
|
let item_name = self.tcx.item_name(trait_item_def_id);
|
||||||
} => {
|
|
||||||
let msg = format!(
|
let msg = format!(
|
||||||
"the requirement `{}` appears on the associated impl type `{}` but not on the \
|
"the requirement `{}` appears on the associated impl type `{}` but not on the \
|
||||||
corresponding associated trait type",
|
corresponding associated trait type",
|
||||||
|
|
|
@ -92,7 +92,6 @@ fn compare_predicate_entailment<'tcx>(
|
||||||
impl_m_span,
|
impl_m_span,
|
||||||
impl_m_hir_id,
|
impl_m_hir_id,
|
||||||
ObligationCauseCode::CompareImplMethodObligation {
|
ObligationCauseCode::CompareImplMethodObligation {
|
||||||
item_name: impl_m.ident.name,
|
|
||||||
impl_item_def_id: impl_m.def_id,
|
impl_item_def_id: impl_m.def_id,
|
||||||
trait_item_def_id: trait_m.def_id,
|
trait_item_def_id: trait_m.def_id,
|
||||||
},
|
},
|
||||||
|
@ -1164,7 +1163,6 @@ fn compare_type_predicate_entailment<'tcx>(
|
||||||
impl_ty_span,
|
impl_ty_span,
|
||||||
impl_ty_hir_id,
|
impl_ty_hir_id,
|
||||||
ObligationCauseCode::CompareImplTypeObligation {
|
ObligationCauseCode::CompareImplTypeObligation {
|
||||||
item_name: impl_ty.ident.name,
|
|
||||||
impl_item_def_id: impl_ty.def_id,
|
impl_item_def_id: impl_ty.def_id,
|
||||||
trait_item_def_id: trait_ty.def_id,
|
trait_item_def_id: trait_ty.def_id,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue