@@ -51,7 +51,7 @@ pub struct ObligationCause<'tcx> {
51
51
/// information.
52
52
pub body_id : LocalDefId ,
53
53
54
- code : InternedObligationCauseCode < ' tcx > ,
54
+ code : ObligationCauseCodeHandle < ' tcx > ,
55
55
}
56
56
57
57
// This custom hash function speeds up hashing for `Obligation` deduplication
@@ -97,7 +97,7 @@ impl<'tcx> ObligationCause<'tcx> {
97
97
98
98
pub fn map_code (
99
99
& mut self ,
100
- f : impl FnOnce ( InternedObligationCauseCode < ' tcx > ) -> ObligationCauseCode < ' tcx > ,
100
+ f : impl FnOnce ( ObligationCauseCodeHandle < ' tcx > ) -> ObligationCauseCode < ' tcx > ,
101
101
) {
102
102
self . code = f ( std:: mem:: take ( & mut self . code ) ) . into ( ) ;
103
103
}
@@ -152,15 +152,16 @@ pub struct UnifyReceiverContext<'tcx> {
152
152
pub args : GenericArgsRef < ' tcx > ,
153
153
}
154
154
155
+ /// A compact form of `ObligationCauseCode`.
155
156
#[ derive( Clone , PartialEq , Eq , Default , HashStable ) ]
156
157
#[ derive( TypeVisitable , TypeFoldable , TyEncodable , TyDecodable ) ]
157
- pub struct InternedObligationCauseCode < ' tcx > {
158
+ pub struct ObligationCauseCodeHandle < ' tcx > {
158
159
/// `None` for `ObligationCauseCode::Misc` (a common case, occurs ~60% of
159
160
/// the time). `Some` otherwise.
160
161
code : Option < Arc < ObligationCauseCode < ' tcx > > > ,
161
162
}
162
163
163
- impl < ' tcx > std:: fmt:: Debug for InternedObligationCauseCode < ' tcx > {
164
+ impl < ' tcx > std:: fmt:: Debug for ObligationCauseCodeHandle < ' tcx > {
164
165
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
165
166
let cause: & ObligationCauseCode < ' _ > = self ;
166
167
cause. fmt ( f)
@@ -169,14 +170,14 @@ impl<'tcx> std::fmt::Debug for InternedObligationCauseCode<'tcx> {
169
170
170
171
impl < ' tcx > ObligationCauseCode < ' tcx > {
171
172
#[ inline( always) ]
172
- fn into ( self ) -> InternedObligationCauseCode < ' tcx > {
173
- InternedObligationCauseCode {
173
+ fn into ( self ) -> ObligationCauseCodeHandle < ' tcx > {
174
+ ObligationCauseCodeHandle {
174
175
code : if let ObligationCauseCode :: Misc = self { None } else { Some ( Arc :: new ( self ) ) } ,
175
176
}
176
177
}
177
178
}
178
179
179
- impl < ' tcx > std:: ops:: Deref for InternedObligationCauseCode < ' tcx > {
180
+ impl < ' tcx > std:: ops:: Deref for ObligationCauseCodeHandle < ' tcx > {
180
181
type Target = ObligationCauseCode < ' tcx > ;
181
182
182
183
fn deref ( & self ) -> & Self :: Target {
@@ -305,7 +306,7 @@ pub enum ObligationCauseCode<'tcx> {
305
306
/// The node of the function call.
306
307
call_hir_id : HirId ,
307
308
/// The obligation introduced by this argument.
308
- parent_code : InternedObligationCauseCode < ' tcx > ,
309
+ parent_code : ObligationCauseCodeHandle < ' tcx > ,
309
310
} ,
310
311
311
312
/// Error derived when checking an impl item is compatible with
@@ -390,7 +391,8 @@ pub enum ObligationCauseCode<'tcx> {
390
391
/// `WellFormed(None)`.
391
392
WellFormed ( Option < WellFormedLoc > ) ,
392
393
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.
394
396
MatchImpl ( ObligationCause < ' tcx > , DefId ) ,
395
397
396
398
BinOp {
@@ -413,7 +415,7 @@ pub enum ObligationCauseCode<'tcx> {
413
415
ConstParam ( Ty < ' tcx > ) ,
414
416
415
417
/// Obligations emitted during the normalization of a weak type alias.
416
- TypeAlias ( InternedObligationCauseCode < ' tcx > , Span , DefId ) ,
418
+ TypeAlias ( ObligationCauseCodeHandle < ' tcx > , Span , DefId ) ,
417
419
}
418
420
419
421
/// Whether a value can be extracted into a const.
@@ -514,12 +516,6 @@ impl<'tcx> ObligationCauseCode<'tcx> {
514
516
#[ cfg( target_pointer_width = "64" ) ]
515
517
rustc_data_structures:: static_assert_size!( ObligationCauseCode <' _>, 48 ) ;
516
518
517
- #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash ) ]
518
- pub enum StatementAsExpression {
519
- CorrectType ,
520
- NeedsBoxing ,
521
- }
522
-
523
519
#[ derive( Clone , Debug , PartialEq , Eq , HashStable , TyEncodable , TyDecodable ) ]
524
520
#[ derive( TypeVisitable , TypeFoldable ) ]
525
521
pub struct MatchExpressionArmCause < ' tcx > {
@@ -584,17 +580,17 @@ pub struct DerivedCause<'tcx> {
584
580
pub parent_trait_pred : ty:: PolyTraitPredicate < ' tcx > ,
585
581
586
582
/// The parent trait had this cause.
587
- pub parent_code : InternedObligationCauseCode < ' tcx > ,
583
+ pub parent_code : ObligationCauseCodeHandle < ' tcx > ,
588
584
}
589
585
590
586
#[ derive( Clone , Debug , PartialEq , Eq , HashStable , TyEncodable , TyDecodable ) ]
591
587
#[ derive( TypeVisitable , TypeFoldable ) ]
592
588
pub struct ImplDerivedCause < ' tcx > {
593
589
pub derived : DerivedCause < ' tcx > ,
594
590
/// 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.
598
594
pub impl_or_alias_def_id : DefId ,
599
595
/// The index of the derived predicate in the parent impl's predicates.
600
596
pub impl_def_predicate_index : Option < usize > ,
@@ -611,7 +607,7 @@ pub struct DerivedHostCause<'tcx> {
611
607
pub parent_host_pred : ty:: Binder < ' tcx , ty:: HostEffectPredicate < ' tcx > > ,
612
608
613
609
/// The parent trait had this cause.
614
- pub parent_code : InternedObligationCauseCode < ' tcx > ,
610
+ pub parent_code : ObligationCauseCodeHandle < ' tcx > ,
615
611
}
616
612
617
613
#[ derive( Clone , Debug , PartialEq , Eq , HashStable , TyEncodable , TyDecodable ) ]
0 commit comments