about summary refs log tree commit diff
path: root/src/libsyntax_ext
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-10-17 22:27:57 -0700
committerGitHub <noreply@github.com>2016-10-17 22:27:57 -0700
commit3543a0f6020fb16860f471e8651fa05f5709e83a (patch)
treea4ed9fd39414df30ca4c891131f55d2c755ef6d8 /src/libsyntax_ext
parent1d3dfa5301f59e86547a4034fb654c4efb47ac0e (diff)
parent94b36594c628d6703f879856b9b3d4d08a6debfa (diff)
downloadrust-3543a0f6020fb16860f471e8651fa05f5709e83a.tar.gz
rust-3543a0f6020fb16860f471e8651fa05f5709e83a.zip
Auto merge of #36969 - nnethercote:rename-Parser-fields, r=eddyb
Clarify the positions of the lexer and parser

The lexer and parser use unclear names to indicate their positions in the
source code. I propose the following renamings.

Lexer:
```
pos      -> next_pos      # it's actually the next pos!
last_pos -> pos           # it's actually the current pos!
curr     -> ch            # the current char
curr_is  -> ch_is         # tests the current char
col (unchanged)           # the current column
```
parser
```
- last_span       -> prev_span          # the previous token's span
- last_token_kind -> prev_token_kind    # the previous token's kind
- LastTokenKind   -> PrevTokenKind      # ditto (but the type)
- token (unchanged)                     # the current token
- span (unchanged)                      # the current span
```

Things to note:
- This proposal removes all uses of "last", which is an unclear word because it
  could mean (a) previous, (b) final, or (c) most recent, i.e. current.
- The "current" things (ch, col, token, span) consistently lack a prefix. The
  "previous" and "next" things consistently have a prefix.
Diffstat (limited to 'src/libsyntax_ext')
-rw-r--r--src/libsyntax_ext/asm.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/libsyntax_ext/asm.rs b/src/libsyntax_ext/asm.rs
index cc4fb604d6c..c16b7d29594 100644
--- a/src/libsyntax_ext/asm.rs
+++ b/src/libsyntax_ext/asm.rs
@@ -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 {