]> git.lizzy.rs Git - rust.git/commitdiff
Remove awful hack concerning `Trait impl Trait` in method resolution code that I...
authorNiko Matsakis <niko@alum.mit.edu>
Mon, 9 Feb 2015 15:44:17 +0000 (10:44 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Mon, 23 Feb 2015 20:28:27 +0000 (15:28 -0500)
src/librustc_typeck/check/method/confirm.rs
src/test/compile-fail/issue-18959.rs
src/test/compile-fail/trait-test-2.rs

index 53976df75d6160e5530a3c481c703afeb5e47cf1..d7db21f3a2f762350f94f0636886695f8b203fbf 100644 (file)
@@ -404,26 +404,9 @@ fn instantiate_method_sig(&mut self,
                all_substs.repr(self.tcx()));
 
         // Instantiate the bounds on the method with the
-        // type/early-bound-regions substitutions performed.  The only
-        // late-bound-regions that can appear in bounds are from the
-        // impl, and those were already instantiated above.
-        //
-        // FIXME(DST). Super hack. For a method on a trait object
-        // `Trait`, the generic signature requires that
-        // `Self:Trait`. Since, for an object, we bind `Self` to the
-        // type `Trait`, this leads to an obligation
-        // `Trait:Trait`. Until such time we DST is fully implemented,
-        // that obligation is not necessarily satisfied. (In the
-        // future, it would be.) But we know that the true `Self` DOES implement
-        // the trait. So we just delete this requirement. Hack hack hack.
-        let mut method_predicates = pick.method_ty.predicates.instantiate(self.tcx(), &all_substs);
-        match pick.kind {
-            probe::ObjectPick(..) => {
-                assert_eq!(method_predicates.predicates.get_slice(subst::SelfSpace).len(), 1);
-                method_predicates.predicates.pop(subst::SelfSpace);
-            }
-            _ => { }
-        }
+        // type/early-bound-regions substitutions performed. There can
+        // be no late-bound regions appearing here.
+        let method_predicates = pick.method_ty.predicates.instantiate(self.tcx(), &all_substs);
         let method_predicates = self.fcx.normalize_associated_types_in(self.span,
                                                                        &method_predicates);
 
index 368f3c16f5188c47debf096ae1caedd17426be68..8fb543fb96703cda1a50fc7c0731dfc11288656f 100644 (file)
@@ -17,7 +17,11 @@ impl Foo for Thing {
     fn foo<T>(&self, _: &T) {}
 }
 
-#[inline(never)] fn foo(b: &Bar) { b.foo(&0_usize) }
+#[inline(never)]
+fn foo(b: &Bar) {
+    b.foo(&0usize)
+    //~^ ERROR the trait `Foo` is not implemented for the type `Bar`
+}
 
 fn main() {
     let mut thing = Thing;
index d8b3176787c040b1f75efdc2b741c05686522092..b09b10ffa0aad9dc22572e47f9348b44d7d7e7ac 100644 (file)
@@ -18,4 +18,5 @@ fn main() {
     10.dup::<i32>(); //~ ERROR does not take type parameters
     10.blah::<i32, i32>(); //~ ERROR incorrect number of type parameters
     (box 10 as Box<bar>).dup(); //~ ERROR cannot convert to a trait object
+    //~^ ERROR the trait `bar` is not implemented for the type `bar`
 }