Skip to content

Commit 0979603

Browse files
authored
Unrolled build for rust-lang#119897
Rollup merge of rust-lang#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
2 parents 1ead476 + fbdc116 commit 0979603

File tree

13 files changed

+82
-85
lines changed

13 files changed

+82
-85
lines changed

compiler/rustc_borrowck/src/diagnostics/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
12151215
Applicability::MaybeIncorrect,
12161216
);
12171217
for error in errors {
1218-
if let FulfillmentErrorCode::CodeSelectionError(
1218+
if let FulfillmentErrorCode::SelectionError(
12191219
SelectionError::Unimplemented,
12201220
) = error.code
12211221
&& let ty::PredicateKind::Clause(ty::ClauseKind::Trait(

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
12911291
}
12921292
// The type doesn't implement Clone because of unmet obligations.
12931293
for error in errors {
1294-
if let traits::FulfillmentErrorCode::CodeSelectionError(
1294+
if let traits::FulfillmentErrorCode::SelectionError(
12951295
traits::SelectionError::Unimplemented,
12961296
) = error.code
12971297
&& let ty::PredicateKind::Clause(ty::ClauseKind::Trait(

compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
8686
// Finally, for ambiguity-related errors, we actually want to look
8787
// for a parameter that is the source of the inference type left
8888
// over in this predicate.
89-
if let traits::FulfillmentErrorCode::CodeAmbiguity { .. } = error.code {
89+
if let traits::FulfillmentErrorCode::Ambiguity { .. } = error.code {
9090
fallback_param_to_point_at = None;
9191
self_param_to_point_at = None;
9292
param_to_point_at =
@@ -361,10 +361,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
361361
error: &traits::FulfillmentError<'tcx>,
362362
span: Span,
363363
) -> bool {
364-
if let traits::FulfillmentErrorCode::CodeSelectionError(
365-
traits::SelectionError::OutputTypeParameterMismatch(
366-
box traits::SelectionOutputTypeParameterMismatch { expected_trait_ref, .. },
367-
),
364+
if let traits::FulfillmentErrorCode::SelectionError(
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_hir_typeck/src/fn_ctxt/suggestions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1648,7 +1648,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16481648
}
16491649
}
16501650
for error in errors {
1651-
if let traits::FulfillmentErrorCode::CodeSelectionError(
1651+
if let traits::FulfillmentErrorCode::SelectionError(
16521652
traits::SelectionError::Unimplemented,
16531653
) = error.code
16541654
&& let ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) =

compiler/rustc_infer/src/traits/mod.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use rustc_middle::ty::error::{ExpectedFound, TypeError};
1717
use rustc_middle::ty::{self, Const, ToPredicate, Ty, TyCtxt};
1818
use rustc_span::Span;
1919

20-
pub use self::FulfillmentErrorCode::*;
2120
pub use self::ImplSource::*;
2221
pub use self::SelectionError::*;
2322

@@ -129,12 +128,12 @@ pub struct FulfillmentError<'tcx> {
129128
#[derive(Clone)]
130129
pub enum FulfillmentErrorCode<'tcx> {
131130
/// Inherently impossible to fulfill; this trait is implemented if and only if it is already implemented.
132-
CodeCycle(Vec<PredicateObligation<'tcx>>),
133-
CodeSelectionError(SelectionError<'tcx>),
134-
CodeProjectionError(MismatchedProjectionTypes<'tcx>),
135-
CodeSubtypeError(ExpectedFound<Ty<'tcx>>, TypeError<'tcx>), // always comes from a SubtypePredicate
136-
CodeConstEquateError(ExpectedFound<Const<'tcx>>, TypeError<'tcx>),
137-
CodeAmbiguity {
131+
Cycle(Vec<PredicateObligation<'tcx>>),
132+
SelectionError(SelectionError<'tcx>),
133+
ProjectionError(MismatchedProjectionTypes<'tcx>),
134+
SubtypeError(ExpectedFound<Ty<'tcx>>, TypeError<'tcx>), // always comes from a SubtypePredicate
135+
ConstEquateError(ExpectedFound<Const<'tcx>>, TypeError<'tcx>),
136+
Ambiguity {
138137
/// Overflow reported from the new solver `-Znext-solver`, which will
139138
/// be reported as an regular error as opposed to a fatal error.
140139
overflow: bool,

compiler/rustc_infer/src/traits/structural_impls.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,19 @@ impl<'tcx> fmt::Debug for traits::FulfillmentError<'tcx> {
3737

3838
impl<'tcx> fmt::Debug for traits::FulfillmentErrorCode<'tcx> {
3939
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
40+
use traits::FulfillmentErrorCode::*;
4041
match *self {
41-
super::CodeSelectionError(ref e) => write!(f, "{e:?}"),
42-
super::CodeProjectionError(ref e) => write!(f, "{e:?}"),
43-
super::CodeSubtypeError(ref a, ref b) => {
42+
SelectionError(ref e) => write!(f, "{e:?}"),
43+
ProjectionError(ref e) => write!(f, "{e:?}"),
44+
SubtypeError(ref a, ref b) => {
4445
write!(f, "CodeSubtypeError({a:?}, {b:?})")
4546
}
46-
super::CodeConstEquateError(ref a, ref b) => {
47+
ConstEquateError(ref a, ref b) => {
4748
write!(f, "CodeConstEquateError({a:?}, {b:?})")
4849
}
49-
super::CodeAmbiguity { overflow: false } => write!(f, "Ambiguity"),
50-
super::CodeAmbiguity { overflow: true } => write!(f, "Overflow"),
51-
super::CodeCycle(ref cycle) => write!(f, "Cycle({cycle:?})"),
50+
Ambiguity { overflow: false } => write!(f, "Ambiguity"),
51+
Ambiguity { overflow: true } => write!(f, "Overflow"),
52+
Cycle(ref cycle) => write!(f, "Cycle({cycle:?})"),
5253
}
5354
}
5455
}

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.
@@ -618,7 +618,7 @@ pub enum SelectionError<'tcx> {
618618
}
619619

620620
#[derive(Clone, Debug, TypeVisitable)]
621-
pub struct SelectionOutputTypeParameterMismatch<'tcx> {
621+
pub struct SignatureMismatchData<'tcx> {
622622
pub found_trait_ref: ty::PolyTraitRef<'tcx>,
623623
pub expected_trait_ref: ty::PolyTraitRef<'tcx>,
624624
pub terr: ty::error::TypeError<'tcx>,

compiler/rustc_trait_selection/src/solve/fulfill.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> {
6666
.0
6767
{
6868
Ok((_, Certainty::Maybe(MaybeCause::Ambiguity), _)) => {
69-
FulfillmentErrorCode::CodeAmbiguity { overflow: false }
69+
FulfillmentErrorCode::Ambiguity { overflow: false }
7070
}
7171
Ok((_, Certainty::Maybe(MaybeCause::Overflow), _)) => {
72-
FulfillmentErrorCode::CodeAmbiguity { overflow: true }
72+
FulfillmentErrorCode::Ambiguity { overflow: true }
7373
}
7474
Ok((_, Certainty::Yes, _)) => {
7575
bug!("did not expect successful goal when collecting ambiguity errors")
@@ -108,18 +108,18 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> {
108108
obligation: obligation.clone(),
109109
code: match goal.predicate.kind().skip_binder() {
110110
ty::PredicateKind::Clause(ty::ClauseKind::Projection(_)) => {
111-
FulfillmentErrorCode::CodeProjectionError(
111+
FulfillmentErrorCode::ProjectionError(
112112
// FIXME: This could be a `Sorts` if the term is a type
113113
MismatchedProjectionTypes { err: TypeError::Mismatch },
114114
)
115115
}
116116
ty::PredicateKind::NormalizesTo(..) => {
117-
FulfillmentErrorCode::CodeProjectionError(
117+
FulfillmentErrorCode::ProjectionError(
118118
MismatchedProjectionTypes { err: TypeError::Mismatch },
119119
)
120120
}
121121
ty::PredicateKind::AliasRelate(_, _, _) => {
122-
FulfillmentErrorCode::CodeProjectionError(
122+
FulfillmentErrorCode::ProjectionError(
123123
MismatchedProjectionTypes { err: TypeError::Mismatch },
124124
)
125125
}
@@ -128,7 +128,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> {
128128
goal.predicate.kind().rebind((pred.a, pred.b)),
129129
);
130130
let expected_found = ExpectedFound::new(true, a, b);
131-
FulfillmentErrorCode::CodeSubtypeError(
131+
FulfillmentErrorCode::SubtypeError(
132132
expected_found,
133133
TypeError::Sorts(expected_found),
134134
)
@@ -138,15 +138,15 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> {
138138
goal.predicate.kind().rebind((pred.a, pred.b)),
139139
);
140140
let expected_found = ExpectedFound::new(false, a, b);
141-
FulfillmentErrorCode::CodeSubtypeError(
141+
FulfillmentErrorCode::SubtypeError(
142142
expected_found,
143143
TypeError::Sorts(expected_found),
144144
)
145145
}
146146
ty::PredicateKind::Clause(_)
147147
| ty::PredicateKind::ObjectSafe(_)
148148
| ty::PredicateKind::Ambiguous => {
149-
FulfillmentErrorCode::CodeSelectionError(
149+
FulfillmentErrorCode::SelectionError(
150150
SelectionError::Unimplemented,
151151
)
152152
}

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

+21-24
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};
@@ -785,14 +785,14 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
785785

786786
ty::PredicateKind::Subtype(predicate) => {
787787
// Errors for Subtype predicates show up as
788-
// `FulfillmentErrorCode::CodeSubtypeError`,
788+
// `FulfillmentErrorCode::SubtypeError`,
789789
// not selection error.
790790
span_bug!(span, "subtype requirement gave wrong error: `{:?}`", predicate)
791791
}
792792

793793
ty::PredicateKind::Coerce(predicate) => {
794794
// Errors for Coerce predicates show up as
795-
// `FulfillmentErrorCode::CodeSubtypeError`,
795+
// `FulfillmentErrorCode::SubtypeError`,
796796
// not selection error.
797797
span_bug!(span, "coerce requirement gave wrong error: `{:?}`", predicate)
798798
}
@@ -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,
@@ -1492,7 +1492,7 @@ pub(super) trait InferCtxtPrivExt<'tcx> {
14921492
kind: ty::ClosureKind,
14931493
) -> DiagnosticBuilder<'tcx>;
14941494

1495-
fn report_type_parameter_mismatch_cyclic_type_error(
1495+
fn report_cyclic_signature_error(
14961496
&self,
14971497
obligation: &PredicateObligation<'tcx>,
14981498
found_trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
@@ -1506,7 +1506,7 @@ pub(super) trait InferCtxtPrivExt<'tcx> {
15061506
def_id: DefId,
15071507
) -> DiagnosticBuilder<'tcx>;
15081508

1509-
fn report_type_parameter_mismatch_error(
1509+
fn report_signature_mismatch_error(
15101510
&self,
15111511
obligation: &PredicateObligation<'tcx>,
15121512
span: Span,
@@ -1572,23 +1572,23 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
15721572
}
15731573

15741574
match error.code {
1575-
FulfillmentErrorCode::CodeSelectionError(ref selection_error) => {
1575+
FulfillmentErrorCode::SelectionError(ref selection_error) => {
15761576
self.report_selection_error(
15771577
error.obligation.clone(),
15781578
&error.root_obligation,
15791579
selection_error,
15801580
);
15811581
}
1582-
FulfillmentErrorCode::CodeProjectionError(ref e) => {
1582+
FulfillmentErrorCode::ProjectionError(ref e) => {
15831583
self.report_projection_error(&error.obligation, e);
15841584
}
1585-
FulfillmentErrorCode::CodeAmbiguity { overflow: false } => {
1585+
FulfillmentErrorCode::Ambiguity { overflow: false } => {
15861586
self.maybe_report_ambiguity(&error.obligation);
15871587
}
1588-
FulfillmentErrorCode::CodeAmbiguity { overflow: true } => {
1588+
FulfillmentErrorCode::Ambiguity { overflow: true } => {
15891589
self.report_overflow_no_abort(error.obligation.clone());
15901590
}
1591-
FulfillmentErrorCode::CodeSubtypeError(ref expected_found, ref err) => {
1591+
FulfillmentErrorCode::SubtypeError(ref expected_found, ref err) => {
15921592
self.report_mismatched_types(
15931593
&error.obligation.cause,
15941594
expected_found.expected,
@@ -1597,7 +1597,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
15971597
)
15981598
.emit();
15991599
}
1600-
FulfillmentErrorCode::CodeConstEquateError(ref expected_found, ref err) => {
1600+
FulfillmentErrorCode::ConstEquateError(ref expected_found, ref err) => {
16011601
let mut diag = self.report_mismatched_consts(
16021602
&error.obligation.cause,
16031603
expected_found.expected,
@@ -1622,7 +1622,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
16221622
}
16231623
diag.emit();
16241624
}
1625-
FulfillmentErrorCode::CodeCycle(ref cycle) => {
1625+
FulfillmentErrorCode::Cycle(ref cycle) => {
16261626
self.report_overflow_obligation_cycle(cycle);
16271627
}
16281628
}
@@ -3366,7 +3366,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
33663366
self.dcx().create_err(err)
33673367
}
33683368

3369-
fn report_type_parameter_mismatch_cyclic_type_error(
3369+
fn report_cyclic_signature_error(
33703370
&self,
33713371
obligation: &PredicateObligation<'tcx>,
33723372
found_trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
@@ -3427,7 +3427,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
34273427
err
34283428
}
34293429

3430-
fn report_type_parameter_mismatch_error(
3430+
fn report_signature_mismatch_error(
34313431
&self,
34323432
obligation: &PredicateObligation<'tcx>,
34333433
span: Span,
@@ -3446,10 +3446,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
34463446
};
34473447

34483448
let found_did = match *found_trait_ty.kind() {
3449-
ty::Closure(did, _) | ty::Foreign(did) | ty::FnDef(did, _) | ty::Coroutine(did, ..) => {
3450-
Some(did)
3451-
}
3452-
ty::Adt(def, _) => Some(def.did()),
3449+
ty::Closure(did, _) | ty::FnDef(did, _) | ty::Coroutine(did, ..) => Some(did),
34533450
_ => None,
34543451
};
34553452

0 commit comments

Comments
 (0)