diff --git a/src/librustc_builtin_macros/asm.rs b/src/librustc_builtin_macros/asm.rs index 9f98cf253c9..b12734a5c40 100644 --- a/src/librustc_builtin_macros/asm.rs +++ b/src/librustc_builtin_macros/asm.rs @@ -151,7 +151,7 @@ fn parse_inline_asm<'a>( let constraint = parse_asm_str(&mut p)?; - let span = p.prev_span; + let span = p.prev_token.span; p.expect(&token::OpenDelim(token::Paren))?; let expr = p.parse_expr()?; @@ -202,7 +202,7 @@ fn parse_inline_asm<'a>( if constraint.as_str().starts_with('=') { struct_span_err!( cx.parse_sess.span_diagnostic, - p.prev_span, + p.prev_token.span, E0662, "input operand constraint contains '='" ) @@ -210,7 +210,7 @@ fn parse_inline_asm<'a>( } else if constraint.as_str().starts_with('+') { struct_span_err!( cx.parse_sess.span_diagnostic, - p.prev_span, + p.prev_token.span, E0663, "input operand constraint contains '+'" ) @@ -233,11 +233,11 @@ fn parse_inline_asm<'a>( let s = parse_asm_str(&mut p)?; if OPTIONS.iter().any(|&opt| s == opt) { - cx.span_warn(p.prev_span, "expected a clobber, found an option"); + cx.span_warn(p.prev_token.span, "expected a clobber, found an option"); } else if s.as_str().starts_with('{') || s.as_str().ends_with('}') { struct_span_err!( cx.parse_sess.span_diagnostic, - p.prev_span, + p.prev_token.span, E0664, "clobber should not be surrounded by braces" ) @@ -259,7 +259,7 @@ fn parse_inline_asm<'a>( } else if option == sym::intel { dialect = AsmDialect::Intel; } else { - cx.span_warn(p.prev_span, "unrecognized option"); + cx.span_warn(p.prev_token.span, "unrecognized option"); } if p.token == token::Comma { diff --git a/src/librustc_builtin_macros/assert.rs b/src/librustc_builtin_macros/assert.rs index 3fc86a5469c..3ff4c79fcae 100644 --- a/src/librustc_builtin_macros/assert.rs +++ b/src/librustc_builtin_macros/assert.rs @@ -106,7 +106,7 @@ fn parse_assert<'a>( let custom_message = if let token::Literal(token::Lit { kind: token::Str, .. }) = parser.token.kind { let mut err = cx.struct_span_warn(parser.token.span, "unexpected string literal"); - let comma_span = parser.prev_span.shrink_to_hi(); + let comma_span = parser.prev_token.span.shrink_to_hi(); err.span_suggestion_short( comma_span, "try adding a comma", diff --git a/src/librustc_parse/parser/attr.rs b/src/librustc_parse/parser/attr.rs index 905f6bef58e..ea7500f6732 100644 --- a/src/librustc_parse/parser/attr.rs +++ b/src/librustc_parse/parser/attr.rs @@ -116,7 +116,7 @@ impl<'a> Parser<'a> { self.expect(&token::OpenDelim(token::Bracket))?; let item = self.parse_attr_item()?; self.expect(&token::CloseDelim(token::Bracket))?; - let hi = self.prev_span; + let hi = self.prev_token.span; let attr_sp = lo.to(hi); @@ -255,7 +255,7 @@ impl<'a> Parser<'a> { while self.token.kind != token::Eof { let lo = self.token.span; let item = self.parse_attr_item()?; - expanded_attrs.push((item, lo.to(self.prev_span))); + expanded_attrs.push((item, lo.to(self.prev_token.span))); if !self.eat(&token::Comma) { break; } @@ -303,7 +303,7 @@ impl<'a> Parser<'a> { let lo = self.token.span; let path = self.parse_path(PathStyle::Mod)?; let kind = self.parse_meta_item_kind()?; - let span = lo.to(self.prev_span); + let span = lo.to(self.prev_token.span); Ok(ast::MetaItem { path, kind, span }) } diff --git a/src/librustc_parse/parser/diagnostics.rs b/src/librustc_parse/parser/diagnostics.rs index 00f5fb97052..29d8075c643 100644 --- a/src/librustc_parse/parser/diagnostics.rs +++ b/src/librustc_parse/parser/diagnostics.rs @@ -260,24 +260,24 @@ impl<'a> Parser<'a> { }; ( format!("expected one of {}, found {}", expect, actual), - (self.prev_span.shrink_to_hi(), format!("expected one of {}", short_expect)), + (self.prev_token.span.shrink_to_hi(), format!("expected one of {}", short_expect)), ) } else if expected.is_empty() { ( format!("unexpected token: {}", actual), - (self.prev_span, "unexpected token after this".to_string()), + (self.prev_token.span, "unexpected token after this".to_string()), ) } else { ( format!("expected {}, found {}", expect, actual), - (self.prev_span.shrink_to_hi(), format!("expected {}", expect)), + (self.prev_token.span.shrink_to_hi(), format!("expected {}", expect)), ) }; self.last_unexpected_token_span = Some(self.token.span); let mut err = self.struct_span_err(self.token.span, &msg_exp); let sp = if self.token == token::Eof { // This is EOF; don't want to point at the following char, but rather the last token. - self.prev_span + self.prev_token.span } else { label_sp }; @@ -298,7 +298,7 @@ impl<'a> Parser<'a> { } let sm = self.sess.source_map(); - if self.prev_span == DUMMY_SP { + if self.prev_token.span == DUMMY_SP { // Account for macro context where the previous span might not be // available to avoid incorrect output (#54841). err.span_label(self.token.span, label_exp); @@ -577,7 +577,7 @@ impl<'a> Parser<'a> { match inner_op.kind { ExprKind::Binary(op, _, _) if op.node.is_comparison() => { // Respan to include both operators. - let op_span = op.span.to(self.prev_span); + let op_span = op.span.to(self.prev_token.span); let mut err = self.struct_span_err(op_span, "comparison operators cannot be chained"); @@ -632,7 +632,7 @@ impl<'a> Parser<'a> { // FIXME: actually check that the two expressions in the binop are // paths and resynthesize new fn call expression instead of using // `ExprKind::Err` placeholder. - mk_err_expr(self, inner_op.span.to(self.prev_span)) + mk_err_expr(self, inner_op.span.to(self.prev_token.span)) } Err(mut expr_err) => { expr_err.cancel(); @@ -654,7 +654,7 @@ impl<'a> Parser<'a> { // FIXME: actually check that the two expressions in the binop are // paths and resynthesize new fn call expression instead of using // `ExprKind::Err` placeholder. - mk_err_expr(self, inner_op.span.to(self.prev_span)) + mk_err_expr(self, inner_op.span.to(self.prev_token.span)) } } } else { @@ -723,7 +723,7 @@ impl<'a> Parser<'a> { self.bump(); // `+` let bounds = self.parse_generic_bounds(None)?; - let sum_span = ty.span.to(self.prev_span); + let sum_span = ty.span.to(self.prev_token.span); let mut err = struct_span_err!( self.sess.span_diagnostic, @@ -790,7 +790,7 @@ impl<'a> Parser<'a> { let mut path = ast::Path { segments: Vec::new(), span: DUMMY_SP }; self.parse_path_segments(&mut path.segments, T::PATH_STYLE)?; - path.span = ty_span.to(self.prev_span); + path.span = ty_span.to(self.prev_token.span); let ty_str = self.span_to_snippet(ty_span).unwrap_or_else(|_| pprust::ty_to_string(&ty)); self.struct_span_err(path.span, "missing angle brackets in associated item path") @@ -809,9 +809,9 @@ impl<'a> Parser<'a> { pub(super) fn maybe_consume_incorrect_semicolon(&mut self, items: &[P]) -> bool { if self.eat(&token::Semi) { - let mut err = self.struct_span_err(self.prev_span, "expected item, found `;`"); + let mut err = self.struct_span_err(self.prev_token.span, "expected item, found `;`"); err.span_suggestion_short( - self.prev_span, + self.prev_token.span, "remove this semicolon", String::new(), Applicability::MachineApplicable, @@ -854,10 +854,10 @@ impl<'a> Parser<'a> { } // We don't want to point at the following span after DUMMY_SP. // This happens when the parser finds an empty TokenStream. - _ if self.prev_span == DUMMY_SP => (self.token.span, self.token.span), + _ if self.prev_token.span == DUMMY_SP => (self.token.span, self.token.span), // EOF, don't want to point at the following char, but rather the last token. - (token::Eof, None) => (self.prev_span, self.token.span), - _ => (self.prev_span.shrink_to_hi(), self.token.span), + (token::Eof, None) => (self.prev_token.span, self.token.span), + _ => (self.prev_token.span.shrink_to_hi(), self.token.span), }; let msg = format!( "expected `{}`, found {}", @@ -894,10 +894,10 @@ impl<'a> Parser<'a> { let sm = self.sess.source_map(); let msg = format!("expected `;`, found `{}`", super::token_descr(&self.token)); let appl = Applicability::MachineApplicable; - if self.token.span == DUMMY_SP || self.prev_span == DUMMY_SP { + if self.token.span == DUMMY_SP || self.prev_token.span == DUMMY_SP { // Likely inside a macro, can't provide meaninful suggestions. return self.expect(&token::Semi).map(drop); - } else if !sm.is_multiline(self.prev_span.until(self.token.span)) { + } else if !sm.is_multiline(self.prev_token.span.until(self.token.span)) { // The current token is in the same line as the prior token, not recoverable. } else if self.look_ahead(1, |t| { t == &token::CloseDelim(token::Brace) || t.can_begin_expr() && t.kind != token::Colon @@ -910,7 +910,7 @@ impl<'a> Parser<'a> { // let x = 32: // let y = 42; self.bump(); - let sp = self.prev_span; + let sp = self.prev_token.span; self.struct_span_err(sp, &msg) .span_suggestion(sp, "change this to `;`", ";".to_string(), appl) .emit(); @@ -927,7 +927,7 @@ impl<'a> Parser<'a> { // // let x = 32 // let y = 42; - let sp = self.prev_span.shrink_to_hi(); + let sp = self.prev_token.span.shrink_to_hi(); self.struct_span_err(sp, &msg) .span_label(self.token.span, "unexpected token") .span_suggestion_short(sp, "add `;` here", ";".to_string(), appl) @@ -961,7 +961,7 @@ impl<'a> Parser<'a> { self.expect(&token::OpenDelim(token::Paren))?; let expr = self.parse_expr()?; self.expect(&token::CloseDelim(token::Paren))?; - Ok((self.prev_span, expr, false)) + Ok((self.prev_token.span, expr, false)) } fn recover_await_prefix(&mut self, await_sp: Span) -> PResult<'a, (Span, P, bool)> { @@ -1036,10 +1036,10 @@ impl<'a> Parser<'a> { .span_to_snippet(pat.span.trim_start(begin_par_sp).unwrap()) .unwrap_or_else(|_| pprust::pat_to_string(&pat)); - self.struct_span_err(self.prev_span, "unexpected closing `)`") + self.struct_span_err(self.prev_token.span, "unexpected closing `)`") .span_label(begin_par_sp, "opening `(`") .span_suggestion( - begin_par_sp.to(self.prev_span), + begin_par_sp.to(self.prev_token.span), "remove parenthesis in `for` loop", format!("{} in {}", pat_str, pprust::expr_to_string(&expr)), // With e.g. `for (x) in y)` this would replace `(x) in y)` @@ -1091,7 +1091,7 @@ impl<'a> Parser<'a> { err.emit(); // Recover from parse error, callers expect the closing delim to be consumed. self.consume_block(delim, ConsumeClosingDelim::Yes); - self.mk_expr(lo.to(self.prev_span), ExprKind::Err, AttrVec::new()) + self.mk_expr(lo.to(self.prev_token.span), ExprKind::Err, AttrVec::new()) } } } @@ -1138,7 +1138,7 @@ impl<'a> Parser<'a> { err.span_label(sp, "unclosed delimiter"); } err.span_suggestion_short( - self.prev_span.shrink_to_hi(), + self.prev_token.span.shrink_to_hi(), &format!("{} may belong here", delim.to_string()), delim.to_string(), Applicability::MaybeIncorrect, @@ -1246,9 +1246,9 @@ impl<'a> Parser<'a> { pub(super) fn check_for_for_in_in_typo(&mut self, in_span: Span) { if self.eat_keyword(kw::In) { // a common typo: `for _ in in bar {}` - self.struct_span_err(self.prev_span, "expected iterable, found keyword `in`") + self.struct_span_err(self.prev_token.span, "expected iterable, found keyword `in`") .span_suggestion_short( - in_span.until(self.prev_span), + in_span.until(self.prev_token.span), "remove the duplicated `in`", String::new(), Applicability::MachineApplicable, diff --git a/src/librustc_parse/parser/expr.rs b/src/librustc_parse/parser/expr.rs index 71ca8fba0b4..c1158483302 100644 --- a/src/librustc_parse/parser/expr.rs +++ b/src/librustc_parse/parser/expr.rs @@ -166,7 +166,7 @@ impl<'a> Parser<'a> { // Adjust the span for interpolated LHS to point to the `$lhs` token // and not to what it refers to. let lhs_span = match self.prev_token.kind { - TokenKind::Interpolated(..) => self.prev_span, + TokenKind::Interpolated(..) => self.prev_token.span, _ => lhs.span, }; @@ -523,7 +523,7 @@ impl<'a> Parser<'a> { expr.map(|e| { ( match self.prev_token.kind { - TokenKind::Interpolated(..) => self.prev_span, + TokenKind::Interpolated(..) => self.prev_token.span, _ => e.span, }, e, @@ -614,7 +614,7 @@ impl<'a> Parser<'a> { fn parse_assoc_op_ascribe(&mut self, lhs: P, lhs_span: Span) -> PResult<'a, P> { let maybe_path = self.could_ascription_be_path(&lhs.kind); - self.last_type_ascription = Some((self.prev_span, maybe_path)); + self.last_type_ascription = Some((self.prev_token.span, maybe_path)); let lhs = self.parse_assoc_op_cast(lhs, lhs_span, ExprKind::Type)?; self.sess.gated_spans.gate(sym::type_ascription, lhs.span); Ok(lhs) @@ -636,7 +636,7 @@ impl<'a> Parser<'a> { let found_raw = self.eat_keyword(kw::Raw); assert!(found_raw); let mutability = self.parse_const_or_mut().unwrap(); - self.sess.gated_spans.gate(sym::raw_ref_op, lo.to(self.prev_span)); + self.sess.gated_spans.gate(sym::raw_ref_op, lo.to(self.prev_token.span)); (ast::BorrowKind::Raw, mutability) } else { // `mut?` @@ -683,7 +683,7 @@ impl<'a> Parser<'a> { loop { if self.eat(&token::Question) { // `expr?` - e = self.mk_expr(lo.to(self.prev_span), ExprKind::Try(e), AttrVec::new()); + e = self.mk_expr(lo.to(self.prev_token.span), ExprKind::Try(e), AttrVec::new()); continue; } if self.eat(&token::Dot) { @@ -735,8 +735,8 @@ impl<'a> Parser<'a> { let fstr = sym.as_str(); let msg = format!("unexpected token: `{}`", sym); - let mut err = self.struct_span_err(self.prev_span, &msg); - err.span_label(self.prev_span, "unexpected token"); + let mut err = self.struct_span_err(self.prev_token.span, &msg); + err.span_label(self.prev_token.span, "unexpected token"); if fstr.chars().all(|x| "0123456789.".contains(x)) { let float = match fstr.parse::() { @@ -756,7 +756,7 @@ impl<'a> Parser<'a> { s.s.word(fstr.splitn(2, '.').last().unwrap().to_string()) }); err.span_suggestion( - lo.to(self.prev_span), + lo.to(self.prev_token.span), "try parenthesizing the first index", sugg, Applicability::MachineApplicable, @@ -782,7 +782,7 @@ impl<'a> Parser<'a> { /// Parse a function call expression, `expr(...)`. fn parse_fn_call_expr(&mut self, lo: Span, fun: P) -> P { let seq = self.parse_paren_expr_seq().map(|args| { - self.mk_expr(lo.to(self.prev_span), self.mk_call(fun, args), AttrVec::new()) + self.mk_expr(lo.to(self.prev_token.span), self.mk_call(fun, args), AttrVec::new()) }); self.recover_seq_parse_error(token::Paren, lo, seq) } @@ -792,7 +792,7 @@ impl<'a> Parser<'a> { self.bump(); // `[` let index = self.parse_expr()?; self.expect(&token::CloseDelim(token::Bracket))?; - Ok(self.mk_expr(lo.to(self.prev_span), self.mk_index(base, index), AttrVec::new())) + Ok(self.mk_expr(lo.to(self.prev_token.span), self.mk_index(base, index), AttrVec::new())) } /// Assuming we have just parsed `.`, continue parsing into an expression. @@ -809,7 +809,7 @@ impl<'a> Parser<'a> { let mut args = self.parse_paren_expr_seq()?; args.insert(0, self_arg); - let span = lo.to(self.prev_span); + let span = lo.to(self.prev_token.span); Ok(self.mk_expr(span, ExprKind::MethodCall(segment, args), AttrVec::new())) } else { // Field access `expr.f` @@ -821,7 +821,7 @@ impl<'a> Parser<'a> { .emit(); } - let span = lo.to(self.prev_span); + let span = lo.to(self.prev_token.span); Ok(self.mk_expr(span, ExprKind::Field(self_arg, segment.ident), AttrVec::new())) } } @@ -867,18 +867,18 @@ impl<'a> Parser<'a> { } else if self.eat_keyword(kw::If) { self.parse_if_expr(attrs) } else if self.eat_keyword(kw::For) { - self.parse_for_expr(None, self.prev_span, attrs) + self.parse_for_expr(None, self.prev_token.span, attrs) } else if self.eat_keyword(kw::While) { - self.parse_while_expr(None, self.prev_span, attrs) + self.parse_while_expr(None, self.prev_token.span, attrs) } else if let Some(label) = self.eat_label() { self.parse_labeled_expr(label, attrs) } else if self.eat_keyword(kw::Loop) { - self.parse_loop_expr(None, self.prev_span, attrs) + self.parse_loop_expr(None, self.prev_token.span, attrs) } else if self.eat_keyword(kw::Continue) { let kind = ExprKind::Continue(self.eat_label()); - Ok(self.mk_expr(lo.to(self.prev_span), kind, attrs)) + Ok(self.mk_expr(lo.to(self.prev_token.span), kind, attrs)) } else if self.eat_keyword(kw::Match) { - let match_sp = self.prev_span; + let match_sp = self.prev_token.span; self.parse_match_expr(attrs).map_err(|mut err| { err.span_label(match_sp, "while parsing this match expression"); err @@ -921,7 +921,7 @@ impl<'a> Parser<'a> { self.parse_closure_expr(attrs) } } else if self.eat_keyword(kw::Await) { - self.recover_incorrect_await_syntax(lo, self.prev_span, attrs) + self.recover_incorrect_await_syntax(lo, self.prev_token.span, attrs) } else { self.parse_lit_expr(attrs) } @@ -934,7 +934,7 @@ impl<'a> Parser<'a> { let lo = self.token.span; match self.parse_opt_lit() { Some(literal) => { - let expr = self.mk_expr(lo.to(self.prev_span), ExprKind::Lit(literal), attrs); + let expr = self.mk_expr(lo.to(self.prev_token.span), ExprKind::Lit(literal), attrs); self.maybe_recover_from_bad_qpath(expr, true) } None => return Err(self.expected_expression_found()), @@ -960,7 +960,7 @@ impl<'a> Parser<'a> { // `(e,)` is a tuple with only one field, `e`. ExprKind::Tup(es) }; - let expr = self.mk_expr(lo.to(self.prev_span), kind, attrs); + let expr = self.mk_expr(lo.to(self.prev_token.span), kind, attrs); self.maybe_recover_from_bad_qpath(expr, true) } @@ -995,7 +995,7 @@ impl<'a> Parser<'a> { ExprKind::Array(vec![first_expr]) } }; - let expr = self.mk_expr(lo.to(self.prev_span), kind, attrs); + let expr = self.mk_expr(lo.to(self.prev_token.span), kind, attrs); self.maybe_recover_from_bad_qpath(expr, true) } @@ -1011,7 +1011,7 @@ impl<'a> Parser<'a> { args: self.parse_mac_args()?, prior_type_ascription: self.last_type_ascription, }; - (self.prev_span, ExprKind::Mac(mac)) + (self.prev_token.span, ExprKind::Mac(mac)) } else if self.check(&token::OpenDelim(token::Brace)) { if let Some(expr) = self.maybe_parse_struct_expr(lo, &path, &attrs) { return expr; @@ -1055,7 +1055,7 @@ impl<'a> Parser<'a> { self.bump(); // `do` self.bump(); // `catch` - let span_dc = lo.to(self.prev_span); + let span_dc = lo.to(self.prev_token.span); self.struct_span_err(span_dc, "found removed `do catch` syntax") .span_suggestion( span_dc, @@ -1076,15 +1076,15 @@ impl<'a> Parser<'a> { /// Parse `"return" expr?`. fn parse_return_expr(&mut self, attrs: AttrVec) -> PResult<'a, P> { - let lo = self.prev_span; + let lo = self.prev_token.span; let kind = ExprKind::Ret(self.parse_expr_opt()?); - let expr = self.mk_expr(lo.to(self.prev_span), kind, attrs); + let expr = self.mk_expr(lo.to(self.prev_token.span), kind, attrs); self.maybe_recover_from_bad_qpath(expr, true) } /// Parse `"('label ":")? break expr?`. fn parse_break_expr(&mut self, attrs: AttrVec) -> PResult<'a, P> { - let lo = self.prev_span; + let lo = self.prev_token.span; let label = self.eat_label(); let kind = if self.token != token::OpenDelim(token::Brace) || !self.restrictions.contains(Restrictions::NO_STRUCT_LITERAL) @@ -1093,15 +1093,15 @@ impl<'a> Parser<'a> { } else { None }; - let expr = self.mk_expr(lo.to(self.prev_span), ExprKind::Break(label, kind), attrs); + let expr = self.mk_expr(lo.to(self.prev_token.span), ExprKind::Break(label, kind), attrs); self.maybe_recover_from_bad_qpath(expr, true) } /// Parse `"yield" expr?`. fn parse_yield_expr(&mut self, attrs: AttrVec) -> PResult<'a, P> { - let lo = self.prev_span; + let lo = self.prev_token.span; let kind = ExprKind::Yield(self.parse_expr_opt()?); - let span = lo.to(self.prev_span); + let span = lo.to(self.prev_token.span); self.sess.gated_spans.gate(sym::generators, span); let expr = self.mk_expr(span, kind, attrs); self.maybe_recover_from_bad_qpath(expr, true) @@ -1306,7 +1306,11 @@ impl<'a> Parser<'a> { let expr = self.mk_expr(lit.span, ExprKind::Lit(lit), AttrVec::new()); if minus_present { - Ok(self.mk_expr(lo.to(self.prev_span), self.mk_unary(UnOp::Neg, expr), AttrVec::new())) + Ok(self.mk_expr( + lo.to(self.prev_token.span), + self.mk_unary(UnOp::Neg, expr), + AttrVec::new(), + )) } else { Ok(expr) } @@ -1349,7 +1353,7 @@ impl<'a> Parser<'a> { let capture_clause = self.parse_capture_clause(); let decl = self.parse_fn_block_decl()?; - let decl_hi = self.prev_span; + let decl_hi = self.prev_token.span; let body = match decl.output { FnRetTy::Default(_) => { let restrictions = self.restrictions - Restrictions::STMT_EXPR; @@ -1404,7 +1408,7 @@ impl<'a> Parser<'a> { let ty = if self.eat(&token::Colon) { self.parse_ty()? } else { - self.mk_ty(self.prev_span, TyKind::Infer) + self.mk_ty(self.prev_token.span, TyKind::Infer) }; Ok(Param { attrs: attrs.into(), @@ -1418,7 +1422,7 @@ impl<'a> Parser<'a> { /// Parses an `if` expression (`if` token already eaten). fn parse_if_expr(&mut self, attrs: AttrVec) -> PResult<'a, P> { - let lo = self.prev_span; + let lo = self.prev_token.span; let cond = self.parse_cond_expr()?; // Verify that the parsed `if` condition makes sense as a condition. If it is a block, then @@ -1437,7 +1441,7 @@ impl<'a> Parser<'a> { })? }; let els = if self.eat_keyword(kw::Else) { Some(self.parse_else_expr()?) } else { None }; - Ok(self.mk_expr(lo.to(self.prev_span), ExprKind::If(cond, thn, els), attrs)) + Ok(self.mk_expr(lo.to(self.prev_token.span), ExprKind::If(cond, thn, els), attrs)) } fn error_missing_if_cond(&self, lo: Span, span: Span) -> P { @@ -1463,7 +1467,7 @@ impl<'a> Parser<'a> { /// Parses a `let $pat = $expr` pseudo-expression. /// The `let` token has already been eaten. fn parse_let_expr(&mut self, attrs: AttrVec) -> PResult<'a, P> { - let lo = self.prev_span; + let lo = self.prev_token.span; let pat = self.parse_top_pat(GateOr::No)?; self.expect(&token::Eq)?; let expr = self.with_res(Restrictions::NO_STRUCT_LITERAL, |this| { @@ -1503,7 +1507,7 @@ impl<'a> Parser<'a> { if !self.eat_keyword(kw::In) { self.error_missing_in_for_loop(); } - self.check_for_for_in_in_typo(self.prev_span); + self.check_for_for_in_in_typo(self.prev_token.span); let expr = self.parse_expr_res(Restrictions::NO_STRUCT_LITERAL, None)?; let pat = self.recover_parens_around_for_head(pat, &expr, begin_paren); @@ -1512,11 +1516,11 @@ impl<'a> Parser<'a> { attrs.extend(iattrs); let kind = ExprKind::ForLoop(pat, expr, loop_block, opt_label); - Ok(self.mk_expr(lo.to(self.prev_span), kind, attrs)) + Ok(self.mk_expr(lo.to(self.prev_token.span), kind, attrs)) } fn error_missing_in_for_loop(&self) { - let in_span = self.prev_span.between(self.token.span); + let in_span = self.prev_token.span.between(self.token.span); self.struct_span_err(in_span, "missing `in` in `for` loop") .span_suggestion_short( in_span, @@ -1538,7 +1542,7 @@ impl<'a> Parser<'a> { let cond = self.parse_cond_expr()?; let (iattrs, body) = self.parse_inner_attrs_and_block()?; attrs.extend(iattrs); - Ok(self.mk_expr(lo.to(self.prev_span), ExprKind::While(cond, body, opt_label), attrs)) + Ok(self.mk_expr(lo.to(self.prev_token.span), ExprKind::While(cond, body, opt_label), attrs)) } /// Parses `loop { ... }` (`loop` token already eaten). @@ -1550,7 +1554,7 @@ impl<'a> Parser<'a> { ) -> PResult<'a, P> { let (iattrs, body) = self.parse_inner_attrs_and_block()?; attrs.extend(iattrs); - Ok(self.mk_expr(lo.to(self.prev_span), ExprKind::Loop(body, opt_label), attrs)) + Ok(self.mk_expr(lo.to(self.prev_token.span), ExprKind::Loop(body, opt_label), attrs)) } fn eat_label(&mut self) -> Option