Skip to content

Commit a34e1c7

Browse files
committed
---
yaml --- r: 187644 b: refs/heads/tmp c: 64d33d8 h: refs/heads/master v: v3
1 parent 3fbb5f1 commit a34e1c7

File tree

4 files changed

+34
-12
lines changed

4 files changed

+34
-12
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: 522d09dfecbeca1595f25ac58c6d0178bbd21d7d
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
37-
refs/heads/tmp: f7a75e0341b6192b20bc271c4a165b9a53d34ff4
37+
refs/heads/tmp: 64d33d892ad3bda256e174e97e51f603896b6c66
3838
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/tmp/src/librustc/middle/traits/select.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
14231423
}
14241424
}
14251425

1426-
ty::ty_rptr(_, ty::mt { ty: referent_ty, mutbl }) => {
1426+
ty::ty_rptr(_, ty::mt { ty: _, mutbl }) => {
14271427
// &mut T or &T
14281428
match bound {
14291429
ty::BoundCopy => {
@@ -1871,8 +1871,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
18711871
}
18721872

18731873
fn confirm_default_impl_candidate(&mut self,
1874-
obligation: &TraitObligation<'tcx>,
1875-
impl_def_id: ast::DefId)
1874+
obligation: &TraitObligation<'tcx>,
1875+
impl_def_id: ast::DefId)
18761876
-> Result<VtableDefaultImplData<PredicateObligation<'tcx>>,
18771877
SelectionError<'tcx>>
18781878
{
@@ -1892,6 +1892,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
18921892
-> VtableDefaultImplData<PredicateObligation<'tcx>>
18931893
{
18941894
let derived_cause = self.derived_cause(obligation, ImplDerivedObligation);
1895+
18951896
let obligations = nested.iter().map(|&nested_ty| {
18961897
// the obligation might be higher-ranked, e.g. for<'a> &'a
18971898
// int : Copy. In that case, we will wind up with
@@ -1918,11 +1919,27 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
19181919
}
19191920
})
19201921
}).collect::<Result<_, _>>();
1921-
let obligations = match obligations {
1922+
1923+
let mut obligations = match obligations {
19221924
Ok(o) => o,
19231925
Err(ErrorReported) => Vec::new()
19241926
};
19251927

1928+
let _: Result<(),()> = self.infcx.try(|snapshot| {
1929+
let (_, skol_map) =
1930+
self.infcx().skolemize_late_bound_regions(&obligation.predicate, snapshot);
1931+
1932+
let substs = obligation.predicate.to_poly_trait_ref().substs();
1933+
let trait_obligations = self.impl_obligations(obligation.cause.clone(),
1934+
obligation.recursion_depth + 1,
1935+
trait_def_id,
1936+
substs,
1937+
skol_map,
1938+
snapshot);
1939+
obligations.push_all(trait_obligations.as_slice());
1940+
Ok(())
1941+
});
1942+
19261943
debug!("vtable_default_impl_data: obligations={}", obligations.repr(self.tcx()));
19271944

19281945
VtableDefaultImplData {

branches/tmp/src/test/compile-fail/typeck-default-trait-impl-supertrait.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ fn foo<T:MyTrait>() { bar::<T>() }
2424
fn bar<T:NotImplemented>() { }
2525

2626
fn main() {
27-
foo::<i32>(); //~ ERROR XXX
28-
bar::<i32>(); //~ ERROR XXX
27+
foo::<i32>(); //~ ERROR the trait `NotImplemented` is not implemented for the type `i32`
28+
bar::<i64>(); //~ ERROR the trait `NotImplemented` is not implemented for the type `i64`
2929
}

branches/tmp/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,19 @@ impl MyTrait for .. {}
2525

2626
fn foo<T:MyTrait>() {
2727
bar::<Option<T>>()
28-
//~^ ERROR not implemented for the type `Option<T>`
29-
//
30-
// This should probably typecheck. This is #20671.
28+
//~^ ERROR the trait `NotImplemented` is not implemented for the type `core::option::Option<T>`
29+
//
30+
// This should probably typecheck. This is #20671.
3131
}
3232

3333
fn bar<T:NotImplemented>() { }
3434

35+
fn test() {
36+
bar::<Option<i32>>();
37+
//~^ ERROR the trait `NotImplemented` is not implemented for the type `core::option::Option<i32>`
38+
}
39+
3540
fn main() {
36-
foo::<i32>(); //~ ERROR not implemented for the type `i32`
37-
bar::<Option<i32>>(); //~ ERROR not implemented for the type `Option<i32>`
41+
foo::<i32>();
42+
//~^ ERROR the trait `NotImplemented` is not implemented for the type `core::option::Option<i32>`
3843
}

0 commit comments

Comments
 (0)