confvar_re = re.compile(r'''/// Lint: (\w+). (.*).*\n *\("([^"]*)", (?:[^,]*), (.*) => (.*)\),''')
-def parse_path(p="src"):
+def parse_path(p="clippy_lints/src"):
d = {}
for f in os.listdir(p):
if f.endswith(".rs"):
elif line.startswith("declare_lint!"):
comment = False
deprecated = False
+ restriction = False
+ elif line.startswith("declare_restriction_lint!"):
+ comment = False
+ deprecated = False
+ restriction = True
elif line.startswith("declare_deprecated_lint!"):
comment = False
deprecated = True
last_comment = []
if not comment:
l = line.strip()
- m = re.search(r"pub\s+([A-Z_]+)", l)
+ m = re.search(r"pub\s+([A-Z_][A-Z_0-9]*)", l)
if m:
name = m.group(1).lower()
# Intentionally either a never looping or infinite loop
- while not deprecated:
+ while not deprecated and not restriction:
m = re.search(level_re, line)
if m:
level = m.group(0)
if deprecated:
level = "Deprecated"
+ elif restriction:
+ level = "Allow"
print("found %s with level %s in %s" % (name, level, f))
d[name] = (level, last_comment)
def main():
(d, c) = parse_path()
+ print('Found %s lints' % len(d))
if "-c" in sys.argv:
check_wiki_page(d, c, "../rust-clippy.wiki/Home.md")
else: