Skip to content

Commit 74fec9b

Browse files
Remove has_errors from FnCtxt
1 parent c0a7612 commit 74fec9b

File tree

6 files changed

+20
-19
lines changed

6 files changed

+20
-19
lines changed

compiler/rustc_hir_typeck/src/expr.rs

-2
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
220220

221221
// Hide the outer diverging and has_errors flags.
222222
let old_diverges = self.diverges.replace(Diverges::Maybe);
223-
let old_has_errors = self.has_errors.replace(false);
224223

225224
let ty = ensure_sufficient_stack(|| match &expr.kind {
226225
hir::ExprKind::Path(
@@ -259,7 +258,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
259258

260259
// Combine the diverging and has_error flags.
261260
self.diverges.set(self.diverges.get() | old_diverges);
262-
self.has_errors.set(self.has_errors.get() | old_has_errors);
263261

264262
debug!("type of {} is...", self.tcx.hir().node_to_string(expr.hir_id));
265263
debug!("... {:?}, expected is {:?}", ty, expected);

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
143143
self.typeck_results.borrow_mut().node_types_mut().insert(id, ty);
144144

145145
if ty.references_error() {
146-
self.has_errors.set(true);
147146
self.set_tainted_by_errors();
148147
}
149148
}

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13341334

13351335
// Hide the outer diverging and `has_errors` flags.
13361336
let old_diverges = self.diverges.replace(Diverges::Maybe);
1337-
let old_has_errors = self.has_errors.replace(false);
13381337

13391338
match stmt.kind {
13401339
hir::StmtKind::Local(l) => {
@@ -1364,7 +1363,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13641363

13651364
// Combine the diverging and `has_error` flags.
13661365
self.diverges.set(self.diverges.get() | old_diverges);
1367-
self.has_errors.set(self.has_errors.get() | old_has_errors);
13681366
}
13691367

13701368
pub fn check_block_no_value(&self, blk: &'tcx hir::Block<'tcx>) {
@@ -1544,11 +1542,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15441542
self.diverges.set(prev_diverges);
15451543
}
15461544

1547-
let mut ty = ctxt.coerce.unwrap().complete(self);
1548-
1549-
if self.has_errors.get() || ty.references_error() {
1550-
ty = self.tcx.ty_error()
1551-
}
1545+
let ty = ctxt.coerce.unwrap().complete(self);
15521546

15531547
self.write_ty(blk.hir_id, ty);
15541548

compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,6 @@ pub struct FnCtxt<'a, 'tcx> {
112112
/// the diverges flag is set to something other than `Maybe`.
113113
pub(super) diverges: Cell<Diverges>,
114114

115-
/// Whether any child nodes have any type errors.
116-
pub(super) has_errors: Cell<bool>,
117-
118115
pub(super) enclosing_breakables: RefCell<EnclosingBreakables<'tcx>>,
119116

120117
pub(super) inh: &'a Inherited<'tcx>,
@@ -145,7 +142,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
145142
resume_yield_tys: None,
146143
ps: Cell::new(UnsafetyState::function(hir::Unsafety::Normal, hir::CRATE_HIR_ID)),
147144
diverges: Cell::new(Diverges::Maybe),
148-
has_errors: Cell::new(false),
149145
enclosing_breakables: RefCell::new(EnclosingBreakables {
150146
stack: Vec::new(),
151147
by_id: Default::default(),

src/test/ui/error-codes/E0767.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
fn main () {
1+
fn main() {
22
'a: loop {
33
|| {
4+
//~^ ERROR mismatched types
45
loop { break 'a; } //~ ERROR E0767
56
}
67
}

src/test/ui/error-codes/E0767.stderr

+17-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
11
error[E0767]: use of unreachable label `'a`
2-
--> $DIR/E0767.rs:4:26
2+
--> $DIR/E0767.rs:5:26
33
|
44
LL | 'a: loop {
55
| -- unreachable label defined here
6-
LL | || {
6+
...
77
LL | loop { break 'a; }
88
| ^^ unreachable label `'a`
99
|
1010
= note: labels are unreachable through functions, closures, async blocks and modules
1111

12-
error: aborting due to previous error
12+
error[E0308]: mismatched types
13+
--> $DIR/E0767.rs:3:9
14+
|
15+
LL | / || {
16+
LL | |
17+
LL | | loop { break 'a; }
18+
LL | | }
19+
| |_________^ expected `()`, found closure
20+
|
21+
= note: expected unit type `()`
22+
found closure `[closure@$DIR/E0767.rs:3:9: 3:11]`
23+
24+
error: aborting due to 2 previous errors
1325

14-
For more information about this error, try `rustc --explain E0767`.
26+
Some errors have detailed explanations: E0308, E0767.
27+
For more information about an error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)