Skip to content

Commit 65c0517

Browse files
committed
---
yaml --- r: 171967 b: refs/heads/beta c: e58f1bd h: refs/heads/master i: 171965: 1d0313b 171963: ad3c7a3 171959: b964128 171951: f28a432 171935: 844e518 171903: feb9034 v: v3
1 parent 4d8cc92 commit 65c0517

File tree

3 files changed

+77
-12
lines changed

3 files changed

+77
-12
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: 2a1ba2f1ac45f6bf48e55be4db5e8d1965fccaf8
34+
refs/heads/beta: e58f1bdc03b775e6d42f23f0cd181b47241bce41
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928

branches/beta/src/librustc_typeck/check/method/probe.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -807,26 +807,26 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
807807
match probe.kind {
808808
InherentImplCandidate(impl_def_id, ref substs) |
809809
ExtensionImplCandidate(impl_def_id, _, ref substs, _) => {
810+
let selcx = &mut traits::SelectionContext::new(self.infcx(), self.fcx);
811+
let cause = traits::ObligationCause::misc(self.span, self.fcx.body_id);
812+
810813
// Check whether the impl imposes obligations we have to worry about.
811814
let impl_generics = ty::lookup_item_type(self.tcx(), impl_def_id).generics;
812815
let impl_bounds = impl_generics.to_bounds(self.tcx(), substs);
813-
// FIXME(#20378) assoc type normalization here?
814-
815-
// Erase any late-bound regions bound in the impl
816-
// which appear in the bounds.
817-
let impl_bounds = self.erase_late_bound_regions(&ty::Binder(impl_bounds));
816+
let traits::Normalized { value: impl_bounds,
817+
obligations: norm_obligations } =
818+
traits::normalize(selcx, cause.clone(), &impl_bounds);
818819

819820
// Convert the bounds into obligations.
820821
let obligations =
821-
traits::predicates_for_generics(
822-
self.tcx(),
823-
traits::ObligationCause::misc(self.span, self.fcx.body_id),
824-
&impl_bounds);
822+
traits::predicates_for_generics(self.tcx(),
823+
cause.clone(),
824+
&impl_bounds);
825825
debug!("impl_obligations={}", obligations.repr(self.tcx()));
826826

827827
// Evaluate those obligations to see if they might possibly hold.
828-
let mut selcx = traits::SelectionContext::new(self.infcx(), self.fcx);
829-
obligations.all(|o| selcx.evaluate_obligation(o))
828+
obligations.all(|o| selcx.evaluate_obligation(o)) &&
829+
norm_obligations.iter().all(|o| selcx.evaluate_obligation(o))
830830
}
831831

832832
ObjectCandidate(..) |
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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 handle projection types which wind up important for
12+
// resolving methods. This test was reduced from a larger example; the
13+
// call to `foo()` at the end was failing to resolve because the
14+
// winnowing stage of method resolution failed to handle an associated
15+
// type projection.
16+
17+
#![feature(associated_types)]
18+
19+
trait Hasher {
20+
type Output;
21+
fn finish(&self) -> Self::Output;
22+
}
23+
24+
trait Hash<H: Hasher> {
25+
fn hash(&self, h: &mut H);
26+
}
27+
28+
trait HashState {
29+
type Wut: Hasher;
30+
fn hasher(&self) -> Self::Wut;
31+
}
32+
33+
struct SipHasher;
34+
impl Hasher for SipHasher {
35+
type Output = u64;
36+
fn finish(&self) -> u64 { 4 }
37+
}
38+
39+
impl Hash<SipHasher> for int {
40+
fn hash(&self, h: &mut SipHasher) {}
41+
}
42+
43+
struct SipState;
44+
impl HashState for SipState {
45+
type Wut = SipHasher;
46+
fn hasher(&self) -> SipHasher { SipHasher }
47+
}
48+
49+
struct Map<S> {
50+
s: S,
51+
}
52+
53+
impl<S> Map<S>
54+
where S: HashState,
55+
<S as HashState>::Wut: Hasher<Output=u64>,
56+
{
57+
fn foo<K>(&self, k: K) where K: Hash< <S as HashState>::Wut> {}
58+
}
59+
60+
fn foo<K: Hash<SipHasher>>(map: &Map<SipState>) {
61+
map.foo(22);
62+
}
63+
64+
fn main() {}
65+

0 commit comments

Comments
 (0)