diff options
| author | Dan Aloni <alonid@gmail.com> | 2020-06-27 21:08:32 +0300 |
|---|---|---|
| committer | Dan Aloni <alonid@gmail.com> | 2020-06-29 23:32:31 +0300 |
| commit | aab37fe52c0f142d116fee67d6eddedc7825dcc7 (patch) | |
| tree | b27d55575ecbff1f92ec4b576fbdf6147a1771f8 | |
| parent | 0ca7f74dbd23a3e8ec491cd3438f490a3ac22741 (diff) | |
| download | rust-aab37fe52c0f142d116fee67d6eddedc7825dcc7.tar.gz rust-aab37fe52c0f142d116fee67d6eddedc7825dcc7.zip | |
Add test for issue #56175
| -rw-r--r-- | src/test/ui/issues/auxiliary/reexported-trait.rs | 17 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-56175.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-56175.stderr | 27 |
3 files changed, 53 insertions, 0 deletions
diff --git a/src/test/ui/issues/auxiliary/reexported-trait.rs b/src/test/ui/issues/auxiliary/reexported-trait.rs new file mode 100644 index 00000000000..51a991bef59 --- /dev/null +++ b/src/test/ui/issues/auxiliary/reexported-trait.rs @@ -0,0 +1,17 @@ +mod private { + pub trait Trait { + fn trait_method(&self) { + } + } + pub trait TraitB { + fn trait_method_b(&self) { + } + } +} + +pub struct FooStruct; +pub use crate::private::Trait; +impl crate::private::Trait for FooStruct {} + +pub use crate::private::TraitB as TraitBRename; +impl crate::private::TraitB for FooStruct {} diff --git a/src/test/ui/issues/issue-56175.rs b/src/test/ui/issues/issue-56175.rs new file mode 100644 index 00000000000..ca1d0d4310a --- /dev/null +++ b/src/test/ui/issues/issue-56175.rs @@ -0,0 +1,9 @@ +// edition:2018 +// aux-crate:reexported_trait=reexported-trait.rs + +fn main() { + reexported_trait::FooStruct.trait_method(); + //~^ ERROR + reexported_trait::FooStruct.trait_method_b(); + //~^ ERROR +} diff --git a/src/test/ui/issues/issue-56175.stderr b/src/test/ui/issues/issue-56175.stderr new file mode 100644 index 00000000000..dc5beb4271d --- /dev/null +++ b/src/test/ui/issues/issue-56175.stderr @@ -0,0 +1,27 @@ +error[E0599]: no method named `trait_method` found for struct `reexported_trait::FooStruct` in the current scope + --> $DIR/issue-56175.rs:5:33 + | +LL | reexported_trait::FooStruct.trait_method(); + | ^^^^^^^^^^^^ method not found in `reexported_trait::FooStruct` + | + = 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 reexported_trait::private::Trait; + | + +error[E0599]: no method named `trait_method_b` found for struct `reexported_trait::FooStruct` in the current scope + --> $DIR/issue-56175.rs:7:33 + | +LL | reexported_trait::FooStruct.trait_method_b(); + | ^^^^^^^^^^^^^^ method not found in `reexported_trait::FooStruct` + | + = 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 reexported_trait::private::TraitB; + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0599`. |
