@@ -51,7 +51,7 @@ pub struct ObligationCause<'tcx> {
5151 /// information.
5252 pub body_id : LocalDefId ,
5353
54- code : InternedObligationCauseCode < ' tcx > ,
54+ code : ObligationCauseCodeHandle < ' tcx > ,
5555}
5656
5757// This custom hash function speeds up hashing for `Obligation` deduplication
@@ -97,7 +97,7 @@ impl<'tcx> ObligationCause<'tcx> {
9797
9898 pub fn map_code (
9999 & mut self ,
100- f : impl FnOnce ( InternedObligationCauseCode < ' tcx > ) -> ObligationCauseCode < ' tcx > ,
100+ f : impl FnOnce ( ObligationCauseCodeHandle < ' tcx > ) -> ObligationCauseCode < ' tcx > ,
101101 ) {
102102 self . code = f ( std:: mem:: take ( & mut self . code ) ) . into ( ) ;
103103 }
@@ -152,15 +152,16 @@ pub struct UnifyReceiverContext<'tcx> {
152152 pub args : GenericArgsRef < ' tcx > ,
153153}
154154
155+ /// A compact form of `ObligationCauseCode`.
155156#[ derive( Clone , PartialEq , Eq , Default , HashStable ) ]
156157#[ derive( TypeVisitable , TypeFoldable , TyEncodable , TyDecodable ) ]
157- pub struct InternedObligationCauseCode < ' tcx > {
158+ pub struct ObligationCauseCodeHandle < ' tcx > {
158159 /// `None` for `ObligationCauseCode::Misc` (a common case, occurs ~60% of
159160 /// the time). `Some` otherwise.
160161 code : Option < Arc < ObligationCauseCode < ' tcx > > > ,
161162}
162163
163- impl < ' tcx > std:: fmt:: Debug for InternedObligationCauseCode < ' tcx > {
164+ impl < ' tcx > std:: fmt:: Debug for ObligationCauseCodeHandle < ' tcx > {
164165 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
165166 let cause: & ObligationCauseCode < ' _ > = self ;
166167 cause. fmt ( f)
@@ -169,14 +170,14 @@ impl<'tcx> std::fmt::Debug for InternedObligationCauseCode<'tcx> {
169170
170171impl < ' tcx > ObligationCauseCode < ' tcx > {
171172 #[ inline( always) ]
172- fn into ( self ) -> InternedObligationCauseCode < ' tcx > {
173- InternedObligationCauseCode {
173+ fn into ( self ) -> ObligationCauseCodeHandle < ' tcx > {
174+ ObligationCauseCodeHandle {
174175 code : if let ObligationCauseCode :: Misc = self { None } else { Some ( Arc :: new ( self ) ) } ,
175176 }
176177 }
177178}
178179
179- impl < ' tcx > std:: ops:: Deref for InternedObligationCauseCode < ' tcx > {
180+ impl < ' tcx > std:: ops:: Deref for ObligationCauseCodeHandle < ' tcx > {
180181 type Target = ObligationCauseCode < ' tcx > ;
181182
182183 fn deref ( & self ) -> & Self :: Target {
@@ -305,7 +306,7 @@ pub enum ObligationCauseCode<'tcx> {
305306 /// The node of the function call.
306307 call_hir_id : HirId ,
307308 /// The obligation introduced by this argument.
308- parent_code : InternedObligationCauseCode < ' tcx > ,
309+ parent_code : ObligationCauseCodeHandle < ' tcx > ,
309310 } ,
310311
311312 /// Error derived when checking an impl item is compatible with
@@ -390,7 +391,8 @@ pub enum ObligationCauseCode<'tcx> {
390391 /// `WellFormed(None)`.
391392 WellFormed ( Option < WellFormedLoc > ) ,
392393
393- /// From `match_impl`. The cause for us having to match an impl, and the DefId we are matching against.
394+ /// From `match_impl`. The cause for us having to match an impl, and the DefId we are matching
395+ /// against.
394396 MatchImpl ( ObligationCause < ' tcx > , DefId ) ,
395397
396398 BinOp {
@@ -413,7 +415,7 @@ pub enum ObligationCauseCode<'tcx> {
413415 ConstParam ( Ty < ' tcx > ) ,
414416
415417 /// Obligations emitted during the normalization of a weak type alias.
416- TypeAlias ( InternedObligationCauseCode < ' tcx > , Span , DefId ) ,
418+ TypeAlias ( ObligationCauseCodeHandle < ' tcx > , Span , DefId ) ,
417419}
418420
419421/// Whether a value can be extracted into a const.
@@ -514,12 +516,6 @@ impl<'tcx> ObligationCauseCode<'tcx> {
514516#[ cfg( target_pointer_width = "64" ) ]
515517rustc_data_structures:: static_assert_size!( ObligationCauseCode <' _>, 48 ) ;
516518
517- #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash ) ]
518- pub enum StatementAsExpression {
519- CorrectType ,
520- NeedsBoxing ,
521- }
522-
523519#[ derive( Clone , Debug , PartialEq , Eq , HashStable , TyEncodable , TyDecodable ) ]
524520#[ derive( TypeVisitable , TypeFoldable ) ]
525521pub struct MatchExpressionArmCause < ' tcx > {
@@ -584,17 +580,17 @@ pub struct DerivedCause<'tcx> {
584580 pub parent_trait_pred : ty:: PolyTraitPredicate < ' tcx > ,
585581
586582 /// The parent trait had this cause.
587- pub parent_code : InternedObligationCauseCode < ' tcx > ,
583+ pub parent_code : ObligationCauseCodeHandle < ' tcx > ,
588584}
589585
590586#[ derive( Clone , Debug , PartialEq , Eq , HashStable , TyEncodable , TyDecodable ) ]
591587#[ derive( TypeVisitable , TypeFoldable ) ]
592588pub struct ImplDerivedCause < ' tcx > {
593589 pub derived : DerivedCause < ' tcx > ,
594590 /// The `DefId` of the `impl` that gave rise to the `derived` obligation.
595- /// If the `derived` obligation arose from a trait alias, which conceptually has a synthetic impl,
596- /// then this will be the `DefId` of that trait alias. Care should therefore be taken to handle
597- /// that exceptional case where appropriate.
591+ /// If the `derived` obligation arose from a trait alias, which conceptually has a synthetic
592+ /// impl, then this will be the `DefId` of that trait alias. Care should therefore be taken to
593+ /// handle that exceptional case where appropriate.
598594 pub impl_or_alias_def_id : DefId ,
599595 /// The index of the derived predicate in the parent impl's predicates.
600596 pub impl_def_predicate_index : Option < usize > ,
@@ -611,7 +607,7 @@ pub struct DerivedHostCause<'tcx> {
611607 pub parent_host_pred : ty:: Binder < ' tcx , ty:: HostEffectPredicate < ' tcx > > ,
612608
613609 /// The parent trait had this cause.
614- pub parent_code : InternedObligationCauseCode < ' tcx > ,
610+ pub parent_code : ObligationCauseCodeHandle < ' tcx > ,
615611}
616612
617613#[ derive( Clone , Debug , PartialEq , Eq , HashStable , TyEncodable , TyDecodable ) ]
0 commit comments