about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/middle/traits/select.rs25
-rw-r--r--src/test/compile-fail/typeck-default-trait-impl-supertrait.rs4
-rw-r--r--src/test/compile-fail/typeck-default-trait-impl-trait-where-clause.rs15
3 files changed, 33 insertions, 11 deletions
diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs
index c5ef55154de..ac782729bc3 100644
--- a/src/librustc/middle/traits/select.rs
+++ b/src/librustc/middle/traits/select.rs
@@ -1423,7 +1423,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
                 }
             }
 
-            ty::ty_rptr(_, ty::mt { ty: referent_ty, mutbl }) => {
+            ty::ty_rptr(_, ty::mt { ty: _, mutbl }) => {
                 // &mut T or &T
                 match bound {
                     ty::BoundCopy => {
@@ -1871,8 +1871,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
     }
 
     fn confirm_default_impl_candidate(&mut self,
-                              obligation: &TraitObligation<'tcx>,
-                              impl_def_id: ast::DefId)
+                                      obligation: &TraitObligation<'tcx>,
+                                      impl_def_id: ast::DefId)
                               -> Result<VtableDefaultImplData<PredicateObligation<'tcx>>,
                                         SelectionError<'tcx>>
     {
@@ -1892,6 +1892,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
                            -> VtableDefaultImplData<PredicateObligation<'tcx>>
     {
         let derived_cause = self.derived_cause(obligation, ImplDerivedObligation);
+
         let obligations = nested.iter().map(|&nested_ty| {
             // the obligation might be higher-ranked, e.g. for<'a> &'a
             // int : Copy. In that case, we will wind up with
@@ -1918,11 +1919,27 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
                 }
             })
         }).collect::<Result<_, _>>();
-        let obligations = match obligations {
+
+        let mut obligations = match obligations {
             Ok(o) => o,
             Err(ErrorReported) => Vec::new()
         };
 
+        let _: Result<(),()> = self.infcx.try(|snapshot| {
+            let (_, skol_map) =
+                self.infcx().skolemize_late_bound_regions(&obligation.predicate, snapshot);
+
+            let substs = obligation.predicate.to_poly_trait_ref().substs();
+            let trait_obligations = self.impl_obligations(obligation.cause.clone(),
+                                                          obligation.recursion_depth + 1,
+                                                          trait_def_id,
+                                                          substs,
+                                                          skol_map,
+                                                          snapshot);
+            obligations.push_all(trait_obligations.as_slice());
+            Ok(())
+        });
+
         debug!("vtable_default_impl_data: obligations={}", obligations.repr(self.tcx()));
 
         VtableDefaultImplData {
diff --git a/src/test/compile-fail/typeck-default-trait-impl-supertrait.rs b/src/test/compile-fail/typeck-default-trait-impl-supertrait.rs
index cb3f50c8d87..c9bfdff6c0e 100644
--- a/src/test/compile-fail/typeck-default-trait-impl-supertrait.rs
+++ b/src/test/compile-fail/typeck-default-trait-impl-supertrait.rs
@@ -24,6 +24,6 @@ fn foo<T:MyTrait>() { bar::<T>() }
 fn bar<T:NotImplemented>() { }
 
 fn main() {
-    foo::<i32>(); //~ ERROR XXX
-    bar::<i32>(); //~ ERROR XXX
+    foo::<i32>(); //~ ERROR the trait `NotImplemented` is not implemented for the type `i32`
+    bar::<i64>(); //~ ERROR the trait `NotImplemented` is not implemented for the type `i64`
 }
diff --git a/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause.rs b/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause.rs
index 85bca7f248c..06f36521157 100644
--- a/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause.rs
+++ b/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause.rs
@@ -25,14 +25,19 @@ impl MyTrait for .. {}
 
 fn foo<T:MyTrait>() {
     bar::<Option<T>>()
-        //~^ ERROR not implemented for the type `Option<T>`
-        //
-        // This should probably typecheck. This is #20671.
+    //~^ ERROR the trait `NotImplemented` is not implemented for the type `core::option::Option<T>`
+    //
+    // This should probably typecheck. This is #20671.
 }
 
 fn bar<T:NotImplemented>() { }
 
+fn test() {
+    bar::<Option<i32>>();
+    //~^ ERROR the trait `NotImplemented` is not implemented for the type `core::option::Option<i32>`
+}
+
 fn main() {
-    foo::<i32>(); //~ ERROR not implemented for the type `i32`
-    bar::<Option<i32>>(); //~ ERROR not implemented for the type `Option<i32>`
+    foo::<i32>();
+    //~^ ERROR the trait `NotImplemented` is not implemented for the type `core::option::Option<i32>`
 }