Skip to content

Commit a2897a6

Browse files
committed
Rename InternedObligationCauseCode.
It's a misleading name, because it's not interned.
1 parent 0895fe2 commit a2897a6

File tree

1 file changed

+16
-15
lines changed
  • compiler/rustc_middle/src/traits

1 file changed

+16
-15
lines changed

compiler/rustc_middle/src/traits/mod.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub struct ObligationCause<'tcx> {
5151
/// information.
5252
pub body_id: LocalDefId,
5353

54-
code: InternedObligationCauseCode<'tcx>,
54+
code: MaybeObligationCauseCode<'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(MaybeObligationCauseCode<'tcx>) -> ObligationCauseCode<'tcx>,
101101
) {
102102
self.code = f(std::mem::take(&mut self.code)).into();
103103
}
@@ -154,13 +154,13 @@ pub struct UnifyReceiverContext<'tcx> {
154154

155155
#[derive(Clone, PartialEq, Eq, Default, HashStable)]
156156
#[derive(TypeVisitable, TypeFoldable, TyEncodable, TyDecodable)]
157-
pub struct InternedObligationCauseCode<'tcx> {
157+
pub struct MaybeObligationCauseCode<'tcx> {
158158
/// `None` for `ObligationCauseCode::Misc` (a common case, occurs ~60% of
159159
/// the time). `Some` otherwise.
160160
code: Option<Arc<ObligationCauseCode<'tcx>>>,
161161
}
162162

163-
impl<'tcx> std::fmt::Debug for InternedObligationCauseCode<'tcx> {
163+
impl<'tcx> std::fmt::Debug for MaybeObligationCauseCode<'tcx> {
164164
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
165165
let cause: &ObligationCauseCode<'_> = self;
166166
cause.fmt(f)
@@ -169,14 +169,14 @@ impl<'tcx> std::fmt::Debug for InternedObligationCauseCode<'tcx> {
169169

170170
impl<'tcx> ObligationCauseCode<'tcx> {
171171
#[inline(always)]
172-
fn into(self) -> InternedObligationCauseCode<'tcx> {
173-
InternedObligationCauseCode {
172+
fn into(self) -> MaybeObligationCauseCode<'tcx> {
173+
MaybeObligationCauseCode {
174174
code: if let ObligationCauseCode::Misc = self { None } else { Some(Arc::new(self)) },
175175
}
176176
}
177177
}
178178

179-
impl<'tcx> std::ops::Deref for InternedObligationCauseCode<'tcx> {
179+
impl<'tcx> std::ops::Deref for MaybeObligationCauseCode<'tcx> {
180180
type Target = ObligationCauseCode<'tcx>;
181181

182182
fn deref(&self) -> &Self::Target {
@@ -305,7 +305,7 @@ pub enum ObligationCauseCode<'tcx> {
305305
/// The node of the function call.
306306
call_hir_id: HirId,
307307
/// The obligation introduced by this argument.
308-
parent_code: InternedObligationCauseCode<'tcx>,
308+
parent_code: MaybeObligationCauseCode<'tcx>,
309309
},
310310

311311
/// Error derived when checking an impl item is compatible with
@@ -390,7 +390,8 @@ pub enum ObligationCauseCode<'tcx> {
390390
/// `WellFormed(None)`.
391391
WellFormed(Option<WellFormedLoc>),
392392

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.
394395
MatchImpl(ObligationCause<'tcx>, DefId),
395396

396397
BinOp {
@@ -413,7 +414,7 @@ pub enum ObligationCauseCode<'tcx> {
413414
ConstParam(Ty<'tcx>),
414415

415416
/// Obligations emitted during the normalization of a weak type alias.
416-
TypeAlias(InternedObligationCauseCode<'tcx>, Span, DefId),
417+
TypeAlias(MaybeObligationCauseCode<'tcx>, Span, DefId),
417418
}
418419

419420
/// Whether a value can be extracted into a const.
@@ -578,17 +579,17 @@ pub struct DerivedCause<'tcx> {
578579
pub parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
579580

580581
/// The parent trait had this cause.
581-
pub parent_code: InternedObligationCauseCode<'tcx>,
582+
pub parent_code: MaybeObligationCauseCode<'tcx>,
582583
}
583584

584585
#[derive(Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)]
585586
#[derive(TypeVisitable, TypeFoldable)]
586587
pub struct ImplDerivedCause<'tcx> {
587588
pub derived: DerivedCause<'tcx>,
588589
/// 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.
592593
pub impl_or_alias_def_id: DefId,
593594
/// The index of the derived predicate in the parent impl's predicates.
594595
pub impl_def_predicate_index: Option<usize>,
@@ -605,7 +606,7 @@ pub struct DerivedHostCause<'tcx> {
605606
pub parent_host_pred: ty::Binder<'tcx, ty::HostEffectPredicate<'tcx>>,
606607

607608
/// The parent trait had this cause.
608-
pub parent_code: InternedObligationCauseCode<'tcx>,
609+
pub parent_code: MaybeObligationCauseCode<'tcx>,
609610
}
610611

611612
#[derive(Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)]

0 commit comments

Comments
 (0)