@@ -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 : MaybeObligationCauseCode < ' 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 ( MaybeObligationCauseCode < ' tcx > ) -> ObligationCauseCode < ' tcx > ,
101
101
) {
102
102
self . code = f ( std:: mem:: take ( & mut self . code ) ) . into ( ) ;
103
103
}
@@ -154,13 +154,13 @@ pub struct UnifyReceiverContext<'tcx> {
154
154
155
155
#[ derive( Clone , PartialEq , Eq , Default , HashStable ) ]
156
156
#[ derive( TypeVisitable , TypeFoldable , TyEncodable , TyDecodable ) ]
157
- pub struct InternedObligationCauseCode < ' tcx > {
157
+ pub struct MaybeObligationCauseCode < ' tcx > {
158
158
/// `None` for `ObligationCauseCode::Misc` (a common case, occurs ~60% of
159
159
/// the time). `Some` otherwise.
160
160
code : Option < Arc < ObligationCauseCode < ' tcx > > > ,
161
161
}
162
162
163
- impl < ' tcx > std:: fmt:: Debug for InternedObligationCauseCode < ' tcx > {
163
+ impl < ' tcx > std:: fmt:: Debug for MaybeObligationCauseCode < ' tcx > {
164
164
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
165
165
let cause: & ObligationCauseCode < ' _ > = self ;
166
166
cause. fmt ( f)
@@ -169,14 +169,14 @@ impl<'tcx> std::fmt::Debug for InternedObligationCauseCode<'tcx> {
169
169
170
170
impl < ' tcx > ObligationCauseCode < ' tcx > {
171
171
#[ inline( always) ]
172
- fn into ( self ) -> InternedObligationCauseCode < ' tcx > {
173
- InternedObligationCauseCode {
172
+ fn into ( self ) -> MaybeObligationCauseCode < ' tcx > {
173
+ MaybeObligationCauseCode {
174
174
code : if let ObligationCauseCode :: Misc = self { None } else { Some ( Arc :: new ( self ) ) } ,
175
175
}
176
176
}
177
177
}
178
178
179
- impl < ' tcx > std:: ops:: Deref for InternedObligationCauseCode < ' tcx > {
179
+ impl < ' tcx > std:: ops:: Deref for MaybeObligationCauseCode < ' tcx > {
180
180
type Target = ObligationCauseCode < ' tcx > ;
181
181
182
182
fn deref ( & self ) -> & Self :: Target {
@@ -305,7 +305,7 @@ pub enum ObligationCauseCode<'tcx> {
305
305
/// The node of the function call.
306
306
call_hir_id : HirId ,
307
307
/// The obligation introduced by this argument.
308
- parent_code : InternedObligationCauseCode < ' tcx > ,
308
+ parent_code : MaybeObligationCauseCode < ' tcx > ,
309
309
} ,
310
310
311
311
/// Error derived when checking an impl item is compatible with
@@ -390,7 +390,8 @@ pub enum ObligationCauseCode<'tcx> {
390
390
/// `WellFormed(None)`.
391
391
WellFormed ( Option < WellFormedLoc > ) ,
392
392
393
- /// From `match_impl`. The cause for us having to match an impl, and the DefId we are matching against.
393
+ /// From `match_impl`. The cause for us having to match an impl, and the DefId we are matching
394
+ /// against.
394
395
MatchImpl ( ObligationCause < ' tcx > , DefId ) ,
395
396
396
397
BinOp {
@@ -413,7 +414,7 @@ pub enum ObligationCauseCode<'tcx> {
413
414
ConstParam ( Ty < ' tcx > ) ,
414
415
415
416
/// Obligations emitted during the normalization of a weak type alias.
416
- TypeAlias ( InternedObligationCauseCode < ' tcx > , Span , DefId ) ,
417
+ TypeAlias ( MaybeObligationCauseCode < ' tcx > , Span , DefId ) ,
417
418
}
418
419
419
420
/// Whether a value can be extracted into a const.
@@ -578,17 +579,17 @@ pub struct DerivedCause<'tcx> {
578
579
pub parent_trait_pred : ty:: PolyTraitPredicate < ' tcx > ,
579
580
580
581
/// The parent trait had this cause.
581
- pub parent_code : InternedObligationCauseCode < ' tcx > ,
582
+ pub parent_code : MaybeObligationCauseCode < ' tcx > ,
582
583
}
583
584
584
585
#[ derive( Clone , Debug , PartialEq , Eq , HashStable , TyEncodable , TyDecodable ) ]
585
586
#[ derive( TypeVisitable , TypeFoldable ) ]
586
587
pub struct ImplDerivedCause < ' tcx > {
587
588
pub derived : DerivedCause < ' tcx > ,
588
589
/// The `DefId` of the `impl` that gave rise to the `derived` obligation.
589
- /// If the `derived` obligation arose from a trait alias, which conceptually has a synthetic impl,
590
- /// then this will be the `DefId` of that trait alias. Care should therefore be taken to handle
591
- /// that exceptional case where appropriate.
590
+ /// If the `derived` obligation arose from a trait alias, which conceptually has a synthetic
591
+ /// impl, then this will be the `DefId` of that trait alias. Care should therefore be taken to
592
+ /// handle that exceptional case where appropriate.
592
593
pub impl_or_alias_def_id : DefId ,
593
594
/// The index of the derived predicate in the parent impl's predicates.
594
595
pub impl_def_predicate_index : Option < usize > ,
@@ -605,7 +606,7 @@ pub struct DerivedHostCause<'tcx> {
605
606
pub parent_host_pred : ty:: Binder < ' tcx , ty:: HostEffectPredicate < ' tcx > > ,
606
607
607
608
/// The parent trait had this cause.
608
- pub parent_code : InternedObligationCauseCode < ' tcx > ,
609
+ pub parent_code : MaybeObligationCauseCode < ' tcx > ,
609
610
}
610
611
611
612
#[ derive( Clone , Debug , PartialEq , Eq , HashStable , TyEncodable , TyDecodable ) ]
0 commit comments