Add an ignore! macro, remove support for nested block comments, re: #2755.

This commit is contained in:
Graydon Hoare 2012-09-07 16:58:27 -07:00
parent 249668f223
commit e9f5a099df
6 changed files with 26 additions and 28 deletions

View File

@ -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() {

View File

@ -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, ...])]];

View File

@ -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.

View File

@ -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() {
}

View File

@ -1,11 +0,0 @@
// -*- rust -*-
// error-pattern: unterminated block comment
/*
* This is an un-balanced /* multi-line comment.
*/
fn main() {
debug!("hello, world.");
}

View File

@ -1,9 +1,6 @@
// -*- rust -*-
/*
* This is a /* depth-balanced */ multi-line comment.
* This is a multi-line comment.
*/
fn main() { }