Skip to content

Commit f9f1f24

Browse files
committed
add regression tests
1 parent ac6f3a3 commit f9f1f24

3 files changed

Lines changed: 170 additions & 2 deletions

tests/ui/imports/private-import-suggestion-path-156244.edition_2015.stderr

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,71 @@ LL - use crate::rename::inner::Item as Item1;
7676
LL + use outer::actual::Item as Item1;
7777
|
7878

79-
error: aborting due to 4 previous errors
79+
error[E0603]: struct import `Hi` is private
80+
--> $DIR/private-import-suggestion-path-156244.rs:51:14
81+
|
82+
LL | use testing::Hi;
83+
| ^^ private struct import
84+
|
85+
note: the struct import `Hi` is defined here...
86+
--> $DIR/private-import-suggestion-path-156244.rs:48:9
87+
|
88+
LL | use super::public::Hi;
89+
| ^^^^^^^^^^^^^^^^^
90+
note: ...and refers to the struct `Hi` which is defined here
91+
--> $DIR/private-import-suggestion-path-156244.rs:44:5
92+
|
93+
LL | pub struct Hi;
94+
| ^^^^^^^^^^^^^^ you could import this directly
95+
help: import `Hi` directly
96+
|
97+
LL - use testing::Hi;
98+
LL + use super::public::Hi;
99+
|
100+
101+
error[E0603]: struct import `Hi` is private
102+
--> $DIR/private-import-suggestion-path-156244.rs:67:37
103+
|
104+
LL | use inaccessible_ancestor::testing::Hi;
105+
| ^^ private struct import
106+
|
107+
note: the struct import `Hi` is defined here...
108+
--> $DIR/private-import-suggestion-path-156244.rs:63:13
109+
|
110+
LL | use super::private::public::Hi;
111+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
112+
note: ...and refers to the struct `Hi` which is defined here
113+
--> $DIR/private-import-suggestion-path-156244.rs:58:13
114+
|
115+
LL | pub struct Hi;
116+
| ^^^^^^^^^^^^^^ you could import this directly
117+
help: import `Hi` directly
118+
|
119+
LL - use inaccessible_ancestor::testing::Hi;
120+
LL + use super::private::public::Hi;
121+
|
122+
123+
error[E0603]: module import `mem` is private
124+
--> $DIR/private-import-suggestion-path-156244.rs:77:21
125+
|
126+
LL | use external_alias::mem;
127+
| ^^^ private module import
128+
|
129+
note: the module import `mem` is defined here...
130+
--> $DIR/private-import-suggestion-path-156244.rs:74:9
131+
|
132+
LL | use super::s::mem;
133+
| ^^^^^^^^^^^^^
134+
note: ...and refers to the module `mem` which is defined here
135+
--> $SRC_DIR/std/src/lib.rs:LL:COL
136+
|
137+
= note: you could import this directly
138+
help: import `mem` directly
139+
|
140+
LL - use external_alias::mem;
141+
LL + use core::mem;
142+
|
143+
144+
error: aborting due to 7 previous errors
80145

81146
For more information about this error, try `rustc --explain E0603`.

tests/ui/imports/private-import-suggestion-path-156244.edition_2018.stderr

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,71 @@ LL - use crate::rename::inner::Item as Item1;
7676
LL + use crate::outer::actual::Item as Item1;
7777
|
7878

79-
error: aborting due to 4 previous errors
79+
error[E0603]: struct import `Hi` is private
80+
--> $DIR/private-import-suggestion-path-156244.rs:51:14
81+
|
82+
LL | use testing::Hi;
83+
| ^^ private struct import
84+
|
85+
note: the struct import `Hi` is defined here...
86+
--> $DIR/private-import-suggestion-path-156244.rs:48:9
87+
|
88+
LL | use super::public::Hi;
89+
| ^^^^^^^^^^^^^^^^^
90+
note: ...and refers to the struct `Hi` which is defined here
91+
--> $DIR/private-import-suggestion-path-156244.rs:44:5
92+
|
93+
LL | pub struct Hi;
94+
| ^^^^^^^^^^^^^^ you could import this directly
95+
help: import `Hi` directly
96+
|
97+
LL - use testing::Hi;
98+
LL + use super::public::Hi;
99+
|
100+
101+
error[E0603]: struct import `Hi` is private
102+
--> $DIR/private-import-suggestion-path-156244.rs:67:37
103+
|
104+
LL | use inaccessible_ancestor::testing::Hi;
105+
| ^^ private struct import
106+
|
107+
note: the struct import `Hi` is defined here...
108+
--> $DIR/private-import-suggestion-path-156244.rs:63:13
109+
|
110+
LL | use super::private::public::Hi;
111+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
112+
note: ...and refers to the struct `Hi` which is defined here
113+
--> $DIR/private-import-suggestion-path-156244.rs:58:13
114+
|
115+
LL | pub struct Hi;
116+
| ^^^^^^^^^^^^^^ you could import this directly
117+
help: import `Hi` directly
118+
|
119+
LL - use inaccessible_ancestor::testing::Hi;
120+
LL + use super::private::public::Hi;
121+
|
122+
123+
error[E0603]: module import `mem` is private
124+
--> $DIR/private-import-suggestion-path-156244.rs:77:21
125+
|
126+
LL | use external_alias::mem;
127+
| ^^^ private module import
128+
|
129+
note: the module import `mem` is defined here...
130+
--> $DIR/private-import-suggestion-path-156244.rs:74:9
131+
|
132+
LL | use super::s::mem;
133+
| ^^^^^^^^^^^^^
134+
note: ...and refers to the module `mem` which is defined here
135+
--> $SRC_DIR/std/src/lib.rs:LL:COL
136+
|
137+
= note: you could import this directly
138+
help: import `mem` directly
139+
|
140+
LL - use external_alias::mem;
141+
LL + use core::mem;
142+
|
143+
144+
error: aborting due to 7 previous errors
80145

81146
For more information about this error, try `rustc --explain E0603`.

tests/ui/imports/private-import-suggestion-path-156244.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,42 @@ mod bad {
3939
//~^ ERROR module import `inner` is private [E0603]
4040
}
4141

42+
// Regression test for https://github.com/rust-lang/rust/issues/157455: no root `super`.
43+
mod public {
44+
pub struct Hi;
45+
}
46+
47+
mod testing {
48+
use super::public::Hi;
49+
}
50+
51+
use testing::Hi;
52+
//~^ ERROR struct import `Hi` is private [E0603]
53+
54+
// Regression test for https://github.com/rust-lang/rust/issues/157455: no private ancestors.
55+
mod inaccessible_ancestor {
56+
mod private {
57+
pub mod public {
58+
pub struct Hi;
59+
}
60+
}
61+
62+
pub mod testing {
63+
use super::private::public::Hi;
64+
}
65+
}
66+
67+
use inaccessible_ancestor::testing::Hi;
68+
//~^ ERROR struct import `Hi` is private [E0603]
69+
70+
// Regression test for https://github.com/rust-lang/rust/issues/157455: no external alias rewrite.
71+
use std as s;
72+
73+
mod external_alias {
74+
use super::s::mem;
75+
}
76+
77+
use external_alias::mem;
78+
//~^ ERROR module import `mem` is private [E0603]
79+
4280
fn main() {}

0 commit comments

Comments
 (0)