Skip to content

Commit

Permalink
Nits and change skip_binder to no_bound_vars for fndef
Browse files Browse the repository at this point in the history
  • Loading branch information
jackh726 committed Jun 19, 2020
1 parent b5d5994 commit 16ad3f3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/librustc_traits/chalk/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use rustc_middle::traits::ChalkRustInterner as RustInterner;
use rustc_middle::ty::subst::{InternalSubsts, Subst, SubstsRef};
use rustc_middle::ty::{self, AssocItemContainer, AssocKind, TyCtxt};
use rustc_middle::ty::{self, AssocItemContainer, AssocKind, Binder, TyCtxt};

use rustc_hir::def_id::DefId;

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

let sig = self.tcx.fn_sig(def_id);
// FIXME(chalk): Why does this have a Binder
let argument_types = sig
.inputs()
.skip_binder()
// FIXME(chalk): collect into an intermediate SmallVec here since
// we need `TypeFoldable` for `no_bound_vars`
let argument_types: Binder<Vec<_>> = sig.map_bound(|i| i.inputs().iter().copied().collect());
let argument_types = argument_types
.no_bound_vars()
.expect("FIXME(chalk): late-bound fn parameters not supported in chalk")
.iter()
.map(|t| t.subst(self.tcx, &bound_vars).lower_into(&self.interner))
.collect();
Expand Down
1 change: 0 additions & 1 deletion src/librustc_traits/chalk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ crate fn evaluate_goal<'tcx>(
.map(|s| match s {
Solution::Unique(_subst) => {
// FIXME(chalk): handle constraints
// assert!(_subst.value.constraints.is_empty());
make_solution(_subst.value.subst)
}
Solution::Ambig(_guidance) => {
Expand Down
15 changes: 15 additions & 0 deletions src/test/ui/chalkify/inherent_impl.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// run-pass
// compile-flags: -Z chalk
// FIXME(chalk): remove when uncommented
#![allow(dead_code, unused_variables)]

trait Foo { }

Expand All @@ -9,6 +11,8 @@ struct S<T: Foo> {
x: T,
}

// FIXME(chalk): need late-bound regions on FnDefs
/*
fn only_foo<T: Foo>(_x: &T) { }
impl<T> S<T> {
Expand All @@ -17,6 +21,7 @@ impl<T> S<T> {
only_foo(&self.x)
}
}
*/

trait Bar { }
impl Bar for u32 { }
Expand All @@ -26,17 +31,27 @@ fn only_bar<T: Bar>() { }
impl<T> S<T> {
// Test that the environment of `dummy_bar` adds up with the environment
// of the inherent impl.
// FIXME(chalk): need late-bound regions on FnDefs
/*
fn dummy_bar<U: Bar>(&self) {
only_foo(&self.x);
only_bar::<U>();
}
*/
fn dummy_bar<U: Bar>() {
only_bar::<U>();
}
}

fn main() {
let s = S {
x: 5,
};

// FIXME(chalk): need late-bound regions on FnDefs
/*
s.dummy_foo();
s.dummy_bar::<u32>();
*/
S::<i32>::dummy_bar::<u32>();
}

0 comments on commit 16ad3f3

Please sign in to comment.