Skip to content

Commit 3ce59ed

Browse files
committed
---
yaml --- r: 172695 b: refs/heads/try c: 115a443 h: refs/heads/master i: 172693: a4cbcac 172691: 9a30759 172687: 4462824 v: v3
1 parent 31cd203 commit 3ce59ed

File tree

4 files changed

+60
-4
lines changed

4 files changed

+60
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 170c4399e614fe599c3d41306b3429ca8b3b68c6
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 5b3cd3900ceda838f5798c30ab96ceb41f962534
5-
refs/heads/try: bb0c8ef373317843c1df7e9110e4bd0978ff47eb
5+
refs/heads/try: 115a443cee40ef51f7ea1f79668bab1149b2d898
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/librustc/middle/traits/project.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,11 @@ pub struct Normalized<'tcx,T> {
244244
pub type NormalizedTy<'tcx> = Normalized<'tcx, Ty<'tcx>>;
245245

246246
impl<'tcx,T> Normalized<'tcx,T> {
247-
fn with<U>(self, value: U) -> Normalized<'tcx,U> {
247+
pub fn with<U>(self, value: U) -> Normalized<'tcx,U> {
248248
Normalized { value: value, obligations: self.obligations }
249249
}
250250
}
251251

252-
253252
pub fn normalize_projection_type<'a,'b,'tcx>(
254253
selcx: &'a mut SelectionContext<'b,'tcx>,
255254
projection_ty: ty::ProjectionTy<'tcx>,

branches/try/src/librustc_typeck/check/wf.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,16 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
235235
// Find the supertrait bounds. This will add `int:Bar`.
236236
let poly_trait_ref = ty::Binder(trait_ref);
237237
let predicates = ty::predicates_for_trait_ref(fcx.tcx(), &poly_trait_ref);
238-
for predicate in predicates.into_iter() {
238+
let predicates = {
239+
let selcx = &mut traits::SelectionContext::new(fcx.infcx(), fcx);
240+
traits::normalize(selcx, cause.clone(), &predicates)
241+
};
242+
for predicate in predicates.value.into_iter() {
239243
fcx.register_predicate(traits::Obligation::new(cause.clone(), predicate));
240244
}
245+
for obligation in predicates.obligations.into_iter() {
246+
fcx.register_predicate(obligation);
247+
}
241248
});
242249
}
243250
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test that we are handle to correctly handle a projection type
12+
// that appears in a supertrait bound. Issue #20559.
13+
14+
trait A
15+
{
16+
type TA;
17+
}
18+
19+
trait B<TB>
20+
{
21+
fn foo (&self, t : TB) -> String;
22+
}
23+
24+
trait C<TC : A> : B<<TC as A>::TA> { }
25+
26+
struct X;
27+
28+
impl A for X
29+
{
30+
type TA = i32;
31+
}
32+
33+
struct Y;
34+
35+
impl C<X> for Y { }
36+
37+
// Both of these impls are required for successful compilation
38+
impl B<i32> for Y
39+
{
40+
fn foo (&self, t : i32) -> String
41+
{
42+
format!("First {}", t)
43+
}
44+
}
45+
46+
fn main ()
47+
{
48+
let y = Y;
49+
assert_eq!(y.foo(5), format!("First 5"));
50+
}

0 commit comments

Comments
 (0)