mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-03 12:13:43 +00:00
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::fmt;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::ops::Deref;
|
||||
|
||||
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 span: Span,
|
||||
|
||||
@ -123,6 +124,14 @@ pub struct ObligationCauseData<'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> {
|
||||
#[inline]
|
||||
pub fn new(
|
||||
|
Loading…
Reference in New Issue
Block a user