mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Merge pull request #2733 from topecongiro/issue-2727
Trim unnecessary whitespaces between a macro call and a semicolon
This commit is contained in:
commit
1d5da1011f
@ -46,6 +46,19 @@ impl<'a> FmtVisitor<'a> {
|
||||
// TODO these format_missing methods are ugly. Refactor and add unit tests
|
||||
// for the central whitespace stripping loop.
|
||||
pub fn format_missing(&mut self, end: BytePos) {
|
||||
// HACK(topecongiro)
|
||||
// We use `format_missing()` to extract a missing comment between a macro
|
||||
// (or alike) and a trailing semicolon. Here we just try to avoid calling
|
||||
// `format_missing_inner` in the common case where there is no such comment.
|
||||
// This is a hack, ideally we should fix a possible bug in `format_missing_inner`
|
||||
// or refactor `visit_mac` and `rewrite_macro`, but this should suffice to fix the
|
||||
// issue (#2727).
|
||||
let missing_snippet = self.snippet(mk_sp(self.last_pos, end));
|
||||
if missing_snippet.trim() == ";" {
|
||||
self.push_str(";");
|
||||
self.last_pos = end;
|
||||
return;
|
||||
}
|
||||
self.format_missing_inner(end, |this, last_snippet, _| this.push_str(last_snippet))
|
||||
}
|
||||
|
||||
|
@ -97,6 +97,10 @@ fn main() {
|
||||
|
||||
// #1092
|
||||
chain!(input, a:take!(max_size), || []);
|
||||
|
||||
// #2727
|
||||
foo!("bar")
|
||||
;
|
||||
}
|
||||
|
||||
impl X {
|
||||
|
@ -124,6 +124,9 @@ fn main() {
|
||||
|
||||
// #1092
|
||||
chain!(input, a: take!(max_size), || []);
|
||||
|
||||
// #2727
|
||||
foo!("bar");
|
||||
}
|
||||
|
||||
impl X {
|
||||
|
Loading…
Reference in New Issue
Block a user