Skip to content

Commit 1003b7f

Browse files
committed
Move BoundTy to ty::TyKind
1 parent 757d6cc commit 1003b7f

File tree

33 files changed

+116
-51
lines changed

33 files changed

+116
-51
lines changed

src/librustc/ich/impls_ty.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,9 @@ for ty::TyKind<'gcx>
852852
Param(param_ty) => {
853853
param_ty.hash_stable(hcx, hasher);
854854
}
855+
Bound(bound_ty) => {
856+
bound_ty.hash_stable(hcx, hasher);
857+
}
855858
Foreign(def_id) => {
856859
def_id.hash_stable(hcx, hasher);
857860
}
@@ -869,7 +872,6 @@ impl_stable_hash_for!(enum ty::InferTy {
869872
FreshTy(a),
870873
FreshIntTy(a),
871874
FreshFloatTy(a),
872-
BoundTy(a),
873875
});
874876

875877
impl<'a, 'gcx> HashStable<StableHashingContext<'a>>

src/librustc/infer/canonical/canonicalizer.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx>
337337
bug!("encountered a fresh type during canonicalization")
338338
}
339339

340-
ty::Infer(ty::BoundTy(_)) => {
341-
bug!("encountered a canonical type during canonicalization")
340+
ty::Bound(_) => {
341+
bug!("encountered a bound type during canonicalization")
342342
}
343343

344344
ty::Closure(..)
@@ -455,7 +455,7 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
455455
/// or returns an existing variable if `kind` has already been
456456
/// seen. `kind` is expected to be an unbound variable (or
457457
/// potentially a free region).
458-
fn canonical_var(&mut self, info: CanonicalVarInfo, kind: Kind<'tcx>) -> BoundTy {
458+
fn canonical_var(&mut self, info: CanonicalVarInfo, kind: Kind<'tcx>) -> BoundTyIndex {
459459
let Canonicalizer {
460460
variables,
461461
query_state,
@@ -506,10 +506,7 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
506506
})
507507
};
508508

509-
BoundTy {
510-
level: ty::INNERMOST,
511-
var,
512-
}
509+
var
513510
}
514511

515512
/// Shorthand helper that creates a canonical region variable for
@@ -552,9 +549,8 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
552549
info: CanonicalVarInfo,
553550
r: ty::Region<'tcx>,
554551
) -> ty::Region<'tcx> {
555-
let b = self.canonical_var(info, r.into());
556-
debug_assert_eq!(ty::INNERMOST, b.level);
557-
self.tcx().mk_region(ty::ReCanonical(b.var))
552+
let var = self.canonical_var(info, r.into());
553+
self.tcx().mk_region(ty::ReCanonical(var))
558554
}
559555

560556
/// Given a type variable `ty_var` of the given kind, first check
@@ -570,9 +566,8 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
570566
let info = CanonicalVarInfo {
571567
kind: CanonicalVarKind::Ty(ty_kind),
572568
};
573-
let b = self.canonical_var(info, ty_var.into());
574-
debug_assert_eq!(ty::INNERMOST, b.level);
575-
self.tcx().mk_infer(ty::InferTy::BoundTy(b))
569+
let var = self.canonical_var(info, ty_var.into());
570+
self.tcx().mk_ty(ty::Bound(BoundTy::new(ty::INNERMOST, var)))
576571
}
577572
}
578573
}

src/librustc/infer/canonical/query_response.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
432432
match result_value.unpack() {
433433
UnpackedKind::Type(result_value) => {
434434
// e.g., here `result_value` might be `?0` in the example above...
435-
if let ty::Infer(ty::InferTy::BoundTy(b)) = result_value.sty {
435+
if let ty::Bound(b) = result_value.sty {
436436
// in which case we would set `canonical_vars[0]` to `Some(?U)`.
437437
opt_values[b.var] = Some(*original_value);
438438
}

src/librustc/infer/canonical/substitute.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for CanonicalVarValuesSubst<'cx, 'g
8585

8686
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
8787
match t.sty {
88-
ty::Infer(ty::InferTy::BoundTy(b)) => {
89-
debug_assert_eq!(ty::INNERMOST, b.level);
88+
ty::Bound(b) => {
9089
match self.var_values.var_values[b.var].unpack() {
9190
UnpackedKind::Type(ty) => ty,
9291
r => bug!("{:?} is a type but value is {:?}", b, r),

src/librustc/infer/freshen.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> {
171171
t
172172
}
173173

174-
ty::Infer(ty::BoundTy(..)) =>
175-
bug!("encountered canonical ty during freshening"),
174+
ty::Bound(..) =>
175+
bug!("encountered bound ty during freshening"),
176176

177177
ty::Generator(..) |
178178
ty::Bool |

src/librustc/traits/coherence.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ fn ty_is_local_constructor(ty: Ty<'_>, in_crate: InCrate) -> bool {
455455
false
456456
}
457457

458-
ty::Infer(..) => match in_crate {
458+
ty::Bound(..) | ty::Infer(..) => match in_crate {
459459
InCrate::Local => false,
460460
// The inference variable might be unified with a local
461461
// type in that remote crate.

src/librustc/traits/error_reporting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
280280
ty::Generator(..) => Some(18),
281281
ty::Foreign(..) => Some(19),
282282
ty::GeneratorWitness(..) => Some(20),
283-
ty::Infer(..) | ty::Error => None,
283+
ty::Bound(..) | ty::Infer(..) | ty::Error => None,
284284
ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
285285
}
286286
}

src/librustc/traits/query/dropck_outlives.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'_, '_, 'tcx>, ty: Ty<'tcx>) ->
252252
| ty::Param(_)
253253
| ty::Opaque(..)
254254
| ty::Infer(_)
255+
| ty::Bound(..)
255256
| ty::Generator(..) => false,
256257

257258
ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),

src/librustc/traits/select.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2445,7 +2445,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
24452445
ty::Infer(ty::TyVar(_)) => Ambiguous,
24462446

24472447
ty::UnnormalizedProjection(..)
2448-
| ty::Infer(ty::BoundTy(_))
2448+
| ty::Bound(_)
24492449
| ty::Infer(ty::FreshTy(_))
24502450
| ty::Infer(ty::FreshIntTy(_))
24512451
| ty::Infer(ty::FreshFloatTy(_)) => {
@@ -2530,7 +2530,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
25302530
}
25312531

25322532
ty::UnnormalizedProjection(..)
2533-
| ty::Infer(ty::BoundTy(_))
2533+
| ty::Bound(_)
25342534
| ty::Infer(ty::FreshTy(_))
25352535
| ty::Infer(ty::FreshIntTy(_))
25362536
| ty::Infer(ty::FreshFloatTy(_)) => {
@@ -2573,7 +2573,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
25732573
| ty::Param(..)
25742574
| ty::Foreign(..)
25752575
| ty::Projection(..)
2576-
| ty::Infer(ty::BoundTy(_))
2576+
| ty::Bound(_)
25772577
| ty::Infer(ty::TyVar(_))
25782578
| ty::Infer(ty::FreshTy(_))
25792579
| ty::Infer(ty::FreshIntTy(_))

src/librustc/ty/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2243,7 +2243,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
22432243
sty_debug_print!(
22442244
self,
22452245
Adt, Array, Slice, RawPtr, Ref, FnDef, FnPtr,
2246-
Generator, GeneratorWitness, Dynamic, Closure, Tuple,
2246+
Generator, GeneratorWitness, Dynamic, Closure, Tuple, Bound,
22472247
Param, Infer, UnnormalizedProjection, Projection, Opaque, Foreign);
22482248

22492249
println!("Substs interner: #{}", self.interners.substs.borrow().len());

0 commit comments

Comments
 (0)