Skip to content

Commit a695304

Browse files
committed
---
yaml --- r: 131772 b: refs/heads/dist-snap c: c253b36 h: refs/heads/master v: v3
1 parent f85fe41 commit a695304

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 457a3c991d79b971be07fce75f9d0c12848fb37c
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 53642eed801d157613de0998cdcf0a3da8c36cb3
9+
refs/heads/dist-snap: c253b3675ab03b6c64021e8acee3988cea81f3f9
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librustc/driver/driver.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ pub fn phase_2_configure_and_expand(sess: &Session,
259259
}
260260
);
261261

262+
// JBC: make CFG processing part of expansion to avoid this problem:
263+
262264
// strip again, in case expansion added anything with a #[cfg].
263265
krate = time(time_passes, "configuration 2", krate, |krate|
264266
front::config::strip_unconfigured_items(krate));
@@ -279,6 +281,9 @@ pub fn phase_2_configure_and_expand(sess: &Session,
279281
krate.encode(&mut json).unwrap();
280282
}
281283

284+
time(time_passes, "checking that all macro invocations are gone", &krate, |krate|
285+
syntax::ext::expand::check_for_macros(&sess.parse_sess, krate));
286+
282287
Some((krate, map))
283288
}
284289

@@ -291,14 +296,14 @@ pub struct CrateAnalysis {
291296
pub name: String,
292297
}
293298

299+
294300
/// Run the resolution, typechecking, region checking and other
295301
/// miscellaneous analysis passes on the crate. Return various
296302
/// structures carrying the results of the analysis.
297303
pub fn phase_3_run_analysis_passes(sess: Session,
298304
krate: &ast::Crate,
299305
ast_map: syntax::ast_map::Map,
300306
name: String) -> CrateAnalysis {
301-
302307
let time_passes = sess.time_passes();
303308

304309
time(time_passes, "external crate/lib resolution", (), |_|

branches/dist-snap/src/libsyntax/ext/expand.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,25 @@ fn original_span(cx: &ExtCtxt) -> Gc<codemap::ExpnInfo> {
11511151
return einfo;
11521152
}
11531153

1154+
/// Check that there are no macro invocations left in the AST:
1155+
pub fn check_for_macros(sess: &parse::ParseSess, krate: &ast::Crate) {
1156+
visit::walk_crate(&mut MacroExterminator{sess:sess}, krate, ());
1157+
}
1158+
1159+
/// A visitor that ensures that no macro invocations remain in an AST.
1160+
struct MacroExterminator<'a>{
1161+
sess: &'a parse::ParseSess
1162+
}
1163+
1164+
impl<'a> visit::Visitor<()> for MacroExterminator<'a> {
1165+
fn visit_mac(&mut self, macro: &ast::Mac, _:()) {
1166+
self.sess.span_diagnostic.span_bug(macro.span,
1167+
"macro exterminator: expected AST \
1168+
with no macro invocations");
1169+
}
1170+
}
1171+
1172+
11541173
#[cfg(test)]
11551174
mod test {
11561175
use super::{pattern_bindings, expand_crate, contains_macro_escape};

0 commit comments

Comments
 (0)