rustc: remove unused field of mc::Categorization::Deref.

This commit is contained in:
Eduard-Mihai Burtescu 2017-05-16 17:54:03 +03:00
parent c6651ffd8e
commit 9a53c3e904
9 changed files with 61 additions and 64 deletions

View File

@ -94,7 +94,7 @@ pub enum Categorization<'tcx> {
StaticItem,
Upvar(Upvar), // upvar referenced by closure env
Local(ast::NodeId), // local variable
Deref(cmt<'tcx>, usize, PointerKind<'tcx>), // deref of a ptr
Deref(cmt<'tcx>, PointerKind<'tcx>), // deref of a ptr
Interior(cmt<'tcx>, InteriorKind), // something interior: field, tuple, etc
Downcast(cmt<'tcx>, DefId), // selects a particular enum variant (*1)
@ -229,8 +229,8 @@ impl<'tcx> cmt_<'tcx> {
pub fn immutability_blame(&self) -> Option<ImmutabilityBlame<'tcx>> {
match self.cat {
Categorization::Deref(ref base_cmt, _, BorrowedPtr(ty::ImmBorrow, _)) |
Categorization::Deref(ref base_cmt, _, Implicit(ty::ImmBorrow, _)) => {
Categorization::Deref(ref base_cmt, BorrowedPtr(ty::ImmBorrow, _)) |
Categorization::Deref(ref base_cmt, Implicit(ty::ImmBorrow, _)) => {
// try to figure out where the immutable reference came from
match base_cmt.cat {
Categorization::Local(node_id) =>
@ -255,13 +255,13 @@ impl<'tcx> cmt_<'tcx> {
}
Categorization::Rvalue(..) |
Categorization::Upvar(..) |
Categorization::Deref(.., UnsafePtr(..)) => {
Categorization::Deref(_, UnsafePtr(..)) => {
// This should not be reachable up to inference limitations.
None
}
Categorization::Interior(ref base_cmt, _) |
Categorization::Downcast(ref base_cmt, _) |
Categorization::Deref(ref base_cmt, _, _) => {
Categorization::Deref(ref base_cmt, _) => {
base_cmt.immutability_blame()
}
Categorization::StaticItem => {
@ -569,7 +569,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
// is an rvalue. That is what we will be
// dereferencing.
let base_cmt = self.cat_rvalue_node(expr.id(), expr.span(), ret_ty);
Ok(self.cat_deref_common(expr, base_cmt, 1, elem_ty, true))
Ok(self.cat_deref_common(expr, base_cmt, elem_ty, true))
}
None => {
self.cat_index(expr, self.cat_expr(&base)?, InteriorOffsetKind::Index)
@ -763,7 +763,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
cmt_ {
id: id,
span: span,
cat: Categorization::Deref(Rc::new(cmt_result), 0, ptr),
cat: Categorization::Deref(Rc::new(cmt_result), ptr),
mutbl: MutabilityCategory::from_borrow_kind(upvar_borrow.kind),
ty: var_ty,
note: NoteUpvarRef(upvar_id)
@ -823,7 +823,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
let ret = cmt_ {
id: id,
span: span,
cat: Categorization::Deref(Rc::new(cmt_result), 0, env_ptr),
cat: Categorization::Deref(Rc::new(cmt_result), env_ptr),
mutbl: deref_mutbl,
ty: var_ty,
note: NoteClosureEnv(upvar_id)
@ -957,7 +957,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
let base_cmt_ty = base_cmt.ty;
match base_cmt_ty.builtin_deref(true, ty::NoPreference) {
Some(mt) => {
let ret = self.cat_deref_common(node, base_cmt, deref_cnt, mt.ty, false);
let ret = self.cat_deref_common(node, base_cmt, mt.ty, false);
debug!("cat_deref ret {:?}", ret);
Ok(ret)
}
@ -972,7 +972,6 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
fn cat_deref_common<N:ast_node>(&self,
node: &N,
base_cmt: cmt<'tcx>,
deref_cnt: usize,
deref_ty: Ty<'tcx>,
implicit: bool)
-> cmt<'tcx>
@ -991,7 +990,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
span: node.span(),
// For unique ptrs, we inherit mutability from the owning reference.
mutbl: MutabilityCategory::from_pointer_kind(base_cmt.mutbl, ptr),
cat: Categorization::Deref(base_cmt, deref_cnt, ptr),
cat: Categorization::Deref(base_cmt, ptr),
ty: deref_ty,
note: NoteNone
});
@ -1300,15 +1299,15 @@ impl<'tcx> cmt_<'tcx> {
Categorization::Rvalue(..) |
Categorization::StaticItem |
Categorization::Local(..) |
Categorization::Deref(.., UnsafePtr(..)) |
Categorization::Deref(.., BorrowedPtr(..)) |
Categorization::Deref(.., Implicit(..)) |
Categorization::Deref(_, UnsafePtr(..)) |
Categorization::Deref(_, BorrowedPtr(..)) |
Categorization::Deref(_, Implicit(..)) |
Categorization::Upvar(..) => {
Rc::new((*self).clone())
}
Categorization::Downcast(ref b, _) |
Categorization::Interior(ref b, _) |
Categorization::Deref(ref b, _, Unique) => {
Categorization::Deref(ref b, Unique) => {
b.guarantor()
}
}
@ -1321,11 +1320,11 @@ impl<'tcx> cmt_<'tcx> {
// aliased and eventually recused.
match self.cat {
Categorization::Deref(ref b, _, BorrowedPtr(ty::MutBorrow, _)) |
Categorization::Deref(ref b, _, Implicit(ty::MutBorrow, _)) |
Categorization::Deref(ref b, _, BorrowedPtr(ty::UniqueImmBorrow, _)) |
Categorization::Deref(ref b, _, Implicit(ty::UniqueImmBorrow, _)) |
Categorization::Deref(ref b, _, Unique) |
Categorization::Deref(ref b, BorrowedPtr(ty::MutBorrow, _)) |
Categorization::Deref(ref b, Implicit(ty::MutBorrow, _)) |
Categorization::Deref(ref b, BorrowedPtr(ty::UniqueImmBorrow, _)) |
Categorization::Deref(ref b, Implicit(ty::UniqueImmBorrow, _)) |
Categorization::Deref(ref b, Unique) |
Categorization::Downcast(ref b, _) |
Categorization::Interior(ref b, _) => {
// Aliasability depends on base cmt
@ -1335,7 +1334,7 @@ impl<'tcx> cmt_<'tcx> {
Categorization::Rvalue(..) |
Categorization::Local(..) |
Categorization::Upvar(..) |
Categorization::Deref(.., UnsafePtr(..)) => { // yes, it's aliasable, but...
Categorization::Deref(_, UnsafePtr(..)) => { // yes, it's aliasable, but...
NonAliasable
}
@ -1347,8 +1346,8 @@ impl<'tcx> cmt_<'tcx> {
}
}
Categorization::Deref(_, _, BorrowedPtr(ty::ImmBorrow, _)) |
Categorization::Deref(_, _, Implicit(ty::ImmBorrow, _)) => {
Categorization::Deref(_, BorrowedPtr(ty::ImmBorrow, _)) |
Categorization::Deref(_, Implicit(ty::ImmBorrow, _)) => {
FreelyAliasable(AliasableBorrowed)
}
}
@ -1360,9 +1359,9 @@ impl<'tcx> cmt_<'tcx> {
match self.note {
NoteClosureEnv(..) | NoteUpvarRef(..) => {
Some(match self.cat {
Categorization::Deref(ref inner, ..) => {
Categorization::Deref(ref inner, _) => {
match inner.cat {
Categorization::Deref(ref inner, ..) => inner.clone(),
Categorization::Deref(ref inner, _) => inner.clone(),
Categorization::Upvar(..) => inner.clone(),
_ => bug!()
}
@ -1390,7 +1389,7 @@ impl<'tcx> cmt_<'tcx> {
"local variable".to_string()
}
}
Categorization::Deref(.., pk) => {
Categorization::Deref(_, pk) => {
let upvar = self.upvar();
match upvar.as_ref().map(|i| &i.cat) {
Some(&Categorization::Upvar(ref var)) => {
@ -1467,8 +1466,8 @@ impl<'tcx> fmt::Debug for Categorization<'tcx> {
Categorization::Upvar(upvar) => {
write!(f, "upvar({:?})", upvar)
}
Categorization::Deref(ref cmt, derefs, ptr) => {
write!(f, "{:?}-{:?}{}->", cmt.cat, ptr, derefs)
Categorization::Deref(ref cmt, ptr) => {
write!(f, "{:?}-{:?}->", cmt.cat, ptr)
}
Categorization::Interior(ref cmt, interior) => {
write!(f, "{:?}.{:?}", cmt.cat, interior)

View File

@ -222,9 +222,9 @@ fn check_and_get_illegal_move_origin<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
cmt: &mc::cmt<'tcx>)
-> Option<mc::cmt<'tcx>> {
match cmt.cat {
Categorization::Deref(.., mc::BorrowedPtr(..)) |
Categorization::Deref(.., mc::Implicit(..)) |
Categorization::Deref(.., mc::UnsafePtr(..)) |
Categorization::Deref(_, mc::BorrowedPtr(..)) |
Categorization::Deref(_, mc::Implicit(..)) |
Categorization::Deref(_, mc::UnsafePtr(..)) |
Categorization::StaticItem => {
Some(cmt.clone())
}
@ -258,7 +258,7 @@ fn check_and_get_illegal_move_origin<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
Some(cmt.clone())
}
Categorization::Deref(ref b, _, mc::Unique) => {
Categorization::Deref(ref b, mc::Unique) => {
check_and_get_illegal_move_origin(bccx, b)
}
}

View File

@ -72,11 +72,11 @@ impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> {
match cmt.cat {
Categorization::Rvalue(..) |
Categorization::Local(..) | // L-Local
Categorization::Local(..) | // L-Local
Categorization::Upvar(..) |
Categorization::Deref(.., mc::BorrowedPtr(..)) | // L-Deref-Borrowed
Categorization::Deref(.., mc::Implicit(..)) |
Categorization::Deref(.., mc::UnsafePtr(..)) => {
Categorization::Deref(_, mc::BorrowedPtr(..)) | // L-Deref-Borrowed
Categorization::Deref(_, mc::Implicit(..)) |
Categorization::Deref(_, mc::UnsafePtr(..)) => {
self.check_scope(self.scope(cmt))
}
@ -85,8 +85,8 @@ impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> {
}
Categorization::Downcast(ref base, _) |
Categorization::Deref(ref base, _, mc::Unique) | // L-Deref-Send
Categorization::Interior(ref base, _) => { // L-Field
Categorization::Deref(ref base, mc::Unique) | // L-Deref-Send
Categorization::Interior(ref base, _) => { // L-Field
self.check(base, discr_scope)
}
}
@ -119,15 +119,15 @@ impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> {
self.bccx.region_maps.var_scope(local_id)))
}
Categorization::StaticItem |
Categorization::Deref(.., mc::UnsafePtr(..)) => {
Categorization::Deref(_, mc::UnsafePtr(..)) => {
self.bccx.tcx.types.re_static
}
Categorization::Deref(.., mc::BorrowedPtr(_, r)) |
Categorization::Deref(.., mc::Implicit(_, r)) => {
Categorization::Deref(_, mc::BorrowedPtr(_, r)) |
Categorization::Deref(_, mc::Implicit(_, r)) => {
r
}
Categorization::Downcast(ref cmt, _) |
Categorization::Deref(ref cmt, _, mc::Unique) |
Categorization::Deref(ref cmt, mc::Unique) |
Categorization::Interior(ref cmt, _) => {
self.scope(cmt)
}

View File

@ -138,9 +138,9 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
move_from: mc::cmt<'tcx>)
-> DiagnosticBuilder<'a> {
match move_from.cat {
Categorization::Deref(.., mc::BorrowedPtr(..)) |
Categorization::Deref(.., mc::Implicit(..)) |
Categorization::Deref(.., mc::UnsafePtr(..)) |
Categorization::Deref(_, mc::BorrowedPtr(..)) |
Categorization::Deref(_, mc::Implicit(..)) |
Categorization::Deref(_, mc::UnsafePtr(..)) |
Categorization::StaticItem => {
let mut err = struct_span_err!(bccx, move_from.span, E0507,
"cannot move out of {}",

View File

@ -133,7 +133,7 @@ impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> {
RestrictionResult::Safe
}
Categorization::Deref(cmt_base, _, pk) => {
Categorization::Deref(cmt_base, pk) => {
match pk {
mc::Unique => {
// R-Deref-Send-Pointer

View File

@ -426,7 +426,7 @@ pub fn opt_loan_path<'tcx>(cmt: &mc::cmt<'tcx>) -> Option<Rc<LoanPath<'tcx>>> {
Some(new_lp(LpUpvar(id)))
}
Categorization::Deref(ref cmt_base, _, pk) => {
Categorization::Deref(ref cmt_base, pk) => {
opt_loan_path(cmt_base).map(|lp| {
new_lp(LpExtend(lp, cmt.mutbl, LpDeref(pk)))
})

View File

@ -512,7 +512,7 @@ impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for CheckCrateVisitor<'a, 'gcx> {
Categorization::StaticItem => {
break;
}
Categorization::Deref(ref cmt, ..) |
Categorization::Deref(ref cmt, _) |
Categorization::Downcast(ref cmt, _) |
Categorization::Interior(ref cmt, _) => {
cur = cmt;

View File

@ -1224,10 +1224,8 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
borrow_kind,
borrow_cmt);
match borrow_cmt.cat.clone() {
Categorization::Deref(ref_cmt, _,
mc::Implicit(ref_kind, ref_region)) |
Categorization::Deref(ref_cmt, _,
mc::BorrowedPtr(ref_kind, ref_region)) => {
Categorization::Deref(ref_cmt, mc::Implicit(ref_kind, ref_region)) |
Categorization::Deref(ref_cmt, mc::BorrowedPtr(ref_kind, ref_region)) => {
match self.link_reborrowed_region(span,
borrow_region, borrow_kind,
ref_cmt, ref_region, ref_kind,
@ -1243,7 +1241,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
}
Categorization::Downcast(cmt_base, _) |
Categorization::Deref(cmt_base, _, mc::Unique) |
Categorization::Deref(cmt_base, mc::Unique) |
Categorization::Interior(cmt_base, _) => {
// Borrowing interior or owned data requires the base
// to be valid and borrowable in the same fashion.
@ -1251,7 +1249,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
borrow_kind = borrow_kind;
}
Categorization::Deref(.., mc::UnsafePtr(..)) |
Categorization::Deref(_, mc::UnsafePtr(..)) |
Categorization::StaticItem |
Categorization::Upvar(..) |
Categorization::Local(..) |

View File

@ -281,8 +281,8 @@ impl<'a, 'gcx, 'tcx> AdjustBorrowKind<'a, 'gcx, 'tcx> {
debug!("adjust_upvar_borrow_kind_for_consume: guarantor={:?}",
guarantor);
match guarantor.cat {
Categorization::Deref(.., mc::BorrowedPtr(..)) |
Categorization::Deref(.., mc::Implicit(..)) => {
Categorization::Deref(_, mc::BorrowedPtr(..)) |
Categorization::Deref(_, mc::Implicit(..)) => {
match cmt.note {
mc::NoteUpvarRef(upvar_id) => {
debug!("adjust_upvar_borrow_kind_for_consume: \
@ -327,7 +327,7 @@ impl<'a, 'gcx, 'tcx> AdjustBorrowKind<'a, 'gcx, 'tcx> {
cmt);
match cmt.cat.clone() {
Categorization::Deref(base, _, mc::Unique) |
Categorization::Deref(base, mc::Unique) |
Categorization::Interior(base, _) |
Categorization::Downcast(base, _) => {
// Interior or owned data is mutable if base is
@ -335,8 +335,8 @@ impl<'a, 'gcx, 'tcx> AdjustBorrowKind<'a, 'gcx, 'tcx> {
self.adjust_upvar_borrow_kind_for_mut(base);
}
Categorization::Deref(base, _, mc::BorrowedPtr(..)) |
Categorization::Deref(base, _, mc::Implicit(..)) => {
Categorization::Deref(base, mc::BorrowedPtr(..)) |
Categorization::Deref(base, mc::Implicit(..)) => {
if !self.try_adjust_upvar_deref(cmt, ty::MutBorrow) {
// assignment to deref of an `&mut`
// borrowed pointer implies that the
@ -346,7 +346,7 @@ impl<'a, 'gcx, 'tcx> AdjustBorrowKind<'a, 'gcx, 'tcx> {
}
}
Categorization::Deref(.., mc::UnsafePtr(..)) |
Categorization::Deref(_, mc::UnsafePtr(..)) |
Categorization::StaticItem |
Categorization::Rvalue(..) |
Categorization::Local(_) |
@ -361,7 +361,7 @@ impl<'a, 'gcx, 'tcx> AdjustBorrowKind<'a, 'gcx, 'tcx> {
cmt);
match cmt.cat.clone() {
Categorization::Deref(base, _, mc::Unique) |
Categorization::Deref(base, mc::Unique) |
Categorization::Interior(base, _) |
Categorization::Downcast(base, _) => {
// Interior or owned data is unique if base is
@ -369,8 +369,8 @@ impl<'a, 'gcx, 'tcx> AdjustBorrowKind<'a, 'gcx, 'tcx> {
self.adjust_upvar_borrow_kind_for_unique(base);
}
Categorization::Deref(base, _, mc::BorrowedPtr(..)) |
Categorization::Deref(base, _, mc::Implicit(..)) => {
Categorization::Deref(base, mc::BorrowedPtr(..)) |
Categorization::Deref(base, mc::Implicit(..)) => {
if !self.try_adjust_upvar_deref(cmt, ty::UniqueImmBorrow) {
// for a borrowed pointer to be unique, its
// base must be unique
@ -378,7 +378,7 @@ impl<'a, 'gcx, 'tcx> AdjustBorrowKind<'a, 'gcx, 'tcx> {
}
}
Categorization::Deref(.., mc::UnsafePtr(..)) |
Categorization::Deref(_, mc::UnsafePtr(..)) |
Categorization::StaticItem |
Categorization::Rvalue(..) |
Categorization::Local(_) |