Skip to content

Commit 81f69a3

Browse files
committed
Move ty::{PolyTraitPredicate, TraitPredicate} to their own little module (cute)
1 parent 7ca97d1 commit 81f69a3

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ mod visibility;
156156
pub use bound_constness::BoundConstness;
157157
pub use impl_polarity::ImplPolarity;
158158
pub use predicate::{
159-
InstantiatedPredicates, OutlivesPredicate, PolyRegionOutlivesPredicate, PolyTraitPredicate,
160-
PolyTypeOutlivesPredicate, Predicate, PredicateKind, RegionOutlivesPredicate, TraitPredicate,
161-
TypeOutlivesPredicate,
159+
InstantiatedPredicates, OutlivesPredicate, PolyRegionOutlivesPredicate, PolySubtypePredicate,
160+
PolyTraitPredicate, PolyTypeOutlivesPredicate, Predicate, PredicateKind,
161+
RegionOutlivesPredicate, SubtypePredicate, TraitPredicate, TypeOutlivesPredicate,
162162
};
163163
pub use visibility::Visibility;
164164

@@ -396,17 +396,6 @@ pub struct CratePredicatesMap<'tcx> {
396396
/// bounds, it will have no entry.
397397
pub predicates: FxHashMap<DefId, &'tcx [(Clause<'tcx>, Span)]>,
398398
}
399-
/// Encodes that `a` must be a subtype of `b`. The `a_is_expected` flag indicates
400-
/// whether the `a` type is the type that we should label as "expected" when
401-
/// presenting user diagnostics.
402-
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, TyEncodable, TyDecodable)]
403-
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
404-
pub struct SubtypePredicate<'tcx> {
405-
pub a_is_expected: bool,
406-
pub a: Ty<'tcx>,
407-
pub b: Ty<'tcx>,
408-
}
409-
pub type PolySubtypePredicate<'tcx> = ty::Binder<'tcx, SubtypePredicate<'tcx>>;
410399

411400
/// Encodes that we have to coerce *from* the `a` type to the `b` type.
412401
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, TyEncodable, TyDecodable)]

compiler/rustc_middle/src/ty/predicate.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,21 @@ use rustc_type_ir::WithCachedTypeInfo;
77

88
use crate::ty::{
99
self, AliasRelationDirection, Binder, BoundConstness, Clause, ClosureKind, CoercePredicate,
10-
Const, DebruijnIndex, EarlyBinder, GenericArg, PolyProjectionPredicate, SubstsRef,
11-
SubtypePredicate, Term, Ty, TypeFlags,
10+
Const, DebruijnIndex, EarlyBinder, GenericArg, PolyProjectionPredicate, SubstsRef, Term, Ty,
11+
TypeFlags,
1212
};
1313

1414
mod instantiated_predicates;
1515
mod outlives_predicate;
16+
mod subtype_predicate;
1617
mod trait_predicate;
1718

1819
pub use instantiated_predicates::InstantiatedPredicates;
1920
pub use outlives_predicate::{
2021
OutlivesPredicate, PolyRegionOutlivesPredicate, PolyTypeOutlivesPredicate,
2122
RegionOutlivesPredicate, TypeOutlivesPredicate,
2223
};
24+
pub use subtype_predicate::{PolySubtypePredicate, SubtypePredicate};
2325
pub use trait_predicate::{PolyTraitPredicate, TraitPredicate};
2426

2527
/// Use this rather than `PredicateKind`, whenever possible.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
use crate::ty::{self, Ty};
2+
3+
pub type PolySubtypePredicate<'tcx> = ty::Binder<'tcx, SubtypePredicate<'tcx>>;
4+
5+
/// Encodes that `a` must be a subtype of `b`. The `a_is_expected` flag indicates
6+
/// whether the `a` type is the type that we should label as "expected" when
7+
/// presenting user diagnostics.
8+
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, TyEncodable, TyDecodable)]
9+
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
10+
pub struct SubtypePredicate<'tcx> {
11+
pub a_is_expected: bool,
12+
pub a: Ty<'tcx>,
13+
pub b: Ty<'tcx>,
14+
}

0 commit comments

Comments
 (0)