Skip to content

Commit c608084

Browse files
committed
rollup merge of #23598: brson/gate
Conflicts: src/compiletest/compiletest.rs src/libcollections/lib.rs src/librustc_back/lib.rs src/libserialize/lib.rs src/libstd/lib.rs src/libtest/lib.rs src/test/run-make/rustdoc-default-impl/foo.rs src/test/run-pass/env-home-dir.rs
2 parents d8b0628 + 8c93a79 commit c608084

File tree

1,839 files changed

+4534
-305
lines changed

Some content is hidden

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

1,839 files changed

+4534
-305
lines changed

src/compiletest/header.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ pub struct TestProps {
4040
pub check_stdout: bool,
4141
// Don't force a --crate-type=dylib flag on the command line
4242
pub no_prefer_dynamic: bool,
43-
// Don't run --pretty expanded when running pretty printing tests
44-
pub no_pretty_expanded: bool,
43+
// Run --pretty expanded when running pretty printing tests
44+
pub pretty_expanded: bool,
4545
// Which pretty mode are we testing with, default to 'normal'
4646
pub pretty_mode: String,
4747
// Only compare pretty output and don't try compiling
@@ -62,7 +62,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
6262
let mut force_host = false;
6363
let mut check_stdout = false;
6464
let mut no_prefer_dynamic = false;
65-
let mut no_pretty_expanded = false;
65+
let mut pretty_expanded = false;
6666
let mut pretty_mode = None;
6767
let mut pretty_compare_only = false;
6868
let mut forbid_output = Vec::new();
@@ -96,8 +96,8 @@ pub fn load_props(testfile: &Path) -> TestProps {
9696
no_prefer_dynamic = parse_no_prefer_dynamic(ln);
9797
}
9898

99-
if !no_pretty_expanded {
100-
no_pretty_expanded = parse_no_pretty_expanded(ln);
99+
if !pretty_expanded {
100+
pretty_expanded = parse_pretty_expanded(ln);
101101
}
102102

103103
if pretty_mode.is_none() {
@@ -152,7 +152,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
152152
force_host: force_host,
153153
check_stdout: check_stdout,
154154
no_prefer_dynamic: no_prefer_dynamic,
155-
no_pretty_expanded: no_pretty_expanded,
155+
pretty_expanded: pretty_expanded,
156156
pretty_mode: pretty_mode.unwrap_or("normal".to_string()),
157157
pretty_compare_only: pretty_compare_only,
158158
forbid_output: forbid_output,
@@ -295,8 +295,8 @@ fn parse_no_prefer_dynamic(line: &str) -> bool {
295295
parse_name_directive(line, "no-prefer-dynamic")
296296
}
297297

298-
fn parse_no_pretty_expanded(line: &str) -> bool {
299-
parse_name_directive(line, "no-pretty-expanded")
298+
fn parse_pretty_expanded(line: &str) -> bool {
299+
parse_name_directive(line, "pretty-expanded")
300300
}
301301

302302
fn parse_pretty_mode(line: &str) -> Option<String> {
@@ -340,7 +340,8 @@ fn parse_pp_exact(line: &str, testfile: &Path) -> Option<PathBuf> {
340340
}
341341

342342
fn parse_name_directive(line: &str, directive: &str) -> bool {
343-
line.contains(directive)
343+
// This 'no-' rule is a quick hack to allow pretty-expanded and no-pretty-expanded to coexist
344+
line.contains(directive) && !line.contains(&("no-".to_string() + directive))
344345
}
345346

346347
pub fn parse_name_value_directive(line: &str, directive: &str)

src/compiletest/runtest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
245245
if !proc_res.status.success() {
246246
fatal_proc_rec("pretty-printed source does not typecheck", &proc_res);
247247
}
248-
if props.no_pretty_expanded { return }
248+
if !props.pretty_expanded { return }
249249

250250
// additionally, run `--pretty expanded` and try to build it.
251251
let proc_res = print_source(config, props, testfile, srcs[round].clone(), "expanded");

src/doc/reference.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,8 +816,7 @@ may optionally begin with any number of `attributes` that apply to the
816816
containing module. Attributes on the anonymous crate module define important
817817
metadata that influences the behavior of the compiler.
818818

819-
```{.rust}
820-
# #![allow(unused_attribute)]
819+
```no_run
821820
// Crate name
822821
#![crate_name = "projx"]
823822
@@ -1020,6 +1019,7 @@ Use declarations support a number of convenient shortcuts:
10201019
An example of `use` declarations:
10211020

10221021
```
1022+
# #![feature(core)]
10231023
use std::iter::range_step;
10241024
use std::option::Option::{Some, None};
10251025
use std::collections::hash_map::{self, HashMap};
@@ -1080,6 +1080,7 @@ declarations.
10801080
An example of what will and will not work for `use` items:
10811081

10821082
```
1083+
# #![feature(core)]
10831084
# #![allow(unused_imports)]
10841085
use foo::core::iter; // good: foo is at the root of the crate
10851086
use foo::baz::foobaz; // good: foo is at the root of the crate
@@ -1781,6 +1782,7 @@ functions, with the exception that they may not have a body and are instead
17811782
terminated by a semicolon.
17821783

17831784
```
1785+
# #![feature(libc)]
17841786
extern crate libc;
17851787
use libc::{c_char, FILE};
17861788

src/doc/trpl/concurrency.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ When `guard` goes out of scope, it will block execution until the thread is
8888
finished. If we didn't want this behaviour, we could use `thread::spawn()`:
8989

9090
```
91+
# #![feature(old_io, std_misc)]
9192
use std::thread;
9293
use std::old_io::timer;
9394
use std::time::Duration;
@@ -146,6 +147,7 @@ As an example, here is a Rust program that would have a data race in many
146147
languages. It will not compile:
147148

148149
```ignore
150+
# #![feature(old_io, std_misc)]
149151
use std::thread;
150152
use std::old_io::timer;
151153
use std::time::Duration;
@@ -185,6 +187,7 @@ only one person at a time can mutate what's inside. For that, we can use the
185187
but for a different reason:
186188

187189
```ignore
190+
# #![feature(old_io, std_misc)]
188191
use std::thread;
189192
use std::old_io::timer;
190193
use std::time::Duration;
@@ -229,6 +232,7 @@ guard across thread boundaries, which gives us our error.
229232
We can use `Arc<T>` to fix this. Here's the working version:
230233

231234
```
235+
# #![feature(old_io, std_misc)]
232236
use std::sync::{Arc, Mutex};
233237
use std::thread;
234238
use std::old_io::timer;
@@ -254,6 +258,7 @@ handle is then moved into the new thread. Let's examine the body of the
254258
thread more closely:
255259

256260
```
261+
# #![feature(old_io, std_misc)]
257262
# use std::sync::{Arc, Mutex};
258263
# use std::thread;
259264
# use std::old_io::timer;

src/doc/trpl/documentation.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,17 @@ fn main() {
237237
}
238238
```
239239

240-
Here's the full algorithm:
241-
242-
1. Given a code block, if it does not contain `fn main()`, it is wrapped in
243-
`fn main() { your_code }`
244-
2. Given that result, if it contains no `extern crate` directives but it also
245-
contains the name of the crate being tested, then `extern crate <name>` is
246-
injected at the top.
247-
3. Some common allow attributes are added for documentation examples at the top.
240+
Here's the full algorithm rustdoc uses to postprocess examples:
241+
242+
1. Any leading `#![foo]` attributes are left intact as crate attributes.
243+
2. Some common `allow` attributes are inserted, including
244+
`unused_variables`, `unused_assignments`, `unused_mut`,
245+
`unused_attributes`, and `dead_code`. Small examples often trigger
246+
these lints.
247+
3. If the example does not contain `extern crate`, then `extern crate
248+
<mycrate>;` is inserted.
249+
2. Finally, if the example does not contain `fn main`, the remainder of the
250+
text is wrapped in `fn main() { your_code }`
248251

249252
Sometimes, this isn't enough, though. For example, all of these code samples
250253
with `///` we've been talking about? The raw text:

src/doc/trpl/ffi.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The following is a minimal example of calling a foreign function which will
1212
compile if snappy is installed:
1313

1414
```no_run
15+
# #![feature(libc)]
1516
extern crate libc;
1617
use libc::size_t;
1718
@@ -45,6 +46,7 @@ keeping the binding correct at runtime.
4546
The `extern` block can be extended to cover the entire snappy API:
4647

4748
```no_run
49+
# #![feature(libc)]
4850
extern crate libc;
4951
use libc::{c_int, size_t};
5052
@@ -80,6 +82,7 @@ length is number of elements currently contained, and the capacity is the total
8082
the allocated memory. The length is less than or equal to the capacity.
8183

8284
```
85+
# #![feature(libc)]
8386
# extern crate libc;
8487
# use libc::{c_int, size_t};
8588
# unsafe fn snappy_validate_compressed_buffer(_: *const u8, _: size_t) -> c_int { 0 }
@@ -104,6 +107,7 @@ required capacity to hold the compressed output. The vector can then be passed t
104107
the true length after compression for setting the length.
105108

106109
```
110+
# #![feature(libc)]
107111
# extern crate libc;
108112
# use libc::{size_t, c_int};
109113
# unsafe fn snappy_compress(a: *const u8, b: size_t, c: *mut u8,
@@ -130,6 +134,7 @@ Decompression is similar, because snappy stores the uncompressed size as part of
130134
format and `snappy_uncompressed_length` will retrieve the exact buffer size required.
131135

132136
```
137+
# #![feature(libc)]
133138
# extern crate libc;
134139
# use libc::{size_t, c_int};
135140
# unsafe fn snappy_uncompress(compressed: *const u8,
@@ -408,6 +413,7 @@ global state. In order to access these variables, you declare them in `extern`
408413
blocks with the `static` keyword:
409414

410415
```no_run
416+
# #![feature(libc)]
411417
extern crate libc;
412418
413419
#[link(name = "readline")]
@@ -426,6 +432,7 @@ interface. To do this, statics can be declared with `mut` so we can mutate
426432
them.
427433

428434
```no_run
435+
# #![feature(libc)]
429436
extern crate libc;
430437
431438
use std::ffi::CString;
@@ -458,6 +465,7 @@ calling foreign functions. Some foreign functions, most notably the Windows API,
458465
conventions. Rust provides a way to tell the compiler which convention to use:
459466

460467
```
468+
# #![feature(libc)]
461469
extern crate libc;
462470
463471
#[cfg(all(target_os = "win32", target_arch = "x86"))]

src/doc/trpl/iterators.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ These two basic iterators should serve you well. There are some more
246246
advanced iterators, including ones that are infinite. Like `count`:
247247

248248
```rust
249+
# #![feature(core)]
249250
std::iter::count(1, 5);
250251
```
251252

@@ -294,6 +295,7 @@ has no side effect on the original iterator. Let's try it out with our infinite
294295
iterator from before, `count()`:
295296

296297
```rust
298+
# #![feature(core)]
297299
for i in std::iter::count(1, 5).take(5) {
298300
println!("{}", i);
299301
}

src/doc/trpl/method-syntax.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ the ability to use this *method call syntax* via the `impl` keyword.
2323
Here's how it works:
2424

2525
```{rust}
26+
# #![feature(core)]
2627
struct Circle {
2728
x: f64,
2829
y: f64,
@@ -87,6 +88,7 @@ original example, `foo.bar().baz()`? This is called 'method chaining', and we
8788
can do it by returning `self`.
8889

8990
```
91+
# #![feature(core)]
9092
struct Circle {
9193
x: f64,
9294
y: f64,
@@ -164,6 +166,7 @@ have method overloading, named arguments, or variable arguments. We employ
164166
the builder pattern instead. It looks like this:
165167

166168
```
169+
# #![feature(core)]
167170
struct Circle {
168171
x: f64,
169172
y: f64,

src/doc/trpl/more-strings.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ Rust provides iterators for each of these situations:
177177
Usually, the `graphemes()` method on `&str` is what you want:
178178

179179
```
180+
# #![feature(unicode)]
180181
let s = "u͔n͈̰̎i̙̮͚̦c͚̉o̼̩̰͗d͔̆̓ͥé";
181182
182183
for l in s.graphemes(true) {

src/doc/trpl/standard-input.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ we haven't seen before. Here's a simple program that reads some input,
55
and then prints it back out:
66

77
```{rust,ignore}
8-
fn main() {
8+
corefn main() {
99
println!("Type something!");
1010
1111
let input = std::old_io::stdin().read_line().ok().expect("Failed to read line");
@@ -28,6 +28,7 @@ Since writing the fully qualified name all the time is annoying, we can use
2828
the `use` statement to import it in:
2929

3030
```{rust}
31+
# #![feature(old_io)]
3132
use std::old_io::stdin;
3233
3334
stdin();
@@ -37,6 +38,7 @@ However, it's considered better practice to not import individual functions, but
3738
to import the module, and only use one level of qualification:
3839

3940
```{rust}
41+
# #![feature(old_io)]
4042
use std::old_io;
4143
4244
old_io::stdin();

src/doc/trpl/testing.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,8 @@ is an opaque "black box" to the optimizer and so forces it to consider any
546546
argument as used.
547547

548548
```rust
549+
# #![feature(test)]
550+
549551
extern crate test;
550552

551553
# fn main() {

src/doc/trpl/traits.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Do you remember the `impl` keyword, used to call a function with method
44
syntax?
55

66
```{rust}
7+
# #![feature(core)]
78
struct Circle {
89
x: f64,
910
y: f64,
@@ -21,6 +22,7 @@ Traits are similar, except that we define a trait with just the method
2122
signature, then implement the trait for that struct. Like this:
2223

2324
```{rust}
25+
# #![feature(core)]
2426
struct Circle {
2527
x: f64,
2628
y: f64,
@@ -84,6 +86,7 @@ which implements `HasArea` will have an `.area()` method.
8486
Here's an extended example of how this works:
8587

8688
```{rust}
89+
# #![feature(core)]
8790
trait HasArea {
8891
fn area(&self) -> f64;
8992
}
@@ -225,6 +228,7 @@ If we add a `use` line right above `main` and make the right things public,
225228
everything is fine:
226229

227230
```{rust}
231+
# #![feature(core)]
228232
use shapes::HasArea;
229233
230234
mod shapes {
@@ -408,6 +412,7 @@ but instead, we found a floating-point variable. We need a different bound. `Flo
408412
to the rescue:
409413

410414
```
415+
# #![feature(std_misc)]
411416
use std::num::Float;
412417
413418
fn inverse<T: Float>(x: T) -> Result<T, String> {
@@ -423,6 +428,7 @@ from the `Float` trait. Both `f32` and `f64` implement `Float`, so our function
423428
works just fine:
424429

425430
```
431+
# #![feature(std_misc)]
426432
# use std::num::Float;
427433
# fn inverse<T: Float>(x: T) -> Result<T, String> {
428434
# if x == Float::zero() { return Err("x cannot be zero!".to_string()) }

0 commit comments

Comments
 (0)