about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2012-09-07 16:58:27 -0700
committerGraydon Hoare <graydon@mozilla.com>2012-09-07 16:58:36 -0700
commite9f5a099dfcb42c7f2bb38974b57bbde7042ee9c (patch)
treeee7269e1d1b3e9d79d8515e297768e72e0be1c59
parent249668f22396bde43523207117b3869e63b49c4f (diff)
downloadrust-e9f5a099dfcb42c7f2bb38974b57bbde7042ee9c.tar.gz
rust-e9f5a099dfcb42c7f2bb38974b57bbde7042ee9c.zip
Add an ignore! macro, remove support for nested block comments, re: #2755.
-rw-r--r--src/libcore/dvec.rs2
-rw-r--r--src/libsyntax/ext/expand.rs1
-rw-r--r--src/libsyntax/parse/lexer.rs19
-rw-r--r--src/test/compile-fail/no-comment-balancing.rs16
-rw-r--r--src/test/compile-fail/unbalanced-comment.rs11
-rw-r--r--src/test/run-pass/multiline-comment.rs5
6 files changed, 26 insertions, 28 deletions
diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs
index eba1cb73cf3..153fa69d4b8 100644
--- a/src/libcore/dvec.rs
+++ b/src/libcore/dvec.rs
@@ -235,13 +235,13 @@ impl<A: copy> DVec<A> {
         }
     }
 
-    /*
     /**
      * Append all elements of an iterable.
      *
      * Failure will occur if the iterable's `each()` method
      * attempts to access this vector.
      */
+    /*
     fn append_iter<A, I:iter::base_iter<A>>(ts: I) {
         do self.swap |v| {
            let mut v = match ts.size_hint() {
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index 984ac9fb0e3..4558d0a1872 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -243,6 +243,7 @@ fn new_span(cx: ext_ctxt, sp: span) -> span {
 fn core_macros() -> ~str {
     return
 ~"{
+    macro_rules! ignore (($($x:tt)*) => (()))
     #macro[[#error[f, ...], log(core::error, #fmt[f, ...])]];
     #macro[[#warn[f, ...], log(core::warn, #fmt[f, ...])]];
     #macro[[#info[f, ...], log(core::info, #fmt[f, ...])]];
diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs
index e4c5d233867..e93f3cfe9c6 100644
--- a/src/libsyntax/parse/lexer.rs
+++ b/src/libsyntax/parse/lexer.rs
@@ -267,21 +267,16 @@ fn consume_block_comment(rdr: string_reader)
                 sp: ast_util::mk_sp(start_chpos, rdr.chpos)
             });
         }
-    }
-
-    let mut level: int = 1;
-    while level > 0 {
-        if is_eof(rdr) { rdr.fatal(~"unterminated block comment"); }
-        if rdr.curr == '/' && nextch(rdr) == '*' {
-            bump(rdr);
-            bump(rdr);
-            level += 1;
-        } else {
+    } else {
+        loop {
+            if is_eof(rdr) { rdr.fatal(~"unterminated block comment"); }
             if rdr.curr == '*' && nextch(rdr) == '/' {
                 bump(rdr);
                 bump(rdr);
-                level -= 1;
-            } else { bump(rdr); }
+                break;
+            } else {
+                bump(rdr);
+            }
         }
     }
     // restart whitespace munch.
diff --git a/src/test/compile-fail/no-comment-balancing.rs b/src/test/compile-fail/no-comment-balancing.rs
new file mode 100644
index 00000000000..5361fce749d
--- /dev/null
+++ b/src/test/compile-fail/no-comment-balancing.rs
@@ -0,0 +1,16 @@
+// error-pattern:
+
+/* This is a test to ensure that we do _not_ support nested/balanced comments. I know you might be
+   thinking "but nested comments are cool", and that would be a valid point, but they are also a
+   thing that would make our lexical syntax non-regular, and we do not want that to be true.
+
+   omitting-things at a higher level (tokens) should be done via token-trees / macros,
+   not comments.
+
+   /*
+     fail here
+   */
+*/
+
+fn main() {
+}
diff --git a/src/test/compile-fail/unbalanced-comment.rs b/src/test/compile-fail/unbalanced-comment.rs
deleted file mode 100644
index d1b7a7721f2..00000000000
--- a/src/test/compile-fail/unbalanced-comment.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-// -*- rust -*-
-
-// error-pattern: unterminated block comment
-
-/*
- * This is an un-balanced /* multi-line comment.
- */
-
-fn main() {
-  debug!("hello, world.");
-}
diff --git a/src/test/run-pass/multiline-comment.rs b/src/test/run-pass/multiline-comment.rs
index 85e80ab201b..3ecb37233ce 100644
--- a/src/test/run-pass/multiline-comment.rs
+++ b/src/test/run-pass/multiline-comment.rs
@@ -1,9 +1,6 @@
-
-
-
 // -*- rust -*-
 
 /*
- * This is a /* depth-balanced */ multi-line comment.
+ * This is a multi-line comment.
  */
 fn main() { }