Skip to content

Commit fbaea87

Browse files
committed
style: Add formatting for extern_ty!
1 parent 1cf49df commit fbaea87

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

ci/style.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from glob import iglob
1010
from pathlib import Path
1111

12-
1312
FMT_DIRS = ["src", "ci"]
1413
IGNORE_FILES = [
1514
# Too much special syntax that we don't want to format
@@ -87,6 +86,9 @@ def fmt_one(fpath: Path, check_only: bool):
8786
# syntax. Replace it with a dummy name.
8887
text = re.sub(r"enum #anon\b", r"enum _fmt_anon", text)
8988

89+
# `extern_ty!` can be formatted as an extern block.
90+
text = re.sub(r"extern_ty!", r'extern "extern-ty-macro"', text)
91+
9092
# If enum variants are annotated with `pub`, rustfmt erases the visibility. To get
9193
# around this we first match on all enums to extract their bodies, then look for `pub`
9294
# visibility indicators. If found, these get stashed in a comment on the preceding
@@ -126,6 +128,7 @@ def enum_sub(m: re.Match) -> str:
126128
text = re.sub(r"cfg_tmp!\(\[(.*?)\]\)", r"#[cfg(\1)]", text, flags=re.DOTALL)
127129
text = re.sub(r"enum _fmt_anon", r"enum #anon", text)
128130
text = re.sub(r"/\* FMT-VIS (.*) END-FMT-VIS \*/\n\s*", r"\1 ", text)
131+
text = re.sub(r'extern "extern-ty-macro"', r"extern_ty!", text)
129132

130133
# And write the formatted file back
131134
fpath.write_text(text)

0 commit comments

Comments
 (0)