Skip to content

Commit f896e14

Browse files
committed
---
yaml --- r: 82899 b: refs/heads/auto c: e44b40c h: refs/heads/master i: 82897: a2dd320 82895: 3b61a54 v: v3
1 parent 7afa8b6 commit f896e14

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
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: fa411500f969be6131aee62e3885460f90c150bb
16+
refs/heads/auto: e44b40ca3a1e8e53b485476e7329a0d8e553d29c
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/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)