cleanup check_match wrt. SignalledError.

This commit is contained in:
Mazdak Farrokhzad 2019-09-26 00:36:41 +02:00
parent 1eb280e2d8
commit defd5088d6
3 changed files with 7 additions and 18 deletions

View File

@ -469,7 +469,7 @@
}
TypeChecking {
query check_match(key: DefId) -> SignalledError {
query check_match(key: DefId) {
cache_on_disk_if { key.is_local() }
}

View File

@ -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;

View File

@ -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);
}