Skip to content

Commit e319f40

Browse files
committed
Remove now dead code.
1 parent d9d10c1 commit e319f40

File tree

1 file changed

+1
-299
lines changed

1 file changed

+1
-299
lines changed

src/librustc_mir/borrow_check.rs

Lines changed: 1 addition & 299 deletions
Original file line numberDiff line numberDiff line change
@@ -544,19 +544,6 @@ impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx>
544544
}
545545
}
546546
}
547-
548-
#[cfg(not_anymore)]
549-
fn borrow(&mut self,
550-
context: Context,
551-
location: Location,
552-
bk: BorrowKind,
553-
lvalue_span: (&Lvalue<'gcx>, Span),
554-
flow_state: &InProgress<'b, 'gcx>) {
555-
debug!("borrow location: {:?} lvalue: {:?} span: {:?}",
556-
location, lvalue_span.0, lvalue_span.1);
557-
self.check_if_path_is_moved(context, lvalue_span, flow_state);
558-
self.check_for_conflicting_loans(context, location, bk, lvalue_span, flow_state);
559-
}
560547
}
561548

562549
impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx> {
@@ -697,64 +684,7 @@ impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx>
697684
}
698685
}
699686
}
700-
701-
#[cfg(not_anymore)]
702-
fn check_for_conflicting_loans(&mut self,
703-
context: Context,
704-
_location: Location,
705-
_bk: BorrowKind,
706-
lvalue_span: (&Lvalue<'gcx>, Span),
707-
flow_state: &InProgress<'b, 'gcx>) {
708-
// NOTE FIXME: The analogous code in old borrowck
709-
// check_loans.rs is careful to iterate over every *issued*
710-
// loan, as opposed to just the in scope ones.
711-
//
712-
// (Or if you prefer, all the *other* iterations over loans
713-
// only consider loans that are in scope of some given
714-
// region::Scope)
715-
//
716-
// The (currently skeletal) code here does not encode such a
717-
// distinction, which means it is almost certainly over
718-
// looking something.
719-
//
720-
// (It is probably going to reject code that should be
721-
// accepted, I suspect, by treated issued-but-out-of-scope
722-
// loans as issued-and-in-scope, and thus causing them to
723-
// interfere with other loans.)
724-
//
725-
// However, I just want to get something running, especially
726-
// since I am trying to move into new territory with NLL, so
727-
// lets get this going first, and then address the issued vs
728-
// in-scope distinction later.
729-
730-
let state = &flow_state.borrows;
731-
let data = &state.base_results.operator().borrows();
732-
733-
debug!("check_for_conflicting_loans location: {:?}", _location);
734-
735-
// does any loan generated here conflict with a previously issued loan?
736-
let mut loans_generated = 0;
737-
for (g, gen) in state.elems_generated().map(|g| (g, &data[g])) {
738-
loans_generated += 1;
739-
for (i, issued) in state.elems_incoming().map(|i| (i, &data[i])) {
740-
debug!("check_for_conflicting_loans gen: {:?} issued: {:?} conflicts: {}",
741-
(g, gen, self.base_path(&gen.lvalue),
742-
self.restrictions(&gen.lvalue).collect::<Vec<_>>()),
743-
(i, issued, self.base_path(&issued.lvalue),
744-
self.restrictions(&issued.lvalue).collect::<Vec<_>>()),
745-
self.conflicts_with(gen, issued));
746-
if self.conflicts_with(gen, issued) {
747-
self.report_conflicting_borrow(context, lvalue_span, gen, issued);
748-
}
749-
}
750-
}
751-
752-
// MIR statically ensures each statement gens *at most one*
753-
// loan; mutual conflict (within a statement) can't arise.
754-
//
755-
// As safe-guard, assert that above property actually holds.
756-
assert!(loans_generated <= 1);
757-
} }
687+
}
758688

759689
impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx> {
760690
fn each_borrow_involving_path<F>(&mut self,
@@ -954,194 +884,6 @@ mod prefixes {
954884
}
955885
}
956886
}
957-
}
958-
959-
#[cfg(not_anymore)]
960-
mod restrictions {
961-
use super::MirBorrowckCtxt;
962-
963-
use rustc::hir;
964-
use rustc::ty::{self, TyCtxt};
965-
use rustc::mir::{Lvalue, Mir, ProjectionElem};
966-
967-
pub(super) struct Restrictions<'c, 'tcx: 'c> {
968-
mir: &'c Mir<'tcx>,
969-
tcx: TyCtxt<'c, 'tcx, 'tcx>,
970-
lvalue_stack: Vec<&'c Lvalue<'tcx>>,
971-
}
972-
973-
impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx> {
974-
pub(super) fn restrictions<'d>(&self,
975-
lvalue: &'d Lvalue<'gcx>)
976-
-> Restrictions<'d, 'gcx> where 'b: 'd
977-
{
978-
let lvalue_stack = if self.has_restrictions(lvalue) { vec![lvalue] } else { vec![] };
979-
Restrictions { lvalue_stack, mir: self.mir, tcx: self.tcx }
980-
}
981-
982-
fn has_restrictions(&self, lvalue: &Lvalue<'gcx>) -> bool {
983-
let mut cursor = lvalue;
984-
loop {
985-
let proj = match *cursor {
986-
Lvalue::Local(_) => return true,
987-
Lvalue::Static(_) => return false,
988-
Lvalue::Projection(ref proj) => proj,
989-
};
990-
match proj.elem {
991-
ProjectionElem::Index(..) |
992-
ProjectionElem::ConstantIndex { .. } |
993-
ProjectionElem::Downcast(..) |
994-
ProjectionElem::Subslice { .. } |
995-
ProjectionElem::Field(_/*field*/, _/*ty*/) => {
996-
cursor = &proj.base;
997-
continue;
998-
}
999-
ProjectionElem::Deref => {
1000-
let ty = proj.base.ty(self.mir, self.tcx).to_ty(self.tcx);
1001-
match ty.sty {
1002-
ty::TyRawPtr(_) => {
1003-
return false;
1004-
}
1005-
ty::TyRef(_, ty::TypeAndMut { ty: _, mutbl: hir::MutImmutable }) => {
1006-
// FIXME: do I need to check validity of
1007-
// region here though? (I think the original
1008-
// check_loans code did, like readme says)
1009-
return false;
1010-
}
1011-
ty::TyRef(_, ty::TypeAndMut { ty: _, mutbl: hir::MutMutable }) => {
1012-
cursor = &proj.base;
1013-
continue;
1014-
}
1015-
ty::TyAdt(..) if ty.is_box() => {
1016-
cursor = &proj.base;
1017-
continue;
1018-
}
1019-
_ => {
1020-
panic!("unknown type fed to Projection Deref.");
1021-
}
1022-
}
1023-
}
1024-
}
1025-
}
1026-
}
1027-
}
1028-
1029-
impl<'c, 'tcx> Iterator for Restrictions<'c, 'tcx> {
1030-
type Item = &'c Lvalue<'tcx>;
1031-
fn next(&mut self) -> Option<Self::Item> {
1032-
'pop: loop {
1033-
let lvalue = match self.lvalue_stack.pop() {
1034-
None => return None,
1035-
Some(lvalue) => lvalue,
1036-
};
1037-
1038-
// `lvalue` may not be a restriction itself, but may
1039-
// hold one further down (e.g. we never return
1040-
// downcasts here, but may return a base of a
1041-
// downcast).
1042-
//
1043-
// Also, we need to enqueue any additional
1044-
// subrestrictions that it implies, since we can only
1045-
// return from from this call alone.
1046-
1047-
let mut cursor = lvalue;
1048-
'cursor: loop {
1049-
let proj = match *cursor {
1050-
Lvalue::Local(_) => return Some(cursor), // search yielded this leaf
1051-
Lvalue::Static(_) => continue 'pop, // fruitless leaf; try next on stack
1052-
Lvalue::Projection(ref proj) => proj,
1053-
};
1054-
1055-
match proj.elem {
1056-
ProjectionElem::Field(_/*field*/, _/*ty*/) => {
1057-
// FIXME: add union handling
1058-
self.lvalue_stack.push(&proj.base);
1059-
return Some(cursor);
1060-
}
1061-
ProjectionElem::Downcast(..) |
1062-
ProjectionElem::Subslice { .. } |
1063-
ProjectionElem::ConstantIndex { .. } |
1064-
ProjectionElem::Index(_) => {
1065-
cursor = &proj.base;
1066-
continue 'cursor;
1067-
}
1068-
ProjectionElem::Deref => {
1069-
// (handled below)
1070-
}
1071-
}
1072-
1073-
assert_eq!(proj.elem, ProjectionElem::Deref);
1074-
1075-
let ty = proj.base.ty(self.mir, self.tcx).to_ty(self.tcx);
1076-
match ty.sty {
1077-
ty::TyRawPtr(_) => {
1078-
// borrowck ignores raw ptrs; treat analogous to imm borrow
1079-
continue 'pop;
1080-
}
1081-
// R-Deref-Imm-Borrowed
1082-
ty::TyRef(_/*rgn*/, ty::TypeAndMut { ty: _, mutbl: hir::MutImmutable }) => {
1083-
// immutably-borrowed referents do not
1084-
// have recursively-implied restrictions
1085-
// (because preventing actions on `*LV`
1086-
// does nothing about aliases like `*LV1`)
1087-
1088-
// FIXME: do I need to check validity of
1089-
// `_r` here though? (I think the original
1090-
// check_loans code did, like the readme
1091-
// says)
1092-
1093-
// (And do I *really* not have to
1094-
// recursively process the `base` as a
1095-
// further search here? Leaving this `if
1096-
// false` here as a hint to look at this
1097-
// again later.
1098-
//
1099-
// Ah, it might be because the
1100-
// restrictions are distinct from the path
1101-
// substructure. Note that there is a
1102-
// separate loop over the path
1103-
// substructure in fn
1104-
// each_borrow_involving_path, for better
1105-
// or for worse.
1106-
1107-
if false {
1108-
cursor = &proj.base;
1109-
continue 'cursor;
1110-
} else {
1111-
continue 'pop;
1112-
}
1113-
}
1114-
1115-
// R-Deref-Mut-Borrowed
1116-
ty::TyRef(_/*rgn*/, ty::TypeAndMut { ty: _, mutbl: hir::MutMutable }) => {
1117-
// mutably-borrowed referents are
1118-
// themselves restricted.
1119-
1120-
// FIXME: do I need to check validity of
1121-
// `_r` here though? (I think the original
1122-
// check_loans code did, like the readme
1123-
// says)
1124-
1125-
// schedule base for future iteration.
1126-
self.lvalue_stack.push(&proj.base);
1127-
return Some(cursor); // search yielded interior node
1128-
}
1129-
1130-
// R-Deref-Send-Pointer
1131-
ty::TyAdt(..) if ty.is_box() => {
1132-
// borrowing interior of a box implies that
1133-
// its base can no longer be mutated (o/w box
1134-
// storage would be freed)
1135-
self.lvalue_stack.push(&proj.base);
1136-
return Some(cursor); // search yielded interior node
1137-
}
1138-
1139-
_ => panic!("unknown type fed to Projection Deref."),
1140-
}
1141-
}
1142-
}
1143-
}
1144-
}
1145887
}
1146888

1147889
impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx> {
@@ -1319,26 +1061,6 @@ impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx>
13191061
}
13201062

13211063
impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx> {
1322-
// FIXME: needs to be able to express errors analogous to check_loans.rs
1323-
#[cfg(not_anymore)]
1324-
fn conflicts_with(&self, loan1: &BorrowData<'gcx>, loan2: &BorrowData<'gcx>) -> bool {
1325-
if loan1.compatible_with(loan2.kind) { return false; }
1326-
1327-
let loan2_base_path = self.base_path(&loan2.lvalue);
1328-
for restricted in self.restrictions(&loan1.lvalue) {
1329-
if restricted != loan2_base_path { continue; }
1330-
return true;
1331-
}
1332-
1333-
let loan1_base_path = self.base_path(&loan1.lvalue);
1334-
for restricted in self.restrictions(&loan2.lvalue) {
1335-
if restricted != loan1_base_path { continue; }
1336-
return true;
1337-
}
1338-
1339-
return false;
1340-
}
1341-
13421064
// FIXME (#16118): function intended to allow the borrow checker
13431065
// to be less precise in its handling of Box while still allowing
13441066
// moves out of a Box. They should be removed when/if we stop
@@ -1518,28 +1240,8 @@ impl<BD> FlowInProgress<BD> where BD: BitDenotation {
15181240
self.curr_state.subtract(&self.stmt_kill);
15191241
}
15201242

1521-
#[allow(dead_code)]
1522-
fn elems_generated(&self) -> indexed_set::Elems<BD::Idx> {
1523-
let univ = self.base_results.sets().bits_per_block();
1524-
self.stmt_gen.elems(univ)
1525-
}
1526-
15271243
fn elems_incoming(&self) -> indexed_set::Elems<BD::Idx> {
15281244
let univ = self.base_results.sets().bits_per_block();
15291245
self.curr_state.elems(univ)
15301246
}
15311247
}
1532-
1533-
impl<'tcx> BorrowData<'tcx> {
1534-
#[allow(dead_code)]
1535-
fn compatible_with(&self, bk: BorrowKind) -> bool {
1536-
match (self.kind, bk) {
1537-
(BorrowKind::Shared, BorrowKind::Shared) => true,
1538-
1539-
(BorrowKind::Mut, _) |
1540-
(BorrowKind::Unique, _) |
1541-
(_, BorrowKind::Mut) |
1542-
(_, BorrowKind::Unique) => false,
1543-
}
1544-
}
1545-
}

0 commit comments

Comments
 (0)