feat: support parsing asm! args

This commit is contained in:
Caleb Cartwright 2021-12-28 19:23:51 -06:00 committed by Caleb Cartwright
parent 50bbb43dab
commit f935f0cf89
3 changed files with 13 additions and 0 deletions

View File

@ -15,6 +15,7 @@
// N.B. these crates are loaded from the sysroot, so they need extern crate. // N.B. these crates are loaded from the sysroot, so they need extern crate.
extern crate rustc_ast; extern crate rustc_ast;
extern crate rustc_ast_pretty; extern crate rustc_ast_pretty;
extern crate rustc_builtin_macros;
extern crate rustc_data_structures; extern crate rustc_data_structures;
extern crate rustc_errors; extern crate rustc_errors;
extern crate rustc_expand; extern crate rustc_expand;

11
src/parse/macros/asm.rs Normal file
View File

@ -0,0 +1,11 @@
use rustc_ast::ast;
use rustc_builtin_macros::asm::{parse_asm_args, AsmArgs};
use crate::rewrite::RewriteContext;
#[allow(dead_code)]
pub(crate) fn parse_asm(context: &RewriteContext<'_>, mac: &ast::MacCall) -> Option<AsmArgs> {
let ts = mac.args.inner_tokens();
let mut parser = super::build_parser(context, ts);
parse_asm_args(&mut parser, context.parse_sess.inner(), mac.span(), false).ok()
}

View File

@ -10,6 +10,7 @@
use crate::macros::MacroArg; use crate::macros::MacroArg;
use crate::rewrite::RewriteContext; use crate::rewrite::RewriteContext;
pub(crate) mod asm;
pub(crate) mod cfg_if; pub(crate) mod cfg_if;
pub(crate) mod lazy_static; pub(crate) mod lazy_static;