diff options
| author | bors <bors@rust-lang.org> | 2016-11-17 07:43:50 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-11-17 07:43:50 -0800 |
| commit | c57b8261496d548e0a3cd8468061ddc5a4dcafe2 (patch) | |
| tree | aa6b693f0cda3854318d75b7708f593f52b4f645 /src/libsyntax/ext/expand.rs | |
| parent | 5bd1e7f59ffe6126db57ea94b90690d1ac39b932 (diff) | |
| parent | 6cb33a089fc4727bc070899f57aab3be1b215785 (diff) | |
| download | rust-c57b8261496d548e0a3cd8468061ddc5a4dcafe2.tar.gz rust-c57b8261496d548e0a3cd8468061ddc5a4dcafe2.zip | |
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
Diffstat (limited to 'src/libsyntax/ext/expand.rs')
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 877b312539f..8e0c3ce8448 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -222,6 +222,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { self.cx.current_expansion.depth = 0; let (expansion, mut invocations) = self.collect_invocations(expansion); + self.resolve_imports(); invocations.reverse(); let mut expansions = Vec::new(); @@ -230,9 +231,9 @@ impl<'a, 'b> MacroExpander<'a, 'b> { loop { let invoc = if let Some(invoc) = invocations.pop() { invoc - } else if undetermined_invocations.is_empty() { - break } else { + self.resolve_imports(); + if undetermined_invocations.is_empty() { break } invocations = mem::replace(&mut undetermined_invocations, Vec::new()); force = !mem::replace(&mut progress, false); continue @@ -292,6 +293,14 @@ impl<'a, 'b> MacroExpander<'a, 'b> { expansion.fold_with(&mut placeholder_expander) } + fn resolve_imports(&mut self) { + if self.monotonic { + let err_count = self.cx.parse_sess.span_diagnostic.err_count(); + self.cx.resolver.resolve_imports(); + self.cx.resolve_err_count += self.cx.parse_sess.span_diagnostic.err_count() - err_count; + } + } + fn collect_invocations(&mut self, expansion: Expansion) -> (Expansion, Vec<Invocation>) { let result = { let mut collector = InvocationCollector { |
