Skip to content

Commit

Permalink
Auto merge of #10674 - KiChjang:codegen-avoid-rust-keywords, r=Manish…
Browse files Browse the repository at this point in the history
…earth

Avoid generating parameter names that are Rust keywords

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10674)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Apr 17, 2016
2 parents a76af66 + c6b6d2c commit f93379f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -36,6 +36,13 @@
CONSTRUCT_HOOK_NAME = '_constructor'
HASINSTANCE_HOOK_NAME = '_hasInstance'

RUST_KEYWORDS = {"abstract", "alignof", "as", "become", "box", "break", "const", "continue",
"else", "enum", "extern", "false", "final", "fn", "for", "if", "impl", "in",
"let", "loop", "macro", "match", "mod", "move", "mut", "offsetof", "override",
"priv", "proc", "pub", "pure", "ref", "return", "static", "self", "sizeof",
"struct", "super", "true", "trait", "type", "typeof", "unsafe", "unsized",
"use", "virtual", "where", "while", "yield"}


def replaceFileIfChanged(filename, newContents):
"""
Expand Down Expand Up @@ -5247,7 +5254,7 @@ def indent(s):
@staticmethod
def makeMemberName(name):
# Can't use Rust keywords as member names.
if name == "type":
if name in RUST_KEYWORDS:
return name + "_"
return name

Expand Down

0 comments on commit f93379f

Please sign in to comment.