Remove CastCheckResult since it's unused

This commit is contained in:
Michael Goulet 2022-09-14 23:42:25 +00:00
parent feb4244f54
commit 0cb217d29b
3 changed files with 22 additions and 38 deletions

View file

@ -203,28 +203,8 @@ fn make_invalid_casting_error<'a, 'tcx>(
)
}
pub enum CastCheckResult<'tcx> {
Ok,
Deferred(CastCheck<'tcx>),
Err(ErrorGuaranteed),
}
pub fn check_cast<'tcx>(
fcx: &FnCtxt<'_, 'tcx>,
expr: &'tcx hir::Expr<'tcx>,
expr_ty: Ty<'tcx>,
cast_ty: Ty<'tcx>,
cast_span: Span,
span: Span,
) -> CastCheckResult<'tcx> {
match CastCheck::new(fcx, expr, expr_ty, cast_ty, cast_span, span) {
Ok(check) => CastCheckResult::Deferred(check),
Err(e) => CastCheckResult::Err(e),
}
}
impl<'a, 'tcx> CastCheck<'tcx> {
fn new(
pub fn new(
fcx: &FnCtxt<'a, 'tcx>,
expr: &'tcx hir::Expr<'tcx>,
expr_ty: Ty<'tcx>,

View file

@ -3,7 +3,7 @@
//! See `mod.rs` for more context on type checking in general.
use crate::astconv::AstConv as _;
use crate::check::cast::{self, CastCheckResult};
use crate::check::cast;
use crate::check::coercion::CoerceMany;
use crate::check::fatally_break_rust;
use crate::check::method::SelfSource;
@ -1270,9 +1270,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} else {
// Defer other checks until we're done type checking.
let mut deferred_cast_checks = self.deferred_cast_checks.borrow_mut();
match cast::check_cast(self, e, t_expr, t_cast, t.span, expr.span) {
CastCheckResult::Ok => t_cast,
CastCheckResult::Deferred(cast_check) => {
match cast::CastCheck::new(self, e, t_expr, t_cast, t.span, expr.span) {
Ok(cast_check) => {
debug!(
"check_expr_cast: deferring cast from {:?} to {:?}: {:?}",
t_cast, t_expr, cast_check,
@ -1280,7 +1279,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
deferred_cast_checks.push(cast_check);
t_cast
}
CastCheckResult::Err(ErrorGuaranteed { .. }) => self.tcx.ty_error(),
Err(_) => self.tcx.ty_error(),
}
}
}