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:
Bekh-Ivanov Aleksey 2016-11-14 07:42:15 +03:00 committed by Nick Cameron
parent 49ce1b641a
commit 935286755c
3 changed files with 22 additions and 1 deletions

View File

@ -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;
}
}
}
}

View File

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

View File

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