Skip to content

Commit decf3d3

Browse files
committed
make ty::Predicate carry a ClosureSubsts
1 parent 0ac8542 commit decf3d3

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
@@ -643,7 +643,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
643643
violations)
644644
}
645645

646-
ty::Predicate::ClosureKind(closure_def_id, kind) => {
646+
ty::Predicate::ClosureKind(closure_def_id, _closure_substs, kind) => {
647647
let found_kind = self.closure_kind(closure_def_id).unwrap();
648648
let closure_span = self.tcx.hir.span_if_local(closure_def_id).unwrap();
649649
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
@@ -438,7 +438,7 @@ fn process_predicate<'a, 'gcx, 'tcx>(
438438
}
439439
}
440440

441-
ty::Predicate::ClosureKind(closure_def_id, kind) => {
441+
ty::Predicate::ClosureKind(closure_def_id, _closure_substs, kind) => {
442442
match selcx.infcx().closure_kind(closure_def_id) {
443443
Some(closure_kind) => {
444444
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
@@ -896,7 +896,7 @@ pub enum Predicate<'tcx> {
896896
/// No direct syntax. May be thought of as `where T : FnFoo<...>`
897897
/// for some substitutions `...` and T being a closure type.
898898
/// Satisfied (or refuted) once we know the closure's kind.
899-
ClosureKind(DefId, ClosureKind),
899+
ClosureKind(DefId, ClosureSubsts<'tcx>, ClosureKind),
900900

901901
/// `T1 <: T2`
902902
Subtype(PolySubtypePredicate<'tcx>),
@@ -999,8 +999,8 @@ impl<'a, 'gcx, 'tcx> Predicate<'tcx> {
999999
Predicate::WellFormed(data.subst(tcx, substs)),
10001000
Predicate::ObjectSafe(trait_def_id) =>
10011001
Predicate::ObjectSafe(trait_def_id),
1002-
Predicate::ClosureKind(closure_def_id, kind) =>
1003-
Predicate::ClosureKind(closure_def_id, kind),
1002+
Predicate::ClosureKind(closure_def_id, closure_substs, kind) =>
1003+
Predicate::ClosureKind(closure_def_id, closure_substs.subst(tcx, substs), kind),
10041004
Predicate::ConstEvaluatable(def_id, const_substs) =>
10051005
Predicate::ConstEvaluatable(def_id, const_substs.subst(tcx, substs)),
10061006
}
@@ -1182,8 +1182,8 @@ impl<'tcx> Predicate<'tcx> {
11821182
ty::Predicate::ObjectSafe(_trait_def_id) => {
11831183
vec![]
11841184
}
1185-
ty::Predicate::ClosureKind(_closure_def_id, _kind) => {
1186-
vec![]
1185+
ty::Predicate::ClosureKind(_closure_def_id, closure_substs, _kind) => {
1186+
closure_substs.substs.types().collect()
11871187
}
11881188
ty::Predicate::ConstEvaluatable(_, substs) => {
11891189
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))
@@ -966,8 +969,8 @@ impl<'tcx> TypeFoldable<'tcx> for ty::Predicate<'tcx> {
966969
ty::Predicate::Projection(binder.fold_with(folder)),
967970
ty::Predicate::WellFormed(data) =>
968971
ty::Predicate::WellFormed(data.fold_with(folder)),
969-
ty::Predicate::ClosureKind(closure_def_id, kind) =>
970-
ty::Predicate::ClosureKind(closure_def_id, kind),
972+
ty::Predicate::ClosureKind(closure_def_id, closure_substs, kind) =>
973+
ty::Predicate::ClosureKind(closure_def_id, closure_substs.fold_with(folder), kind),
971974
ty::Predicate::ObjectSafe(trait_def_id) =>
972975
ty::Predicate::ObjectSafe(trait_def_id),
973976
ty::Predicate::ConstEvaluatable(def_id, substs) =>
@@ -984,7 +987,8 @@ impl<'tcx> TypeFoldable<'tcx> for ty::Predicate<'tcx> {
984987
ty::Predicate::TypeOutlives(ref binder) => binder.visit_with(visitor),
985988
ty::Predicate::Projection(ref binder) => binder.visit_with(visitor),
986989
ty::Predicate::WellFormed(data) => data.visit_with(visitor),
987-
ty::Predicate::ClosureKind(_closure_def_id, _kind) => false,
990+
ty::Predicate::ClosureKind(_closure_def_id, closure_substs, _kind) =>
991+
closure_substs.visit_with(visitor),
988992
ty::Predicate::ObjectSafe(_trait_def_id) => false,
989993
ty::Predicate::ConstEvaluatable(_def_id, substs) => substs.visit_with(visitor),
990994
}

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)