Skip to content

[WIP] Check future proofing of macros with multiple arms using FIRST sets. #34140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
1 change: 1 addition & 0 deletions src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#![feature(pattern)]
#![feature(placement_in)]
#![feature(placement_new_protocol)]
#![feature(rustc_attrs)]
#![feature(shared)]
#![feature(slice_patterns)]
#![feature(specialization)]
Expand Down
1 change: 1 addition & 0 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#![feature(libc)]
#![feature(nonzero)]
#![feature(quote)]
#![feature(rustc_attrs)]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(slice_patterns)]
Expand Down
1 change: 1 addition & 0 deletions src/librustc_metadata/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#![feature(box_patterns)]
#![feature(enumset)]
#![feature(quote)]
#![feature(rustc_attrs)]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(staged_api)]
Expand Down
1 change: 1 addition & 0 deletions src/librustc_mir/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ impl BlockAndExtension for BasicBlock {

/// Update a block pointer and return the value.
/// Use it like `let x = unpack!(block = self.foo(block, foo))`.
#[rustc_unsafe_macro]
macro_rules! unpack {
($x:ident = $c:expr) => {
{
Expand Down
1 change: 1 addition & 0 deletions src/librustc_mir/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!

#![feature(associated_consts)]
#![feature(box_patterns)]
#![feature(rustc_attrs)]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(staged_api)]
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/ext/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -715,12 +715,12 @@ impl<'a> ExtCtxt<'a> {
}
}

pub fn insert_macro(&mut self, def: ast::MacroDef) {
pub fn insert_macro(&mut self, def: ast::MacroDef, imported: bool) {
if def.export {
self.exported_macros.push(def.clone());
}
if def.use_locally {
let ext = macro_rules::compile(self, &def);
let ext = macro_rules::compile(self, &def, imported);
self.syntax_env.insert(def.ident.name, ext);
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ fn expand_mac_invoc<T>(mac: ast::Mac, ident: Option<Ident>, attrs: Vec<ast::Attr
}
});

let check = !attr::contains_name(&attrs, "rustc_unsafe_macro");
// DON'T mark before expansion.
fld.cx.insert_macro(ast::MacroDef {
ident: ident,
Expand All @@ -290,7 +291,7 @@ fn expand_mac_invoc<T>(mac: ast::Mac, ident: Option<Ident>, attrs: Vec<ast::Attr
export: attr::contains_name(&attrs, "macro_export"),
allow_internal_unstable: attr::contains_name(&attrs, "allow_internal_unstable"),
attrs: attrs,
});
}, check);

// macro_rules! has a side effect but expands to nothing.
fld.cx.bt_pop();
Expand Down Expand Up @@ -911,7 +912,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
// We need to error on `#[macro_use] extern crate` when it isn't at the
// crate root, because `$crate` won't work properly.
for def in self.cx.loader.load_crate(item, self.at_crate_root) {
self.cx.insert_macro(def);
self.cx.insert_macro(def, false);
}
} else {
let at_crate_root = ::std::mem::replace(&mut self.at_crate_root, false);
Expand Down
Loading