Skip to content

Commit 8691c64

Browse files
committed
cargo run cargo-fmt
Reformat codebase with current version to pass self_tests (formats macros without repetitions).
1 parent d8c154f commit 8691c64

File tree

4 files changed

+34
-32
lines changed

4 files changed

+34
-32
lines changed

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ macro_rules! is_nightly_channel {
3636
option_env!("CFG_RELEASE_CHANNEL")
3737
.map(|c| c == "nightly")
3838
.unwrap_or(true)
39-
}
39+
};
4040
}
4141

4242
macro_rules! configuration_option_enum{

src/macros.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ use syntax::util::ThinVec;
3333
use codemap::SpanUtils;
3434
use comment::{contains_comment, remove_trailing_white_spaces, FindUncommented};
3535
use expr::{rewrite_array, rewrite_call_inner};
36-
use lists::{itemize_list, write_list, DefinitiveListTactic, ListFormatting, SeparatorPlace, SeparatorTactic};
36+
use lists::{itemize_list, write_list, DefinitiveListTactic, ListFormatting, SeparatorPlace,
37+
SeparatorTactic};
3738
use rewrite::{Rewrite, RewriteContext};
3839
use shape::{Indent, Shape};
3940
use utils::{format_visibility, mk_sp};
@@ -102,7 +103,7 @@ fn parse_macro_arg(parser: &mut Parser) -> Option<MacroArg> {
102103
parser.sess.span_diagnostic.reset_err_count();
103104
}
104105
}
105-
}
106+
};
106107
}
107108

108109
parse_macro_arg!(Expr, parse_expr);
@@ -312,8 +313,8 @@ pub fn rewrite_macro_def(
312313

313314
let arm_shape = if multi_branch_style {
314315
shape
315-
.block_indent(context.config.tab_spaces())
316-
.with_max_width(context.config)
316+
.block_indent(context.config.tab_spaces())
317+
.with_max_width(context.config)
317318
} else {
318319
shape
319320
};
@@ -743,7 +744,12 @@ struct MacroBranch {
743744
}
744745

745746
impl MacroBranch {
746-
fn rewrite(&self, context: &RewriteContext, shape: Shape, multi_branch_style: bool) -> Option<String> {
747+
fn rewrite(
748+
&self,
749+
context: &RewriteContext,
750+
shape: Shape,
751+
multi_branch_style: bool,
752+
) -> Option<String> {
747753
// Only attempt to format function-like macros.
748754
if self.args_paren_kind != DelimToken::Paren {
749755
// FIXME(#1539): implement for non-sugared macros.
@@ -807,10 +813,7 @@ impl MacroBranch {
807813
// FIXME: this could be *much* more efficient.
808814
for (old, new) in &substs {
809815
if old_body.find(new).is_some() {
810-
debug!(
811-
"rewrite_macro_def: bailing matching variable: `{}`",
812-
new
813-
);
816+
debug!("rewrite_macro_def: bailing matching variable: `{}`", new);
814817
return None;
815818
}
816819
new_body = new_body.replace(new, old);

src/spanned.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,30 @@ pub trait Spanned {
2020
}
2121

2222
macro_rules! span_with_attrs_lo_hi {
23-
($this:ident, $lo:expr, $hi:expr) => {
24-
{
25-
let attrs = outer_attributes(&$this.attrs);
26-
if attrs.is_empty() {
27-
mk_sp($lo, $hi)
28-
} else {
29-
mk_sp(attrs[0].span.lo(), $hi)
30-
}
23+
($this: ident, $lo: expr, $hi: expr) => {{
24+
let attrs = outer_attributes(&$this.attrs);
25+
if attrs.is_empty() {
26+
mk_sp($lo, $hi)
27+
} else {
28+
mk_sp(attrs[0].span.lo(), $hi)
3129
}
32-
}
30+
}};
3331
}
3432

3533
macro_rules! span_with_attrs {
36-
($this:ident) => {
34+
($this: ident) => {
3735
span_with_attrs_lo_hi!($this, $this.span.lo(), $this.span.hi())
38-
}
36+
};
3937
}
4038

4139
macro_rules! implement_spanned {
42-
($this:ty) => {
40+
($this: ty) => {
4341
impl Spanned for $this {
4442
fn span(&self) -> Span {
4543
span_with_attrs!(self)
4644
}
4745
}
48-
}
46+
};
4947
}
5048

5149
// Implement `Spanned` for structs with `attrs` field.

src/utils.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,9 @@ macro_rules! msg {
342342
// For format_missing and last_pos, need to use the source callsite (if applicable).
343343
// Required as generated code spans aren't guaranteed to follow on from the last span.
344344
macro_rules! source {
345-
($this:ident, $sp: expr) => {
345+
($this: ident, $sp: expr) => {
346346
$sp.source_callsite()
347-
}
347+
};
348348
}
349349

350350
pub fn mk_sp(lo: BytePos, hi: BytePos) -> Span {
@@ -353,28 +353,29 @@ pub fn mk_sp(lo: BytePos, hi: BytePos) -> Span {
353353

354354
// Return true if the given span does not intersect with file lines.
355355
macro_rules! out_of_file_lines_range {
356-
($self:ident, $span:expr) => {
357-
!$self.config
356+
($self: ident, $span: expr) => {
357+
!$self
358+
.config
358359
.file_lines()
359360
.intersects(&$self.codemap.lookup_line_range($span))
360-
}
361+
};
361362
}
362363

363364
macro_rules! skip_out_of_file_lines_range {
364-
($self:ident, $span:expr) => {
365+
($self: ident, $span: expr) => {
365366
if out_of_file_lines_range!($self, $span) {
366367
return None;
367368
}
368-
}
369+
};
369370
}
370371

371372
macro_rules! skip_out_of_file_lines_range_visitor {
372-
($self:ident, $span:expr) => {
373+
($self: ident, $span: expr) => {
373374
if out_of_file_lines_range!($self, $span) {
374375
$self.push_rewrite($span, None);
375376
return;
376377
}
377-
}
378+
};
378379
}
379380

380381
// Wraps String in an Option. Returns Some when the string adheres to the

0 commit comments

Comments
 (0)