From defd5088d616bb324c92069b2c1129b76bc0ff94 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Thu, 26 Sep 2019 00:36:41 +0200 Subject: [PATCH] cleanup check_match wrt. SignalledError. --- src/librustc/query/mod.rs | 2 +- src/librustc/ty/query/mod.rs | 2 +- src/librustc_mir/hair/pattern/check_match.rs | 21 +++++--------------- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/librustc/query/mod.rs b/src/librustc/query/mod.rs index 38af38b8282..6de351fa13a 100644 --- a/src/librustc/query/mod.rs +++ b/src/librustc/query/mod.rs @@ -469,7 +469,7 @@ } TypeChecking { - query check_match(key: DefId) -> SignalledError { + query check_match(key: DefId) { cache_on_disk_if { key.is_local() } } diff --git a/src/librustc/ty/query/mod.rs b/src/librustc/ty/query/mod.rs index fb2ad2aa54d..f4b99ca3688 100644 --- a/src/librustc/ty/query/mod.rs +++ b/src/librustc/ty/query/mod.rs @@ -4,7 +4,7 @@ use crate::hir::{self, TraitCandidate, ItemLocalId, CodegenFnAttrs}; use crate::infer::canonical::{self, Canonical}; use crate::lint; -use crate::middle::borrowck::{BorrowCheckResult, SignalledError}; +use crate::middle::borrowck::BorrowCheckResult; use crate::middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary, ForeignModule}; use crate::middle::cstore::{NativeLibraryKind, DepKind, CrateSource}; use crate::middle::privacy::AccessLevels; diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs index 4572519683d..b57e57ba3ec 100644 --- a/src/librustc_mir/hair/pattern/check_match.rs +++ b/src/librustc_mir/hair/pattern/check_match.rs @@ -4,7 +4,6 @@ use super::{PatCtxt, PatternError, PatKind}; -use rustc::middle::borrowck::SignalledError; use rustc::session::Session; use rustc::ty::{self, Ty, TyCtxt}; use rustc::ty::subst::{InternalSubsts, SubstsRef}; @@ -21,11 +20,10 @@ use syntax_pos::{Span, DUMMY_SP, MultiSpan}; -crate fn check_match(tcx: TyCtxt<'_>, def_id: DefId) -> SignalledError { - let body_id = if let Some(id) = tcx.hir().as_local_hir_id(def_id) { - tcx.hir().body_owned_by(id) - } else { - return SignalledError::NoErrorsSeen; +crate fn check_match(tcx: TyCtxt<'_>, def_id: DefId) { + let body_id = match tcx.hir().as_local_hir_id(def_id) { + None => return, + Some(id) => tcx.hir().body_owned_by(id), }; let mut visitor = MatchVisitor { @@ -33,10 +31,8 @@ tables: tcx.body_tables(body_id), param_env: tcx.param_env(def_id), identity_substs: InternalSubsts::identity_for_item(tcx, def_id), - signalled_error: SignalledError::NoErrorsSeen, }; visitor.visit_body(tcx.hir().body(body_id)); - visitor.signalled_error } fn create_e0004(sess: &Session, sp: Span, error_message: String) -> DiagnosticBuilder<'_> { @@ -48,7 +44,6 @@ struct MatchVisitor<'a, 'tcx> { tables: &'a ty::TypeckTables<'tcx>, param_env: ty::ParamEnv<'tcx>, identity_substs: SubstsRef<'tcx>, - signalled_error: SignalledError, } impl<'tcx> Visitor<'tcx> for MatchVisitor<'_, 'tcx> { @@ -136,13 +131,7 @@ fn check_match( // First, check legality of move bindings. self.check_patterns(arm.guard.is_some(), &arm.pat); - // Second, if there is a guard on each arm, make sure it isn't - // assigning or borrowing anything mutably. - if arm.guard.is_some() { - self.signalled_error = SignalledError::SawSomeError; - } - - // Third, perform some lints. + // Second, perform some lints. check_for_bindings_named_same_as_variants(self, &arm.pat); }