File tree Expand file tree Collapse file tree 6 files changed +97
-0
lines changed Expand file tree Collapse file tree 6 files changed +97
-0
lines changed Original file line number Diff line number Diff line change 1+ /* This crate declares an item as both `prelude::*` and `m::Tr`.
2+ * The compiler should always suggest `m::Tr`. */
3+
4+ pub struct S ;
5+
6+ pub mod prelude {
7+ pub use crate :: m:: Tr as _;
8+ }
9+
10+ pub mod m {
11+ pub trait Tr { fn method ( & self ) ; }
12+ impl Tr for crate :: S { fn method ( & self ) { } }
13+ }
Original file line number Diff line number Diff line change 1+ /* This crate declares an item that is unnamed.
2+ * Its only public path is through `prelude::*`. */
3+
4+ pub struct S ;
5+
6+ mod m {
7+ pub trait Tr { fn method ( & self ) ; }
8+ impl Tr for crate :: S { fn method ( & self ) { } }
9+ }
10+
11+ pub mod prelude {
12+ pub use crate :: m:: Tr as _;
13+ }
Original file line number Diff line number Diff line change 1+ // aux-build:overlapping_pub_trait_source.rs
2+
3+ /*
4+ * This crate declares two public paths, `m::Tr` and `prelude::_`. Make sure we prefer the former.
5+ */
6+ extern crate overlapping_pub_trait_source;
7+
8+ fn main ( ) {
9+ //~^ HELP the following trait is implemented but not in scope; perhaps add a `use` for it:
10+ //~| SUGGESTION overlapping_pub_trait_source::prelude::_
11+ use overlapping_pub_trait_source:: S ;
12+ S . method ( ) ;
13+ //~^ ERROR no method named `method` found for struct `S` in the current scope [E0599]
14+ //~| HELP items from traits can only be used if the trait is in scope
15+ }
Original file line number Diff line number Diff line change 1+ error[E0599]: no method named `method` found for struct `S` in the current scope
2+ --> $DIR/overlapping_pub_trait.rs:12:7
3+ |
4+ LL | S.method();
5+ | ^^^^^^ method not found in `S`
6+ |
7+ ::: $DIR/auxiliary/overlapping_pub_trait_source.rs:11:23
8+ |
9+ LL | pub trait Tr { fn method(&self); }
10+ | ------ the method is available for `S` here
11+ |
12+ = help: items from traits can only be used if the trait is in scope
13+ help: the following trait is implemented but not in scope; perhaps add a `use` for it:
14+ |
15+ LL | use overlapping_pub_trait_source::prelude::_;
16+ |
17+
18+ error: aborting due to previous error
19+
20+ For more information about this error, try `rustc --explain E0599`.
Original file line number Diff line number Diff line change 1+ // aux-build:unnamed_pub_trait_source.rs
2+
3+ /*
4+ * This crate declares an unnameable public path for our item. Make sure we don't suggest
5+ * importing it by name, and instead we suggest importing it by glob.
6+ */
7+ extern crate unnamed_pub_trait_source;
8+
9+ fn main ( ) {
10+ //~^ HELP the following trait is implemented but not in scope; perhaps add a `use` for it:
11+ //~| SUGGESTION unnamed_pub_trait_source::prelude::_
12+ use unnamed_pub_trait_source:: S ;
13+ S . method ( ) ;
14+ //~^ ERROR no method named `method` found for struct `S` in the current scope [E0599]
15+ //~| HELP items from traits can only be used if the trait is in scope
16+ }
Original file line number Diff line number Diff line change 1+ error[E0599]: no method named `method` found for struct `S` in the current scope
2+ --> $DIR/unnamed_pub_trait.rs:13:7
3+ |
4+ LL | S.method();
5+ | ^^^^^^ method not found in `S`
6+ |
7+ ::: $DIR/auxiliary/unnamed_pub_trait_source.rs:7:23
8+ |
9+ LL | pub trait Tr { fn method(&self); }
10+ | ------ the method is available for `S` here
11+ |
12+ = help: items from traits can only be used if the trait is in scope
13+ help: the following trait is implemented but not in scope; perhaps add a `use` for it:
14+ |
15+ LL | use unnamed_pub_trait_source::prelude::_;
16+ |
17+
18+ error: aborting due to previous error
19+
20+ For more information about this error, try `rustc --explain E0599`.
You can’t perform that action at this time.
0 commit comments