Skip to content

Commit c57b826

Browse files
authored
Auto merge of #37732 - jseyfried:use_extern_macros, r=nrc
Support `use`ing externally defined macros behind `#![feature(use_extern_macros)]` With `#![feature(use_extern_macros)]`, - A name collision between macros from different upstream crates is much less of an issue since we can `use` the macros in different submodules or rename with `as`. - We can reexport macros with `pub use`, so `#![feature(macro_reexport)]` is no longer needed. - These reexports are allowed in any module, so crates can expose a macro-modular interface. If a macro invocation can resolve to both a `use` import and a `macro_rules!` or `#[macro_use]`, it is an ambiguity error. r? @nrc
2 parents 5bd1e7f + 6cb33a0 commit c57b826

File tree

14 files changed

+618
-386
lines changed

14 files changed

+618
-386
lines changed

src/librustc_driver/driver.rs

-2
Original file line numberDiff line numberDiff line change
@@ -755,8 +755,6 @@ pub fn phase_2_configure_and_expand<'a, F>(sess: &Session,
755755
|| ast_validation::check_crate(sess, &krate));
756756

757757
time(sess.time_passes(), "name resolution", || -> CompileResult {
758-
resolver.resolve_imports();
759-
760758
// Since import resolution will eventually happen in expansion,
761759
// don't perform `after_expand` until after import resolution.
762760
after_expand(&krate)?;

src/librustc_resolve/build_reduced_graph.rs

+92-60
Large diffs are not rendered by default.

src/librustc_resolve/check_unused.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
use std::ops::{Deref, DerefMut};
2323

2424
use Resolver;
25-
use Namespace::{TypeNS, ValueNS};
2625

2726
use rustc::lint;
2827
use rustc::util::nodemap::NodeMap;
@@ -56,8 +55,9 @@ impl<'a, 'b> UnusedImportCheckVisitor<'a, 'b> {
5655
// We have information about whether `use` (import) directives are actually
5756
// used now. If an import is not used at all, we signal a lint error.
5857
fn check_import(&mut self, item_id: ast::NodeId, id: ast::NodeId, span: Span) {
59-
if !self.used_imports.contains(&(id, TypeNS)) &&
60-
!self.used_imports.contains(&(id, ValueNS)) {
58+
let mut used = false;
59+
self.per_ns(|this, ns| used |= this.used_imports.contains(&(id, ns)));
60+
if !used {
6161
if self.maybe_unused_trait_imports.contains(&id) {
6262
// Check later.
6363
return;

0 commit comments

Comments
 (0)