]> git.lizzy.rs Git - rust.git/commitdiff
Nits and change skip_binder to no_bound_vars for fndef
authorJack Huey <jack.huey@umassmed.edu>
Wed, 3 Jun 2020 16:21:56 +0000 (12:21 -0400)
committerJack Huey <jack.huey@umassmed.edu>
Fri, 19 Jun 2020 18:05:14 +0000 (14:05 -0400)
src/librustc_traits/chalk/db.rs
src/librustc_traits/chalk/mod.rs
src/test/ui/chalkify/inherent_impl.rs

index 4976ba06815c827cf84ce4f9619774293266b176..78fb787a319ef4205a472f7a101b95de4e1ce7e5 100644 (file)
@@ -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;
 
@@ -177,10 +177,12 @@ fn fn_def_datum(
             .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();
index d8f9a40b9432ed63fe804e20f73f04c7b1a27f07..6f657be0908b45848e3d815d25447b66884edbbc 100644 (file)
         .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) => {
index 44e120c1eebbaabfd4bd162118ff3943199b5303..9dd9eb320ddd3b22a292fe4f43ca4953d0a8ed4f 100644 (file)
@@ -1,5 +1,7 @@
 // run-pass
 // compile-flags: -Z chalk
+// FIXME(chalk): remove when uncommented
+#![allow(dead_code, unused_variables)]
 
 trait Foo { }
 
@@ -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> {
@@ -17,6 +21,7 @@ fn dummy_foo(&self) {
         only_foo(&self.x)
     }
 }
+*/
 
 trait Bar { }
 impl Bar for u32 { }
@@ -26,10 +31,16 @@ 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() {
@@ -37,6 +48,10 @@ fn main() {
         x: 5,
     };
 
+    // FIXME(chalk): need late-bound regions on FnDefs
+    /*
     s.dummy_foo();
     s.dummy_bar::<u32>();
+    */
+    S::<i32>::dummy_bar::<u32>();
 }