Simplify ObligationCauseData hash to skip ObligationCauseCode
selection deduplicates obligations through a hashset at some point, computing the hashes for ObligationCauseCode appears to dominate the hashing cost. bodyid + span + discriminant hash hopefully will sufficiently unique unique enough.
This commit is contained in:
parent
ad44239975
commit
78b5f2d2fa
@ -23,6 +23,7 @@ use smallvec::SmallVec;
|
|||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::hash::{Hash, Hasher};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
pub use self::select::{EvaluationCache, EvaluationResult, OverflowError, SelectionCache};
|
pub use self::select::{EvaluationCache, EvaluationResult, OverflowError, SelectionCache};
|
||||||
@ -108,7 +109,7 @@ impl Deref for ObligationCause<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Lift)]
|
#[derive(Clone, Debug, PartialEq, Eq, Lift)]
|
||||||
pub struct ObligationCauseData<'tcx> {
|
pub struct ObligationCauseData<'tcx> {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
|
|
||||||
@ -123,6 +124,14 @@ pub struct ObligationCauseData<'tcx> {
|
|||||||
pub code: ObligationCauseCode<'tcx>,
|
pub code: ObligationCauseCode<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Hash for ObligationCauseData<'_> {
|
||||||
|
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||||
|
self.body_id.hash(state);
|
||||||
|
self.span.hash(state);
|
||||||
|
std::mem::discriminant(&self.code).hash(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'tcx> ObligationCause<'tcx> {
|
impl<'tcx> ObligationCause<'tcx> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user