Remove unnecessary bool from ExpectedFound

This commit is contained in:
Michael Goulet
2024-11-23 04:46:53 +00:00
parent f5be3ca1e3
commit d294e4746b
13 changed files with 58 additions and 90 deletions

View File

@@ -557,8 +557,11 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
ProcessResult::Changed(mk_pending(ok.obligations))
}
Ok(Err(err)) => {
let expected_found =
ExpectedFound::new(subtype.a_is_expected, subtype.a, subtype.b);
let expected_found = if subtype.a_is_expected {
ExpectedFound::new(subtype.a, subtype.b)
} else {
ExpectedFound::new(subtype.b, subtype.a)
};
ProcessResult::Error(FulfillmentErrorCode::Subtype(expected_found, err))
}
}
@@ -578,7 +581,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
}
Ok(Ok(ok)) => ProcessResult::Changed(mk_pending(ok.obligations)),
Ok(Err(err)) => {
let expected_found = ExpectedFound::new(false, coerce.a, coerce.b);
let expected_found = ExpectedFound::new(coerce.b, coerce.a);
ProcessResult::Error(FulfillmentErrorCode::Subtype(expected_found, err))
}
}
@@ -703,7 +706,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
}
Err(err) => {
ProcessResult::Error(FulfillmentErrorCode::ConstEquate(
ExpectedFound::new(true, c1, c2),
ExpectedFound::new(c1, c2),
err,
))
}
@@ -727,7 +730,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
ProcessResult::Unchanged
} else {
// Two different constants using generic parameters ~> error.
let expected_found = ExpectedFound::new(true, c1, c2);
let expected_found = ExpectedFound::new(c1, c2);
ProcessResult::Error(FulfillmentErrorCode::ConstEquate(
expected_found,
TypeError::ConstMismatch(expected_found),

View File

@@ -70,7 +70,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for MatchAgainstFreshVars<'tcx> {
) => Ok(a),
(&ty::Infer(_), _) | (_, &ty::Infer(_)) => {
Err(TypeError::Sorts(ExpectedFound::new(true, a, b)))
Err(TypeError::Sorts(ExpectedFound::new(a, b)))
}
(&ty::Error(guar), _) | (_, &ty::Error(guar)) => Ok(Ty::new_error(self.cx(), guar)),
@@ -95,7 +95,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for MatchAgainstFreshVars<'tcx> {
}
(ty::ConstKind::Infer(_), _) | (_, ty::ConstKind::Infer(_)) => {
return Err(TypeError::ConstMismatch(ExpectedFound::new(true, a, b)));
return Err(TypeError::ConstMismatch(ExpectedFound::new(a, b)));
}
_ => {}