diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index d0adf51d79e6..13647d420c36 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -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> { 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(&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) diff --git a/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs b/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs index f193588dd7d6..baa18307510e 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs @@ -222,9 +222,9 @@ fn check_and_get_illegal_move_origin<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, cmt: &mc::cmt<'tcx>) -> Option> { 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) } } diff --git a/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs b/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs index 5fc5682a60b4..0a6375ab187d 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs @@ -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) } diff --git a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs index 1ee6d565d0d7..f7c3bb36da7d 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs @@ -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 {}", diff --git a/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs b/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs index 7f90a8b19d4a..b7965f81b882 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs @@ -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 diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 9b084acc1938..0b2cb1b93f92 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -426,7 +426,7 @@ pub fn opt_loan_path<'tcx>(cmt: &mc::cmt<'tcx>) -> Option>> { 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))) }) diff --git a/src/librustc_passes/consts.rs b/src/librustc_passes/consts.rs index 8f087ac212e8..09e90b78d604 100644 --- a/src/librustc_passes/consts.rs +++ b/src/librustc_passes/consts.rs @@ -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; diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index b29bf01ba199..2c4188e392d8 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -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(..) | diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index 114290c52d19..799d6186653e 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -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(_) |