Skip to content

Commit fbdc116

Browse files
OutputTypeParameterMismatch -> SignatureMismatch
1 parent f37a919 commit fbdc116

File tree

4 files changed

+23
-25
lines changed

4 files changed

+23
-25
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
362362
span: Span,
363363
) -> bool {
364364
if let traits::FulfillmentErrorCode::SelectionError(
365-
traits::SelectionError::OutputTypeParameterMismatch(
366-
box traits::SelectionOutputTypeParameterMismatch { expected_trait_ref, .. },
367-
),
365+
traits::SelectionError::SignatureMismatch(box traits::SignatureMismatchData {
366+
expected_trait_ref,
367+
..
368+
}),
368369
) = error.code
369370
&& let ty::Closure(def_id, _) | ty::Coroutine(def_id, ..) =
370371
expected_trait_ref.skip_binder().self_ty().kind()

compiler/rustc_middle/src/traits/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ pub enum SelectionError<'tcx> {
604604
/// After a closure impl has selected, its "outputs" were evaluated
605605
/// (which for closures includes the "input" type params) and they
606606
/// didn't resolve. See `confirm_poly_trait_refs` for more.
607-
OutputTypeParameterMismatch(Box<SelectionOutputTypeParameterMismatch<'tcx>>),
607+
SignatureMismatch(Box<SignatureMismatchData<'tcx>>),
608608
/// The trait pointed by `DefId` is not object safe.
609609
TraitNotObjectSafe(DefId),
610610
/// A given constant couldn't be evaluated.
@@ -621,7 +621,7 @@ pub enum SelectionError<'tcx> {
621621
}
622622

623623
#[derive(Clone, Debug, TypeVisitable)]
624-
pub struct SelectionOutputTypeParameterMismatch<'tcx> {
624+
pub struct SignatureMismatchData<'tcx> {
625625
pub found_trait_ref: ty::PolyTraitRef<'tcx>,
626626
pub expected_trait_ref: ty::PolyTraitRef<'tcx>,
627627
pub terr: ty::error::TypeError<'tcx>,

compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs

+12-15
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use crate::traits::specialize::to_pretty_impl_header;
1414
use crate::traits::NormalizeExt;
1515
use crate::traits::{
1616
elaborate, FulfillmentError, FulfillmentErrorCode, MismatchedProjectionTypes, Obligation,
17-
ObligationCause, ObligationCauseCode, ObligationCtxt, OutputTypeParameterMismatch, Overflow,
18-
PredicateObligation, SelectionError, TraitNotObjectSafe,
17+
ObligationCause, ObligationCauseCode, ObligationCtxt, Overflow, PredicateObligation,
18+
SelectionError, SignatureMismatch, TraitNotObjectSafe,
1919
};
2020
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
2121
use rustc_errors::{
@@ -30,7 +30,7 @@ use rustc_hir::{GenericParam, Item, Node};
3030
use rustc_infer::infer::error_reporting::TypeErrCtxt;
3131
use rustc_infer::infer::{InferOk, TypeTrace};
3232
use rustc_middle::traits::select::OverflowError;
33-
use rustc_middle::traits::{DefiningAnchor, SelectionOutputTypeParameterMismatch};
33+
use rustc_middle::traits::{DefiningAnchor, SignatureMismatchData};
3434
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
3535
use rustc_middle::ty::error::{ExpectedFound, TypeError};
3636
use rustc_middle::ty::fold::{BottomUpFolder, TypeFolder, TypeSuperFoldable};
@@ -891,22 +891,22 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
891891
}
892892
}
893893

894-
OutputTypeParameterMismatch(box SelectionOutputTypeParameterMismatch {
894+
SignatureMismatch(box SignatureMismatchData {
895895
found_trait_ref,
896896
expected_trait_ref,
897897
terr: terr @ TypeError::CyclicTy(_),
898-
}) => self.report_type_parameter_mismatch_cyclic_type_error(
898+
}) => self.report_cyclic_signature_error(
899899
&obligation,
900900
found_trait_ref,
901901
expected_trait_ref,
902902
terr,
903903
),
904-
OutputTypeParameterMismatch(box SelectionOutputTypeParameterMismatch {
904+
SignatureMismatch(box SignatureMismatchData {
905905
found_trait_ref,
906906
expected_trait_ref,
907907
terr: _,
908908
}) => {
909-
match self.report_type_parameter_mismatch_error(
909+
match self.report_signature_mismatch_error(
910910
&obligation,
911911
span,
912912
found_trait_ref,
@@ -1495,7 +1495,7 @@ pub(super) trait InferCtxtPrivExt<'tcx> {
14951495
kind: ty::ClosureKind,
14961496
) -> DiagnosticBuilder<'tcx>;
14971497

1498-
fn report_type_parameter_mismatch_cyclic_type_error(
1498+
fn report_cyclic_signature_error(
14991499
&self,
15001500
obligation: &PredicateObligation<'tcx>,
15011501
found_trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
@@ -1509,7 +1509,7 @@ pub(super) trait InferCtxtPrivExt<'tcx> {
15091509
def_id: DefId,
15101510
) -> DiagnosticBuilder<'tcx>;
15111511

1512-
fn report_type_parameter_mismatch_error(
1512+
fn report_signature_mismatch_error(
15131513
&self,
15141514
obligation: &PredicateObligation<'tcx>,
15151515
span: Span,
@@ -3369,7 +3369,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
33693369
self.dcx().create_err(err)
33703370
}
33713371

3372-
fn report_type_parameter_mismatch_cyclic_type_error(
3372+
fn report_cyclic_signature_error(
33733373
&self,
33743374
obligation: &PredicateObligation<'tcx>,
33753375
found_trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
@@ -3430,7 +3430,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
34303430
err
34313431
}
34323432

3433-
fn report_type_parameter_mismatch_error(
3433+
fn report_signature_mismatch_error(
34343434
&self,
34353435
obligation: &PredicateObligation<'tcx>,
34363436
span: Span,
@@ -3449,10 +3449,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
34493449
};
34503450

34513451
let found_did = match *found_trait_ty.kind() {
3452-
ty::Closure(did, _) | ty::Foreign(did) | ty::FnDef(did, _) | ty::Coroutine(did, ..) => {
3453-
Some(did)
3454-
}
3455-
ty::Adt(def, _) => Some(def.did()),
3452+
ty::Closure(did, _) | ty::FnDef(did, _) | ty::Coroutine(did, ..) => Some(did),
34563453
_ => None,
34573454
};
34583455

compiler/rustc_trait_selection/src/traits/select/confirmation.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_data_structures::stack::ensure_sufficient_stack;
1111
use rustc_hir::lang_items::LangItem;
1212
use rustc_infer::infer::BoundRegionConversionTime::HigherRankedType;
1313
use rustc_infer::infer::{DefineOpaqueTypes, InferOk};
14-
use rustc_middle::traits::{BuiltinImplSource, SelectionOutputTypeParameterMismatch};
14+
use rustc_middle::traits::{BuiltinImplSource, SignatureMismatchData};
1515
use rustc_middle::ty::{
1616
self, GenericArgs, GenericArgsRef, GenericParamDefKind, ToPolyTraitRef, ToPredicate,
1717
TraitPredicate, Ty, TyCtxt, TypeVisitableExt,
@@ -26,9 +26,9 @@ use crate::traits::vtable::{
2626
};
2727
use crate::traits::{
2828
BuiltinDerivedObligation, ImplDerivedObligation, ImplDerivedObligationCause, ImplSource,
29-
ImplSourceUserDefinedData, Normalized, Obligation, ObligationCause,
30-
OutputTypeParameterMismatch, PolyTraitObligation, PredicateObligation, Selection,
31-
SelectionError, TraitNotObjectSafe, Unimplemented,
29+
ImplSourceUserDefinedData, Normalized, Obligation, ObligationCause, PolyTraitObligation,
30+
PredicateObligation, Selection, SelectionError, SignatureMismatch, TraitNotObjectSafe,
31+
Unimplemented,
3232
};
3333

3434
use super::BuiltinImplConditions;
@@ -922,7 +922,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
922922
obligations
923923
})
924924
.map_err(|terr| {
925-
OutputTypeParameterMismatch(Box::new(SelectionOutputTypeParameterMismatch {
925+
SignatureMismatch(Box::new(SignatureMismatchData {
926926
expected_trait_ref: obligation_trait_ref,
927927
found_trait_ref: expected_trait_ref,
928928
terr,

0 commit comments

Comments
 (0)