1
Fork 0

Rename Parser::last_span as prev_span.

This is a [breaking-change] for libsyntax.
This commit is contained in:
Nicholas Nethercote 2016-09-21 12:09:22 +10:00
parent a5dac7a2af
commit 2747923c27
6 changed files with 175 additions and 179 deletions

View file

@ -582,7 +582,7 @@ impl<'a> CrateReader<'a> {
unreachable!();
}
};
let local_span = mk_sp(lo, p.last_span.hi);
let local_span = mk_sp(lo, p.prev_span.hi);
// Mark the attrs as used
for attr in &def.attrs {

View file

@ -139,9 +139,9 @@ impl<'a> SpanUtils<'a> {
let mut prev = toks.real_token();
let mut result = None;
let mut bracket_count = 0;
let mut last_span = None;
let mut prev_span = None;
while prev.tok != token::Eof {
last_span = None;
prev_span = None;
let mut next = toks.real_token();
if (next.tok == token::OpenDelim(token::Paren) || next.tok == token::Lt) &&
@ -166,12 +166,12 @@ impl<'a> SpanUtils<'a> {
};
if prev.tok.is_ident() && bracket_count == 0 {
last_span = Some(prev.sp);
prev_span = Some(prev.sp);
}
prev = next;
}
if result.is_none() && last_span.is_some() {
return self.make_sub_span(span, last_span);
if result.is_none() && prev_span.is_some() {
return self.make_sub_span(span, prev_span);
}
return self.make_sub_span(span, result);
}

View file

@ -804,7 +804,7 @@ impl CodeMap {
}
pub fn macro_backtrace(&self, span: Span) -> Vec<MacroBacktrace> {
let mut last_span = DUMMY_SP;
let mut prev_span = DUMMY_SP;
let mut span = span;
let mut result = vec![];
loop {
@ -827,14 +827,14 @@ impl CodeMap {
None => break,
Some((call_site, macro_decl_name, def_site_span)) => {
// Don't print recursive invocations
if !call_site.source_equal(&last_span) {
if !call_site.source_equal(&prev_span) {
result.push(MacroBacktrace {
call_site: call_site,
macro_decl_name: macro_decl_name,
def_site_span: def_site_span,
});
}
last_span = span;
prev_span = span;
span = call_site;
}
}

View file

@ -126,7 +126,7 @@ impl<'a> Parser<'a> {
self.expect(&token::OpenDelim(token::Bracket))?;
let meta_item = self.parse_meta_item()?;
self.expect(&token::CloseDelim(token::Bracket))?;
let hi = self.last_span.hi;
let hi = self.prev_span.hi;
(mk_sp(lo, hi), meta_item, style)
}
@ -231,16 +231,16 @@ impl<'a> Parser<'a> {
token::Eq => {
self.bump();
let lit = self.parse_unsuffixed_lit()?;
let hi = self.last_span.hi;
let hi = self.prev_span.hi;
Ok(P(spanned(lo, hi, ast::MetaItemKind::NameValue(name, lit))))
}
token::OpenDelim(token::Paren) => {
let inner_items = self.parse_meta_seq()?;
let hi = self.last_span.hi;
let hi = self.prev_span.hi;
Ok(P(spanned(lo, hi, ast::MetaItemKind::List(name, inner_items))))
}
_ => {
let hi = self.last_span.hi;
let hi = self.prev_span.hi;
Ok(P(spanned(lo, hi, ast::MetaItemKind::Word(name))))
}
}
@ -253,14 +253,14 @@ impl<'a> Parser<'a> {
match self.parse_unsuffixed_lit() {
Ok(lit) => {
return Ok(spanned(lo, self.last_span.hi, ast::NestedMetaItemKind::Literal(lit)))
return Ok(spanned(lo, self.prev_span.hi, ast::NestedMetaItemKind::Literal(lit)))
}
Err(ref mut err) => self.diagnostic().cancel(err)
}
match self.parse_meta_item() {
Ok(mi) => {
return Ok(spanned(lo, self.last_span.hi, ast::NestedMetaItemKind::MetaItem(mi)))
return Ok(spanned(lo, self.prev_span.hi, ast::NestedMetaItemKind::MetaItem(mi)))
}
Err(ref mut err) => self.diagnostic().cancel(err)
}

File diff suppressed because it is too large Load diff

View file

@ -122,7 +122,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt,
let (constraint, _str_style) = panictry!(p.parse_str());
let span = p.last_span;
let span = p.prev_span;
panictry!(p.expect(&token::OpenDelim(token::Paren)));
let out = panictry!(p.parse_expr());
@ -167,9 +167,9 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt,
let (constraint, _str_style) = panictry!(p.parse_str());
if constraint.starts_with("=") {
cx.span_err(p.last_span, "input operand constraint contains '='");
cx.span_err(p.prev_span, "input operand constraint contains '='");
} else if constraint.starts_with("+") {
cx.span_err(p.last_span, "input operand constraint contains '+'");
cx.span_err(p.prev_span, "input operand constraint contains '+'");
}
panictry!(p.expect(&token::OpenDelim(token::Paren)));
@ -189,9 +189,9 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt,
let (s, _str_style) = panictry!(p.parse_str());
if OPTIONS.iter().any(|&opt| s == opt) {
cx.span_warn(p.last_span, "expected a clobber, found an option");
cx.span_warn(p.prev_span, "expected a clobber, found an option");
} else if s.starts_with("{") || s.ends_with("}") {
cx.span_err(p.last_span, "clobber should not be surrounded by braces");
cx.span_err(p.prev_span, "clobber should not be surrounded by braces");
}
clobs.push(s);
@ -209,7 +209,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt,
} else if option == "intel" {
dialect = AsmDialect::Intel;
} else {
cx.span_warn(p.last_span, "unrecognized option");
cx.span_warn(p.prev_span, "unrecognized option");
}
if p.token == token::Comma {