Skip to content

Commit 2bebdf0

Browse files
committed
add test
1 parent bc74d2b commit 2bebdf0

File tree

4 files changed

+81
-17
lines changed

4 files changed

+81
-17
lines changed
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
//@ edition: 2021
22

3-
pub trait Foo {
4-
fn foo();
3+
pub trait TraitA {
4+
fn a();
5+
}
6+
7+
pub trait TraitB {
8+
fn b();
9+
}
10+
11+
pub trait TraitC {
12+
fn c();
513
}

tests/ui/typeck/auxiliary/suggest-trait-reexported-as-not-doc-visible-b.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,28 @@
22
//@ edition: 2021
33
//@ aux-crate:suggest_trait_reexported_as_not_doc_visible_a=suggest-trait-reexported-as-not-doc-visible-a.rs
44

5-
pub struct Bar;
6-
7-
impl __DocHidden::Foo for Bar {
8-
fn foo() {}
9-
}
5+
#[doc(hidden)]
6+
pub use suggest_trait_reexported_as_not_doc_visible_a::TraitA;
107

118
#[doc(hidden)]
129
pub mod __DocHidden {
13-
pub use suggest_trait_reexported_as_not_doc_visible_a::Foo;
10+
pub use suggest_trait_reexported_as_not_doc_visible_a::TraitB;
11+
12+
pub mod Inner {
13+
pub use suggest_trait_reexported_as_not_doc_visible_a::TraitC;
14+
}
15+
}
16+
17+
impl suggest_trait_reexported_as_not_doc_visible_a::TraitA for Foo {
18+
fn a() {}
1419
}
20+
21+
impl __DocHidden::TraitB for Foo {
22+
fn b() {}
23+
}
24+
25+
impl __DocHidden::Inner::TraitC for Foo {
26+
fn c() {}
27+
}
28+
29+
pub struct Foo;

tests/ui/typeck/suggest-trait-reexported-as-not-doc-visible.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
//@ aux-crate:suggest_trait_reexported_as_not_doc_visible_a=suggest-trait-reexported-as-not-doc-visible-a.rs
44
//@ aux-crate:suggest_trait_reexported_as_not_doc_visible_b=suggest-trait-reexported-as-not-doc-visible-b.rs
55

6-
use suggest_trait_reexported_as_not_doc_visible_b::Bar;
6+
use suggest_trait_reexported_as_not_doc_visible_b::Foo;
77

88
fn main() {
9-
Bar::foo();
10-
//~^ ERROR: no function or associated item named `foo` found for struct `Bar` in the current scope [E0599]
9+
Foo::a();
10+
//~ no function or associated item named `a` found for struct `Foo` in the current scope [E0599]
11+
Foo::b();
12+
Foo::c();
1113
}
Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,54 @@
1-
error[E0599]: no function or associated item named `foo` found for struct `Bar` in the current scope
1+
error[E0599]: no function or associated item named `a` found for struct `Foo` in the current scope
22
--> $DIR/suggest-trait-reexported-as-not-doc-visible.rs:9:10
33
|
4-
LL | Bar::foo();
5-
| ^^^ function or associated item not found in `Bar`
4+
LL | Foo::a();
5+
| ^ function or associated item not found in `Foo`
66
|
77
= help: items from traits can only be used if the trait is in scope
8-
help: trait `Foo` which provides `foo` is implemented but not in scope; perhaps you want to import it
8+
help: trait `TraitA` which provides `a` is implemented but not in scope; perhaps you want to import it
99
|
10-
LL + use suggest_trait_reexported_as_not_doc_visible_a::Foo;
10+
LL + use suggest_trait_reexported_as_not_doc_visible_b::TraitA;
11+
|
12+
help: there is an associated function `b` with a similar name
13+
|
14+
LL - Foo::a();
15+
LL + Foo::b();
16+
|
17+
18+
error[E0599]: no function or associated item named `b` found for struct `Foo` in the current scope
19+
--> $DIR/suggest-trait-reexported-as-not-doc-visible.rs:10:10
20+
|
21+
LL | Foo::b();
22+
| ^ function or associated item not found in `Foo`
23+
|
24+
= help: items from traits can only be used if the trait is in scope
25+
help: trait `TraitB` which provides `b` is implemented but not in scope; perhaps you want to import it
26+
|
27+
LL + use suggest_trait_reexported_as_not_doc_visible_a::TraitB;
28+
|
29+
help: there is an associated function `a` with a similar name
30+
|
31+
LL - Foo::b();
32+
LL + Foo::a();
33+
|
34+
35+
error[E0599]: no function or associated item named `c` found for struct `Foo` in the current scope
36+
--> $DIR/suggest-trait-reexported-as-not-doc-visible.rs:11:10
37+
|
38+
LL | Foo::c();
39+
| ^ function or associated item not found in `Foo`
40+
|
41+
= help: items from traits can only be used if the trait is in scope
42+
help: trait `TraitC` which provides `c` is implemented but not in scope; perhaps you want to import it
43+
|
44+
LL + use suggest_trait_reexported_as_not_doc_visible_a::TraitC;
45+
|
46+
help: there is an associated function `a` with a similar name
47+
|
48+
LL - Foo::c();
49+
LL + Foo::a();
1150
|
1251

13-
error: aborting due to 1 previous error
52+
error: aborting due to 3 previous errors
1453

1554
For more information about this error, try `rustc --explain E0599`.

0 commit comments

Comments
 (0)