Rollup merge of #119897 - compiler-errors:fulfillment-errors, r=lcnr
`OutputTypeParameterMismatch` -> `SignatureMismatch` I'm probably missing something that made this rename more complicated. What did you end up getting stuck on when renaming this selection error, `@lcnr?` **also** I renamed the `FulfillmentErrorCode` variants. This is just churn but I wanted to do it forever. I can move it out of this PR if desired. r? lcnr
This commit is contained in:
commit
1e46be6a53
13 changed files with 82 additions and 85 deletions
|
@ -1215,7 +1215,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
for error in errors {
|
for error in errors {
|
||||||
if let FulfillmentErrorCode::CodeSelectionError(
|
if let FulfillmentErrorCode::SelectionError(
|
||||||
SelectionError::Unimplemented,
|
SelectionError::Unimplemented,
|
||||||
) = error.code
|
) = error.code
|
||||||
&& let ty::PredicateKind::Clause(ty::ClauseKind::Trait(
|
&& let ty::PredicateKind::Clause(ty::ClauseKind::Trait(
|
||||||
|
|
|
@ -1291,7 +1291,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
// The type doesn't implement Clone because of unmet obligations.
|
// The type doesn't implement Clone because of unmet obligations.
|
||||||
for error in errors {
|
for error in errors {
|
||||||
if let traits::FulfillmentErrorCode::CodeSelectionError(
|
if let traits::FulfillmentErrorCode::SelectionError(
|
||||||
traits::SelectionError::Unimplemented,
|
traits::SelectionError::Unimplemented,
|
||||||
) = error.code
|
) = error.code
|
||||||
&& let ty::PredicateKind::Clause(ty::ClauseKind::Trait(
|
&& let ty::PredicateKind::Clause(ty::ClauseKind::Trait(
|
||||||
|
|
|
@ -86,7 +86,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// Finally, for ambiguity-related errors, we actually want to look
|
// Finally, for ambiguity-related errors, we actually want to look
|
||||||
// for a parameter that is the source of the inference type left
|
// for a parameter that is the source of the inference type left
|
||||||
// over in this predicate.
|
// over in this predicate.
|
||||||
if let traits::FulfillmentErrorCode::CodeAmbiguity { .. } = error.code {
|
if let traits::FulfillmentErrorCode::Ambiguity { .. } = error.code {
|
||||||
fallback_param_to_point_at = None;
|
fallback_param_to_point_at = None;
|
||||||
self_param_to_point_at = None;
|
self_param_to_point_at = None;
|
||||||
param_to_point_at =
|
param_to_point_at =
|
||||||
|
@ -361,10 +361,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
error: &traits::FulfillmentError<'tcx>,
|
error: &traits::FulfillmentError<'tcx>,
|
||||||
span: Span,
|
span: Span,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
if let traits::FulfillmentErrorCode::CodeSelectionError(
|
if let traits::FulfillmentErrorCode::SelectionError(
|
||||||
traits::SelectionError::OutputTypeParameterMismatch(
|
traits::SelectionError::SignatureMismatch(box traits::SignatureMismatchData {
|
||||||
box traits::SelectionOutputTypeParameterMismatch { expected_trait_ref, .. },
|
expected_trait_ref,
|
||||||
),
|
..
|
||||||
|
}),
|
||||||
) = error.code
|
) = error.code
|
||||||
&& let ty::Closure(def_id, _) | ty::Coroutine(def_id, ..) =
|
&& let ty::Closure(def_id, _) | ty::Coroutine(def_id, ..) =
|
||||||
expected_trait_ref.skip_binder().self_ty().kind()
|
expected_trait_ref.skip_binder().self_ty().kind()
|
||||||
|
|
|
@ -1648,7 +1648,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for error in errors {
|
for error in errors {
|
||||||
if let traits::FulfillmentErrorCode::CodeSelectionError(
|
if let traits::FulfillmentErrorCode::SelectionError(
|
||||||
traits::SelectionError::Unimplemented,
|
traits::SelectionError::Unimplemented,
|
||||||
) = error.code
|
) = error.code
|
||||||
&& let ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) =
|
&& let ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) =
|
||||||
|
|
|
@ -17,7 +17,6 @@ use rustc_middle::ty::error::{ExpectedFound, TypeError};
|
||||||
use rustc_middle::ty::{self, Const, ToPredicate, Ty, TyCtxt};
|
use rustc_middle::ty::{self, Const, ToPredicate, Ty, TyCtxt};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
pub use self::FulfillmentErrorCode::*;
|
|
||||||
pub use self::ImplSource::*;
|
pub use self::ImplSource::*;
|
||||||
pub use self::SelectionError::*;
|
pub use self::SelectionError::*;
|
||||||
|
|
||||||
|
@ -129,12 +128,12 @@ pub struct FulfillmentError<'tcx> {
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum FulfillmentErrorCode<'tcx> {
|
pub enum FulfillmentErrorCode<'tcx> {
|
||||||
/// Inherently impossible to fulfill; this trait is implemented if and only if it is already implemented.
|
/// Inherently impossible to fulfill; this trait is implemented if and only if it is already implemented.
|
||||||
CodeCycle(Vec<PredicateObligation<'tcx>>),
|
Cycle(Vec<PredicateObligation<'tcx>>),
|
||||||
CodeSelectionError(SelectionError<'tcx>),
|
SelectionError(SelectionError<'tcx>),
|
||||||
CodeProjectionError(MismatchedProjectionTypes<'tcx>),
|
ProjectionError(MismatchedProjectionTypes<'tcx>),
|
||||||
CodeSubtypeError(ExpectedFound<Ty<'tcx>>, TypeError<'tcx>), // always comes from a SubtypePredicate
|
SubtypeError(ExpectedFound<Ty<'tcx>>, TypeError<'tcx>), // always comes from a SubtypePredicate
|
||||||
CodeConstEquateError(ExpectedFound<Const<'tcx>>, TypeError<'tcx>),
|
ConstEquateError(ExpectedFound<Const<'tcx>>, TypeError<'tcx>),
|
||||||
CodeAmbiguity {
|
Ambiguity {
|
||||||
/// Overflow reported from the new solver `-Znext-solver`, which will
|
/// Overflow reported from the new solver `-Znext-solver`, which will
|
||||||
/// be reported as an regular error as opposed to a fatal error.
|
/// be reported as an regular error as opposed to a fatal error.
|
||||||
overflow: bool,
|
overflow: bool,
|
||||||
|
|
|
@ -37,18 +37,19 @@ impl<'tcx> fmt::Debug for traits::FulfillmentError<'tcx> {
|
||||||
|
|
||||||
impl<'tcx> fmt::Debug for traits::FulfillmentErrorCode<'tcx> {
|
impl<'tcx> fmt::Debug for traits::FulfillmentErrorCode<'tcx> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
use traits::FulfillmentErrorCode::*;
|
||||||
match *self {
|
match *self {
|
||||||
super::CodeSelectionError(ref e) => write!(f, "{e:?}"),
|
SelectionError(ref e) => write!(f, "{e:?}"),
|
||||||
super::CodeProjectionError(ref e) => write!(f, "{e:?}"),
|
ProjectionError(ref e) => write!(f, "{e:?}"),
|
||||||
super::CodeSubtypeError(ref a, ref b) => {
|
SubtypeError(ref a, ref b) => {
|
||||||
write!(f, "CodeSubtypeError({a:?}, {b:?})")
|
write!(f, "CodeSubtypeError({a:?}, {b:?})")
|
||||||
}
|
}
|
||||||
super::CodeConstEquateError(ref a, ref b) => {
|
ConstEquateError(ref a, ref b) => {
|
||||||
write!(f, "CodeConstEquateError({a:?}, {b:?})")
|
write!(f, "CodeConstEquateError({a:?}, {b:?})")
|
||||||
}
|
}
|
||||||
super::CodeAmbiguity { overflow: false } => write!(f, "Ambiguity"),
|
Ambiguity { overflow: false } => write!(f, "Ambiguity"),
|
||||||
super::CodeAmbiguity { overflow: true } => write!(f, "Overflow"),
|
Ambiguity { overflow: true } => write!(f, "Overflow"),
|
||||||
super::CodeCycle(ref cycle) => write!(f, "Cycle({cycle:?})"),
|
Cycle(ref cycle) => write!(f, "Cycle({cycle:?})"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -604,7 +604,7 @@ pub enum SelectionError<'tcx> {
|
||||||
/// After a closure impl has selected, its "outputs" were evaluated
|
/// After a closure impl has selected, its "outputs" were evaluated
|
||||||
/// (which for closures includes the "input" type params) and they
|
/// (which for closures includes the "input" type params) and they
|
||||||
/// didn't resolve. See `confirm_poly_trait_refs` for more.
|
/// didn't resolve. See `confirm_poly_trait_refs` for more.
|
||||||
OutputTypeParameterMismatch(Box<SelectionOutputTypeParameterMismatch<'tcx>>),
|
SignatureMismatch(Box<SignatureMismatchData<'tcx>>),
|
||||||
/// The trait pointed by `DefId` is not object safe.
|
/// The trait pointed by `DefId` is not object safe.
|
||||||
TraitNotObjectSafe(DefId),
|
TraitNotObjectSafe(DefId),
|
||||||
/// A given constant couldn't be evaluated.
|
/// A given constant couldn't be evaluated.
|
||||||
|
@ -618,7 +618,7 @@ pub enum SelectionError<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, TypeVisitable)]
|
#[derive(Clone, Debug, TypeVisitable)]
|
||||||
pub struct SelectionOutputTypeParameterMismatch<'tcx> {
|
pub struct SignatureMismatchData<'tcx> {
|
||||||
pub found_trait_ref: ty::PolyTraitRef<'tcx>,
|
pub found_trait_ref: ty::PolyTraitRef<'tcx>,
|
||||||
pub expected_trait_ref: ty::PolyTraitRef<'tcx>,
|
pub expected_trait_ref: ty::PolyTraitRef<'tcx>,
|
||||||
pub terr: ty::error::TypeError<'tcx>,
|
pub terr: ty::error::TypeError<'tcx>,
|
||||||
|
|
|
@ -66,10 +66,10 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> {
|
||||||
.0
|
.0
|
||||||
{
|
{
|
||||||
Ok((_, Certainty::Maybe(MaybeCause::Ambiguity), _)) => {
|
Ok((_, Certainty::Maybe(MaybeCause::Ambiguity), _)) => {
|
||||||
FulfillmentErrorCode::CodeAmbiguity { overflow: false }
|
FulfillmentErrorCode::Ambiguity { overflow: false }
|
||||||
}
|
}
|
||||||
Ok((_, Certainty::Maybe(MaybeCause::Overflow), _)) => {
|
Ok((_, Certainty::Maybe(MaybeCause::Overflow), _)) => {
|
||||||
FulfillmentErrorCode::CodeAmbiguity { overflow: true }
|
FulfillmentErrorCode::Ambiguity { overflow: true }
|
||||||
}
|
}
|
||||||
Ok((_, Certainty::Yes, _)) => {
|
Ok((_, Certainty::Yes, _)) => {
|
||||||
bug!("did not expect successful goal when collecting ambiguity errors")
|
bug!("did not expect successful goal when collecting ambiguity errors")
|
||||||
|
@ -108,18 +108,18 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> {
|
||||||
obligation: obligation.clone(),
|
obligation: obligation.clone(),
|
||||||
code: match goal.predicate.kind().skip_binder() {
|
code: match goal.predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Clause(ty::ClauseKind::Projection(_)) => {
|
ty::PredicateKind::Clause(ty::ClauseKind::Projection(_)) => {
|
||||||
FulfillmentErrorCode::CodeProjectionError(
|
FulfillmentErrorCode::ProjectionError(
|
||||||
// FIXME: This could be a `Sorts` if the term is a type
|
// FIXME: This could be a `Sorts` if the term is a type
|
||||||
MismatchedProjectionTypes { err: TypeError::Mismatch },
|
MismatchedProjectionTypes { err: TypeError::Mismatch },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
ty::PredicateKind::NormalizesTo(..) => {
|
ty::PredicateKind::NormalizesTo(..) => {
|
||||||
FulfillmentErrorCode::CodeProjectionError(
|
FulfillmentErrorCode::ProjectionError(
|
||||||
MismatchedProjectionTypes { err: TypeError::Mismatch },
|
MismatchedProjectionTypes { err: TypeError::Mismatch },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
ty::PredicateKind::AliasRelate(_, _, _) => {
|
ty::PredicateKind::AliasRelate(_, _, _) => {
|
||||||
FulfillmentErrorCode::CodeProjectionError(
|
FulfillmentErrorCode::ProjectionError(
|
||||||
MismatchedProjectionTypes { err: TypeError::Mismatch },
|
MismatchedProjectionTypes { err: TypeError::Mismatch },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> {
|
||||||
goal.predicate.kind().rebind((pred.a, pred.b)),
|
goal.predicate.kind().rebind((pred.a, pred.b)),
|
||||||
);
|
);
|
||||||
let expected_found = ExpectedFound::new(true, a, b);
|
let expected_found = ExpectedFound::new(true, a, b);
|
||||||
FulfillmentErrorCode::CodeSubtypeError(
|
FulfillmentErrorCode::SubtypeError(
|
||||||
expected_found,
|
expected_found,
|
||||||
TypeError::Sorts(expected_found),
|
TypeError::Sorts(expected_found),
|
||||||
)
|
)
|
||||||
|
@ -138,7 +138,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> {
|
||||||
goal.predicate.kind().rebind((pred.a, pred.b)),
|
goal.predicate.kind().rebind((pred.a, pred.b)),
|
||||||
);
|
);
|
||||||
let expected_found = ExpectedFound::new(false, a, b);
|
let expected_found = ExpectedFound::new(false, a, b);
|
||||||
FulfillmentErrorCode::CodeSubtypeError(
|
FulfillmentErrorCode::SubtypeError(
|
||||||
expected_found,
|
expected_found,
|
||||||
TypeError::Sorts(expected_found),
|
TypeError::Sorts(expected_found),
|
||||||
)
|
)
|
||||||
|
@ -146,7 +146,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> {
|
||||||
ty::PredicateKind::Clause(_)
|
ty::PredicateKind::Clause(_)
|
||||||
| ty::PredicateKind::ObjectSafe(_)
|
| ty::PredicateKind::ObjectSafe(_)
|
||||||
| ty::PredicateKind::Ambiguous => {
|
| ty::PredicateKind::Ambiguous => {
|
||||||
FulfillmentErrorCode::CodeSelectionError(
|
FulfillmentErrorCode::SelectionError(
|
||||||
SelectionError::Unimplemented,
|
SelectionError::Unimplemented,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,8 @@ use crate::traits::specialize::to_pretty_impl_header;
|
||||||
use crate::traits::NormalizeExt;
|
use crate::traits::NormalizeExt;
|
||||||
use crate::traits::{
|
use crate::traits::{
|
||||||
elaborate, FulfillmentError, FulfillmentErrorCode, MismatchedProjectionTypes, Obligation,
|
elaborate, FulfillmentError, FulfillmentErrorCode, MismatchedProjectionTypes, Obligation,
|
||||||
ObligationCause, ObligationCauseCode, ObligationCtxt, OutputTypeParameterMismatch, Overflow,
|
ObligationCause, ObligationCauseCode, ObligationCtxt, Overflow, PredicateObligation,
|
||||||
PredicateObligation, SelectionError, TraitNotObjectSafe,
|
SelectionError, SignatureMismatch, TraitNotObjectSafe,
|
||||||
};
|
};
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
|
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
|
@ -30,7 +30,7 @@ use rustc_hir::{GenericParam, Item, Node};
|
||||||
use rustc_infer::infer::error_reporting::TypeErrCtxt;
|
use rustc_infer::infer::error_reporting::TypeErrCtxt;
|
||||||
use rustc_infer::infer::{InferOk, TypeTrace};
|
use rustc_infer::infer::{InferOk, TypeTrace};
|
||||||
use rustc_middle::traits::select::OverflowError;
|
use rustc_middle::traits::select::OverflowError;
|
||||||
use rustc_middle::traits::{DefiningAnchor, SelectionOutputTypeParameterMismatch};
|
use rustc_middle::traits::{DefiningAnchor, SignatureMismatchData};
|
||||||
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
|
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
|
||||||
use rustc_middle::ty::error::{ExpectedFound, TypeError};
|
use rustc_middle::ty::error::{ExpectedFound, TypeError};
|
||||||
use rustc_middle::ty::fold::{BottomUpFolder, TypeFolder, TypeSuperFoldable};
|
use rustc_middle::ty::fold::{BottomUpFolder, TypeFolder, TypeSuperFoldable};
|
||||||
|
@ -785,14 +785,14 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
|
|
||||||
ty::PredicateKind::Subtype(predicate) => {
|
ty::PredicateKind::Subtype(predicate) => {
|
||||||
// Errors for Subtype predicates show up as
|
// Errors for Subtype predicates show up as
|
||||||
// `FulfillmentErrorCode::CodeSubtypeError`,
|
// `FulfillmentErrorCode::SubtypeError`,
|
||||||
// not selection error.
|
// not selection error.
|
||||||
span_bug!(span, "subtype requirement gave wrong error: `{:?}`", predicate)
|
span_bug!(span, "subtype requirement gave wrong error: `{:?}`", predicate)
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::PredicateKind::Coerce(predicate) => {
|
ty::PredicateKind::Coerce(predicate) => {
|
||||||
// Errors for Coerce predicates show up as
|
// Errors for Coerce predicates show up as
|
||||||
// `FulfillmentErrorCode::CodeSubtypeError`,
|
// `FulfillmentErrorCode::SubtypeError`,
|
||||||
// not selection error.
|
// not selection error.
|
||||||
span_bug!(span, "coerce requirement gave wrong error: `{:?}`", predicate)
|
span_bug!(span, "coerce requirement gave wrong error: `{:?}`", predicate)
|
||||||
}
|
}
|
||||||
|
@ -891,22 +891,22 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputTypeParameterMismatch(box SelectionOutputTypeParameterMismatch {
|
SignatureMismatch(box SignatureMismatchData {
|
||||||
found_trait_ref,
|
found_trait_ref,
|
||||||
expected_trait_ref,
|
expected_trait_ref,
|
||||||
terr: terr @ TypeError::CyclicTy(_),
|
terr: terr @ TypeError::CyclicTy(_),
|
||||||
}) => self.report_type_parameter_mismatch_cyclic_type_error(
|
}) => self.report_cyclic_signature_error(
|
||||||
&obligation,
|
&obligation,
|
||||||
found_trait_ref,
|
found_trait_ref,
|
||||||
expected_trait_ref,
|
expected_trait_ref,
|
||||||
terr,
|
terr,
|
||||||
),
|
),
|
||||||
OutputTypeParameterMismatch(box SelectionOutputTypeParameterMismatch {
|
SignatureMismatch(box SignatureMismatchData {
|
||||||
found_trait_ref,
|
found_trait_ref,
|
||||||
expected_trait_ref,
|
expected_trait_ref,
|
||||||
terr: _,
|
terr: _,
|
||||||
}) => {
|
}) => {
|
||||||
match self.report_type_parameter_mismatch_error(
|
match self.report_signature_mismatch_error(
|
||||||
&obligation,
|
&obligation,
|
||||||
span,
|
span,
|
||||||
found_trait_ref,
|
found_trait_ref,
|
||||||
|
@ -1492,7 +1492,7 @@ pub(super) trait InferCtxtPrivExt<'tcx> {
|
||||||
kind: ty::ClosureKind,
|
kind: ty::ClosureKind,
|
||||||
) -> DiagnosticBuilder<'tcx>;
|
) -> DiagnosticBuilder<'tcx>;
|
||||||
|
|
||||||
fn report_type_parameter_mismatch_cyclic_type_error(
|
fn report_cyclic_signature_error(
|
||||||
&self,
|
&self,
|
||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
found_trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
found_trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
||||||
|
@ -1506,7 +1506,7 @@ pub(super) trait InferCtxtPrivExt<'tcx> {
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
) -> DiagnosticBuilder<'tcx>;
|
) -> DiagnosticBuilder<'tcx>;
|
||||||
|
|
||||||
fn report_type_parameter_mismatch_error(
|
fn report_signature_mismatch_error(
|
||||||
&self,
|
&self,
|
||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
span: Span,
|
span: Span,
|
||||||
|
@ -1572,23 +1572,23 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
match error.code {
|
match error.code {
|
||||||
FulfillmentErrorCode::CodeSelectionError(ref selection_error) => {
|
FulfillmentErrorCode::SelectionError(ref selection_error) => {
|
||||||
self.report_selection_error(
|
self.report_selection_error(
|
||||||
error.obligation.clone(),
|
error.obligation.clone(),
|
||||||
&error.root_obligation,
|
&error.root_obligation,
|
||||||
selection_error,
|
selection_error,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
FulfillmentErrorCode::CodeProjectionError(ref e) => {
|
FulfillmentErrorCode::ProjectionError(ref e) => {
|
||||||
self.report_projection_error(&error.obligation, e);
|
self.report_projection_error(&error.obligation, e);
|
||||||
}
|
}
|
||||||
FulfillmentErrorCode::CodeAmbiguity { overflow: false } => {
|
FulfillmentErrorCode::Ambiguity { overflow: false } => {
|
||||||
self.maybe_report_ambiguity(&error.obligation);
|
self.maybe_report_ambiguity(&error.obligation);
|
||||||
}
|
}
|
||||||
FulfillmentErrorCode::CodeAmbiguity { overflow: true } => {
|
FulfillmentErrorCode::Ambiguity { overflow: true } => {
|
||||||
self.report_overflow_no_abort(error.obligation.clone());
|
self.report_overflow_no_abort(error.obligation.clone());
|
||||||
}
|
}
|
||||||
FulfillmentErrorCode::CodeSubtypeError(ref expected_found, ref err) => {
|
FulfillmentErrorCode::SubtypeError(ref expected_found, ref err) => {
|
||||||
self.report_mismatched_types(
|
self.report_mismatched_types(
|
||||||
&error.obligation.cause,
|
&error.obligation.cause,
|
||||||
expected_found.expected,
|
expected_found.expected,
|
||||||
|
@ -1597,7 +1597,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
FulfillmentErrorCode::CodeConstEquateError(ref expected_found, ref err) => {
|
FulfillmentErrorCode::ConstEquateError(ref expected_found, ref err) => {
|
||||||
let mut diag = self.report_mismatched_consts(
|
let mut diag = self.report_mismatched_consts(
|
||||||
&error.obligation.cause,
|
&error.obligation.cause,
|
||||||
expected_found.expected,
|
expected_found.expected,
|
||||||
|
@ -1622,7 +1622,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
diag.emit();
|
diag.emit();
|
||||||
}
|
}
|
||||||
FulfillmentErrorCode::CodeCycle(ref cycle) => {
|
FulfillmentErrorCode::Cycle(ref cycle) => {
|
||||||
self.report_overflow_obligation_cycle(cycle);
|
self.report_overflow_obligation_cycle(cycle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3366,7 +3366,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
self.dcx().create_err(err)
|
self.dcx().create_err(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn report_type_parameter_mismatch_cyclic_type_error(
|
fn report_cyclic_signature_error(
|
||||||
&self,
|
&self,
|
||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
found_trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
found_trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
||||||
|
@ -3427,7 +3427,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
|
|
||||||
fn report_type_parameter_mismatch_error(
|
fn report_signature_mismatch_error(
|
||||||
&self,
|
&self,
|
||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
span: Span,
|
span: Span,
|
||||||
|
@ -3446,10 +3446,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let found_did = match *found_trait_ty.kind() {
|
let found_did = match *found_trait_ty.kind() {
|
||||||
ty::Closure(did, _) | ty::Foreign(did) | ty::FnDef(did, _) | ty::Coroutine(did, ..) => {
|
ty::Closure(did, _) | ty::FnDef(did, _) | ty::Coroutine(did, ..) => Some(did),
|
||||||
Some(did)
|
|
||||||
}
|
|
||||||
ty::Adt(def, _) => Some(def.did()),
|
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,6 @@ use super::const_evaluatable;
|
||||||
use super::project::{self, ProjectAndUnifyResult};
|
use super::project::{self, ProjectAndUnifyResult};
|
||||||
use super::select::SelectionContext;
|
use super::select::SelectionContext;
|
||||||
use super::wf;
|
use super::wf;
|
||||||
use super::CodeAmbiguity;
|
|
||||||
use super::CodeProjectionError;
|
|
||||||
use super::CodeSelectionError;
|
|
||||||
use super::EvaluationResult;
|
use super::EvaluationResult;
|
||||||
use super::PredicateObligation;
|
use super::PredicateObligation;
|
||||||
use super::Unimplemented;
|
use super::Unimplemented;
|
||||||
|
@ -140,7 +137,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
|
||||||
_infcx: &InferCtxt<'tcx>,
|
_infcx: &InferCtxt<'tcx>,
|
||||||
) -> Vec<FulfillmentError<'tcx>> {
|
) -> Vec<FulfillmentError<'tcx>> {
|
||||||
self.predicates
|
self.predicates
|
||||||
.to_errors(CodeAmbiguity { overflow: false })
|
.to_errors(FulfillmentErrorCode::Ambiguity { overflow: false })
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(to_fulfillment_error)
|
.map(to_fulfillment_error)
|
||||||
.collect()
|
.collect()
|
||||||
|
@ -414,7 +411,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
||||||
|
|
||||||
ty::PredicateKind::ObjectSafe(trait_def_id) => {
|
ty::PredicateKind::ObjectSafe(trait_def_id) => {
|
||||||
if !self.selcx.tcx().check_is_object_safe(trait_def_id) {
|
if !self.selcx.tcx().check_is_object_safe(trait_def_id) {
|
||||||
ProcessResult::Error(CodeSelectionError(Unimplemented))
|
ProcessResult::Error(FulfillmentErrorCode::SelectionError(Unimplemented))
|
||||||
} else {
|
} else {
|
||||||
ProcessResult::Changed(vec![])
|
ProcessResult::Changed(vec![])
|
||||||
}
|
}
|
||||||
|
@ -485,7 +482,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
||||||
Ok(Err(err)) => {
|
Ok(Err(err)) => {
|
||||||
let expected_found =
|
let expected_found =
|
||||||
ExpectedFound::new(subtype.a_is_expected, subtype.a, subtype.b);
|
ExpectedFound::new(subtype.a_is_expected, subtype.a, subtype.b);
|
||||||
ProcessResult::Error(FulfillmentErrorCode::CodeSubtypeError(
|
ProcessResult::Error(FulfillmentErrorCode::SubtypeError(
|
||||||
expected_found,
|
expected_found,
|
||||||
err,
|
err,
|
||||||
))
|
))
|
||||||
|
@ -508,7 +505,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
||||||
Ok(Ok(ok)) => ProcessResult::Changed(mk_pending(ok.obligations)),
|
Ok(Ok(ok)) => ProcessResult::Changed(mk_pending(ok.obligations)),
|
||||||
Ok(Err(err)) => {
|
Ok(Err(err)) => {
|
||||||
let expected_found = ExpectedFound::new(false, coerce.a, coerce.b);
|
let expected_found = ExpectedFound::new(false, coerce.a, coerce.b);
|
||||||
ProcessResult::Error(FulfillmentErrorCode::CodeSubtypeError(
|
ProcessResult::Error(FulfillmentErrorCode::SubtypeError(
|
||||||
expected_found,
|
expected_found,
|
||||||
err,
|
err,
|
||||||
))
|
))
|
||||||
|
@ -534,7 +531,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
||||||
Err(
|
Err(
|
||||||
e @ NotConstEvaluatable::MentionsParam
|
e @ NotConstEvaluatable::MentionsParam
|
||||||
| e @ NotConstEvaluatable::Error(_),
|
| e @ NotConstEvaluatable::Error(_),
|
||||||
) => ProcessResult::Error(CodeSelectionError(
|
) => ProcessResult::Error(FulfillmentErrorCode::SelectionError(
|
||||||
SelectionError::NotConstEvaluatable(e),
|
SelectionError::NotConstEvaluatable(e),
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
|
@ -623,20 +620,22 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
||||||
Ok(inf_ok) => {
|
Ok(inf_ok) => {
|
||||||
ProcessResult::Changed(mk_pending(inf_ok.into_obligations()))
|
ProcessResult::Changed(mk_pending(inf_ok.into_obligations()))
|
||||||
}
|
}
|
||||||
Err(err) => ProcessResult::Error(
|
Err(err) => {
|
||||||
FulfillmentErrorCode::CodeConstEquateError(
|
ProcessResult::Error(FulfillmentErrorCode::ConstEquateError(
|
||||||
ExpectedFound::new(true, c1, c2),
|
ExpectedFound::new(true, c1, c2),
|
||||||
err,
|
err,
|
||||||
),
|
))
|
||||||
),
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(Err(ErrorHandled::Reported(reported, _)), _)
|
(Err(ErrorHandled::Reported(reported, _)), _)
|
||||||
| (_, Err(ErrorHandled::Reported(reported, _))) => ProcessResult::Error(
|
| (_, Err(ErrorHandled::Reported(reported, _))) => {
|
||||||
CodeSelectionError(SelectionError::NotConstEvaluatable(
|
ProcessResult::Error(FulfillmentErrorCode::SelectionError(
|
||||||
NotConstEvaluatable::Error(reported.into()),
|
SelectionError::NotConstEvaluatable(NotConstEvaluatable::Error(
|
||||||
)),
|
reported.into(),
|
||||||
),
|
)),
|
||||||
|
))
|
||||||
|
}
|
||||||
(Err(ErrorHandled::TooGeneric(_)), _)
|
(Err(ErrorHandled::TooGeneric(_)), _)
|
||||||
| (_, Err(ErrorHandled::TooGeneric(_))) => {
|
| (_, Err(ErrorHandled::TooGeneric(_))) => {
|
||||||
if c1.has_non_region_infer() || c2.has_non_region_infer() {
|
if c1.has_non_region_infer() || c2.has_non_region_infer() {
|
||||||
|
@ -644,7 +643,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
||||||
} else {
|
} else {
|
||||||
// Two different constants using generic parameters ~> error.
|
// Two different constants using generic parameters ~> error.
|
||||||
let expected_found = ExpectedFound::new(true, c1, c2);
|
let expected_found = ExpectedFound::new(true, c1, c2);
|
||||||
ProcessResult::Error(FulfillmentErrorCode::CodeConstEquateError(
|
ProcessResult::Error(FulfillmentErrorCode::ConstEquateError(
|
||||||
expected_found,
|
expected_found,
|
||||||
TypeError::ConstMismatch(expected_found),
|
TypeError::ConstMismatch(expected_found),
|
||||||
))
|
))
|
||||||
|
@ -659,7 +658,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
||||||
ty,
|
ty,
|
||||||
) {
|
) {
|
||||||
Ok(inf_ok) => ProcessResult::Changed(mk_pending(inf_ok.into_obligations())),
|
Ok(inf_ok) => ProcessResult::Changed(mk_pending(inf_ok.into_obligations())),
|
||||||
Err(_) => ProcessResult::Error(FulfillmentErrorCode::CodeSelectionError(
|
Err(_) => ProcessResult::Error(FulfillmentErrorCode::SelectionError(
|
||||||
SelectionError::Unimplemented,
|
SelectionError::Unimplemented,
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
|
@ -682,7 +681,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
let cycle: Vec<_> = cycle.map(|c| c.obligation.clone()).collect();
|
let cycle: Vec<_> = cycle.map(|c| c.obligation.clone()).collect();
|
||||||
Err(FulfillmentErrorCode::CodeCycle(cycle))
|
Err(FulfillmentErrorCode::Cycle(cycle))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -737,7 +736,7 @@ impl<'a, 'tcx> FulfillProcessor<'a, 'tcx> {
|
||||||
Err(selection_err) => {
|
Err(selection_err) => {
|
||||||
debug!("selecting trait at depth {} yielded Err", obligation.recursion_depth);
|
debug!("selecting trait at depth {} yielded Err", obligation.recursion_depth);
|
||||||
|
|
||||||
ProcessResult::Error(CodeSelectionError(selection_err))
|
ProcessResult::Error(FulfillmentErrorCode::SelectionError(selection_err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -789,7 +788,7 @@ impl<'a, 'tcx> FulfillProcessor<'a, 'tcx> {
|
||||||
project_obligation.with(tcx, project_obligation.predicate),
|
project_obligation.with(tcx, project_obligation.predicate),
|
||||||
])),
|
])),
|
||||||
ProjectAndUnifyResult::MismatchedProjectionTypes(e) => {
|
ProjectAndUnifyResult::MismatchedProjectionTypes(e) => {
|
||||||
ProcessResult::Error(CodeProjectionError(e))
|
ProcessResult::Error(FulfillmentErrorCode::ProjectionError(e))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||||
use rustc_hir::lang_items::LangItem;
|
use rustc_hir::lang_items::LangItem;
|
||||||
use rustc_infer::infer::BoundRegionConversionTime::HigherRankedType;
|
use rustc_infer::infer::BoundRegionConversionTime::HigherRankedType;
|
||||||
use rustc_infer::infer::{DefineOpaqueTypes, InferOk};
|
use rustc_infer::infer::{DefineOpaqueTypes, InferOk};
|
||||||
use rustc_middle::traits::{BuiltinImplSource, SelectionOutputTypeParameterMismatch};
|
use rustc_middle::traits::{BuiltinImplSource, SignatureMismatchData};
|
||||||
use rustc_middle::ty::{
|
use rustc_middle::ty::{
|
||||||
self, GenericArgs, GenericArgsRef, GenericParamDefKind, ToPolyTraitRef, ToPredicate,
|
self, GenericArgs, GenericArgsRef, GenericParamDefKind, ToPolyTraitRef, ToPredicate,
|
||||||
TraitPredicate, Ty, TyCtxt, TypeVisitableExt,
|
TraitPredicate, Ty, TyCtxt, TypeVisitableExt,
|
||||||
|
@ -26,9 +26,9 @@ use crate::traits::vtable::{
|
||||||
};
|
};
|
||||||
use crate::traits::{
|
use crate::traits::{
|
||||||
BuiltinDerivedObligation, ImplDerivedObligation, ImplDerivedObligationCause, ImplSource,
|
BuiltinDerivedObligation, ImplDerivedObligation, ImplDerivedObligationCause, ImplSource,
|
||||||
ImplSourceUserDefinedData, Normalized, Obligation, ObligationCause,
|
ImplSourceUserDefinedData, Normalized, Obligation, ObligationCause, PolyTraitObligation,
|
||||||
OutputTypeParameterMismatch, PolyTraitObligation, PredicateObligation, Selection,
|
PredicateObligation, Selection, SelectionError, SignatureMismatch, TraitNotObjectSafe,
|
||||||
SelectionError, TraitNotObjectSafe, Unimplemented,
|
Unimplemented,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::BuiltinImplConditions;
|
use super::BuiltinImplConditions;
|
||||||
|
@ -922,7 +922,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
obligations
|
obligations
|
||||||
})
|
})
|
||||||
.map_err(|terr| {
|
.map_err(|terr| {
|
||||||
OutputTypeParameterMismatch(Box::new(SelectionOutputTypeParameterMismatch {
|
SignatureMismatch(Box::new(SignatureMismatchData {
|
||||||
expected_trait_ref: obligation_trait_ref,
|
expected_trait_ref: obligation_trait_ref,
|
||||||
found_trait_ref: expected_trait_ref,
|
found_trait_ref: expected_trait_ref,
|
||||||
terr,
|
terr,
|
||||||
|
|
|
@ -63,7 +63,7 @@ pub fn codegen_select_candidate<'tcx>(
|
||||||
// Cycle errors are the only post-monomorphization errors possible; emit them now so
|
// Cycle errors are the only post-monomorphization errors possible; emit them now so
|
||||||
// `rustc_ty_utils::resolve_associated_item` doesn't return `None` post-monomorphization.
|
// `rustc_ty_utils::resolve_associated_item` doesn't return `None` post-monomorphization.
|
||||||
for err in errors {
|
for err in errors {
|
||||||
if let FulfillmentErrorCode::CodeCycle(cycle) = err.code {
|
if let FulfillmentErrorCode::Cycle(cycle) = err.code {
|
||||||
infcx.err_ctxt().report_overflow_obligation_cycle(&cycle);
|
infcx.err_ctxt().report_overflow_obligation_cycle(&cycle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ fn normalize_projection_ty<'tcx>(
|
||||||
// that impl vars are constrained by the signature, for example).
|
// that impl vars are constrained by the signature, for example).
|
||||||
if !tcx.sess.opts.actually_rustdoc {
|
if !tcx.sess.opts.actually_rustdoc {
|
||||||
for error in &errors {
|
for error in &errors {
|
||||||
if let FulfillmentErrorCode::CodeCycle(cycle) = &error.code {
|
if let FulfillmentErrorCode::Cycle(cycle) = &error.code {
|
||||||
ocx.infcx.err_ctxt().report_overflow_obligation_cycle(cycle);
|
ocx.infcx.err_ctxt().report_overflow_obligation_cycle(cycle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue