1 # Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 # file at the top-level directory of this distribution and at
3 # http://rust-lang.org/COPYRIGHT.
5 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 # option. This file may not be copied, modified, or distributed
9 # except according to those terms.
11 # Digs error codes out of files named 'diagnostics.rs' across
12 # the tree, and ensures thare are no duplicates.
20 for (dirpath, dirnames, filenames) in os.walk(src_dir):
22 if "src/test" in dirpath or "src/llvm" in dirpath:
23 # Short circuit for fast
26 for filename in filenames:
27 if filename != "diagnostics.rs":
30 path = os.path.join(dirpath, filename)
32 with open(path, 'r') as f:
35 p = re.compile("(E\d\d\d\d)")
40 new_record = [(errcode, path, line_num, line)]
41 existing = errcode_map.get(errcode)
42 if existing is not None:
44 errcode_map[errcode] = existing + new_record
46 errcode_map[errcode] = new_record
52 for errcode in errcode_map:
53 entries = errcode_map[errcode]
54 all_errors += [entries[0][0]]
56 print "error: duplicate error code " + errcode
58 print entry[1] + ": " + str(entry[2])
62 print str(len(errcode_map)) + " error codes"
67 print "highest error code: " + all_errors[0]