Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lint to check that all crates have #![unstable] #31627

Merged
merged 1 commit into from
Feb 16, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/etc/tidy.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@

interesting_files = ['.rs', '.py', '.js', '.sh', '.c', '.h']
uninteresting_files = ['miniz.c', 'jquery', 'rust_android_dummy']
stable_whitelist = {
'src/bootstrap',
'src/build_helper',
'src/libcollectionstest',
'src/libcore',
'src/libstd',
'src/rustc/std_shim',
'src/test'
}


def report_error_name_no(name, no, s):
Expand Down Expand Up @@ -93,6 +102,7 @@ def interesting_file(f):
file_counts = {ext: 0 for ext in interesting_files}

all_paths = set()
needs_unstable_attr = set()

try:
for (dirpath, dirnames, filenames) in os.walk(src_dir):
Expand Down Expand Up @@ -149,6 +159,9 @@ def interesting_file(f):
else:
if "SNAP " in line:
report_warn("unmatched SNAP line: " + line)
search = re.search(r'^#!\[unstable', line)
if search:
needs_unstable_attr.discard(filename)

if cr_flag in line:
check_cr = False
Expand Down Expand Up @@ -181,6 +194,9 @@ def interesting_file(f):
check_cr = True
check_tab = True
check_linelength = True
if all(f not in filename for f in stable_whitelist) and \
re.search(r'src/.*/lib\.rs', filename):
needs_unstable_attr.add(filename)

# Put a reasonable limit on the amount of header data we use for
# the licenseck
Expand All @@ -195,6 +211,8 @@ def interesting_file(f):
update_counts(current_name)
assert len(current_contents) > 0
do_license_check(current_name, current_contents)
for f in needs_unstable_attr:
report_error_name_no(f, 1, "requires unstable attribute")

except UnicodeDecodeError as e:
report_err("UTF-8 decoding error " + str(e))
Expand Down