Fix update_lints.py for dir modules

This commit is contained in:
Michael Wright 2018-09-30 06:25:23 +02:00
parent c2ee9c29ab
commit f01fa227c0
1 changed files with 11 additions and 5 deletions

View File

@ -46,7 +46,12 @@ def collect(deprecated_lints, clippy_lints, fn):
# remove \-newline escapes from description string # remove \-newline escapes from description string
desc = nl_escape_re.sub('', match.group('desc')) desc = nl_escape_re.sub('', match.group('desc'))
cat = match.group('cat') cat = match.group('cat')
clippy_lints[cat].append((os.path.splitext(os.path.basename(fn))[0], if cat in ('internal', 'internal_warn'):
continue
module_name = os.path.splitext(os.path.basename(fn))[0]
if module_name == 'mod':
module_name = os.path.basename(os.path.dirname(fn))
clippy_lints[cat].append((module_name,
match.group('name').lower(), match.group('name').lower(),
"allow", "allow",
desc.replace('\\"', '"'))) desc.replace('\\"', '"')))
@ -138,10 +143,11 @@ def main(print_only=False, check=False):
return return
# collect all lints from source files # collect all lints from source files
for fn in os.listdir('clippy_lints/src'): for root, dirs, files in os.walk('clippy_lints/src'):
if fn.endswith('.rs'): for fn in files:
collect(deprecated_lints, clippy_lints, if fn.endswith('.rs'):
os.path.join('clippy_lints', 'src', fn)) collect(deprecated_lints, clippy_lints,
os.path.join(root, fn))
# determine version # determine version
with open('Cargo.toml') as fp: with open('Cargo.toml') as fp: