Skip to content

Commit

Permalink
rustc_borrowck: Don't hash types in loan paths
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Aug 25, 2016
1 parent 71bdeea commit 14b4d72
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/librustc_borrowck/borrowck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use rustc::ty::{self, TyCtxt};
use std::fmt;
use std::mem;
use std::rc::Rc;
use std::hash::{Hash, Hasher};
use syntax::ast;
use syntax::attr::AttrMetaMethods;
use syntax_pos::{MultiSpan, Span};
Expand Down Expand Up @@ -345,18 +346,21 @@ impl<'tcx> Loan<'tcx> {
}
}

#[derive(Eq, Hash)]
#[derive(Eq)]
pub struct LoanPath<'tcx> {
kind: LoanPathKind<'tcx>,
ty: ty::Ty<'tcx>,
}

impl<'tcx> PartialEq for LoanPath<'tcx> {
fn eq(&self, that: &LoanPath<'tcx>) -> bool {
let r = self.kind == that.kind;
debug_assert!(self.ty == that.ty || !r,
"Somehow loan paths are equal though their tys are not.");
r
self.kind == that.kind
}
}

impl<'tcx> Hash for LoanPath<'tcx> {
fn hash<H: Hasher>(&self, state: &mut H) {
self.kind.hash(state);
}
}

Expand Down

0 comments on commit 14b4d72

Please sign in to comment.