Skip to content

Rest In Peace, AST borrowck (2012-2019) #64790

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 28, 2019
Prev Previous commit
Next Next commit
cleanup check_match wrt. SignalledError.
  • Loading branch information
Centril committed Sep 27, 2019
commit defd5088d616bb324c92069b2c1129b76bc0ff94
2 changes: 1 addition & 1 deletion src/librustc/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ rustc_queries! {
}

TypeChecking {
query check_match(key: DefId) -> SignalledError {
query check_match(key: DefId) {
cache_on_disk_if { key.is_local() }
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::hir::def::{DefKind, Export};
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;
Expand Down
21 changes: 5 additions & 16 deletions src/librustc_mir/hair/pattern/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use super::_match::WitnessPreference::*;

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};
Expand All @@ -21,22 +20,19 @@ use std::slice;

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 {
tcx,
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<'_> {
Expand All @@ -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> {
Expand Down Expand Up @@ -136,13 +131,7 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
// 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);
}

Expand Down