Inline check_expr_meets_expectation_or_error

This commit is contained in:
Michael Goulet 2023-08-03 04:19:42 +00:00
parent 6868b93cf5
commit f3589a723d

View File

@ -68,20 +68,10 @@ fn check_expr_eq_type(&self, expr: &'tcx hir::Expr<'tcx>, expected: Ty<'tcx>) {
pub fn check_expr_has_type_or_error( pub fn check_expr_has_type_or_error(
&self, &self,
expr: &'tcx hir::Expr<'tcx>, expr: &'tcx hir::Expr<'tcx>,
expected: Ty<'tcx>, expected_ty: Ty<'tcx>,
extend_err: impl FnMut(&mut Diagnostic), extend_err: impl FnOnce(&mut Diagnostic),
) -> Ty<'tcx> { ) -> Ty<'tcx> {
self.check_expr_meets_expectation_or_error(expr, ExpectHasType(expected), extend_err) let mut ty = self.check_expr_with_expectation(expr, ExpectHasType(expected_ty));
}
fn check_expr_meets_expectation_or_error(
&self,
expr: &'tcx hir::Expr<'tcx>,
expected: Expectation<'tcx>,
mut extend_err: impl FnMut(&mut Diagnostic),
) -> Ty<'tcx> {
let expected_ty = expected.to_option(&self).unwrap_or(self.tcx.types.bool);
let mut ty = self.check_expr_with_expectation(expr, expected);
// While we don't allow *arbitrary* coercions here, we *do* allow // While we don't allow *arbitrary* coercions here, we *do* allow
// coercions from ! to `expected`. // coercions from ! to `expected`.