Skip to content

Commit f6f0e04

Browse files
committed
Remove an unused error count check
1 parent f68741b commit f6f0e04

File tree

2 files changed

+1
-30
lines changed
  • compiler/rustc_hir_typeck/src/fn_ctxt
  • src/tools/clippy/clippy_lints/src/transmute

2 files changed

+1
-30
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@ pub struct FnCtxt<'a, 'tcx> {
4545
/// eventually).
4646
pub(super) param_env: ty::ParamEnv<'tcx>,
4747

48-
/// Number of errors that had been reported when we started
49-
/// checking this function. On exit, if we find that *more* errors
50-
/// have been reported, we will skip regionck and other work that
51-
/// expects the types within the function to be consistent.
52-
// FIXME(matthewjasper) This should not exist, and it's not correct
53-
// if type checking is run in parallel.
54-
err_count_on_creation: usize,
55-
5648
/// If `Some`, this stores coercion information for returned
5749
/// expressions. If `None`, this is in a context where return is
5850
/// inappropriate, such as a const expression.
@@ -126,7 +118,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
126118
FnCtxt {
127119
body_id,
128120
param_env,
129-
err_count_on_creation: inh.tcx.dcx().err_count(),
130121
ret_coercion: None,
131122
ret_coercion_span: Cell::new(None),
132123
coroutine_types: None,
@@ -195,10 +186,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
195186
}),
196187
}
197188
}
198-
199-
pub fn errors_reported_since_creation(&self) -> bool {
200-
self.dcx().err_count() > self.err_count_on_creation
201-
}
202189
}
203190

204191
impl<'a, 'tcx> Deref for FnCtxt<'a, 'tcx> {

src/tools/clippy/clippy_lints/src/transmute/utils.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ pub(super) fn check_cast<'tcx>(
3737
let inherited = Inherited::new(cx.tcx, local_def_id);
3838
let fn_ctxt = FnCtxt::new(&inherited, cx.param_env, local_def_id);
3939

40-
// If we already have errors, we can't be sure we can pointer cast.
41-
assert!(
42-
!fn_ctxt.errors_reported_since_creation(),
43-
"Newly created FnCtxt contained errors"
44-
);
45-
4640
if let Ok(check) = cast::CastCheck::new(
4741
&fn_ctxt,
4842
e,
@@ -53,17 +47,7 @@ pub(super) fn check_cast<'tcx>(
5347
DUMMY_SP,
5448
hir::Constness::NotConst,
5549
) {
56-
let res = check.do_check(&fn_ctxt);
57-
58-
// do_check's documentation says that it might return Ok and create
59-
// errors in the fcx instead of returning Err in some cases. Those cases
60-
// should be filtered out before getting here.
61-
assert!(
62-
!fn_ctxt.errors_reported_since_creation(),
63-
"`fn_ctxt` contained errors after cast check!"
64-
);
65-
66-
res.ok()
50+
check.do_check(&fn_ctxt).ok()
6751
} else {
6852
None
6953
}

0 commit comments

Comments
 (0)