Skip to content

Commit

Permalink
typeck: use diverges.replace(..)
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Jan 21, 2020
1 parent ce361fb commit d47673d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
6 changes: 2 additions & 4 deletions src/librustc_typeck/check/_match.rs
Expand Up @@ -50,10 +50,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

self.warn_arms_when_scrutinee_diverges(arms, match_src);

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

// rust-lang/rust#55810: Typecheck patterns first (via eager
// collection into `Vec`), so we get types for all bindings.
Expand Down
6 changes: 2 additions & 4 deletions src/librustc_typeck/check/expr.rs
Expand Up @@ -165,10 +165,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}

// Hide the outer diverging and has_errors flags.
let old_diverges = self.diverges.get();
let old_has_errors = self.has_errors.get();
self.diverges.set(Diverges::Maybe);
self.has_errors.set(false);
let old_diverges = self.diverges.replace(Diverges::Maybe);
let old_has_errors = self.has_errors.replace(false);

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

Expand Down
7 changes: 2 additions & 5 deletions src/librustc_typeck/check/mod.rs
Expand Up @@ -4418,10 +4418,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.warn_if_unreachable(stmt.hir_id, stmt.span, "statement");

// Hide the outer diverging and `has_errors` flags.
let old_diverges = self.diverges.get();
let old_has_errors = self.has_errors.get();
self.diverges.set(Diverges::Maybe);
self.has_errors.set(false);
let old_diverges = self.diverges.replace(Diverges::Maybe);
let old_has_errors = self.has_errors.replace(false);

match stmt.kind {
hir::StmtKind::Local(ref l) => {
Expand All @@ -4431,7 +4429,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
hir::StmtKind::Item(_) => {}
hir::StmtKind::Expr(ref expr) => {
// Check with expected type of `()`.

self.check_expr_has_type_or_error(&expr, self.tcx.mk_unit(), |err| {
self.suggest_semicolon_at_end(expr.span, err);
});
Expand Down

0 comments on commit d47673d

Please sign in to comment.