Skip to content

Commit

Permalink
Check other fields are consistent in LoanPath::common.
Browse files Browse the repository at this point in the history
  • Loading branch information
pnkfelix committed Nov 25, 2014
1 parent 09d67fd commit 21fe017
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/librustc/middle/borrowck/mod.rs
Expand Up @@ -386,10 +386,11 @@ impl<'tcx> LoanPath<'tcx> {
(&LpExtend(ref base, a, LpInterior(id)),
&LpExtend(ref base2, _, LpInterior(id2))) => {
if id == id2 {
assert!(self.ty == other.ty);
base.common(&**base2).map(|x| {
let xd = x.depth();
if base.depth() == xd && base2.depth() == xd {
assert_eq!(base.ty, base2.ty);
assert_eq!(self.ty, other.ty);
LoanPath {
kind: LpExtend(Rc::new(x), a, LpInterior(id)),
ty: self.ty,
Expand All @@ -406,15 +407,15 @@ impl<'tcx> LoanPath<'tcx> {
(_, &LpExtend(ref other, _, LpDeref(_))) => self.common(&**other),
(&LpVar(id), &LpVar(id2)) => {
if id == id2 {
assert!(self.ty == other.ty);
assert_eq!(self.ty, other.ty);
Some(LoanPath { kind: LpVar(id), ty: self.ty })
} else {
None
}
}
(&LpUpvar(id), &LpUpvar(id2)) => {
if id == id2 {
assert!(self.ty == other.ty);
assert_eq!(self.ty, other.ty);
Some(LoanPath { kind: LpUpvar(id), ty: self.ty })
} else {
None
Expand Down

0 comments on commit 21fe017

Please sign in to comment.