Skip to main content

escape_target_keyword

Function escape_target_keyword 

Source
pub fn escape_target_keyword(name: &str, target: KeywordTarget) -> String
Expand description

Escape name (an already case-converted value identifier) against the target’s reserved-word set: a name that collides with a keyword gets a trailing _, otherwise it is returned unchanged.

Idempotent — the suffixed form is never itself a keyword, so re-escaping is a no-op. Apply this at every site that emits or keys on a Bock value binding (declaration, reference, and the Go scope-inference maps) so the escaped name is used uniformly. Do not apply it to member/field/method names or to type names (see the section comment).