Skip to content

Commit f70847a

Browse files
authored
Rollup merge of rust-lang#67677 - petrochenkov:dupexp, r=Centril
resolve: Minor cleanup of duplicate macro reexports Enabled by rust-lang#65785 which changed `duplicate_macro_exports` from a lint to a hard error.
2 parents 047a4bb + a0d8b79 commit f70847a

File tree

3 files changed

+9
-33
lines changed

3 files changed

+9
-33
lines changed

src/librustc_resolve/resolve_imports.rs

+1-25
Original file line numberDiff line numberDiff line change
@@ -528,31 +528,7 @@ impl<'a> Resolver<'a> {
528528
resolution.shadowed_glob = Some(glob_binding);
529529
}
530530
(false, false) => {
531-
if let (&NameBindingKind::Res(_, true), &NameBindingKind::Res(_, true)) =
532-
(&old_binding.kind, &binding.kind)
533-
{
534-
this.session
535-
.struct_span_err(
536-
binding.span,
537-
&format!(
538-
"a macro named `{}` has already been exported",
539-
key.ident
540-
),
541-
)
542-
.span_label(
543-
binding.span,
544-
format!("`{}` already exported", key.ident),
545-
)
546-
.span_note(
547-
old_binding.span,
548-
"previous macro export is now shadowed",
549-
)
550-
.emit();
551-
552-
resolution.binding = Some(binding);
553-
} else {
554-
return Err(old_binding);
555-
}
531+
return Err(old_binding);
556532
}
557533
}
558534
} else {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
macro_rules! foo { ($i:ident) => {} }
33

44
#[macro_export]
5-
macro_rules! foo { () => {} } //~ ERROR a macro named `foo` has already been exported
5+
macro_rules! foo { () => {} } //~ ERROR the name `foo` is defined multiple times
66

77
fn main() {}

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
error: a macro named `foo` has already been exported
1+
error[E0428]: the name `foo` is defined multiple times
22
--> $DIR/issue-38715.rs:5:1
33
|
4+
LL | macro_rules! foo { ($i:ident) => {} }
5+
| ---------------- previous definition of the macro `foo` here
6+
...
47
LL | macro_rules! foo { () => {} }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `foo` already exported
6-
|
7-
note: previous macro export is now shadowed
8-
--> $DIR/issue-38715.rs:2:1
8+
| ^^^^^^^^^^^^^^^^ `foo` redefined here
99
|
10-
LL | macro_rules! foo { ($i:ident) => {} }
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
= note: `foo` must be defined only once in the macro namespace of this module
1211

1312
error: aborting due to previous error
1413

14+
For more information about this error, try `rustc --explain E0428`.

0 commit comments

Comments
 (0)