Skip to content

Commit 6f092c8

Browse files
committed
Add lint to check that all crates have #![unstable]
1 parent 5801991 commit 6f092c8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/etc/tidy.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@
2424

2525
interesting_files = ['.rs', '.py', '.js', '.sh', '.c', '.h']
2626
uninteresting_files = ['miniz.c', 'jquery', 'rust_android_dummy']
27+
stable_whitelist = {
28+
'src/bootstrap',
29+
'src/build_helper',
30+
'src/libcollectionstest',
31+
'src/libcore',
32+
'src/libstd',
33+
'src/rustc/std_shim',
34+
'src/test'
35+
}
2736

2837

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

95104
all_paths = set()
105+
needs_unstable_attr = set()
96106

97107
try:
98108
for (dirpath, dirnames, filenames) in os.walk(src_dir):
@@ -149,6 +159,9 @@ def interesting_file(f):
149159
else:
150160
if "SNAP " in line:
151161
report_warn("unmatched SNAP line: " + line)
162+
search = re.search(r'^#!\[unstable', line)
163+
if search:
164+
needs_unstable_attr.discard(filename)
152165

153166
if cr_flag in line:
154167
check_cr = False
@@ -181,6 +194,9 @@ def interesting_file(f):
181194
check_cr = True
182195
check_tab = True
183196
check_linelength = True
197+
if all(f not in filename for f in stable_whitelist) and \
198+
re.search(r'src/.*/lib\.rs', filename):
199+
needs_unstable_attr.add(filename)
184200

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

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

0 commit comments

Comments
 (0)