Skip to content

fix: stop advising -> for every arrow in a range - #192

Merged
webern merged 3 commits into
mainfrom
m/deslag-arrows
Oct 17, 2026
Merged

webern merged 3 commits into
mainfrom
m/deslag-arrows

Conversation

@webern

@webern webern commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

Summary

The banned_chars arrow ranges (U+2190 to U+21FF, U+27F0 to U+27FF, U+2900 to U+297F, U+2798 to U+27AF, U+27B1 to U+27BE and U+2B00 to U+2B11) advised -> for every arrow that has no rule of its own. Most of those ranges mix directions, so the advice reversed or garbled the meaning: a leftwards hook arrow, an upwards white arrow, a right-over-left pair and a north west arrow were all told "write ->".

Now an arrow that only a range covers gets no replacement. A rule's instead is an Option, and None says that no one thing fits. The report names the character and tells the writer to choose: an ASCII arrow that points the same way, or words for what it means. fix leaves these characters alone, with its own reason. This is the second option the issue offers. It matches the module doc, which already says that the default of a range rule is a guess at meaning that is left to the writer.

One report line, before and after, for U+21A9:

before:  lines 3, 5: U+21A9 arrow "↩"; write `->`
after:   lines 3, 5: U+21A9 arrow "↩"; no one fits; write an ASCII arrow pointing the same way, or words

Findings are unchanged: the same characters are banned on the same lines. Only the advice on a range arrow's line changes. The rules for one character, such as U+2192 (->) and U+21D0 (<=), keep their replacements. Every existing .stderr and .json under tests/cases/ and tests/golden/banned_chars.txt are byte-identical, since none of them holds an arrow that only a range covers.

The issue's example of U+21D0 was stale: it has had its own rule since the issue was filed.

Not done: naming the direction of each arrow from its Unicode name. It needs a name table (a dependency, or about 300 entries written by hand that CI cannot check), and it would still need this fallback for arrows that no ASCII arrow writes, such as circles, zigzags and harpoons. It can come later on top of this. No changelog entry: this fixes wrong advice and adds no lint, setting, feature or migration.

Testing

  • make ci-fast: exit 0
  • tests/chars.rs: no arrow range rule names a replacement; U+21A9, U+21E7, U+21C4, U+2B01 and U+279C get none; U+2192 still gets ->, U+21D0 <=, and a ban entry in the config still names a replacement
  • new cases tests/cases/banned_chars/arrows and fix_arrows, each mixing a single-rule arrow with range arrows that point left, up and both ways
  • the new unit tests and the new cases fail with the range rules set back to ->
  • tests/corpus.rs the_corpus_is_fixed_only_where_the_report_says: the arrows fix leaves moved from the range-default reason (6 to 4) to the new no-replacement reason (0 to 2); make test passes
  • no run of the big tier; CI runs it

References

@webern webern added bug Something isn't working ai Primarily authored by AI (whether PR, Issue, Whatever) labels Oct 17, 2026
The arrow ranges told the writer to write `->` for each arrow that has
no rule of its own. Most of those ranges mix directions, so the advice
turned U+21A9 (leftwards) or U+21E7 (upwards) into a right arrow.

A rule can now say that it has no replacement. The ranges of arrows say
that, and the report names the character and tells the writer to choose
an ASCII arrow that points the same way, or words for what it means.
`fix` leaves these characters alone, with its own reason. The same
characters are banned on the same lines, so findings do not change.

The rules with one character, such as U+2192 and U+21D0, keep their
replacements.
The report line for an arrow that only a range rule covers was about
three times as long as the others. It now says: no one fits; write an
ASCII arrow pointing the same way, or words.

The doc comment on `lints.banned_chars` said every banned character has
something plain to write instead. That is no longer true for these
arrows, so it now says most do.
The fix test over the corpus pins how many banned characters fix leaves
for each reason. Two arrows that only a range rule covers (U+21C4 and
U+21E7) moved from the reason for a range default to the new reason for
an arrow with no replacement. The other counts, and the number fixed,
are the same.
@webern
webern marked this pull request as ready for review October 17, 2026 09:44
@webern
webern merged commit 46e9dec into main Oct 17, 2026
8 checks passed
@webern
webern deleted the m/deslag-arrows branch October 17, 2026 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai Primarily authored by AI (whether PR, Issue, Whatever) bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

banned_chars advises -> for arrows that point the other way

1 participant