Skip to content

Commit db144bf

Browse files
committed
---
yaml --- r: 41855 b: refs/heads/master c: 04d38f3 h: refs/heads/master i: 41853: 15a2cf6 41851: 11e8b8b 41847: 2a65939 41839: 89ea0b7 41823: 4c4908b 41791: 8469c24 41727: 5479d73 v: v3
1 parent 20c206f commit db144bf

File tree

7 files changed

+31
-55
lines changed

7 files changed

+31
-55
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: b3cbe9e3c1115239997e806498fa5bc7eea7bc98
2+
refs/heads/master: 04d38f38e72146ee7709f24e16e1d9cd5df41adc
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
55
refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650

trunk/doc/rust.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -594,16 +594,16 @@ and may optionally begin with any number of `attributes` that apply to the conta
594594
Atributes on the anonymous crate module define important metadata that influences
595595
the behavior of the compiler.
596596

597-
~~~~~~~~
597+
~~~~~~~~{.xfail-test}
598598
// Linkage attributes
599-
#[ link(name = "projx",
599+
#[ link(name = "projx"
600600
vers = "2.5",
601601
uuid = "9cccc5d5-aceb-4af5-8285-811211826b82") ];
602602
603603
// Additional metadata attributes
604-
#[ desc = "Project X" ];
605-
#[ license = "BSD" ];
606-
#[ author = "Jane Doe" ];
604+
#[ desc = "Project X",
605+
license = "BSD" ];
606+
author = "Jane Doe" ];
607607
608608
// Specify the output type
609609
#[ crate_type = "lib" ];

trunk/doc/tutorial-ffi.md

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ argument, which it then converts to a hexadecimal string and prints to
1212
standard output. If you have the OpenSSL libraries installed, it
1313
should compile and run without any extra effort.
1414

15-
~~~~
15+
~~~~ {.xfail-test}
1616
extern mod std;
17-
use libc::size_t;
17+
use libc::c_uint;
1818
1919
extern mod crypto {
20-
fn SHA1(src: *u8, sz: size_t, out: *u8) -> *u8;
20+
fn SHA1(src: *u8, sz: c_uint, out: *u8) -> *u8;
2121
}
2222
2323
fn as_hex(data: ~[u8]) -> ~str {
@@ -29,7 +29,7 @@ fn as_hex(data: ~[u8]) -> ~str {
2929
fn sha1(data: ~str) -> ~str unsafe {
3030
let bytes = str::to_bytes(data);
3131
let hash = crypto::SHA1(vec::raw::to_ptr(bytes),
32-
vec::len(bytes) as size_t, ptr::null());
32+
vec::len(bytes) as c_uint, ptr::null());
3333
return as_hex(vec::from_buf(hash, 20));
3434
}
3535
@@ -43,11 +43,9 @@ fn main() {
4343
Before we can call the `SHA1` function defined in the OpenSSL library, we have
4444
to declare it. That is what this part of the program does:
4545

46-
~~~~
47-
# use libc::size_t;
46+
~~~~ {.xfail-test}
4847
extern mod crypto {
49-
fn SHA1(src: *u8, sz: size_t, out: *u8) -> *u8;
50-
}
48+
fn SHA1(src: *u8, sz: uint, out: *u8) -> *u8; }
5149
~~~~
5250

5351
An `extern` module declaration containing function signatures introduces the
@@ -64,11 +62,10 @@ searches for the shared library with that name, and links the library into the
6462
program. If you want the module to have a different name from the actual
6563
library, you can use the `"link_name"` attribute, like:
6664

67-
~~~~
68-
# use libc::size_t;
65+
~~~~ {.xfail-test}
6966
#[link_name = "crypto"]
7067
extern mod something {
71-
fn SHA1(src: *u8, sz: size_t, out: *u8) -> *u8;
68+
fn SHA1(src: *u8, sz: uint, out: *u8) -> *u8;
7269
}
7370
~~~~
7471

@@ -97,10 +94,9 @@ calling conventions.
9794

9895
The foreign `SHA1` function takes three arguments, and returns a pointer.
9996

100-
~~~~
101-
# use libc::size_t;
97+
~~~~ {.xfail-test}
10298
# extern mod crypto {
103-
fn SHA1(src: *u8, sz: size_t, out: *u8) -> *u8;
99+
fn SHA1(src: *u8, sz: libc::c_uint, out: *u8) -> *u8;
104100
# }
105101
~~~~
106102

@@ -112,8 +108,8 @@ probably even worse, your code will work on one platform, but break on
112108
another.
113109

114110
In this case, we declare that `SHA1` takes two `unsigned char*`
115-
arguments and one `size_t`. The Rust equivalents are `*u8`
116-
unsafe pointers and an `libc::size_t` (which, like `unsigned long`, is a
111+
arguments and one `unsigned long`. The Rust equivalents are `*u8`
112+
unsafe pointers and an `uint` (which, like `unsigned long`, is a
117113
machine-word-sized type).
118114

119115
The standard library provides various functions to create unsafe pointers,
@@ -128,16 +124,14 @@ The `sha1` function is the most obscure part of the program.
128124

129125
~~~~
130126
# pub mod crypto {
131-
# use libc::size_t;
132-
# pub fn SHA1(src: *u8, sz: size_t, out: *u8) -> *u8 { out }
127+
# pub fn SHA1(src: *u8, sz: uint, out: *u8) -> *u8 { out }
133128
# }
134-
# use libc::size_t;
135129
# fn as_hex(data: ~[u8]) -> ~str { ~"hi" }
136130
fn sha1(data: ~str) -> ~str {
137131
unsafe {
138132
let bytes = str::to_bytes(data);
139133
let hash = crypto::SHA1(vec::raw::to_ptr(bytes),
140-
vec::len(bytes) as size_t, ptr::null());
134+
vec::len(bytes), ptr::null());
141135
return as_hex(vec::from_buf(hash, 20));
142136
}
143137
}
@@ -175,16 +169,14 @@ Let's look at our `sha1` function again.
175169

176170
~~~~
177171
# pub mod crypto {
178-
# use libc::size_t;
179-
# pub fn SHA1(src: *u8, sz: size_t, out: *u8) -> *u8 { out }
172+
# pub fn SHA1(src: *u8, sz: uint, out: *u8) -> *u8 { out }
180173
# }
181-
# use libc::size_t;
182174
# fn as_hex(data: ~[u8]) -> ~str { ~"hi" }
183175
# fn x(data: ~str) -> ~str {
184176
# unsafe {
185177
let bytes = str::to_bytes(data);
186178
let hash = crypto::SHA1(vec::raw::to_ptr(bytes),
187-
vec::len(bytes) as size_t, ptr::null());
179+
vec::len(bytes), ptr::null());
188180
return as_hex(vec::from_buf(hash, 20));
189181
# }
190182
# }

trunk/doc/tutorial-tasks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ let result = port.recv();
220220
The `Port` and `Chan` pair created by `stream` enables efficient communication
221221
between a single sender and a single receiver, but multiple senders cannot use
222222
a single `Chan`, and multiple receivers cannot use a single `Port`. What if our
223-
example needed to compute multiple results across a number of tasks? The
223+
example needed to computer multiple results across a number of tasks? The
224224
following program is ill-typed:
225225

226226
~~~ {.xfail-test}

trunk/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2393,7 +2393,7 @@ override the name used to search for the crate.
23932393

23942394
Our example crate declared this set of `link` attributes:
23952395

2396-
~~~~
2396+
~~~~ {.xfail-test}
23972397
#[link(name = "farm", vers = "2.5", author = "mjh")];
23982398
~~~~
23992399

trunk/src/etc/extract-tests.py

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
# Script for extracting compilable fragments from markdown
44
# documentation. See prep.js for a description of the format
5-
# recognized by this tool. Expects a directory fragments/ to exist
5+
# recognized by this tool. Expects a directory fragements/ to exist
66
# under the current directory, and writes the fragments in there as
77
# individual .rs files.
88

9-
import sys, re
9+
import sys, re;
1010

1111
if len(sys.argv) < 3:
1212
print("Please provide an input filename")
@@ -26,7 +26,7 @@
2626
while cur < len(lines):
2727
line = lines[cur]
2828
cur += 1
29-
chap = re.match("# (.*)", line)
29+
chap = re.match("# (.*)", line);
3030
if chap:
3131
chapter = re.sub(r"\W", "_", chap.group(1)).lower()
3232
chapter_n = 1
@@ -51,30 +51,14 @@
5151
else:
5252
# Lines beginning with '# ' are turned into valid code
5353
line = re.sub("^# ", "", line)
54-
# Allow ellipses in code snippets
54+
# Allow elipses in code snippets
5555
line = re.sub("\.\.\.", "", line)
5656
block += line
5757
if not ignore:
5858
if not re.search(r"\bfn main\b", block):
5959
block = "fn main() {\n" + block + "\n}\n"
6060
if not re.search(r"\bextern mod std\b", block):
61-
block = "extern mod std;\n" + block
62-
block = """#[ forbid(ctypes) ];
63-
#[ forbid(deprecated_mode) ];
64-
#[ forbid(deprecated_pattern) ];
65-
#[ forbid(implicit_copies) ];
66-
#[ forbid(non_implicitly_copyable_typarams) ];
67-
#[ forbid(path_statement) ];
68-
#[ forbid(type_limits) ];
69-
#[ forbid(unrecognized_lint) ];
70-
#[ forbid(unused_imports) ];
71-
#[ forbid(vecs_implicitly_copyable) ];
72-
#[ forbid(while_true) ];
73-
74-
#[ warn(deprecated_self) ];
75-
#[ warn(non_camel_case_types) ];
76-
#[ warn(structural_records) ];\n
77-
""" + block
61+
block = "extern mod std;\n" + block;
7862
if xfail:
7963
block = "// xfail-test\n" + block
8064
filename = (dest + "/" + str(chapter)

trunk/src/libcore/int-template.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub pure fn is_nonnegative(x: T) -> bool { x >= 0 as T }
7272

7373
#[inline(always)]
7474
/// Iterate over the range [`lo`..`hi`)
75-
pub fn range(lo: T, hi: T, it: fn(T) -> bool) {
75+
pub pure fn range(lo: T, hi: T, it: fn(T) -> bool) {
7676
let mut i = lo;
7777
while i < hi {
7878
if !it(i) { break }
@@ -150,7 +150,7 @@ impl T: iter::Times {
150150
`x` is an int, this is functionally equivalent to \
151151
`for int::range(0, x) |_i| { /* anything */ }`."]
152152
pure fn times(&self, it: fn() -> bool) {
153-
if *self < 0 {
153+
if is_negative(*self) {
154154
fail fmt!("The .times method expects a nonnegative number, \
155155
but found %?", self);
156156
}

0 commit comments

Comments
 (0)