Remove Spanned from ast::Mac
This commit is contained in:
parent
73d2da0894
commit
433b1e36e1
17 changed files with 54 additions and 52 deletions
|
|
@ -8,13 +8,13 @@ use crate::ast::{self, Attribute, AttrStyle, Ident, CaptureBy, BlockCheckMode};
|
|||
use crate::ast::{Expr, ExprKind, RangeLimits, Label, Movability, IsAsync, Arm};
|
||||
use crate::ast::{Ty, TyKind, FunctionRetTy, Arg, FnDecl};
|
||||
use crate::ast::{BinOpKind, BinOp, UnOp};
|
||||
use crate::ast::{Mac_, AnonConst, Field};
|
||||
use crate::ast::{Mac, AnonConst, Field};
|
||||
|
||||
use crate::parse::classify;
|
||||
use crate::parse::token::{self, Token};
|
||||
use crate::parse::diagnostics::{Error};
|
||||
use crate::print::pprust;
|
||||
use crate::source_map::{self, respan, Span};
|
||||
use crate::source_map::{self, Span};
|
||||
use crate::symbol::{kw, sym};
|
||||
use crate::util::parser::{AssocOp, Fixity, prec_let_scrutinee_needs_par};
|
||||
|
||||
|
|
@ -1011,12 +1011,13 @@ impl<'a> Parser<'a> {
|
|||
// MACRO INVOCATION expression
|
||||
let (delim, tts) = self.expect_delimited_token_tree()?;
|
||||
hi = self.prev_span;
|
||||
ex = ExprKind::Mac(respan(lo.to(hi), Mac_ {
|
||||
ex = ExprKind::Mac(Mac {
|
||||
path,
|
||||
tts,
|
||||
delim,
|
||||
span: lo.to(hi),
|
||||
prior_type_ascription: self.last_type_ascription,
|
||||
}));
|
||||
});
|
||||
} else if self.check(&token::OpenDelim(token::Brace)) {
|
||||
if let Some(expr) = self.maybe_parse_struct_expr(lo, &path, &attrs) {
|
||||
return expr;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use crate::ast::{Visibility, VisibilityKind, Mutability, FnDecl, FnHeader};
|
|||
use crate::ast::{ForeignItem, ForeignItemKind};
|
||||
use crate::ast::{Ty, TyKind, GenericBounds, TraitRef};
|
||||
use crate::ast::{EnumDef, VariantData, StructField, AnonConst};
|
||||
use crate::ast::{Mac, Mac_, MacDelimiter};
|
||||
use crate::ast::{Mac, MacDelimiter};
|
||||
use crate::ext::base::DummyResult;
|
||||
use crate::parse::token;
|
||||
use crate::parse::parser::maybe_append;
|
||||
|
|
@ -530,12 +530,13 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
|
||||
let hi = self.prev_span;
|
||||
let mac = respan(mac_lo.to(hi), Mac_ {
|
||||
let mac = Mac {
|
||||
path,
|
||||
tts,
|
||||
delim,
|
||||
span: mac_lo.to(hi),
|
||||
prior_type_ascription: self.last_type_ascription,
|
||||
});
|
||||
};
|
||||
let item =
|
||||
self.mk_item(lo.to(hi), Ident::invalid(), ItemKind::Mac(mac), visibility, attrs);
|
||||
return Ok(Some(item));
|
||||
|
|
@ -604,12 +605,13 @@ impl<'a> Parser<'a> {
|
|||
self.expect(&token::Semi)?;
|
||||
}
|
||||
|
||||
Ok(Some(respan(lo.to(self.prev_span), Mac_ {
|
||||
Ok(Some(Mac {
|
||||
path,
|
||||
tts,
|
||||
delim,
|
||||
span: lo.to(self.prev_span),
|
||||
prior_type_ascription: self.last_type_ascription,
|
||||
})))
|
||||
}))
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use super::{Parser, PResult, PathStyle};
|
|||
|
||||
use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole};
|
||||
use crate::ptr::P;
|
||||
use crate::ast::{self, Attribute, Pat, PatKind, FieldPat, RangeEnd, RangeSyntax, Mac_};
|
||||
use crate::ast::{self, Attribute, Pat, PatKind, FieldPat, RangeEnd, RangeSyntax, Mac};
|
||||
use crate::ast::{BindingMode, Ident, Mutability, Path, QSelf, Expr, ExprKind};
|
||||
use crate::parse::token::{self};
|
||||
use crate::print::pprust;
|
||||
|
|
@ -275,12 +275,13 @@ impl<'a> Parser<'a> {
|
|||
fn parse_pat_mac_invoc(&mut self, lo: Span, path: Path) -> PResult<'a, PatKind> {
|
||||
self.bump();
|
||||
let (delim, tts) = self.expect_delimited_token_tree()?;
|
||||
let mac = respan(lo.to(self.prev_span), Mac_ {
|
||||
let mac = Mac {
|
||||
path,
|
||||
tts,
|
||||
delim,
|
||||
span: lo.to(self.prev_span),
|
||||
prior_type_ascription: self.last_type_ascription,
|
||||
});
|
||||
};
|
||||
Ok(PatKind::Mac(mac))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use super::path::PathStyle;
|
|||
use crate::ptr::P;
|
||||
use crate::{maybe_whole, ThinVec};
|
||||
use crate::ast::{self, Stmt, StmtKind, Local, Block, BlockCheckMode, Expr, ExprKind};
|
||||
use crate::ast::{Attribute, AttrStyle, VisibilityKind, MacStmtStyle, Mac_, MacDelimiter};
|
||||
use crate::ast::{Attribute, AttrStyle, VisibilityKind, MacStmtStyle, Mac, MacDelimiter};
|
||||
use crate::ext::base::DummyResult;
|
||||
use crate::parse::{classify, DirectoryOwnership};
|
||||
use crate::parse::diagnostics::Error;
|
||||
|
|
@ -99,12 +99,13 @@ impl<'a> Parser<'a> {
|
|||
MacStmtStyle::NoBraces
|
||||
};
|
||||
|
||||
let mac = respan(lo.to(hi), Mac_ {
|
||||
let mac = Mac {
|
||||
path,
|
||||
tts,
|
||||
delim,
|
||||
span: lo.to(hi),
|
||||
prior_type_ascription: self.last_type_ascription,
|
||||
});
|
||||
};
|
||||
let node = if delim == MacDelimiter::Brace ||
|
||||
self.token == token::Semi || self.token == token::Eof {
|
||||
StmtKind::Mac(P((mac, style, attrs.into())))
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ use crate::{maybe_whole, maybe_recover_from_interpolated_ty_qpath};
|
|||
use crate::ptr::P;
|
||||
use crate::ast::{self, Ty, TyKind, MutTy, BareFnTy, FunctionRetTy, GenericParam, Lifetime, Ident};
|
||||
use crate::ast::{TraitBoundModifier, TraitObjectSyntax, GenericBound, GenericBounds, PolyTraitRef};
|
||||
use crate::ast::{Mutability, AnonConst, FnDecl, Mac_};
|
||||
use crate::ast::{Mutability, AnonConst, FnDecl, Mac};
|
||||
use crate::parse::token::{self, Token};
|
||||
use crate::source_map::{respan, Span};
|
||||
use crate::source_map::Span;
|
||||
use crate::symbol::{kw};
|
||||
|
||||
use rustc_target::spec::abi::Abi;
|
||||
|
|
@ -175,13 +175,14 @@ impl<'a> Parser<'a> {
|
|||
if self.eat(&token::Not) {
|
||||
// Macro invocation in type position
|
||||
let (delim, tts) = self.expect_delimited_token_tree()?;
|
||||
let node = Mac_ {
|
||||
let mac = Mac {
|
||||
path,
|
||||
tts,
|
||||
delim,
|
||||
span: lo.to(self.prev_span),
|
||||
prior_type_ascription: self.last_type_ascription,
|
||||
};
|
||||
TyKind::Mac(respan(lo.to(self.prev_span), node))
|
||||
TyKind::Mac(mac)
|
||||
} else {
|
||||
// Just a type path or bound list (trait object type) starting with a trait.
|
||||
// `Type`
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ fn ttdelim_span() {
|
|||
"foo!( fn main() { body } )".to_string(), &sess).unwrap();
|
||||
|
||||
let tts: Vec<_> = match expr.node {
|
||||
ast::ExprKind::Mac(ref mac) => mac.node.stream().trees().collect(),
|
||||
ast::ExprKind::Mac(ref mac) => mac.stream().trees().collect(),
|
||||
_ => panic!("not a macro"),
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue