Skip to content

Commit d47673d

Browse files
committed
typeck: use diverges.replace(..)
1 parent ce361fb commit d47673d

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

src/librustc_typeck/check/_match.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
5050

5151
self.warn_arms_when_scrutinee_diverges(arms, match_src);
5252

53-
// Otherwise, we have to union together the types that the
54-
// arms produce and so forth.
55-
let scrut_diverges = self.diverges.get();
56-
self.diverges.set(Diverges::Maybe);
53+
// Otherwise, we have to union together the types that the arms produce and so forth.
54+
let scrut_diverges = self.diverges.replace(Diverges::Maybe);
5755

5856
// rust-lang/rust#55810: Typecheck patterns first (via eager
5957
// collection into `Vec`), so we get types for all bindings.

src/librustc_typeck/check/expr.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
165165
}
166166

167167
// Hide the outer diverging and has_errors flags.
168-
let old_diverges = self.diverges.get();
169-
let old_has_errors = self.has_errors.get();
170-
self.diverges.set(Diverges::Maybe);
171-
self.has_errors.set(false);
168+
let old_diverges = self.diverges.replace(Diverges::Maybe);
169+
let old_has_errors = self.has_errors.replace(false);
172170

173171
let ty = self.check_expr_kind(expr, expected, needs);
174172

src/librustc_typeck/check/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4418,10 +4418,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
44184418
self.warn_if_unreachable(stmt.hir_id, stmt.span, "statement");
44194419

44204420
// Hide the outer diverging and `has_errors` flags.
4421-
let old_diverges = self.diverges.get();
4422-
let old_has_errors = self.has_errors.get();
4423-
self.diverges.set(Diverges::Maybe);
4424-
self.has_errors.set(false);
4421+
let old_diverges = self.diverges.replace(Diverges::Maybe);
4422+
let old_has_errors = self.has_errors.replace(false);
44254423

44264424
match stmt.kind {
44274425
hir::StmtKind::Local(ref l) => {
@@ -4431,7 +4429,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
44314429
hir::StmtKind::Item(_) => {}
44324430
hir::StmtKind::Expr(ref expr) => {
44334431
// Check with expected type of `()`.
4434-
44354432
self.check_expr_has_type_or_error(&expr, self.tcx.mk_unit(), |err| {
44364433
self.suggest_semicolon_at_end(expr.span, err);
44374434
});

0 commit comments

Comments
 (0)