Skip to content

Commit aab37fe

Browse files
committed
Add test for issue rust-lang#56175
1 parent 0ca7f74 commit aab37fe

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
mod private {
2+
pub trait Trait {
3+
fn trait_method(&self) {
4+
}
5+
}
6+
pub trait TraitB {
7+
fn trait_method_b(&self) {
8+
}
9+
}
10+
}
11+
12+
pub struct FooStruct;
13+
pub use crate::private::Trait;
14+
impl crate::private::Trait for FooStruct {}
15+
16+
pub use crate::private::TraitB as TraitBRename;
17+
impl crate::private::TraitB for FooStruct {}

src/test/ui/issues/issue-56175.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// edition:2018
2+
// aux-crate:reexported_trait=reexported-trait.rs
3+
4+
fn main() {
5+
reexported_trait::FooStruct.trait_method();
6+
//~^ ERROR
7+
reexported_trait::FooStruct.trait_method_b();
8+
//~^ ERROR
9+
}

src/test/ui/issues/issue-56175.stderr

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
error[E0599]: no method named `trait_method` found for struct `reexported_trait::FooStruct` in the current scope
2+
--> $DIR/issue-56175.rs:5:33
3+
|
4+
LL | reexported_trait::FooStruct.trait_method();
5+
| ^^^^^^^^^^^^ method not found in `reexported_trait::FooStruct`
6+
|
7+
= help: items from traits can only be used if the trait is in scope
8+
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
9+
|
10+
LL | use reexported_trait::private::Trait;
11+
|
12+
13+
error[E0599]: no method named `trait_method_b` found for struct `reexported_trait::FooStruct` in the current scope
14+
--> $DIR/issue-56175.rs:7:33
15+
|
16+
LL | reexported_trait::FooStruct.trait_method_b();
17+
| ^^^^^^^^^^^^^^ method not found in `reexported_trait::FooStruct`
18+
|
19+
= help: items from traits can only be used if the trait is in scope
20+
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
21+
|
22+
LL | use reexported_trait::private::TraitB;
23+
|
24+
25+
error: aborting due to 2 previous errors
26+
27+
For more information about this error, try `rustc --explain E0599`.

0 commit comments

Comments
 (0)