Remove an unused error count check
This commit is contained in:
parent
f68741b637
commit
f6f0e04e9b
@ -45,14 +45,6 @@ pub struct FnCtxt<'a, 'tcx> {
|
|||||||
/// eventually).
|
/// eventually).
|
||||||
pub(super) param_env: ty::ParamEnv<'tcx>,
|
pub(super) param_env: ty::ParamEnv<'tcx>,
|
||||||
|
|
||||||
/// Number of errors that had been reported when we started
|
|
||||||
/// checking this function. On exit, if we find that *more* errors
|
|
||||||
/// have been reported, we will skip regionck and other work that
|
|
||||||
/// expects the types within the function to be consistent.
|
|
||||||
// FIXME(matthewjasper) This should not exist, and it's not correct
|
|
||||||
// if type checking is run in parallel.
|
|
||||||
err_count_on_creation: usize,
|
|
||||||
|
|
||||||
/// If `Some`, this stores coercion information for returned
|
/// If `Some`, this stores coercion information for returned
|
||||||
/// expressions. If `None`, this is in a context where return is
|
/// expressions. If `None`, this is in a context where return is
|
||||||
/// inappropriate, such as a const expression.
|
/// inappropriate, such as a const expression.
|
||||||
@ -126,7 +118,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
FnCtxt {
|
FnCtxt {
|
||||||
body_id,
|
body_id,
|
||||||
param_env,
|
param_env,
|
||||||
err_count_on_creation: inh.tcx.dcx().err_count(),
|
|
||||||
ret_coercion: None,
|
ret_coercion: None,
|
||||||
ret_coercion_span: Cell::new(None),
|
ret_coercion_span: Cell::new(None),
|
||||||
coroutine_types: None,
|
coroutine_types: None,
|
||||||
@ -195,10 +186,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn errors_reported_since_creation(&self) -> bool {
|
|
||||||
self.dcx().err_count() > self.err_count_on_creation
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> Deref for FnCtxt<'a, 'tcx> {
|
impl<'a, 'tcx> Deref for FnCtxt<'a, 'tcx> {
|
||||||
|
@ -37,12 +37,6 @@ pub(super) fn check_cast<'tcx>(
|
|||||||
let inherited = Inherited::new(cx.tcx, local_def_id);
|
let inherited = Inherited::new(cx.tcx, local_def_id);
|
||||||
let fn_ctxt = FnCtxt::new(&inherited, cx.param_env, local_def_id);
|
let fn_ctxt = FnCtxt::new(&inherited, cx.param_env, local_def_id);
|
||||||
|
|
||||||
// If we already have errors, we can't be sure we can pointer cast.
|
|
||||||
assert!(
|
|
||||||
!fn_ctxt.errors_reported_since_creation(),
|
|
||||||
"Newly created FnCtxt contained errors"
|
|
||||||
);
|
|
||||||
|
|
||||||
if let Ok(check) = cast::CastCheck::new(
|
if let Ok(check) = cast::CastCheck::new(
|
||||||
&fn_ctxt,
|
&fn_ctxt,
|
||||||
e,
|
e,
|
||||||
@ -53,17 +47,7 @@ pub(super) fn check_cast<'tcx>(
|
|||||||
DUMMY_SP,
|
DUMMY_SP,
|
||||||
hir::Constness::NotConst,
|
hir::Constness::NotConst,
|
||||||
) {
|
) {
|
||||||
let res = check.do_check(&fn_ctxt);
|
check.do_check(&fn_ctxt).ok()
|
||||||
|
|
||||||
// do_check's documentation says that it might return Ok and create
|
|
||||||
// errors in the fcx instead of returning Err in some cases. Those cases
|
|
||||||
// should be filtered out before getting here.
|
|
||||||
assert!(
|
|
||||||
!fn_ctxt.errors_reported_since_creation(),
|
|
||||||
"`fn_ctxt` contained errors after cast check!"
|
|
||||||
);
|
|
||||||
|
|
||||||
res.ok()
|
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user