@@ -95,6 +95,11 @@ impl<'tcx> ObligationCause<'tcx> {
9595 & self . code
9696 }
9797
98+ #[ inline]
99+ pub fn code_handle ( & self ) -> & ObligationCauseCodeHandle < ' tcx > {
100+ & self . code
101+ }
102+
98103 pub fn map_code (
99104 & mut self ,
100105 f : impl FnOnce ( ObligationCauseCodeHandle < ' tcx > ) -> ObligationCauseCode < ' tcx > ,
@@ -145,7 +150,7 @@ impl<'tcx> ObligationCause<'tcx> {
145150}
146151
147152/// A compact form of `ObligationCauseCode`.
148- #[ derive( Clone , PartialEq , Eq , Default , HashStable ) ]
153+ #[ derive( Clone , PartialEq , Eq , Default , HashStable , Hash ) ]
149154#[ derive( TypeVisitable , TypeFoldable , TyEncodable , TyDecodable ) ]
150155pub struct ObligationCauseCodeHandle < ' tcx > {
151156 /// `None` for `ObligationCauseCode::Misc` (a common case, occurs ~60% of
@@ -177,7 +182,7 @@ impl<'tcx> std::ops::Deref for ObligationCauseCodeHandle<'tcx> {
177182 }
178183}
179184
180- #[ derive( Clone , Debug , PartialEq , Eq , HashStable , TyEncodable , TyDecodable ) ]
185+ #[ derive( Clone , Debug , PartialEq , Eq , HashStable , TyEncodable , TyDecodable , Hash ) ]
181186#[ derive( TypeVisitable , TypeFoldable ) ]
182187pub enum ObligationCauseCode < ' tcx > {
183188 /// Not well classified or should be obvious from the span.
@@ -420,7 +425,7 @@ pub enum ObligationCauseCode<'tcx> {
420425
421426/// Whether a value can be extracted into a const.
422427/// Used for diagnostics around array repeat expressions.
423- #[ derive( Copy , Clone , Debug , PartialEq , Eq , HashStable , TyEncodable , TyDecodable ) ]
428+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , HashStable , Hash , TyEncodable , TyDecodable ) ]
424429pub enum IsConstable {
425430 No ,
426431 /// Call to a const fn
@@ -516,7 +521,7 @@ impl<'tcx> ObligationCauseCode<'tcx> {
516521#[ cfg( target_pointer_width = "64" ) ]
517522rustc_data_structures:: static_assert_size!( ObligationCauseCode <' _>, 48 ) ;
518523
519- #[ derive( Clone , Debug , PartialEq , Eq , HashStable , TyEncodable , TyDecodable ) ]
524+ #[ derive( Clone , Debug , PartialEq , Eq , HashStable , Hash , TyEncodable , TyDecodable ) ]
520525#[ derive( TypeVisitable , TypeFoldable ) ]
521526pub struct MatchExpressionArmCause < ' tcx > {
522527 pub arm_block_id : Option < HirId > ,
@@ -543,7 +548,7 @@ pub struct MatchExpressionArmCause<'tcx> {
543548/// Fields here refer to the scrutinee of a pattern.
544549/// If the scrutinee isn't given in the diagnostic, then this won't exist.
545550#[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
546- #[ derive( TypeFoldable , TypeVisitable , HashStable , TyEncodable , TyDecodable ) ]
551+ #[ derive( TypeFoldable , TypeVisitable , HashStable , Hash , TyEncodable , TyDecodable ) ]
547552pub struct PatternOriginExpr {
548553 /// A span representing the scrutinee expression, with all leading references
549554 /// peeled from the expression.
@@ -558,7 +563,7 @@ pub struct PatternOriginExpr {
558563 pub peeled_prefix_suggestion_parentheses : bool ,
559564}
560565
561- #[ derive( Clone , Debug , PartialEq , Eq , HashStable , TyEncodable , TyDecodable ) ]
566+ #[ derive( Clone , Debug , PartialEq , Eq , HashStable , Hash , TyEncodable , TyDecodable ) ]
562567#[ derive( TypeVisitable , TypeFoldable ) ]
563568pub struct DerivedCause < ' tcx > {
564569 /// The trait predicate of the parent obligation that led to the
@@ -571,7 +576,7 @@ pub struct DerivedCause<'tcx> {
571576 pub parent_code : ObligationCauseCodeHandle < ' tcx > ,
572577}
573578
574- #[ derive( Clone , Debug , PartialEq , Eq , HashStable , TyEncodable , TyDecodable ) ]
579+ #[ derive( Clone , Debug , PartialEq , Eq , HashStable , Hash , TyEncodable , TyDecodable ) ]
575580#[ derive( TypeVisitable , TypeFoldable ) ]
576581pub struct ImplDerivedCause < ' tcx > {
577582 pub derived : DerivedCause < ' tcx > ,
@@ -585,7 +590,7 @@ pub struct ImplDerivedCause<'tcx> {
585590 pub span : Span ,
586591}
587592
588- #[ derive( Clone , Debug , PartialEq , Eq , HashStable , TyEncodable , TyDecodable ) ]
593+ #[ derive( Clone , Debug , PartialEq , Eq , HashStable , Hash , TyEncodable , TyDecodable ) ]
589594#[ derive( TypeVisitable , TypeFoldable ) ]
590595pub struct DerivedHostCause < ' tcx > {
591596 /// The trait predicate of the parent obligation that led to the
@@ -598,7 +603,7 @@ pub struct DerivedHostCause<'tcx> {
598603 pub parent_code : ObligationCauseCodeHandle < ' tcx > ,
599604}
600605
601- #[ derive( Clone , Debug , PartialEq , Eq , HashStable , TyEncodable , TyDecodable ) ]
606+ #[ derive( Clone , Debug , PartialEq , Eq , Hash , HashStable , TyEncodable , TyDecodable ) ]
602607#[ derive( TypeVisitable , TypeFoldable ) ]
603608pub struct ImplDerivedHostCause < ' tcx > {
604609 pub derived : DerivedHostCause < ' tcx > ,
0 commit comments