report ambig impl methods
This commit is contained in:
parent
f4cc5ff226
commit
f1129635ee
4 changed files with 30 additions and 0 deletions
|
@ -2738,6 +2738,25 @@ impl methods for lookup {
|
|||
self.tcx().sess.span_err(
|
||||
self.expr.span,
|
||||
"multiple applicable methods in scope");
|
||||
|
||||
// I would like to print out how each impl was imported,
|
||||
// but I cannot for the life of me figure out how to
|
||||
// annotate resolve to preserve this information.
|
||||
for results.eachi { |i, result|
|
||||
let (_, _, did) = result;
|
||||
let span = if did.crate == ast::local_crate {
|
||||
alt check self.tcx().items.get(did.node) {
|
||||
ast_map::node_method(m, _, _) { m.span }
|
||||
}
|
||||
} else {
|
||||
self.expr.span
|
||||
};
|
||||
self.tcx().sess.span_note(
|
||||
span,
|
||||
#fmt["candidate #%u is %s",
|
||||
(i+1u),
|
||||
ty::item_path_str(self.tcx(), did)]);
|
||||
}
|
||||
}
|
||||
|
||||
let (self_substs, n_tps, did) = results[0];
|
||||
|
|
1
src/test/auxiliary/ambig_impl_2_lib.rs
Normal file
1
src/test/auxiliary/ambig_impl_2_lib.rs
Normal file
|
@ -0,0 +1 @@
|
|||
impl methods1 for uint { fn me() -> uint { self } }
|
3
src/test/compile-fail/ambig_impl_1.rs
Normal file
3
src/test/compile-fail/ambig_impl_1.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
impl methods1 for uint { fn me() -> uint { self } } //! NOTE candidate #1 is methods1::me
|
||||
impl methods2 for uint { fn me() -> uint { self } } //! NOTE candidate #2 is methods2::me
|
||||
fn main() { 1u.me(); } //! ERROR multiple applicable methods in scope
|
7
src/test/compile-fail/ambig_impl_2_exe.rs
Normal file
7
src/test/compile-fail/ambig_impl_2_exe.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
// xfail-fast aux-build
|
||||
// aux-build:ambig_impl_2_lib.rs
|
||||
use ambig_impl_2_lib;
|
||||
import ambig_impl_2_lib::methods1;
|
||||
impl methods2 for uint { fn me() -> uint { self } } //! NOTE candidate #2 is methods2::me
|
||||
fn main() { 1u.me(); } //! ERROR multiple applicable methods in scope
|
||||
//!^ NOTE candidate #1 is ambig_impl_2_lib::methods1::me
|
Loading…
Add table
Reference in a new issue