forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement suggestions for traits to import.
For a call like `foo.bar()` where the method `bar` can't be resolved, the compiler will search for traits that have methods with name `bar` to give a more informative error, providing a list of possibilities. Closes rust-lang#7643.
- Loading branch information
Showing
7 changed files
with
249 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
pub use reexport::Reexported; | ||
|
||
pub mod foo { | ||
pub trait PubPub { | ||
fn method(&self); | ||
} | ||
} | ||
pub mod bar { | ||
trait PubPriv { | ||
fn method(&self); | ||
} | ||
} | ||
mod qux { | ||
pub trait PrivPub { | ||
fn method(&self); | ||
} | ||
} | ||
mod quz { | ||
trait PrivPriv { | ||
fn method(&self); | ||
} | ||
} | ||
|
||
mod reexport { | ||
pub trait Reexported { | ||
fn method(&self); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// aux-build:no_method_suggested_traits.rs | ||
|
||
extern crate no_method_suggested_traits; | ||
|
||
mod foo { | ||
trait Bar { //~ HELP `foo::Bar` | ||
fn method(&self); | ||
} | ||
} | ||
|
||
fn main() { | ||
1u32.method(); | ||
//~^ ERROR does not implement | ||
//~^^ HELP the following traits define a method `method` | ||
//~^^^ HELP `no_method_suggested_traits::foo::PubPub` | ||
//~^^^^ HELP `no_method_suggested_traits::reexport::Reexported` | ||
//~^^^^^ HELP `no_method_suggested_traits::bar::PubPriv` | ||
//~^^^^^^ HELP `no_method_suggested_traits::qux::PrivPub` | ||
//~^^^^^^^ HELP `no_method_suggested_traits::quz::PrivPriv` | ||
} |