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:
parent
49ce1b641a
commit
935286755c
3 changed files with 22 additions and 1 deletions
|
|
@ -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!{ () };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue