Add an ignore! macro, remove support for nested block comments, re: #2755.
This commit is contained in:
parent
249668f223
commit
e9f5a099df
@ -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() {
|
||||
|
@ -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, ...])]];
|
||||
|
@ -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.
|
||||
|
16
src/test/compile-fail/no-comment-balancing.rs
Normal file
16
src/test/compile-fail/no-comment-balancing.rs
Normal 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() {
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
// -*- rust -*-
|
||||
|
||||
// error-pattern: unterminated block comment
|
||||
|
||||
/*
|
||||
* This is an un-balanced /* multi-line comment.
|
||||
*/
|
||||
|
||||
fn main() {
|
||||
debug!("hello, world.");
|
||||
}
|
@ -1,9 +1,6 @@
|
||||
|
||||
|
||||
|
||||
// -*- rust -*-
|
||||
|
||||
/*
|
||||
* This is a /* depth-balanced */ multi-line comment.
|
||||
* This is a multi-line comment.
|
||||
*/
|
||||
fn main() { }
|
||||
|
Loading…
x
Reference in New Issue
Block a user