Skip to content

Commit 2d7d7e5

Browse files
committed
docs: adjust code blocks to pass with rustdoc.
The changes are basically just because rustdoc runs tests/rendering on more snippets by default (i.e. everything without a `notrust` tag), and not anything significant.
1 parent 8e90412 commit 2d7d7e5

File tree

7 files changed

+92
-73
lines changed

7 files changed

+92
-73
lines changed

src/doc/complement-lang-faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ For simplicity, we do not plan to do so. Implementing automatic semicolon insert
135135

136136
**Short answer** set the RUST_LOG environment variable to the name of your source file, sans extension.
137137

138-
```sh
138+
``` {.sh .notrust}
139139
rustc hello.rs
140140
export RUST_LOG=hello
141141
./hello

src/doc/guide-ffi.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ to the C library and afterwards be invoked from there.
263263
A basic example is:
264264

265265
Rust code:
266+
266267
~~~~ {.ignore}
267268
extern fn callback(a:i32) {
268269
println!("I'm called from C with value {0}", a);
@@ -283,7 +284,8 @@ fn main() {
283284
~~~~
284285

285286
C code:
286-
~~~~ {.ignore}
287+
288+
~~~~ {.notrust}
287289
typedef void (*rust_callback)(int32_t);
288290
rust_callback cb;
289291
@@ -314,6 +316,7 @@ the notification. This will allow the callback to unsafely access the
314316
referenced Rust object.
315317

316318
Rust code:
319+
317320
~~~~ {.ignore}
318321
319322
struct RustObject {
@@ -346,7 +349,8 @@ fn main() {
346349
~~~~
347350

348351
C code:
349-
~~~~ {.ignore}
352+
353+
~~~~ {.notrust}
350354
typedef void (*rust_callback)(int32_t);
351355
void* cb_target;
352356
rust_callback cb;

src/doc/guide-lifetimes.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ struct X { f: int }
205205
fn example1() {
206206
let mut x = X { f: 3 };
207207
let y = &mut x.f; // -+ L
208-
... // |
208+
// ... // |
209209
} // -+
210210
~~~
211211

@@ -221,7 +221,7 @@ The situation gets more complex when borrowing data inside heap boxes:
221221
fn example2() {
222222
let mut x = @X { f: 3 };
223223
let y = &x.f; // -+ L
224-
... // |
224+
// ... // |
225225
} // -+
226226
~~~
227227

@@ -251,7 +251,7 @@ fn example2() {
251251
let mut x = @X {f: 3};
252252
let x1 = x;
253253
let y = &x1.f; // -+ L
254-
... // |
254+
// ... // |
255255
} // -+
256256
~~~
257257

@@ -282,7 +282,7 @@ fn example3() -> int {
282282
return *y; // |
283283
} // -+
284284
x = ~Foo {f: 4};
285-
...
285+
// ...
286286
# return 0;
287287
}
288288
~~~

src/doc/guide-testing.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ amount.
185185
For example:
186186

187187
~~~
188+
# #[allow(unused_imports)];
188189
extern crate test;
189190
190191
use std::vec;
@@ -201,6 +202,8 @@ fn initialise_a_vector(b: &mut BenchHarness) {
201202
b.iter(|| {vec::from_elem(1024, 0u64);} );
202203
b.bytes = 1024 * 8;
203204
}
205+
206+
# fn main() {}
204207
~~~
205208

206209
The benchmark runner will calibrate measurement of the benchmark
@@ -244,6 +247,7 @@ recognize that some calculation has no external effects and remove
244247
it entirely.
245248

246249
~~~
250+
# #[allow(unused_imports)];
247251
extern crate test;
248252
use test::BenchHarness;
249253
@@ -253,6 +257,8 @@ fn bench_xor_1000_ints(bh: &mut BenchHarness) {
253257
range(0, 1000).fold(0, |old, new| old ^ new);
254258
});
255259
}
260+
261+
# fn main() {}
256262
~~~
257263

258264
gives the following results
@@ -271,6 +277,7 @@ cannot remove the computation entirely. This could be done for the
271277
example above by adjusting the `bh.iter` call to
272278

273279
~~~
280+
# struct X; impl X { fn iter<T>(&self, _: || -> T) {} } let bh = X;
274281
bh.iter(|| range(0, 1000).fold(0, |old, new| old ^ new))
275282
~~~
276283

@@ -281,9 +288,12 @@ forces it to consider any argument as used.
281288
~~~
282289
extern crate test;
283290
291+
# fn main() {
292+
# struct X; impl X { fn iter<T>(&self, _: || -> T) {} } let bh = X;
284293
bh.iter(|| {
285294
test::black_box(range(0, 1000).fold(0, |old, new| old ^ new));
286295
});
296+
# }
287297
~~~
288298

289299
Neither of these read or modify the value, and are very cheap for

src/doc/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ li {list-style-type: none; }
2525

2626
* [The standard library, `std`](std/index.html)
2727

28+
<!-- force the two lists to be separate -->
29+
2830
* [The `arena` allocation library](arena/index.html)
2931
* [The `collections` library](collections/index.html)
3032
* [The `extra` library of extra stuff](extra/index.html)

0 commit comments

Comments
 (0)