Skip to content

Commit 16ad3f3

Browse files
committed
Nits and change skip_binder to no_bound_vars for fndef
1 parent b5d5994 commit 16ad3f3

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

src/librustc_traits/chalk/db.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
use rustc_middle::traits::ChalkRustInterner as RustInterner;
1010
use rustc_middle::ty::subst::{InternalSubsts, Subst, SubstsRef};
11-
use rustc_middle::ty::{self, AssocItemContainer, AssocKind, TyCtxt};
11+
use rustc_middle::ty::{self, AssocItemContainer, AssocKind, Binder, TyCtxt};
1212

1313
use rustc_hir::def_id::DefId;
1414

@@ -177,10 +177,12 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
177177
.filter_map(|wc| LowerInto::<Option<chalk_ir::QuantifiedWhereClause<RustInterner<'tcx>>>>::lower_into(wc, &self.interner)).collect();
178178

179179
let sig = self.tcx.fn_sig(def_id);
180-
// FIXME(chalk): Why does this have a Binder
181-
let argument_types = sig
182-
.inputs()
183-
.skip_binder()
180+
// FIXME(chalk): collect into an intermediate SmallVec here since
181+
// we need `TypeFoldable` for `no_bound_vars`
182+
let argument_types: Binder<Vec<_>> = sig.map_bound(|i| i.inputs().iter().copied().collect());
183+
let argument_types = argument_types
184+
.no_bound_vars()
185+
.expect("FIXME(chalk): late-bound fn parameters not supported in chalk")
184186
.iter()
185187
.map(|t| t.subst(self.tcx, &bound_vars).lower_into(&self.interner))
186188
.collect();

src/librustc_traits/chalk/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ crate fn evaluate_goal<'tcx>(
199199
.map(|s| match s {
200200
Solution::Unique(_subst) => {
201201
// FIXME(chalk): handle constraints
202-
// assert!(_subst.value.constraints.is_empty());
203202
make_solution(_subst.value.subst)
204203
}
205204
Solution::Ambig(_guidance) => {

src/test/ui/chalkify/inherent_impl.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// run-pass
22
// compile-flags: -Z chalk
3+
// FIXME(chalk): remove when uncommented
4+
#![allow(dead_code, unused_variables)]
35

46
trait Foo { }
57

@@ -9,6 +11,8 @@ struct S<T: Foo> {
911
x: T,
1012
}
1113

14+
// FIXME(chalk): need late-bound regions on FnDefs
15+
/*
1216
fn only_foo<T: Foo>(_x: &T) { }
1317
1418
impl<T> S<T> {
@@ -17,6 +21,7 @@ impl<T> S<T> {
1721
only_foo(&self.x)
1822
}
1923
}
24+
*/
2025

2126
trait Bar { }
2227
impl Bar for u32 { }
@@ -26,17 +31,27 @@ fn only_bar<T: Bar>() { }
2631
impl<T> S<T> {
2732
// Test that the environment of `dummy_bar` adds up with the environment
2833
// of the inherent impl.
34+
// FIXME(chalk): need late-bound regions on FnDefs
35+
/*
2936
fn dummy_bar<U: Bar>(&self) {
3037
only_foo(&self.x);
3138
only_bar::<U>();
3239
}
40+
*/
41+
fn dummy_bar<U: Bar>() {
42+
only_bar::<U>();
43+
}
3344
}
3445

3546
fn main() {
3647
let s = S {
3748
x: 5,
3849
};
3950

51+
// FIXME(chalk): need late-bound regions on FnDefs
52+
/*
4053
s.dummy_foo();
4154
s.dummy_bar::<u32>();
55+
*/
56+
S::<i32>::dummy_bar::<u32>();
4257
}

0 commit comments

Comments
 (0)