Skip to content

Commit 1c8fb66

Browse files
committed
Move BoundTy to ty::TyKind
1 parent f99911a commit 1c8fb66

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
@@ -898,6 +898,9 @@ for ty::TyKind<'gcx>
898898
Param(param_ty) => {
899899
param_ty.hash_stable(hcx, hasher);
900900
}
901+
Bound(bound_ty) => {
902+
bound_ty.hash_stable(hcx, hasher);
903+
}
901904
Foreign(def_id) => {
902905
def_id.hash_stable(hcx, hasher);
903906
}
@@ -915,7 +918,6 @@ impl_stable_hash_for!(enum ty::InferTy {
915918
FreshTy(a),
916919
FreshIntTy(a),
917920
FreshFloatTy(a),
918-
BoundTy(a),
919921
});
920922

921923
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
@@ -283,8 +283,8 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx>
283283
bug!("encountered a fresh type during canonicalization")
284284
}
285285

286-
ty::Infer(ty::BoundTy(_)) => {
287-
bug!("encountered a canonical type during canonicalization")
286+
ty::Bound(_) => {
287+
bug!("encountered a bound type during canonicalization")
288288
}
289289

290290
ty::Closure(..)
@@ -393,7 +393,7 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
393393
/// or returns an existing variable if `kind` has already been
394394
/// seen. `kind` is expected to be an unbound variable (or
395395
/// potentially a free region).
396-
fn canonical_var(&mut self, info: CanonicalVarInfo, kind: Kind<'tcx>) -> BoundTy {
396+
fn canonical_var(&mut self, info: CanonicalVarInfo, kind: Kind<'tcx>) -> BoundTyIndex {
397397
let Canonicalizer {
398398
variables,
399399
query_state,
@@ -444,19 +444,15 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
444444
})
445445
};
446446

447-
BoundTy {
448-
level: ty::INNERMOST,
449-
var,
450-
}
447+
var
451448
}
452449

453450
fn canonical_var_for_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
454451
let info = CanonicalVarInfo {
455452
kind: CanonicalVarKind::Region,
456453
};
457-
let b = self.canonical_var(info, r.into());
458-
debug_assert_eq!(ty::INNERMOST, b.level);
459-
self.tcx().mk_region(ty::ReCanonical(b.var))
454+
let var = self.canonical_var(info, r.into());
455+
self.tcx().mk_region(ty::ReCanonical(var))
460456
}
461457

462458
/// Given a type variable `ty_var` of the given kind, first check
@@ -472,9 +468,8 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
472468
let info = CanonicalVarInfo {
473469
kind: CanonicalVarKind::Ty(ty_kind),
474470
};
475-
let b = self.canonical_var(info, ty_var.into());
476-
debug_assert_eq!(ty::INNERMOST, b.level);
477-
self.tcx().mk_infer(ty::InferTy::BoundTy(b))
471+
let var = self.canonical_var(info, ty_var.into());
472+
self.tcx().mk_ty(ty::Bound(BoundTy::new(ty::INNERMOST, var)))
478473
}
479474
}
480475
}

src/librustc/infer/canonical/query_response.rs

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

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
@@ -281,7 +281,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
281281
ty::Generator(..) => Some(18),
282282
ty::Foreign(..) => Some(19),
283283
ty::GeneratorWitness(..) => Some(20),
284-
ty::Infer(..) | ty::Error => None,
284+
ty::Bound(..) | ty::Infer(..) | ty::Error => None,
285285
ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
286286
}
287287
}

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
@@ -2421,7 +2421,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
24212421
ty::Infer(ty::TyVar(_)) => Ambiguous,
24222422

24232423
ty::UnnormalizedProjection(..)
2424-
| ty::Infer(ty::BoundTy(_))
2424+
| ty::Bound(_)
24252425
| ty::Infer(ty::FreshTy(_))
24262426
| ty::Infer(ty::FreshIntTy(_))
24272427
| ty::Infer(ty::FreshFloatTy(_)) => {
@@ -2506,7 +2506,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
25062506
}
25072507

25082508
ty::UnnormalizedProjection(..)
2509-
| ty::Infer(ty::BoundTy(_))
2509+
| ty::Bound(_)
25102510
| ty::Infer(ty::FreshTy(_))
25112511
| ty::Infer(ty::FreshIntTy(_))
25122512
| ty::Infer(ty::FreshFloatTy(_)) => {
@@ -2549,7 +2549,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
25492549
| ty::Param(..)
25502550
| ty::Foreign(..)
25512551
| ty::Projection(..)
2552-
| ty::Infer(ty::BoundTy(_))
2552+
| ty::Bound(_)
25532553
| ty::Infer(ty::TyVar(_))
25542554
| ty::Infer(ty::FreshTy(_))
25552555
| ty::Infer(ty::FreshIntTy(_))

src/librustc/ty/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2223,7 +2223,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
22232223
sty_debug_print!(
22242224
self,
22252225
Adt, Array, Slice, RawPtr, Ref, FnDef, FnPtr,
2226-
Generator, GeneratorWitness, Dynamic, Closure, Tuple,
2226+
Generator, GeneratorWitness, Dynamic, Closure, Tuple, Bound,
22272227
Param, Infer, UnnormalizedProjection, Projection, Opaque, Foreign);
22282228

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

0 commit comments

Comments
 (0)