Skip to content

Commit 281af41

Browse files
committed
---
yaml --- r: 172115 b: refs/heads/beta c: ebe8411 h: refs/heads/master i: 172113: 42ac282 172111: 985f2aa v: v3
1 parent 10bac17 commit 281af41

File tree

4 files changed

+70
-2
lines changed

4 files changed

+70
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3131
refs/heads/issue-18208-method-dispatch-3-quick-reject: 2009f85b9f99dedcec4404418eda9ddba90258a2
3232
refs/heads/batch: b5571ed71a5879c0495a982506258d5d267744ed
3333
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
34-
refs/heads/beta: b1b4bc90b8a1d2fc73b76cbbd0104f6c1acee33f
34+
refs/heads/beta: ebe8411874f8bb8ba2f7eae2f482a54d34195f69
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,9 @@ fn assemble_candidates_from_predicates<'cx,'tcx>(
452452
for predicate in elaborate_predicates(selcx.tcx(), env_predicates) {
453453
match predicate {
454454
ty::Predicate::Projection(ref data) => {
455-
let is_match = infcx.probe(|_| {
455+
let same_name = data.item_name() == obligation.predicate.item_name;
456+
457+
let is_match = same_name && infcx.probe(|_| {
456458
let origin = infer::Misc(obligation.cause.span);
457459
let obligation_poly_trait_ref =
458460
obligation_trait_ref.to_poly_trait_ref();
@@ -465,6 +467,9 @@ fn assemble_candidates_from_predicates<'cx,'tcx>(
465467
});
466468

467469
if is_match {
470+
debug!("assemble_candidates_from_predicates: candidate {}",
471+
data.repr(selcx.tcx()));
472+
468473
candidate_set.vec.push(
469474
ProjectionTyCandidate::ParamEnv(data.clone()));
470475
}
@@ -527,6 +532,9 @@ fn assemble_candidates_from_impls<'cx,'tcx>(
527532

528533
match vtable {
529534
super::VtableImpl(data) => {
535+
debug!("assemble_candidates_from_impls: impl candidate {}",
536+
data.repr(selcx.tcx()));
537+
530538
candidate_set.vec.push(
531539
ProjectionTyCandidate::Impl(data));
532540
}

branches/beta/src/librustc/middle/ty.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,6 +1892,10 @@ pub struct ProjectionPredicate<'tcx> {
18921892
pub type PolyProjectionPredicate<'tcx> = Binder<ProjectionPredicate<'tcx>>;
18931893

18941894
impl<'tcx> PolyProjectionPredicate<'tcx> {
1895+
pub fn item_name(&self) -> ast::Name {
1896+
self.0.projection_ty.item_name // safe to skip the binder to access a name
1897+
}
1898+
18951899
pub fn sort_key(&self) -> (ast::DefId, ast::Name) {
18961900
self.0.projection_ty.sort_key()
18971901
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
trait Foo {
12+
type X;
13+
type Y;
14+
}
15+
16+
fn have_x_want_x<T:Foo<X=u32>>(t: &T)
17+
{
18+
want_x(t);
19+
}
20+
21+
fn have_x_want_y<T:Foo<X=u32>>(t: &T)
22+
{
23+
want_y(t); //~ ERROR type mismatch
24+
}
25+
26+
fn have_y_want_x<T:Foo<Y=i32>>(t: &T)
27+
{
28+
want_x(t); //~ ERROR type mismatch
29+
}
30+
31+
fn have_y_want_y<T:Foo<Y=i32>>(t: &T)
32+
{
33+
want_y(t);
34+
}
35+
36+
fn have_xy_want_x<T:Foo<X=u32,Y=i32>>(t: &T)
37+
{
38+
want_x(t);
39+
}
40+
41+
fn have_xy_want_y<T:Foo<X=u32,Y=i32>>(t: &T)
42+
{
43+
want_y(t);
44+
}
45+
46+
fn have_xy_want_xy<T:Foo<X=u32,Y=i32>>(t: &T)
47+
{
48+
want_x(t);
49+
want_y(t);
50+
}
51+
52+
fn want_x<T:Foo<X=u32>>(t: &T) { }
53+
54+
fn want_y<T:Foo<Y=i32>>(t: &T) { }
55+
56+
fn main() { }

0 commit comments

Comments
 (0)