Skip to content

Commit 375b19b

Browse files
committed
---
yaml --- r: 218714 b: refs/heads/snap-stage3 c: 0ae30e6 h: refs/heads/master v: v3
1 parent a830d73 commit 375b19b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+880
-915
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: c044791d80ea0dc5c4b57b6030a67b69f8510239
3-
refs/heads/snap-stage3: 5a2c766cdd5e8f2652b30b8b4dfa9db050e574eb
3+
refs/heads/snap-stage3: 0ae30e608c5823a195af62051bfc4e9460f4bd25
44
refs/heads/try: b53c0f93eedcdedd4fd89bccc5a3a09d1c5cd23e
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/snap-stage3/src/doc/trpl/macros.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ There are additional rules regarding the next token after a metavariable:
478478

479479
* `expr` variables may only be followed by one of: `=> , ;`
480480
* `ty` and `path` variables may only be followed by one of: `=> , : = > as`
481-
* `pat` variables may only be followed by one of: `=> , = if in`
481+
* `pat` variables may only be followed by one of: `=> , =`
482482
* Other variables may be followed by any token.
483483

484484
These rules provide some flexibility for Rust’s syntax to evolve without
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
4+
# file at the top-level directory of this distribution and at
5+
# http://rust-lang.org/COPYRIGHT.
6+
#
7+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
8+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
9+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
10+
# option. This file may not be copied, modified, or distributed
11+
# except according to those terms.
12+
13+
import sys
14+
import subprocess
15+
import re
16+
17+
18+
def main():
19+
if len(sys.argv) <= 1:
20+
print('Usage: %s [ --apply ] filename1.rs filename2.rs ...'
21+
% sys.argv[0])
22+
elif sys.argv[1] == '--apply':
23+
for filename in sys.argv[2:]:
24+
patch(filename)
25+
else:
26+
for filename in sys.argv[1:]:
27+
diff(filename)
28+
29+
30+
def patch(filename):
31+
source = read(filename)
32+
rewritten = rewrite_bytes_macros(source)
33+
if rewritten is not None and rewritten != source:
34+
write(filename, rewritten)
35+
36+
37+
def diff(filename):
38+
rewritten = rewrite_bytes_macros(read(filename))
39+
if rewritten is not None:
40+
p = subprocess.Popen(['diff', '-u', filename, '-'],
41+
stdin=subprocess.PIPE)
42+
p.stdin.write(rewritten)
43+
p.stdin.close()
44+
p.wait()
45+
46+
47+
def read(filename):
48+
with open(filename, 'rb') as f:
49+
return f.read()
50+
51+
52+
def write(filename, content):
53+
with open(filename, 'wb') as f:
54+
f.write(content)
55+
56+
57+
def rewrite_bytes_macros(source):
58+
rewritten, num_occurrences = BYTES_MACRO_RE.subn(rewrite_one_macro, source)
59+
if num_occurrences > 0:
60+
return rewritten
61+
62+
63+
BYTES_MACRO_RE = re.compile(br'bytes!\( (?P<args> [^)]* ) \)', re.VERBOSE)
64+
65+
66+
def rewrite_one_macro(match):
67+
try:
68+
bytes = parse_bytes(split_args(match.group('args')))
69+
return b'b"' + b''.join(map(escape, bytes)) + b'"'
70+
except SkipThisRewrite:
71+
print('Skipped: %s' % match.group(0).decode('utf8', 'replace'))
72+
return match.group(0)
73+
74+
75+
class SkipThisRewrite(Exception):
76+
pass
77+
78+
79+
def split_args(args):
80+
previous = b''
81+
for arg in args.split(b','):
82+
if previous:
83+
arg = previous + b',' + arg
84+
if arg.count(b'"') % 2 == 0:
85+
yield arg
86+
previous = b''
87+
else:
88+
previous = arg
89+
if previous:
90+
yield previous
91+
92+
93+
def parse_bytes(args):
94+
for arg in args:
95+
arg = arg.strip()
96+
if (arg.startswith(b'"') and arg.endswith(b'"')) or (
97+
arg.startswith(b"'") and arg.endswith(b"'")):
98+
# Escaped newline means something different in Rust and Python.
99+
if b'\\\n' in arg:
100+
raise SkipThisRewrite
101+
for byte in eval(b'u' + arg).encode('utf8'):
102+
yield ord(byte)
103+
else:
104+
if arg.endswith(b'u8'):
105+
arg = arg[:-2]
106+
# Assume that all Rust integer literals
107+
# are valid Python integer literals
108+
value = int(eval(arg))
109+
assert value <= 0xFF
110+
yield value
111+
112+
113+
def escape(byte):
114+
c = chr(byte)
115+
escaped = {
116+
b'\0': br'\0',
117+
b'\t': br'\t',
118+
b'\n': br'\n',
119+
b'\r': br'\r',
120+
b'\'': b'\\\'',
121+
b'\\': br'\\',
122+
}.get(c)
123+
if escaped is not None:
124+
return escaped
125+
elif b' ' <= c <= b'~':
126+
return chr(byte)
127+
else:
128+
return ('\\x%02X' % byte).encode('ascii')
129+
130+
131+
if str is not bytes:
132+
# Python 3.x
133+
ord = lambda x: x
134+
chr = lambda x: bytes([x])
135+
136+
137+
if __name__ == '__main__':
138+
main()

branches/snap-stage3/src/etc/check-summary.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def summarise(fname):
3434
summaries.append((fname, summary))
3535

3636
def count(t):
37-
return sum(map(lambda f: len(f[1].get(t, [])), summaries))
37+
return sum(map(lambda (f, s): len(s.get(t, [])), summaries))
3838

3939
logfiles = sys.argv[1:]
4040
for files in map(glob.glob, logfiles):
@@ -43,15 +43,15 @@ def count(t):
4343
failed = count('failed')
4444
ignored = count('ignored')
4545
measured = count('bench')
46-
print("summary of %d test runs: %d passed; %d failed; %d ignored; %d measured" %
47-
(len(logfiles), ok, failed, ignored, measured))
48-
print("")
46+
print "summary of %d test runs: %d passed; %d failed; %d ignored; %d measured" % \
47+
(len(logfiles), ok, failed, ignored, measured)
48+
print ""
4949

5050
if failed > 0:
51-
print("failed tests:")
51+
print "failed tests:"
5252
for f, s in summaries:
5353
failures = s.get('failed', [])
5454
if len(failures) > 0:
55-
print(" %s:" % (f))
55+
print " %s:" % (f)
5656
for test in failures:
57-
print(" %s" % (test))
57+
print " %s" % (test)

branches/snap-stage3/src/etc/errorck.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import re
1717

1818
if len(sys.argv) < 2:
19-
print("usage: errorck.py <src-dir>")
19+
print "usage: errorck.py <src-dir>"
2020
sys.exit(1)
2121

2222
src_dir = sys.argv[1]

branches/snap-stage3/src/etc/featureck.py

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,10 @@
1818
# since the same version
1919
# * Prints information about features
2020

21-
import sys
22-
import os
23-
import re
24-
import codecs
21+
import sys, os, re
2522

2623
if len(sys.argv) < 2:
27-
print("usage: featureck.py <src-dir>")
24+
print "usage: featurkck.py <src-dir>"
2825
sys.exit(1)
2926

3027
src_dir = sys.argv[1]
@@ -50,7 +47,7 @@
5047
line = line.replace("(", "").replace("),", "").replace(")", "")
5148
parts = line.split(",")
5249
if len(parts) != 3:
53-
print("error: unexpected number of components in line: " + original_line)
50+
print "error: unexpected number of components in line: " + original_line
5451
sys.exit(1)
5552
feature_name = parts[0].strip().replace('"', "")
5653
since = parts[1].strip().replace('"', "")
@@ -82,7 +79,7 @@
8279
continue
8380

8481
path = os.path.join(dirpath, filename)
85-
with codecs.open(filename=path, mode='r', encoding="utf-8") as f:
82+
with open(path, 'r') as f:
8683
line_num = 0
8784
for line in f:
8885
line_num += 1
@@ -110,9 +107,9 @@
110107
if not mm is None:
111108
since = mm.group(1)
112109
else:
113-
print("error: misformed stability attribute")
114-
print("line %d of %:" % (line_num, path))
115-
print(line)
110+
print "error: misformed stability attribute"
111+
print "line " + str(line_num) + " of " + path + ":"
112+
print line
116113
errors = True
117114

118115
lib_features[feature_name] = feature_name
@@ -126,24 +123,24 @@
126123
(expected_since, source_path, source_line_num, source_line) = \
127124
lib_features_and_level.get((feature_name, level))
128125
if since != expected_since:
129-
print("error: mismatch in %s feature '%s'" % (level, feature_name))
130-
print("line %d of %s:" % (source_line_num, source_path))
131-
print(source_line)
132-
print("line %d of %s:" % (line_num, path))
133-
print(line)
126+
print "error: mismatch in " + level + " feature '" + feature_name + "'"
127+
print "line " + str(source_line_num) + " of " + source_path + ":"
128+
print source_line
129+
print "line " + str(line_num) + " of " + path + ":"
130+
print line
134131
errors = True
135132

136133
# Verify that this lib feature doesn't duplicate a lang feature
137134
if feature_name in language_feature_names:
138-
print("error: lib feature '%s' duplicates a lang feature" % (feature_name))
139-
print("line %d of %s:" % (line_num, path))
140-
print(line)
135+
print "error: lib feature '" + feature_name + "' duplicates a lang feature"
136+
print "line " + str(line_num) + " of " + path + ":"
137+
print line
141138
errors = True
142139

143140
else:
144-
print("error: misformed stability attribute")
145-
print("line %d of %s:" % (line_num, path))
146-
print(line)
141+
print "error: misformed stability attribute"
142+
print "line " + str(line_num) + " of " + path + ":"
143+
print line
147144
errors = True
148145

149146
# Merge data about both lists
@@ -178,7 +175,7 @@
178175
is_unstable = lib_features_and_level.get((name, "unstable")) is not None
179176

180177
if is_stable and is_unstable:
181-
print("error: feature '%s' is both stable and unstable" % (name))
178+
print "error: feature '" + name + "' is both stable and unstable"
182179
errors = True
183180

184181
if is_stable:
@@ -195,21 +192,21 @@
195192
for name in lib_feature_stats:
196193
if language_feature_stats.get(name) is not None:
197194
if not name in joint_features:
198-
print("error: feature '%s' is both a lang and lib feature but not whitelisted" % (name))
195+
print "error: feature '" + name + "' is both a lang and lib feature but not whitelisted"
199196
errors = True
200197
lang_status = language_feature_stats[name][3]
201198
lib_status = lib_feature_stats[name][3]
202199
lang_stable_since = language_feature_stats[name][4]
203200
lib_stable_since = lib_feature_stats[name][4]
204201

205202
if lang_status != lib_status and lib_status != "deprecated":
206-
print("error: feature '%s' has lang status %s " +
207-
"but lib status %s" % (name, lang_status, lib_status))
203+
print "error: feature '" + name + "' has lang status " + lang_status + \
204+
" but lib status " + lib_status
208205
errors = True
209206

210207
if lang_stable_since != lib_stable_since:
211-
print("error: feature '%s' has lang stable since %s " +
212-
"but lib stable since %s" % (name, lang_stable_since, lib_stable_since))
208+
print "error: feature '" + name + "' has lang stable since " + lang_stable_since + \
209+
" but lib stable since " + lib_stable_since
213210
errors = True
214211

215212
merged_stats[name] = (name, True, True, lang_status, lang_stable_since)
@@ -243,5 +240,5 @@
243240

244241
print
245242
for line in lines:
246-
print("* " + line)
243+
print "* " + line
247244
print

branches/snap-stage3/src/etc/tidy.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def interesting_file(f):
8181
check_linelength = True
8282

8383
if len(sys.argv) < 2:
84-
print("usage: tidy.py <src-dir>")
84+
print "usage: tidy.py <src-dir>"
8585
sys.exit(1)
8686

8787
src_dir = sys.argv[1]
@@ -200,10 +200,10 @@ def interesting_file(f):
200200

201201
print
202202
for ext in sorted(file_counts, key=file_counts.get, reverse=True):
203-
print("* linted {} {} files".format(file_counts[ext], ext))
204-
print("* linted {} other files".format(count_other_linted_files))
205-
print("* total lines of code: {}".format(count_lines))
206-
print("* total non-blank lines of code: {}".format(count_non_blank_lines))
207-
print()
203+
print "* linted {} {} files".format(file_counts[ext], ext)
204+
print "* linted {} other files".format(count_other_linted_files)
205+
print "* total lines of code: {}".format(count_lines)
206+
print "* total non-blank lines of code: {}".format(count_non_blank_lines)
207+
print
208208

209209
sys.exit(err)

0 commit comments

Comments
 (0)