Skip to content

Commit 2e83c6d

Browse files
authored
Rollup merge of rust-lang#66889 - dtolnay:fmt6, r=rkruppe
Make python-generated source files compatible with rustfmt This PR adjusts the generators for src/libcore/num/dec2flt/table.rs, src/libcore/unicode/printable.rs, and src/libcore/unicode/tables.rs to make it so running `rustfmt` on the generated files no longer needs to apply any changes. This involves tweaking the python scripts where reasonable to better match rustfmt's style, and adding `#[rustfmt::skip]` to big constant tables that there's no point having rustfmt rewrap. r? @Dylan-DPC
2 parents c85f635 + 28eb31f commit 2e83c6d

File tree

6 files changed

+1288
-1263
lines changed

6 files changed

+1288
-1263
lines changed

src/etc/dec2flt_table.py

100644100755
+10-5
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,18 @@ def print_proper_powers():
111111
print("pub const MIN_E: i16 = {};".format(MIN_E))
112112
print("pub const MAX_E: i16 = {};".format(MAX_E))
113113
print()
114+
print("#[rustfmt::skip]")
114115
typ = "([u64; {0}], [i16; {0}])".format(len(powers))
115-
print("pub const POWERS: ", typ, " = ([", sep='')
116+
print("pub const POWERS: ", typ, " = (", sep='')
117+
print(" [")
116118
for z in powers:
117-
print(" 0x{:x},".format(z.sig))
118-
print("], [")
119+
print(" 0x{:x},".format(z.sig))
120+
print(" ],")
121+
print(" [")
119122
for z in powers:
120-
print(" {},".format(z.exp))
121-
print("]);")
123+
print(" {},".format(z.exp))
124+
print(" ],")
125+
print(");")
122126

123127

124128
def print_short_powers(num_bits, significand_size):
@@ -127,6 +131,7 @@ def print_short_powers(num_bits, significand_size):
127131
max_e = int(ceil(log(max_sig, 5)))
128132
e_range = range(max_e)
129133
typ = "[f{}; {}]".format(num_bits, len(e_range))
134+
print("#[rustfmt::skip]")
130135
print("pub const F", num_bits, "_SHORT_POWERS: ", typ, " = [", sep='')
131136
for e in e_range:
132137
print(" 1e{},".format(e))

0 commit comments

Comments
 (0)