Skip to content

Commit fa016bc

Browse files
committed
Destribute placeholders
1 parent 07e0e75 commit fa016bc

File tree

5 files changed

+21
-16
lines changed

5 files changed

+21
-16
lines changed

compiler/rustc_middle/src/ty/consts.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
use crate::middle::resolve_bound_vars as rbv;
2-
use crate::mir::interpret::LitToConstInput;
3-
use crate::ty::{self, InternalSubsts, ParamEnv, ParamEnvAnd, Ty, TyCtxt};
1+
use std::fmt;
2+
43
use rustc_data_structures::intern::Interned;
54
use rustc_hir as hir;
65
use rustc_hir::def::{DefKind, Res};
76
use rustc_hir::def_id::LocalDefId;
87
use rustc_macros::HashStable;
9-
use std::fmt;
8+
9+
use crate::middle::resolve_bound_vars as rbv;
10+
use crate::mir::interpret::LitToConstInput;
11+
use crate::ty::{self, BoundVar, InternalSubsts, ParamEnv, ParamEnvAnd, Placeholder, Ty, TyCtxt};
1012

1113
mod int;
1214
mod kind;
@@ -37,6 +39,8 @@ pub struct ConstData<'tcx> {
3739
pub kind: ConstKind<'tcx>,
3840
}
3941

42+
pub type PlaceholderConst<'tcx> = Placeholder<BoundVar>;
43+
4044
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
4145
static_assert_size!(ConstData<'_>, 40);
4246

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ mod param_env;
8080
mod parameterized;
8181
mod placeholder;
8282
mod predicate;
83+
mod region;
8384
mod rvalue_scopes;
8485
mod structural_impls;
8586
mod sty;
@@ -118,8 +119,8 @@ pub use self::coherence::{
118119
CrateInherentImpls, ImplHeader, ImplOverlapKind, ImplPolarity, ImplSubject,
119120
};
120121
pub use self::consts::{
121-
BoundConst, Const, ConstData, ConstInt, ConstKind, Expr, InferConst, ScalarInt,
122-
UnevaluatedConst, ValTree,
122+
BoundConst, Const, ConstData, ConstInt, ConstKind, Expr, InferConst, PlaceholderConst,
123+
ScalarInt, UnevaluatedConst, ValTree,
123124
};
124125
pub use self::context::{
125126
tls, CtxtInterners, DeducedParamAttrs, FreeRegionInfo, GlobalCtxt, Lift, TyCtxt, TyCtxtFeed,
@@ -137,14 +138,15 @@ pub use self::list::List;
137138
pub use self::opaque::{OpaqueHiddenType, OpaqueTypeKey};
138139
pub use self::param_env::{ParamEnv, ParamEnvAnd};
139140
pub use self::parameterized::ParameterizedOverTcx;
140-
pub use self::placeholder::{Placeholder, PlaceholderConst, PlaceholderRegion, PlaceholderType};
141+
pub use self::placeholder::Placeholder;
141142
pub use self::predicate::{
142143
BoundConstness, Clause, CoercePredicate, CratePredicatesMap, InstantiatedPredicates,
143144
OutlivesPredicate, PolyCoercePredicate, PolyProjectionPredicate, PolyRegionOutlivesPredicate,
144145
PolySubtypePredicate, PolyTraitPredicate, PolyTypeOutlivesPredicate, Predicate, PredicateKind,
145146
ProjectionPredicate, RegionOutlivesPredicate, SubtypePredicate, ToPredicate, TraitPredicate,
146147
TypeOutlivesPredicate,
147148
};
149+
pub use self::region::PlaceholderRegion;
148150
pub use self::rvalue_scopes::RvalueScopes;
149151
pub use self::sty::BoundRegionKind::*;
150152
pub use self::sty::{
@@ -160,7 +162,7 @@ pub use self::subst::*;
160162
pub use self::symbol_name::SymbolName;
161163
pub use self::term::{ParamTerm, Term, TermKind};
162164
pub use self::trait_def::TraitDef;
163-
pub use self::ty_::Ty;
165+
pub use self::ty_::{PlaceholderType, Ty};
164166
pub use self::typeck_results::{
165167
CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations,
166168
GeneratorDiagnosticData, GeneratorInteriorTypeCause, TypeckResults, UserType,

compiler/rustc_middle/src/ty/placeholder.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
use crate::ty::{BoundRegion, BoundTy, BoundVar, UniverseIndex};
2-
3-
pub type PlaceholderRegion = Placeholder<BoundRegion>;
4-
5-
pub type PlaceholderType = Placeholder<BoundTy>;
6-
7-
pub type PlaceholderConst<'tcx> = Placeholder<BoundVar>;
1+
use crate::ty::UniverseIndex;
82

93
/// The "placeholder index" fully defines a placeholder region, type, or const. Placeholders are
104
/// identified by both a universe, as well as a name residing within that universe. Distinct bound
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
use crate::ty::{BoundRegion, Placeholder};
2+
3+
pub type PlaceholderRegion = Placeholder<BoundRegion>;

compiler/rustc_middle/src/ty/ty_.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
use crate::ty::{Interned, TyKind, WithCachedTypeInfo};
1+
use crate::ty::{BoundTy, Interned, Placeholder, TyKind, WithCachedTypeInfo};
22

33
/// Use this rather than `TyKind`, whenever possible.
44
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable)]
55
#[rustc_diagnostic_item = "Ty"]
66
#[rustc_pass_by_value]
77
pub struct Ty<'tcx>(pub(super) Interned<'tcx, WithCachedTypeInfo<TyKind<'tcx>>>);
88

9+
pub type PlaceholderType = Placeholder<BoundTy>;
10+
911
// FIXME: move `Ty` inherent impls here (and possibly change structure wrt `sty` mod)

0 commit comments

Comments
 (0)