Skip to content

Commit ac4b685

Browse files
mockersfpetrochenkov
authored andcommitted
#56411 do not suggest a fix for a import conflict in a macro
1 parent 0b1669d commit ac4b685

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed

src/librustc_resolve/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -5147,11 +5147,13 @@ impl<'a> Resolver<'a> {
51475147
if let (
51485148
Ok(snippet),
51495149
NameBindingKind::Import { directive, ..},
5150-
_dummy @ false,
5150+
false,
5151+
false,
51515152
) = (
51525153
cm.span_to_snippet(binding.span),
51535154
binding.kind.clone(),
51545155
binding.span.is_dummy(),
5156+
binding.span.ctxt().outer().expn_info().is_some(),
51555157
) {
51565158
let suggested_name = if name.as_str().chars().next().unwrap().is_uppercase() {
51575159
format!("Other{}", name)

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

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
macro_rules! import {
2+
( $($name:ident),* ) => {
3+
$(
4+
mod $name;
5+
pub use self::$name;
6+
//~^ ERROR the name `issue_56411` is defined multiple times
7+
//~| ERROR `issue_56411` is private, and cannot be re-exported
8+
9+
)*
10+
}
11+
}
12+
13+
import!(issue_56411);
14+
15+
fn main() {
16+
println!("Hello, world!");
17+
}

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

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
error[E0255]: the name `issue_56411` is defined multiple times
2+
--> $DIR/issue-56411.rs:5:21
3+
|
4+
LL | mod $name;
5+
| ---------- previous definition of the module `issue_56411` here
6+
LL | pub use self::$name;
7+
| ^^^^^^^^^^^
8+
| |
9+
| `issue_56411` reimported here
10+
| you can use `as` to change the binding name of the import
11+
...
12+
LL | import!(issue_56411);
13+
| --------------------- in this macro invocation
14+
|
15+
= note: `issue_56411` must be defined only once in the type namespace of this module
16+
17+
error[E0365]: `issue_56411` is private, and cannot be re-exported
18+
--> $DIR/issue-56411.rs:5:21
19+
|
20+
LL | pub use self::$name;
21+
| ^^^^^^^^^^^ re-export of private `issue_56411`
22+
...
23+
LL | import!(issue_56411);
24+
| --------------------- in this macro invocation
25+
|
26+
= note: consider declaring type or module `issue_56411` with `pub`
27+
28+
error: aborting due to 2 previous errors
29+
30+
Some errors occurred: E0255, E0365.
31+
For more information about an error, try `rustc --explain E0255`.

src/test/ui/issues/issue_56411.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// compile-pass
2+
3+
struct T {}
4+
5+
fn main() {}

0 commit comments

Comments
 (0)