Skip to content

Commit 8e01e74

Browse files
committed
---
yaml --- r: 118763 b: refs/heads/snap-stage3 c: bb06790 h: refs/heads/master i: 118761: 84c11ae 118759: d70414c v: v3
1 parent 50c8ce7 commit 8e01e74

File tree

194 files changed

+4721
-2730
lines changed

Some content is hidden

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

194 files changed

+4721
-2730
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: b1646cbfd908dc948b251e362669af421100647a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 4eb5d7baf928a922b30d71e64f7be258d1a82f2f
4+
refs/heads/snap-stage3: bb06790c37e839c98427b966cd079da712268415
55
refs/heads/try: 1813e5aa1a03b0596b8de7abd1af31edf5d6098f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/compiler-rt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit 7b97b8468f0614072cf3299fa8c51e85f609316f
1+
Subproject commit 62a4ca6055ad6fda8faf767b93b5736dcdfb7013

branches/snap-stage3/src/compiletest/runtest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ fn make_out_name(config: &Config, testfile: &Path, extension: &str) -> Path {
12691269

12701270
fn aux_output_dir_name(config: &Config, testfile: &Path) -> Path {
12711271
let mut f = output_base_name(config, testfile);
1272-
match f.filename().map(|s| Vec::from_slice(s).append(bytes!(".libaux"))) {
1272+
match f.filename().map(|s| Vec::from_slice(s).append(b".libaux")) {
12731273
Some(v) => f.set_filename(v),
12741274
None => ()
12751275
}
@@ -1490,7 +1490,7 @@ fn append_suffix_to_stem(p: &Path, suffix: &str) -> Path {
14901490
(*p).clone()
14911491
} else {
14921492
let stem = p.filestem().unwrap();
1493-
p.with_filename(Vec::from_slice(stem).append(bytes!("-")).append(suffix.as_bytes()))
1493+
p.with_filename(Vec::from_slice(stem).append(b"-").append(suffix.as_bytes()))
14941494
}
14951495
}
14961496

branches/snap-stage3/src/doc/complement-cheatsheet.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ character.
7676
~~~
7777
use std::str;
7878
79-
let x = bytes!(72u8,"ello ",0xF0,0x90,0x80,"World!");
79+
let x = b"Hello \xF0\x90\x80World!";
8080
let y = str::from_utf8_lossy(x);
8181
~~~
8282

branches/snap-stage3/src/doc/rust.md

Lines changed: 78 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ rule. A literal is a form of constant expression, so is evaluated (primarily)
234234
at compile time.
235235

236236
~~~~ {.ebnf .gram}
237-
literal : string_lit | char_lit | num_lit ;
237+
literal : string_lit | char_lit | byte_string_lit | byte_lit | num_lit ;
238238
~~~~
239239

240240
#### Character and string literals
@@ -244,17 +244,17 @@ char_lit : '\x27' char_body '\x27' ;
244244
string_lit : '"' string_body * '"' | 'r' raw_string ;
245245
246246
char_body : non_single_quote
247-
| '\x5c' [ '\x27' | common_escape ] ;
247+
| '\x5c' [ '\x27' | common_escape | unicode_escape ] ;
248248
249249
string_body : non_double_quote
250-
| '\x5c' [ '\x22' | common_escape ] ;
250+
| '\x5c' [ '\x22' | common_escape | unicode_escape ] ;
251251
raw_string : '"' raw_string_body '"' | '#' raw_string '#' ;
252252
253253
common_escape : '\x5c'
254254
| 'n' | 'r' | 't' | '0'
255255
| 'x' hex_digit 2
256-
| 'u' hex_digit 4
257-
| 'U' hex_digit 8 ;
256+
unicode_escape : 'u' hex_digit 4
257+
| 'U' hex_digit 8 ;
258258
259259
hex_digit : 'a' | 'b' | 'c' | 'd' | 'e' | 'f'
260260
| 'A' | 'B' | 'C' | 'D' | 'E' | 'F'
@@ -294,7 +294,7 @@ the following forms:
294294
escaped in order to denote *itself*.
295295

296296
Raw string literals do not process any escapes. They start with the character
297-
`U+0072` (`r`), followed zero or more of the character `U+0023` (`#`) and a
297+
`U+0072` (`r`), followed by zero or more of the character `U+0023` (`#`) and a
298298
`U+0022` (double-quote) character. The _raw string body_ is not defined in the
299299
EBNF grammar above: it can contain any sequence of Unicode characters and is
300300
terminated only by another `U+0022` (double-quote) character, followed by the
@@ -319,6 +319,78 @@ r##"foo #"# bar"##; // foo #"# bar
319319
"\\x52"; r"\x52"; // \x52
320320
~~~~
321321

322+
#### Byte and byte string literals
323+
324+
~~~~ {.ebnf .gram}
325+
byte_lit : 'b' '\x27' byte_body '\x27' ;
326+
byte_string_lit : 'b' '"' string_body * '"' | 'b' 'r' raw_byte_string ;
327+
328+
byte_body : ascii_non_single_quote
329+
| '\x5c' [ '\x27' | common_escape ] ;
330+
331+
byte_string_body : ascii_non_double_quote
332+
| '\x5c' [ '\x22' | common_escape ] ;
333+
raw_byte_string : '"' raw_byte_string_body '"' | '#' raw_byte_string '#' ;
334+
335+
~~~~
336+
337+
A _byte literal_ is a single ASCII character (in the `U+0000` to `U+007F` range)
338+
enclosed within two `U+0027` (single-quote) characters,
339+
with the exception of `U+0027` itself,
340+
which must be _escaped_ by a preceding U+005C character (`\`),
341+
or a single _escape_.
342+
It is equivalent to a `u8` unsigned 8-bit integer _number literal_.
343+
344+
A _byte string literal_ is a sequence of ASCII characters and _escapes_
345+
enclosed within two `U+0022` (double-quote) characters,
346+
with the exception of `U+0022` itself,
347+
which must be _escaped_ by a preceding `U+005C` character (`\`),
348+
or a _raw byte string literal_.
349+
It is equivalent to a `&'static [u8]` borrowed vectior unsigned 8-bit integers.
350+
351+
Some additional _escapes_ are available in either byte or non-raw byte string
352+
literals. An escape starts with a `U+005C` (`\`) and continues with one of
353+
the following forms:
354+
355+
* An _byte escape_ escape starts with `U+0078` (`x`) and is
356+
followed by exactly two _hex digits_. It denotes the byte
357+
equal to the provided hex value.
358+
* A _whitespace escape_ is one of the characters `U+006E` (`n`), `U+0072`
359+
(`r`), or `U+0074` (`t`), denoting the bytes values `0x0A` (ASCII LF),
360+
`0x0D` (ASCII CR) or `0x09` (ASCII HT) respectively.
361+
* The _backslash escape_ is the character `U+005C` (`\`) which must be
362+
escaped in order to denote its ASCII encoding `0x5C`.
363+
364+
Raw byte string literals do not process any escapes.
365+
They start with the character `U+0072` (`r`),
366+
followed by `U+0062` (`b`),
367+
followed by zero or more of the character `U+0023` (`#`),
368+
and a `U+0022` (double-quote) character.
369+
The _raw string body_ is not defined in the EBNF grammar above:
370+
it can contain any sequence of ASCII characters and is
371+
terminated only by another `U+0022` (double-quote) character, followed by the
372+
same number of `U+0023` (`#`) characters that preceded the opening `U+0022`
373+
(double-quote) character.
374+
A raw byte string literal can not contain any non-ASCII byte.
375+
376+
All characters contained in the raw string body represent their ASCII encoding,
377+
the characters `U+0022` (double-quote) (except when followed by at least as
378+
many `U+0023` (`#`) characters as were used to start the raw string literal) or
379+
`U+005C` (`\`) do not have any special meaning.
380+
381+
Examples for byte string literals:
382+
383+
~~~~
384+
b"foo"; br"foo"; // foo
385+
b"\"foo\""; br#""foo""#; // "foo"
386+
387+
b"foo #\"# bar";
388+
br##"foo #"# bar"##; // foo #"# bar
389+
390+
b"\x52"; b"R"; br"R"; // R
391+
b"\\x52"; br"\x52"; // \x52
392+
~~~~
393+
322394
#### Number literals
323395

324396
~~~~ {.ebnf .gram}
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
#!/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/emacs/run_rust_emacs_tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/bin/sh
12
# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
23
# file at the top-level directory of this distribution and at
34
# http://rust-lang.org/COPYRIGHT.

0 commit comments

Comments
 (0)