Test for issue-86035
This commit is contained in:
parent
99b0799608
commit
48dab5c960
6 changed files with 97 additions and 0 deletions
|
@ -0,0 +1,13 @@
|
|||
/* This crate declares an item as both `prelude::*` and `m::Tr`.
|
||||
* The compiler should always suggest `m::Tr`. */
|
||||
|
||||
pub struct S;
|
||||
|
||||
pub mod prelude {
|
||||
pub use crate::m::Tr as _;
|
||||
}
|
||||
|
||||
pub mod m {
|
||||
pub trait Tr { fn method(&self); }
|
||||
impl Tr for crate::S { fn method(&self) {} }
|
||||
}
|
13
src/test/ui/imports/auxiliary/unnamed_pub_trait_source.rs
Normal file
13
src/test/ui/imports/auxiliary/unnamed_pub_trait_source.rs
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* This crate declares an item that is unnamed.
|
||||
* Its only public path is through `prelude::*`. */
|
||||
|
||||
pub struct S;
|
||||
|
||||
mod m {
|
||||
pub trait Tr { fn method(&self); }
|
||||
impl Tr for crate::S { fn method(&self) {} }
|
||||
}
|
||||
|
||||
pub mod prelude {
|
||||
pub use crate::m::Tr as _;
|
||||
}
|
15
src/test/ui/imports/overlapping_pub_trait.rs
Normal file
15
src/test/ui/imports/overlapping_pub_trait.rs
Normal file
|
@ -0,0 +1,15 @@
|
|||
// aux-build:overlapping_pub_trait_source.rs
|
||||
|
||||
/*
|
||||
* This crate declares two public paths, `m::Tr` and `prelude::_`. Make sure we prefer the former.
|
||||
*/
|
||||
extern crate overlapping_pub_trait_source;
|
||||
|
||||
fn main() {
|
||||
//~^ HELP the following trait is implemented but not in scope; perhaps add a `use` for it:
|
||||
//~| SUGGESTION overlapping_pub_trait_source::prelude::_
|
||||
use overlapping_pub_trait_source::S;
|
||||
S.method();
|
||||
//~^ ERROR no method named `method` found for struct `S` in the current scope [E0599]
|
||||
//~| HELP items from traits can only be used if the trait is in scope
|
||||
}
|
20
src/test/ui/imports/overlapping_pub_trait.stderr
Normal file
20
src/test/ui/imports/overlapping_pub_trait.stderr
Normal file
|
@ -0,0 +1,20 @@
|
|||
error[E0599]: no method named `method` found for struct `S` in the current scope
|
||||
--> $DIR/overlapping_pub_trait.rs:12:7
|
||||
|
|
||||
LL | S.method();
|
||||
| ^^^^^^ method not found in `S`
|
||||
|
|
||||
::: $DIR/auxiliary/overlapping_pub_trait_source.rs:11:23
|
||||
|
|
||||
LL | pub trait Tr { fn method(&self); }
|
||||
| ------ the method is available for `S` here
|
||||
|
|
||||
= help: items from traits can only be used if the trait is in scope
|
||||
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
||||
|
|
||||
LL | use overlapping_pub_trait_source::prelude::_;
|
||||
|
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0599`.
|
16
src/test/ui/imports/unnamed_pub_trait.rs
Normal file
16
src/test/ui/imports/unnamed_pub_trait.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
// aux-build:unnamed_pub_trait_source.rs
|
||||
|
||||
/*
|
||||
* This crate declares an unnameable public path for our item. Make sure we don't suggest
|
||||
* importing it by name, and instead we suggest importing it by glob.
|
||||
*/
|
||||
extern crate unnamed_pub_trait_source;
|
||||
|
||||
fn main() {
|
||||
//~^ HELP the following trait is implemented but not in scope; perhaps add a `use` for it:
|
||||
//~| SUGGESTION unnamed_pub_trait_source::prelude::_
|
||||
use unnamed_pub_trait_source::S;
|
||||
S.method();
|
||||
//~^ ERROR no method named `method` found for struct `S` in the current scope [E0599]
|
||||
//~| HELP items from traits can only be used if the trait is in scope
|
||||
}
|
20
src/test/ui/imports/unnamed_pub_trait.stderr
Normal file
20
src/test/ui/imports/unnamed_pub_trait.stderr
Normal file
|
@ -0,0 +1,20 @@
|
|||
error[E0599]: no method named `method` found for struct `S` in the current scope
|
||||
--> $DIR/unnamed_pub_trait.rs:13:7
|
||||
|
|
||||
LL | S.method();
|
||||
| ^^^^^^ method not found in `S`
|
||||
|
|
||||
::: $DIR/auxiliary/unnamed_pub_trait_source.rs:7:23
|
||||
|
|
||||
LL | pub trait Tr { fn method(&self); }
|
||||
| ------ the method is available for `S` here
|
||||
|
|
||||
= help: items from traits can only be used if the trait is in scope
|
||||
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
||||
|
|
||||
LL | use unnamed_pub_trait_source::prelude::_;
|
||||
|
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0599`.
|
Loading…
Add table
Reference in a new issue