Skip to content

Commit da58872

Browse files
committed
---
yaml --- r: 95172 b: refs/heads/dist-snap c: e44b40c h: refs/heads/master v: v3
1 parent 3847f53 commit da58872

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: fa411500f969be6131aee62e3885460f90c150bb
9+
refs/heads/dist-snap: e44b40ca3a1e8e53b485476e7329a0d8e553d29c
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librustc/middle/typeck/check/method.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,13 @@ impl<'self> LookupContext<'self> {
12881288
fn report_candidate(&self, idx: uint, origin: &method_origin) {
12891289
match *origin {
12901290
method_static(impl_did) => {
1291-
self.report_static_candidate(idx, impl_did)
1291+
// If it is an instantiated default method, use the original
1292+
// default method for error reporting.
1293+
let did = match provided_source(self.tcx(), impl_did) {
1294+
None => impl_did,
1295+
Some(did) => did
1296+
};
1297+
self.report_static_candidate(idx, did)
12921298
}
12931299
method_param(ref mp) => {
12941300
self.report_param_candidate(idx, (*mp).trait_id)
@@ -1302,7 +1308,8 @@ impl<'self> LookupContext<'self> {
13021308
fn report_static_candidate(&self, idx: uint, did: DefId) {
13031309
let span = if did.crate == ast::LOCAL_CRATE {
13041310
match self.tcx().items.find(&did.node) {
1305-
Some(&ast_map::node_method(m, _, _)) => m.span,
1311+
Some(&ast_map::node_method(m, _, _))
1312+
| Some(&ast_map::node_trait_method(@ast::provided(m), _, _)) => m.span,
13061313
_ => fail2!("report_static_candidate: bad item {:?}", did)
13071314
}
13081315
} else {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2013 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 { fn method(&self) {} } //~ NOTE `Foo::method`
12+
trait Bar { fn method(&self) {} } //~ NOTE `Bar::method`
13+
14+
impl Foo for uint {}
15+
impl Bar for uint {}
16+
17+
fn main() {
18+
1u.method(); //~ ERROR multiple applicable methods in scope
19+
}

0 commit comments

Comments
 (0)