about summary refs log tree commit diff
path: root/src/libsyntax/parse/comments.rs
diff options
context:
space:
mode:
authorDaniel Fagnan <dnfagnan@gmail.com>2014-02-24 19:42:40 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-03-20 18:06:53 -0700
commit4e00cf613428d24d305a89e4f8e79b70ea8e8322 (patch)
tree183c414832596437bfc0e6a04b81f8542cbd53c0 /src/libsyntax/parse/comments.rs
parent6eae7df43cd21b76fe91eeaf6ef2af9bd2a8fafc (diff)
downloadrust-4e00cf613428d24d305a89e4f8e79b70ea8e8322.tar.gz
rust-4e00cf613428d24d305a89e4f8e79b70ea8e8322.zip
Added new attribute syntax with backward compatibility.
Signed-off-by: Daniel Fagnan <dnfagnan@gmail.com>
Diffstat (limited to 'src/libsyntax/parse/comments.rs')
-rw-r--r--src/libsyntax/parse/comments.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs
index 8abc01b6d75..1221d8401be 100644
--- a/src/libsyntax/parse/comments.rs
+++ b/src/libsyntax/parse/comments.rs
@@ -12,7 +12,7 @@ use ast;
 use codemap::{BytePos, CharPos, CodeMap, Pos};
 use diagnostic;
 use parse::lexer::{is_whitespace, with_str_from, Reader};
-use parse::lexer::{StringReader, bump, is_eof, nextch_is, TokenAndSpan};
+use parse::lexer::{StringReader, bump, peek, is_eof, nextch_is, TokenAndSpan};
 use parse::lexer::{is_line_non_doc_comment, is_block_non_doc_comment};
 use parse::lexer;
 use parse::token;
@@ -331,7 +331,11 @@ fn consume_comment(rdr: &StringReader,
     } else if rdr.curr_is('/') && nextch_is(rdr, '*') {
         read_block_comment(rdr, code_to_the_left, comments);
     } else if rdr.curr_is('#') && nextch_is(rdr, '!') {
-        read_shebang_comment(rdr, code_to_the_left, comments);
+        // Make sure the following token is **not** the beginning
+        // of an inner attribute, which starts with the same syntax.
+        if peek(rdr, 2).unwrap() != '[' {
+            read_shebang_comment(rdr, code_to_the_left, comments);
+        }
     } else { fail!(); }
     debug!("<<< consume comment");
 }