STRA-338: architecture gate forbids new mechanical file names (impl_*, *_fn, numbered), baseline lists the 964 existing; rustsplit names modules after what they hold
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
4b04c24981
commit
ac60df040f
@@ -87,16 +87,18 @@ def _item_end(sig, k, keyword):
|
||||
|
||||
|
||||
def _impl_name(sig, k):
|
||||
"""`Foo` for `impl Foo`, `Trait_for_Foo` for `impl<T> Trait for Foo`; at most three identifiers."""
|
||||
j, depth, words = k + 1, 0, []
|
||||
"""`Foo` for `impl Foo`, `Trait_for_Foo` for `impl<T> path::Trait for path::Foo<T>`: the last identifier of each path."""
|
||||
j, depth, before, after, seen_for = k + 1, 0, None, None, False
|
||||
while j < len(sig) and sig[j].text not in ("{", "where"):
|
||||
depth += (sig[j].text == "<") - (sig[j].text == ">")
|
||||
if depth == 0 and sig[j].kind == "ident" and sig[j].text != "for":
|
||||
words.append(sig[j].text)
|
||||
elif depth == 0 and sig[j].text == "for":
|
||||
words.append("for")
|
||||
if depth == 0 and sig[j].text == "for":
|
||||
seen_for = True
|
||||
elif depth == 0 and sig[j].kind == "ident":
|
||||
before, after = (before, sig[j].text) if seen_for else (sig[j].text, after)
|
||||
j += 1
|
||||
return "_".join(words[:3]) or "impl"
|
||||
if seen_for:
|
||||
return f"{before}_for_{after}" if before and after else before or after or "impl"
|
||||
return before or "impl"
|
||||
|
||||
|
||||
def _name_of(sig, k, keyword):
|
||||
|
||||
Reference in New Issue
Block a user