Skip to content

Commit 1ff3cd8

Browse files
committed
make ty::Predicate carry a ClosureSubsts
1 parent 12b67c6 commit 1ff3cd8

File tree

8 files changed

+25
-20
lines changed

8 files changed

+25
-20
lines changed

src/librustc/ich/impls_ty.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,9 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::Predicate<'gcx> {
236236
ty::Predicate::ObjectSafe(def_id) => {
237237
def_id.hash_stable(hcx, hasher);
238238
}
239-
ty::Predicate::ClosureKind(def_id, closure_kind) => {
239+
ty::Predicate::ClosureKind(def_id, closure_substs, closure_kind) => {
240240
def_id.hash_stable(hcx, hasher);
241+
closure_substs.hash_stable(hcx, hasher);
241242
closure_kind.hash_stable(hcx, hasher);
242243
}
243244
ty::Predicate::ConstEvaluatable(def_id, substs) => {

src/librustc/traits/error_reporting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
661661
violations)
662662
}
663663

664-
ty::Predicate::ClosureKind(closure_def_id, kind) => {
664+
ty::Predicate::ClosureKind(closure_def_id, _closure_substs, kind) => {
665665
let found_kind = self.closure_kind(closure_def_id).unwrap();
666666
let closure_span = self.tcx.hir.span_if_local(closure_def_id).unwrap();
667667
let node_id = self.tcx.hir.as_local_node_id(closure_def_id).unwrap();

src/librustc/traits/fulfill.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ fn process_predicate<'a, 'gcx, 'tcx>(
491491
}
492492
}
493493

494-
ty::Predicate::ClosureKind(closure_def_id, kind) => {
494+
ty::Predicate::ClosureKind(closure_def_id, _closure_substs, kind) => {
495495
match selcx.infcx().closure_kind(closure_def_id) {
496496
Some(closure_kind) => {
497497
if closure_kind.extends(kind) {

src/librustc/traits/select.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
718718
}
719719
}
720720

721-
ty::Predicate::ClosureKind(closure_def_id, kind) => {
721+
ty::Predicate::ClosureKind(closure_def_id, _closure_substs, kind) => {
722722
match self.infcx.closure_kind(closure_def_id) {
723723
Some(closure_kind) => {
724724
if closure_kind.extends(kind) {
@@ -2726,7 +2726,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
27262726
obligations.push(Obligation::new(
27272727
obligation.cause.clone(),
27282728
obligation.param_env,
2729-
ty::Predicate::ClosureKind(closure_def_id, kind)));
2729+
ty::Predicate::ClosureKind(closure_def_id, substs, kind)));
27302730

27312731
Ok(VtableClosureData {
27322732
closure_def_id,

src/librustc/traits/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ fn anonymize_predicate<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
4343
ty::Predicate::ObjectSafe(data) =>
4444
ty::Predicate::ObjectSafe(data),
4545

46-
ty::Predicate::ClosureKind(closure_def_id, kind) =>
47-
ty::Predicate::ClosureKind(closure_def_id, kind),
46+
ty::Predicate::ClosureKind(closure_def_id, closure_substs, kind) =>
47+
ty::Predicate::ClosureKind(closure_def_id, closure_substs, kind),
4848

4949
ty::Predicate::Subtype(ref data) =>
5050
ty::Predicate::Subtype(tcx.anonymize_late_bound_regions(data)),

src/librustc/ty/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ pub enum Predicate<'tcx> {
886886
/// No direct syntax. May be thought of as `where T : FnFoo<...>`
887887
/// for some substitutions `...` and T being a closure type.
888888
/// Satisfied (or refuted) once we know the closure's kind.
889-
ClosureKind(DefId, ClosureKind),
889+
ClosureKind(DefId, ClosureSubsts<'tcx>, ClosureKind),
890890

891891
/// `T1 <: T2`
892892
Subtype(PolySubtypePredicate<'tcx>),
@@ -983,8 +983,8 @@ impl<'a, 'gcx, 'tcx> Predicate<'tcx> {
983983
Predicate::WellFormed(data.subst(tcx, substs)),
984984
Predicate::ObjectSafe(trait_def_id) =>
985985
Predicate::ObjectSafe(trait_def_id),
986-
Predicate::ClosureKind(closure_def_id, kind) =>
987-
Predicate::ClosureKind(closure_def_id, kind),
986+
Predicate::ClosureKind(closure_def_id, closure_substs, kind) =>
987+
Predicate::ClosureKind(closure_def_id, closure_substs.subst(tcx, substs), kind),
988988
Predicate::ConstEvaluatable(def_id, const_substs) =>
989989
Predicate::ConstEvaluatable(def_id, const_substs.subst(tcx, substs)),
990990
}
@@ -1166,8 +1166,8 @@ impl<'tcx> Predicate<'tcx> {
11661166
ty::Predicate::ObjectSafe(_trait_def_id) => {
11671167
vec![]
11681168
}
1169-
ty::Predicate::ClosureKind(_closure_def_id, _kind) => {
1170-
vec![]
1169+
ty::Predicate::ClosureKind(_closure_def_id, closure_substs, _kind) => {
1170+
closure_substs.substs.types().collect()
11711171
}
11721172
ty::Predicate::ConstEvaluatable(_, substs) => {
11731173
substs.types().collect()

src/librustc/ty/structural_impls.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,11 @@ impl<'a, 'tcx> Lift<'tcx> for ty::Predicate<'a> {
211211
ty::Predicate::WellFormed(ty) => {
212212
tcx.lift(&ty).map(ty::Predicate::WellFormed)
213213
}
214-
ty::Predicate::ClosureKind(closure_def_id, kind) => {
215-
Some(ty::Predicate::ClosureKind(closure_def_id, kind))
214+
ty::Predicate::ClosureKind(closure_def_id, closure_substs, kind) => {
215+
tcx.lift(&closure_substs)
216+
.map(|closure_substs| ty::Predicate::ClosureKind(closure_def_id,
217+
closure_substs,
218+
kind))
216219
}
217220
ty::Predicate::ObjectSafe(trait_def_id) => {
218221
Some(ty::Predicate::ObjectSafe(trait_def_id))
@@ -965,8 +968,8 @@ impl<'tcx> TypeFoldable<'tcx> for ty::Predicate<'tcx> {
965968
ty::Predicate::Projection(binder.fold_with(folder)),
966969
ty::Predicate::WellFormed(data) =>
967970
ty::Predicate::WellFormed(data.fold_with(folder)),
968-
ty::Predicate::ClosureKind(closure_def_id, kind) =>
969-
ty::Predicate::ClosureKind(closure_def_id, kind),
971+
ty::Predicate::ClosureKind(closure_def_id, closure_substs, kind) =>
972+
ty::Predicate::ClosureKind(closure_def_id, closure_substs.fold_with(folder), kind),
970973
ty::Predicate::ObjectSafe(trait_def_id) =>
971974
ty::Predicate::ObjectSafe(trait_def_id),
972975
ty::Predicate::ConstEvaluatable(def_id, substs) =>
@@ -983,7 +986,8 @@ impl<'tcx> TypeFoldable<'tcx> for ty::Predicate<'tcx> {
983986
ty::Predicate::TypeOutlives(ref binder) => binder.visit_with(visitor),
984987
ty::Predicate::Projection(ref binder) => binder.visit_with(visitor),
985988
ty::Predicate::WellFormed(data) => data.visit_with(visitor),
986-
ty::Predicate::ClosureKind(_closure_def_id, _kind) => false,
989+
ty::Predicate::ClosureKind(_closure_def_id, closure_substs, _kind) =>
990+
closure_substs.visit_with(visitor),
987991
ty::Predicate::ObjectSafe(_trait_def_id) => false,
988992
ty::Predicate::ConstEvaluatable(_def_id, substs) => substs.visit_with(visitor),
989993
}

src/librustc/util/ppaux.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ define_print! {
12571257
ty::tls::with(|tcx| {
12581258
write!(f, "the trait `{}` is object-safe", tcx.item_path_str(trait_def_id))
12591259
}),
1260-
ty::Predicate::ClosureKind(closure_def_id, kind) =>
1260+
ty::Predicate::ClosureKind(closure_def_id, _closure_substs, kind) =>
12611261
ty::tls::with(|tcx| {
12621262
write!(f, "the closure `{}` implements the trait `{}`",
12631263
tcx.item_path_str(closure_def_id), kind)
@@ -1281,8 +1281,8 @@ define_print! {
12811281
ty::Predicate::ObjectSafe(trait_def_id) => {
12821282
write!(f, "ObjectSafe({:?})", trait_def_id)
12831283
}
1284-
ty::Predicate::ClosureKind(closure_def_id, kind) => {
1285-
write!(f, "ClosureKind({:?}, {:?})", closure_def_id, kind)
1284+
ty::Predicate::ClosureKind(closure_def_id, closure_substs, kind) => {
1285+
write!(f, "ClosureKind({:?}, {:?}, {:?})", closure_def_id, closure_substs, kind)
12861286
}
12871287
ty::Predicate::ConstEvaluatable(def_id, substs) => {
12881288
write!(f, "ConstEvaluatable({:?}, {:?})", def_id, substs)

0 commit comments

Comments
 (0)