Skip to content

Commit a848e28

Browse files
ytmimicalebcartwright
authored andcommittedApr 7, 2024
Revert "Initial work on formatting headers"
This reverts commit dd301b0.
1 parent 202fa22 commit a848e28

File tree

4 files changed

+7
-130
lines changed

4 files changed

+7
-130
lines changed
 

‎src/header.rs

-102
This file was deleted.

‎src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ mod emitter;
7171
mod expr;
7272
mod format_report_formatter;
7373
pub(crate) mod formatting;
74-
pub(crate) mod header;
7574
mod ignore_path;
7675
mod imports;
7776
mod items;

‎src/macros.rs

+7-15
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use crate::comment::{
2727
use crate::config::lists::*;
2828
use crate::config::Version;
2929
use crate::expr::{rewrite_array, rewrite_assign_rhs, RhsAssignKind};
30-
use crate::header::{format_header, HeaderPart};
3130
use crate::lists::{itemize_list, write_list, ListFormatting};
3231
use crate::overflow;
3332
use crate::parse::macros::lazy_static::parse_lazy_static;
@@ -37,8 +36,8 @@ use crate::shape::{Indent, Shape};
3736
use crate::source_map::SpanUtils;
3837
use crate::spanned::Spanned;
3938
use crate::utils::{
40-
filtered_str_fits, indent_next_line, is_empty_line, mk_sp, remove_trailing_white_spaces,
41-
rewrite_ident, trim_left_preserve_layout, NodeIdExt,
39+
filtered_str_fits, format_visibility, indent_next_line, is_empty_line, mk_sp,
40+
remove_trailing_white_spaces, rewrite_ident, trim_left_preserve_layout, NodeIdExt,
4241
};
4342
use crate::visitor::FmtVisitor;
4443

@@ -419,21 +418,14 @@ pub(crate) fn rewrite_macro_def(
419418
None => return snippet,
420419
};
421420

422-
let mut header = if def.macro_rules {
423-
let pos = context.snippet_provider.span_after(span, "macro_rules!");
424-
vec![HeaderPart::new("macro_rules!", span.with_hi(pos))]
421+
let mut result = if def.macro_rules {
422+
String::from("macro_rules!")
425423
} else {
426-
let macro_lo = context.snippet_provider.span_before(span, "macro");
427-
let macro_hi = macro_lo + BytePos("macro".len() as u32);
428-
vec![
429-
HeaderPart::visibility(context, vis),
430-
HeaderPart::new("macro", mk_sp(macro_lo, macro_hi)),
431-
]
424+
format!("{}macro", format_visibility(context, vis))
432425
};
433426

434-
header.push(HeaderPart::ident(context, ident));
435-
436-
let mut result = format_header(context, shape, header);
427+
result += " ";
428+
result += rewrite_ident(context, ident);
437429

438430
let multi_branch_style = def.macro_rules || parsed_def.branches.len() != 1;
439431

‎tests/target/keywords.rs

-12
This file was deleted.

0 commit comments

Comments
 (0)