Skip to content

Commit 300b6bb

Browse files
committed
Remove macro_reexport
It's subsumed by `feature(use_extern_macros)` and `pub use`
1 parent a4a7947 commit 300b6bb

25 files changed

+252
-677
lines changed

src/librustc_resolve/build_reduced_graph.rs

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ impl<'a> ToNameBinding<'a> for (Def, ty::Visibility, Span, Mark) {
7171
struct LegacyMacroImports {
7272
import_all: Option<Span>,
7373
imports: Vec<(Name, Span)>,
74-
reexports: Vec<(Name, Span)>,
7574
}
7675

7776
impl<'a> Resolver<'a> {
@@ -621,7 +620,7 @@ impl<'a> Resolver<'a> {
621620
let legacy_imports = self.legacy_macro_imports(&item.attrs);
622621
let mut used = legacy_imports != LegacyMacroImports::default();
623622

624-
// `#[macro_use]` and `#[macro_reexport]` are only allowed at the crate root.
623+
// `#[macro_use]` is only allowed at the crate root.
625624
if self.current_module.parent.is_some() && used {
626625
span_err!(self.session, item.span, E0468,
627626
"an `extern crate` loading macros must be at the crate root");
@@ -669,17 +668,6 @@ impl<'a> Resolver<'a> {
669668
}
670669
}
671670
}
672-
for (name, span) in legacy_imports.reexports {
673-
self.cstore.export_macros_untracked(module.def_id().unwrap().krate);
674-
let ident = Ident::with_empty_ctxt(name);
675-
let result = self.resolve_ident_in_module(module, ident, MacroNS, false, false, span);
676-
if let Ok(binding) = result {
677-
let (def, vis) = (binding.def(), binding.vis);
678-
self.macro_exports.push(Export { ident, def, vis, span, is_import: true });
679-
} else {
680-
span_err!(self.session, span, E0470, "re-exported macro not found");
681-
}
682-
}
683671
used
684672
}
685673

@@ -721,21 +709,6 @@ impl<'a> Resolver<'a> {
721709
},
722710
None => imports.import_all = Some(attr.span),
723711
}
724-
} else if attr.check_name("macro_reexport") {
725-
let bad_macro_reexport = |this: &mut Self, span| {
726-
span_err!(this.session, span, E0467, "bad macro re-export");
727-
};
728-
if let Some(names) = attr.meta_item_list() {
729-
for attr in names {
730-
if let Some(word) = attr.word() {
731-
imports.reexports.push((word.ident.name, attr.span()));
732-
} else {
733-
bad_macro_reexport(self, attr.span());
734-
}
735-
}
736-
} else {
737-
bad_macro_reexport(self, attr.span());
738-
}
739712
}
740713
}
741714
imports

src/librustc_resolve/diagnostics.rs

Lines changed: 2 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,35 +1395,6 @@ If you would like to import all exported macros, write `macro_use` with no
13951395
arguments.
13961396
"##,
13971397

1398-
E0467: r##"
1399-
Macro re-export declarations were empty or malformed.
1400-
1401-
Erroneous code examples:
1402-
1403-
```compile_fail,E0467
1404-
#[macro_reexport] // error: no macros listed for export
1405-
extern crate core as macros_for_good;
1406-
1407-
#[macro_reexport(fun_macro = "foo")] // error: not a macro identifier
1408-
extern crate core as other_macros_for_good;
1409-
```
1410-
1411-
This is a syntax error at the level of attribute declarations.
1412-
1413-
Currently, `macro_reexport` requires at least one macro name to be listed.
1414-
Unlike `macro_use`, listing no names does not re-export all macros from the
1415-
given crate.
1416-
1417-
Decide which macros you would like to export and list them properly.
1418-
1419-
These are proper re-export declarations:
1420-
1421-
```ignore (cannot-doctest-multicrate-project)
1422-
#[macro_reexport(some_macro, another_macro)]
1423-
extern crate macros_for_good;
1424-
```
1425-
"##,
1426-
14271398
E0468: r##"
14281399
A non-root module attempts to import macros from another crate.
14291400
@@ -1496,48 +1467,6 @@ extern crate some_crate; //ok!
14961467
```
14971468
"##,
14981469

1499-
E0470: r##"
1500-
A macro listed for re-export was not found.
1501-
1502-
Erroneous code example:
1503-
1504-
```compile_fail,E0470
1505-
#[macro_reexport(drink, be_merry)]
1506-
extern crate alloc;
1507-
1508-
fn main() {
1509-
// ...
1510-
}
1511-
```
1512-
1513-
Either the listed macro is not contained in the imported crate, or it is not
1514-
exported from the given crate.
1515-
1516-
This could be caused by a typo. Did you misspell the macro's name?
1517-
1518-
Double-check the names of the macros listed for re-export, and that the crate
1519-
in question exports them.
1520-
1521-
A working version:
1522-
1523-
```ignore (cannot-doctest-multicrate-project)
1524-
// In some_crate crate:
1525-
#[macro_export]
1526-
macro_rules! eat {
1527-
...
1528-
}
1529-
1530-
#[macro_export]
1531-
macro_rules! drink {
1532-
...
1533-
}
1534-
1535-
// In your_crate:
1536-
#[macro_reexport(eat, drink)]
1537-
extern crate some_crate;
1538-
```
1539-
"##,
1540-
15411470
E0530: r##"
15421471
A binding shadowed something it shouldn't.
15431472
@@ -1715,6 +1644,8 @@ register_diagnostics! {
17151644
// E0421, merged into 531
17161645
E0531, // unresolved pattern path kind `name`
17171646
// E0427, merged into 530
1647+
// E0467, removed
1648+
// E0470, removed
17181649
E0573,
17191650
E0574,
17201651
E0575,

src/librustdoc/visit_ast.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ pub struct RustdocVisitor<'a, 'tcx: 'a, 'rcx: 'a> {
4949
inlining: bool,
5050
/// Is the current module and all of its parents public?
5151
inside_public_path: bool,
52-
reexported_macros: FxHashSet<DefId>,
5352
exact_paths: Option<FxHashMap<DefId, Vec<String>>>,
5453
}
5554

@@ -66,7 +65,6 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
6665
view_item_stack: stack,
6766
inlining: false,
6867
inside_public_path: true,
69-
reexported_macros: FxHashSet(),
7068
exact_paths: Some(FxHashMap()),
7169
cstore,
7270
}
@@ -221,7 +219,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
221219
if let Some(exports) = self.cx.tcx.module_exports(def_id) {
222220
for export in exports.iter().filter(|e| e.vis == Visibility::Public) {
223221
if let Def::Macro(def_id, ..) = export.def {
224-
if def_id.krate == LOCAL_CRATE || self.reexported_macros.contains(&def_id) {
222+
if def_id.krate == LOCAL_CRATE {
225223
continue // These are `krate.exported_macros`, handled in `self.visit()`.
226224
}
227225

@@ -298,17 +296,6 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
298296
let is_no_inline = use_attrs.lists("doc").has_word("no_inline") ||
299297
use_attrs.lists("doc").has_word("hidden");
300298

301-
// Memoize the non-inlined `pub use`'d macros so we don't push an extra
302-
// declaration in `visit_mod_contents()`
303-
if !def_did.is_local() {
304-
if let Def::Macro(did, _) = def {
305-
if please_inline { return true }
306-
debug!("memoizing non-inlined macro export: {:?}", def);
307-
self.reexported_macros.insert(did);
308-
return false;
309-
}
310-
}
311-
312299
// For cross-crate impl inlining we need to know whether items are
313300
// reachable in documentation - a previously nonreachable item can be
314301
// made reachable by cross-crate inlining which we're checking here.

src/libstd/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@
273273
#![feature(libc)]
274274
#![feature(link_args)]
275275
#![feature(linkage)]
276-
#![feature(macro_reexport)]
277276
#![feature(macro_vis_matcher)]
278277
#![feature(needs_panic_runtime)]
279278
#![feature(never_type)]
@@ -313,6 +312,7 @@
313312
#![feature(unboxed_closures)]
314313
#![feature(untagged_unions)]
315314
#![feature(unwind_attributes)]
315+
#![feature(use_extern_macros)]
316316
#![feature(vec_push_all)]
317317
#![feature(doc_cfg)]
318318
#![feature(doc_masked)]
@@ -347,15 +347,13 @@ use prelude::v1::*;
347347
#[cfg(test)] extern crate test;
348348
#[cfg(test)] extern crate rand;
349349

350-
// We want to re-export a few macros from core but libcore has already been
351-
// imported by the compiler (via our #[no_std] attribute) In this case we just
352-
// add a new crate name so we can attach the re-exports to it.
353-
#[macro_reexport(assert_eq, assert_ne, debug_assert, debug_assert_eq,
354-
debug_assert_ne, unreachable, unimplemented, write, writeln, try)]
355-
extern crate core as __core;
350+
// Re-export a few macros from core
351+
#[stable(feature = "rust1", since = "1.0.0")]
352+
pub use core::{assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne};
353+
#[stable(feature = "rust1", since = "1.0.0")]
354+
pub use core::{unreachable, unimplemented, write, writeln, try};
356355

357356
#[macro_use]
358-
#[macro_reexport(vec, format)]
359357
extern crate alloc as alloc_crate;
360358
extern crate alloc_system;
361359
#[doc(masked)]
@@ -450,6 +448,8 @@ pub use alloc_crate::borrow;
450448
#[stable(feature = "rust1", since = "1.0.0")]
451449
pub use alloc_crate::fmt;
452450
#[stable(feature = "rust1", since = "1.0.0")]
451+
pub use alloc_crate::format;
452+
#[stable(feature = "rust1", since = "1.0.0")]
453453
pub use alloc_crate::slice;
454454
#[stable(feature = "rust1", since = "1.0.0")]
455455
pub use alloc_crate::str;

src/libsyntax/feature_gate.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,6 @@ declare_features! (
162162
// OIBIT specific features
163163
(active, optin_builtin_traits, "1.0.0", Some(13231), None),
164164

165-
// macro re-export needs more discussion and stabilization
166-
(active, macro_reexport, "1.0.0", Some(29638), None),
167-
168165
// Allows use of #[staged_api]
169166
// rustc internal
170167
(active, staged_api, "1.0.0", None, None),
@@ -484,6 +481,8 @@ declare_features! (
484481
(removed, simd, "1.0.0", Some(27731), None),
485482
// Merged into `slice_patterns`
486483
(removed, advanced_slice_patterns, "1.0.0", Some(23121), None),
484+
// Subsumed by `use`
485+
(removed, macro_reexport, "1.0.0", Some(29638), None),
487486
);
488487

489488
declare_features! (
@@ -673,7 +672,6 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG
673672
("forbid", Normal, Ungated),
674673
("deny", Normal, Ungated),
675674

676-
("macro_reexport", Normal, Ungated),
677675
("macro_use", Normal, Ungated),
678676
("macro_export", Normal, Ungated),
679677
("plugin_registrar", Normal, Ungated),
@@ -1516,11 +1514,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
15161514
gate_feature_post!(&self, underscore_imports, i.span,
15171515
"renaming extern crates with `_` is unstable");
15181516
}
1519-
if let Some(attr) = attr::find_by_name(&i.attrs[..], "macro_reexport") {
1520-
gate_feature_post!(&self, macro_reexport, attr.span,
1521-
"macros re-exports are experimental \
1522-
and possibly buggy");
1523-
}
15241517
}
15251518

15261519
ast::ItemKind::ForeignMod(ref foreign_module) => {

src/test/compile-fail-fulldeps/gated-macro-reexports.rs

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/test/compile-fail/auxiliary/macro_non_reexport_2.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/test/compile-fail/auxiliary/macro_reexport_1.rs

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/test/compile-fail/macro-no-implicit-reexport.rs

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/test/compile-fail/macro-reexport-malformed-1.rs

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/test/compile-fail/macro-reexport-malformed-2.rs

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)