Skip to content

Commit 04c0494

Browse files
rename some variants in FulfillmentErrorCode
1 parent cf77474 commit 04c0494

File tree

9 files changed

+46
-62
lines changed

9 files changed

+46
-62
lines changed

Diff for: compiler/rustc_borrowck/src/diagnostics/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
13441344
Applicability::MaybeIncorrect,
13451345
);
13461346
for error in errors {
1347-
if let FulfillmentErrorCode::SelectionError(
1347+
if let FulfillmentErrorCode::Select(
13481348
SelectionError::Unimplemented,
13491349
) = error.code
13501350
&& let ty::PredicateKind::Clause(ty::ClauseKind::Trait(

Diff for: compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
12831283
}
12841284
// The type doesn't implement Clone because of unmet obligations.
12851285
for error in errors {
1286-
if let traits::FulfillmentErrorCode::SelectionError(
1286+
if let traits::FulfillmentErrorCode::Select(
12871287
traits::SelectionError::Unimplemented,
12881288
) = error.code
12891289
&& let ty::PredicateKind::Clause(ty::ClauseKind::Trait(

Diff for: compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
360360
error: &traits::FulfillmentError<'tcx>,
361361
span: Span,
362362
) -> bool {
363-
if let traits::FulfillmentErrorCode::SelectionError(
364-
traits::SelectionError::SignatureMismatch(box traits::SignatureMismatchData {
365-
expected_trait_ref,
366-
..
367-
}),
368-
) = error.code
363+
if let traits::FulfillmentErrorCode::Select(traits::SelectionError::SignatureMismatch(
364+
box traits::SignatureMismatchData { expected_trait_ref, .. },
365+
)) = error.code
369366
&& let ty::Closure(def_id, _) | ty::Coroutine(def_id, ..) =
370367
expected_trait_ref.self_ty().kind()
371368
&& span.overlaps(self.tcx.def_span(*def_id))

Diff for: compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1700,7 +1700,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17001700
}
17011701
}
17021702
for error in errors {
1703-
if let traits::FulfillmentErrorCode::SelectionError(
1703+
if let traits::FulfillmentErrorCode::Select(
17041704
traits::SelectionError::Unimplemented,
17051705
) = error.code
17061706
&& let ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) =

Diff for: compiler/rustc_infer/src/traits/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ pub enum FulfillmentErrorCode<'tcx> {
138138
/// Inherently impossible to fulfill; this trait is implemented if and only
139139
/// if it is already implemented.
140140
Cycle(Vec<PredicateObligation<'tcx>>),
141-
SelectionError(SelectionError<'tcx>),
142-
ProjectionError(MismatchedProjectionTypes<'tcx>),
143-
SubtypeError(ExpectedFound<Ty<'tcx>>, TypeError<'tcx>), // always comes from a SubtypePredicate
144-
ConstEquateError(ExpectedFound<Const<'tcx>>, TypeError<'tcx>),
141+
Select(SelectionError<'tcx>),
142+
Project(MismatchedProjectionTypes<'tcx>),
143+
Subtype(ExpectedFound<Ty<'tcx>>, TypeError<'tcx>), // always comes from a SubtypePredicate
144+
ConstEquate(ExpectedFound<Const<'tcx>>, TypeError<'tcx>),
145145
Ambiguity {
146146
/// Overflow is only `Some(suggest_recursion_limit)` when using the next generation
147147
/// trait solver `-Znext-solver`. With the old solver overflow is eagerly handled by
@@ -209,10 +209,10 @@ impl<'tcx> FulfillmentError<'tcx> {
209209

210210
pub fn is_true_error(&self) -> bool {
211211
match self.code {
212-
FulfillmentErrorCode::SelectionError(_)
213-
| FulfillmentErrorCode::ProjectionError(_)
214-
| FulfillmentErrorCode::SubtypeError(_, _)
215-
| FulfillmentErrorCode::ConstEquateError(_, _) => true,
212+
FulfillmentErrorCode::Select(_)
213+
| FulfillmentErrorCode::Project(_)
214+
| FulfillmentErrorCode::Subtype(_, _)
215+
| FulfillmentErrorCode::ConstEquate(_, _) => true,
216216
FulfillmentErrorCode::Cycle(_) | FulfillmentErrorCode::Ambiguity { overflow: _ } => {
217217
false
218218
}

Diff for: compiler/rustc_infer/src/traits/structural_impls.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ impl<'tcx> fmt::Debug for traits::FulfillmentErrorCode<'tcx> {
3939
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4040
use traits::FulfillmentErrorCode::*;
4141
match *self {
42-
SelectionError(ref e) => write!(f, "{e:?}"),
43-
ProjectionError(ref e) => write!(f, "{e:?}"),
44-
SubtypeError(ref a, ref b) => {
42+
Select(ref e) => write!(f, "{e:?}"),
43+
Project(ref e) => write!(f, "{e:?}"),
44+
Subtype(ref a, ref b) => {
4545
write!(f, "CodeSubtypeError({a:?}, {b:?})")
4646
}
47-
ConstEquateError(ref a, ref b) => {
47+
ConstEquate(ref a, ref b) => {
4848
write!(f, "CodeConstEquateError({a:?}, {b:?})")
4949
}
5050
Ambiguity { overflow: None } => write!(f, "Ambiguity"),

Diff for: compiler/rustc_trait_selection/src/solve/fulfill.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -203,39 +203,35 @@ fn fulfillment_error_for_no_solution<'tcx>(
203203

204204
let code = match obligation.predicate.kind().skip_binder() {
205205
ty::PredicateKind::Clause(ty::ClauseKind::Projection(_)) => {
206-
FulfillmentErrorCode::ProjectionError(
206+
FulfillmentErrorCode::Project(
207207
// FIXME: This could be a `Sorts` if the term is a type
208208
MismatchedProjectionTypes { err: TypeError::Mismatch },
209209
)
210210
}
211211
ty::PredicateKind::NormalizesTo(..) => {
212-
FulfillmentErrorCode::ProjectionError(MismatchedProjectionTypes {
213-
err: TypeError::Mismatch,
214-
})
212+
FulfillmentErrorCode::Project(MismatchedProjectionTypes { err: TypeError::Mismatch })
215213
}
216214
ty::PredicateKind::AliasRelate(_, _, _) => {
217-
FulfillmentErrorCode::ProjectionError(MismatchedProjectionTypes {
218-
err: TypeError::Mismatch,
219-
})
215+
FulfillmentErrorCode::Project(MismatchedProjectionTypes { err: TypeError::Mismatch })
220216
}
221217
ty::PredicateKind::Subtype(pred) => {
222218
let (a, b) = infcx.enter_forall_and_leak_universe(
223219
obligation.predicate.kind().rebind((pred.a, pred.b)),
224220
);
225221
let expected_found = ExpectedFound::new(true, a, b);
226-
FulfillmentErrorCode::SubtypeError(expected_found, TypeError::Sorts(expected_found))
222+
FulfillmentErrorCode::Subtype(expected_found, TypeError::Sorts(expected_found))
227223
}
228224
ty::PredicateKind::Coerce(pred) => {
229225
let (a, b) = infcx.enter_forall_and_leak_universe(
230226
obligation.predicate.kind().rebind((pred.a, pred.b)),
231227
);
232228
let expected_found = ExpectedFound::new(false, a, b);
233-
FulfillmentErrorCode::SubtypeError(expected_found, TypeError::Sorts(expected_found))
229+
FulfillmentErrorCode::Subtype(expected_found, TypeError::Sorts(expected_found))
234230
}
235231
ty::PredicateKind::Clause(_)
236232
| ty::PredicateKind::ObjectSafe(_)
237233
| ty::PredicateKind::Ambiguous => {
238-
FulfillmentErrorCode::SelectionError(SelectionError::Unimplemented)
234+
FulfillmentErrorCode::Select(SelectionError::Unimplemented)
239235
}
240236
ty::PredicateKind::ConstEquate(..) => {
241237
bug!("unexpected goal: {obligation:?}")

Diff for: compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -1504,13 +1504,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
15041504
}
15051505

15061506
match error.code {
1507-
FulfillmentErrorCode::SelectionError(ref selection_error) => self
1508-
.report_selection_error(
1509-
error.obligation.clone(),
1510-
&error.root_obligation,
1511-
selection_error,
1512-
),
1513-
FulfillmentErrorCode::ProjectionError(ref e) => {
1507+
FulfillmentErrorCode::Select(ref selection_error) => self.report_selection_error(
1508+
error.obligation.clone(),
1509+
&error.root_obligation,
1510+
selection_error,
1511+
),
1512+
FulfillmentErrorCode::Project(ref e) => {
15141513
self.report_projection_error(&error.obligation, e)
15151514
}
15161515
FulfillmentErrorCode::Ambiguity { overflow: None } => {
@@ -1519,15 +1518,15 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
15191518
FulfillmentErrorCode::Ambiguity { overflow: Some(suggest_increasing_limit) } => {
15201519
self.report_overflow_no_abort(error.obligation.clone(), suggest_increasing_limit)
15211520
}
1522-
FulfillmentErrorCode::SubtypeError(ref expected_found, ref err) => self
1521+
FulfillmentErrorCode::Subtype(ref expected_found, ref err) => self
15231522
.report_mismatched_types(
15241523
&error.obligation.cause,
15251524
expected_found.expected,
15261525
expected_found.found,
15271526
*err,
15281527
)
15291528
.emit(),
1530-
FulfillmentErrorCode::ConstEquateError(ref expected_found, ref err) => {
1529+
FulfillmentErrorCode::ConstEquate(ref expected_found, ref err) => {
15311530
let mut diag = self.report_mismatched_consts(
15321531
&error.obligation.cause,
15331532
expected_found.expected,

Diff for: compiler/rustc_trait_selection/src/traits/fulfill.rs

+14-22
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
411411

412412
ty::PredicateKind::ObjectSafe(trait_def_id) => {
413413
if !self.selcx.tcx().check_is_object_safe(trait_def_id) {
414-
ProcessResult::Error(FulfillmentErrorCode::SelectionError(Unimplemented))
414+
ProcessResult::Error(FulfillmentErrorCode::Select(Unimplemented))
415415
} else {
416416
ProcessResult::Changed(vec![])
417417
}
@@ -435,7 +435,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
435435
ty,
436436
) {
437437
Ok(inf_ok) => ProcessResult::Changed(mk_pending(inf_ok.into_obligations())),
438-
Err(_) => ProcessResult::Error(FulfillmentErrorCode::SelectionError(
438+
Err(_) => ProcessResult::Error(FulfillmentErrorCode::Select(
439439
SelectionError::Unimplemented,
440440
)),
441441
}
@@ -493,10 +493,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
493493
Ok(Err(err)) => {
494494
let expected_found =
495495
ExpectedFound::new(subtype.a_is_expected, subtype.a, subtype.b);
496-
ProcessResult::Error(FulfillmentErrorCode::SubtypeError(
497-
expected_found,
498-
err,
499-
))
496+
ProcessResult::Error(FulfillmentErrorCode::Subtype(expected_found, err))
500497
}
501498
}
502499
}
@@ -516,10 +513,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
516513
Ok(Ok(ok)) => ProcessResult::Changed(mk_pending(ok.obligations)),
517514
Ok(Err(err)) => {
518515
let expected_found = ExpectedFound::new(false, coerce.a, coerce.b);
519-
ProcessResult::Error(FulfillmentErrorCode::SubtypeError(
520-
expected_found,
521-
err,
522-
))
516+
ProcessResult::Error(FulfillmentErrorCode::Subtype(expected_found, err))
523517
}
524518
}
525519
}
@@ -542,7 +536,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
542536
Err(
543537
e @ NotConstEvaluatable::MentionsParam
544538
| e @ NotConstEvaluatable::Error(_),
545-
) => ProcessResult::Error(FulfillmentErrorCode::SelectionError(
539+
) => ProcessResult::Error(FulfillmentErrorCode::Select(
546540
SelectionError::NotConstEvaluatable(e),
547541
)),
548542
}
@@ -638,29 +632,27 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
638632
ProcessResult::Changed(mk_pending(inf_ok.into_obligations()))
639633
}
640634
Err(err) => {
641-
ProcessResult::Error(FulfillmentErrorCode::ConstEquateError(
635+
ProcessResult::Error(FulfillmentErrorCode::ConstEquate(
642636
ExpectedFound::new(true, c1, c2),
643637
err,
644638
))
645639
}
646640
}
647641
}
648642
(Err(ErrorHandled::Reported(reported, _)), _)
649-
| (_, Err(ErrorHandled::Reported(reported, _))) => {
650-
ProcessResult::Error(FulfillmentErrorCode::SelectionError(
651-
SelectionError::NotConstEvaluatable(NotConstEvaluatable::Error(
652-
reported.into(),
653-
)),
654-
))
655-
}
643+
| (_, Err(ErrorHandled::Reported(reported, _))) => ProcessResult::Error(
644+
FulfillmentErrorCode::Select(SelectionError::NotConstEvaluatable(
645+
NotConstEvaluatable::Error(reported.into()),
646+
)),
647+
),
656648
(Err(ErrorHandled::TooGeneric(_)), _)
657649
| (_, Err(ErrorHandled::TooGeneric(_))) => {
658650
if c1.has_non_region_infer() || c2.has_non_region_infer() {
659651
ProcessResult::Unchanged
660652
} else {
661653
// Two different constants using generic parameters ~> error.
662654
let expected_found = ExpectedFound::new(true, c1, c2);
663-
ProcessResult::Error(FulfillmentErrorCode::ConstEquateError(
655+
ProcessResult::Error(FulfillmentErrorCode::ConstEquate(
664656
expected_found,
665657
TypeError::ConstMismatch(expected_found),
666658
))
@@ -741,7 +733,7 @@ impl<'a, 'tcx> FulfillProcessor<'a, 'tcx> {
741733
Err(selection_err) => {
742734
debug!("selecting trait at depth {} yielded Err", obligation.recursion_depth);
743735

744-
ProcessResult::Error(FulfillmentErrorCode::SelectionError(selection_err))
736+
ProcessResult::Error(FulfillmentErrorCode::Select(selection_err))
745737
}
746738
}
747739
}
@@ -793,7 +785,7 @@ impl<'a, 'tcx> FulfillProcessor<'a, 'tcx> {
793785
project_obligation.with(tcx, project_obligation.predicate),
794786
])),
795787
ProjectAndUnifyResult::MismatchedProjectionTypes(e) => {
796-
ProcessResult::Error(FulfillmentErrorCode::ProjectionError(e))
788+
ProcessResult::Error(FulfillmentErrorCode::Project(e))
797789
}
798790
}
799791
}

0 commit comments

Comments
 (0)