mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Stripping trailing commas and spaces from vec! elements (#1219)
* Stripping trailing commas and spaces from `vec!` elements * Stripping trailing commas and spaces ONLY from `vec!` elements * Added comment
This commit is contained in:
committed by
Nick Cameron
parent
49ce1b641a
commit
935286755c
+6
-1
@@ -114,7 +114,12 @@ pub fn rewrite_macro(mac: &ast::Mac,
|
||||
parser.bump();
|
||||
|
||||
if parser.token == Token::Eof {
|
||||
return None;
|
||||
// vec! is a special case of bracket macro which should be formated as an array.
|
||||
if macro_name == "vec!" {
|
||||
break;
|
||||
} else {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,15 @@ fn main() {
|
||||
|
||||
vec! [a /* comment */];
|
||||
|
||||
// Trailing spaces after a comma
|
||||
vec![
|
||||
a,
|
||||
];
|
||||
|
||||
unknown_bracket_macro__comma_should_not_be_stripped![
|
||||
a,
|
||||
];
|
||||
|
||||
foo(makro!(1, 3));
|
||||
|
||||
hamkaas!{ () };
|
||||
|
||||
@@ -34,6 +34,13 @@ fn main() {
|
||||
|
||||
vec![a /* comment */];
|
||||
|
||||
// Trailing spaces after a comma
|
||||
vec![a];
|
||||
|
||||
unknown_bracket_macro__comma_should_not_be_stripped![
|
||||
a,
|
||||
];
|
||||
|
||||
foo(makro!(1, 3));
|
||||
|
||||
hamkaas!{ () };
|
||||
|
||||
Reference in New Issue
Block a user