Skip to content

Commit 23694da

Browse files
committed
---
yaml --- r: 278254 b: refs/heads/auto c: de0906f h: refs/heads/master
1 parent 37d88b8 commit 23694da

File tree

166 files changed

+2978
-5051
lines changed

Some content is hidden

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

166 files changed

+2978
-5051
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: 33dc100dfae60cd91e3621ec64fb0d6aaac9e670
11+
refs/heads/auto: de0906fe12b8663006151be7b1e32ca540710a18
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/mk/crates.mk

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ TARGET_CRATES := libc std term \
5353
getopts collections test rand \
5454
core alloc \
5555
rustc_unicode rustc_bitflags \
56-
alloc_system alloc_jemalloc \
57-
panic_abort panic_unwind unwind
56+
alloc_system alloc_jemalloc
5857
RUSTC_CRATES := rustc rustc_typeck rustc_mir rustc_borrowck rustc_resolve rustc_driver \
5958
rustc_trans rustc_back rustc_llvm rustc_privacy rustc_lint \
6059
rustc_data_structures rustc_platform_intrinsics \
@@ -73,18 +72,10 @@ DEPS_libc := core
7372
DEPS_rand := core
7473
DEPS_rustc_bitflags := core
7574
DEPS_rustc_unicode := core
76-
DEPS_panic_abort := libc alloc
77-
DEPS_panic_unwind := libc alloc unwind
78-
DEPS_unwind := libc
79-
80-
# FIXME(stage0): change this to just `RUSTFLAGS_panic_abort := ...`
81-
RUSTFLAGS1_panic_abort := -C panic=abort
82-
RUSTFLAGS2_panic_abort := -C panic=abort
83-
RUSTFLAGS3_panic_abort := -C panic=abort
8475

8576
DEPS_std := core libc rand alloc collections rustc_unicode \
8677
native:backtrace \
87-
alloc_system panic_abort panic_unwind unwind
78+
alloc_system
8879
DEPS_arena := std
8980
DEPS_glob := std
9081
DEPS_flate := std native:miniz
@@ -157,9 +148,6 @@ ONLY_RLIB_rustc_unicode := 1
157148
ONLY_RLIB_rustc_bitflags := 1
158149
ONLY_RLIB_alloc_system := 1
159150
ONLY_RLIB_alloc_jemalloc := 1
160-
ONLY_RLIB_panic_unwind := 1
161-
ONLY_RLIB_panic_abort := 1
162-
ONLY_RLIB_unwind := 1
163151

164152
TARGET_SPECIFIC_alloc_jemalloc := 1
165153

branches/auto/mk/tests.mk

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ DEPS_collectionstest :=
2323
$(eval $(call RUST_CRATE,collectionstest))
2424

2525
TEST_TARGET_CRATES = $(filter-out core rustc_unicode alloc_system libc \
26-
alloc_jemalloc panic_unwind \
27-
panic_abort,$(TARGET_CRATES)) \
26+
alloc_jemalloc,$(TARGET_CRATES)) \
2827
collectionstest coretest
2928
TEST_DOC_CRATES = $(DOC_CRATES) arena flate fmt_macros getopts graphviz \
3029
log rand rbml serialize syntax term test

branches/auto/src/bootstrap/rustc.rs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,10 @@ fn main() {
4848
} else {
4949
env::var_os("RUSTC_REAL").unwrap()
5050
};
51-
let stage = env::var("RUSTC_STAGE").unwrap();
5251

5352
let mut cmd = Command::new(rustc);
5453
cmd.args(&args)
55-
.arg("--cfg").arg(format!("stage{}", stage));
54+
.arg("--cfg").arg(format!("stage{}", env::var("RUSTC_STAGE").unwrap()));
5655

5756
if let Some(target) = target {
5857
// The stage0 compiler has a special sysroot distinct from what we
@@ -79,22 +78,6 @@ fn main() {
7978
cmd.args(&s.split(" ").filter(|s| !s.is_empty()).collect::<Vec<_>>());
8079
}
8180

82-
// If we're compiling specifically the `panic_abort` crate then we pass
83-
// the `-C panic=abort` option. Note that we do not do this for any
84-
// other crate intentionally as this is the only crate for now that we
85-
// ship with panic=abort.
86-
//
87-
// This... is a bit of a hack how we detect this. Ideally this
88-
// information should be encoded in the crate I guess? Would likely
89-
// require an RFC amendment to RFC 1513, however.
90-
let is_panic_abort = args.windows(2).any(|a| {
91-
&*a[0] == "--crate-name" && &*a[1] == "panic_abort"
92-
});
93-
// FIXME(stage0): remove this `stage != "0"` condition
94-
if is_panic_abort && stage != "0" {
95-
cmd.arg("-C").arg("panic=abort");
96-
}
97-
9881
// Set various options from config.toml to configure how we're building
9982
// code.
10083
if env::var("RUSTC_DEBUGINFO") == Ok("true".to_string()) {

branches/auto/src/doc/book/error-handling.md

Lines changed: 59 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,9 +1573,8 @@ detail on Getopts, but there is [some good documentation][15]
15731573
describing it. The short story is that Getopts generates an argument
15741574
parser and a help message from a vector of options (The fact that it
15751575
is a vector is hidden behind a struct and a set of methods). Once the
1576-
parsing is done, the parser returns a struct that records matches
1577-
for defined options, and remaining "free" arguments.
1578-
From there, we can get information about the flags, for
1576+
parsing is done, we can decode the program arguments into a Rust
1577+
struct. From there, we can get information about the flags, for
15791578
instance, whether they were passed in, and what arguments they
15801579
had. Here's our program with the appropriate `extern crate`
15811580
statements, and the basic argument setup for Getopts:
@@ -1606,8 +1605,8 @@ fn main() {
16061605
print_usage(&program, opts);
16071606
return;
16081607
}
1609-
let data_path = &matches.free[0];
1610-
let city: &str = &matches.free[1];
1608+
let data_path = &args[1];
1609+
let city = &args[2];
16111610
16121611
// Do stuff with information
16131612
}
@@ -1681,8 +1680,8 @@ fn main() {
16811680
return;
16821681
}
16831682
1684-
let data_path = &matches.free[0];
1685-
let city: &str = &matches.free[1];
1683+
let data_path = &args[1];
1684+
let city: &str = &args[2];
16861685
16871686
let file = File::open(data_path).unwrap();
16881687
let mut rdr = csv::Reader::from_reader(file);
@@ -1793,15 +1792,13 @@ fn main() {
17931792
Ok(m) => { m }
17941793
Err(e) => { panic!(e.to_string()) }
17951794
};
1796-
17971795
if matches.opt_present("h") {
17981796
print_usage(&program, opts);
17991797
return;
18001798
}
18011799
1802-
let data_path = &matches.free[0];
1803-
let city: &str = &matches.free[1];
1804-
1800+
let data_path = &args[1];
1801+
let city = &args[2];
18051802
for pop in search(data_path, city) {
18061803
println!("{}, {}: {:?}", pop.city, pop.country, pop.count);
18071804
}
@@ -1879,14 +1876,14 @@ when calling `search`:
18791876

18801877
```rust,ignore
18811878
...
1882-
match search(data_path, city) {
1883-
Ok(pops) => {
1884-
for pop in pops {
1885-
println!("{}, {}: {:?}", pop.city, pop.country, pop.count);
1886-
}
1879+
match search(&data_file, &city) {
1880+
Ok(pops) => {
1881+
for pop in pops {
1882+
println!("{}, {}: {:?}", pop.city, pop.country, pop.count);
18871883
}
1888-
Err(err) => println!("{}", err)
18891884
}
1885+
Err(err) => println!("{}", err)
1886+
}
18901887
...
18911888
```
18921889

@@ -1917,37 +1914,43 @@ fn print_usage(program: &str, opts: Options) {
19171914
println!("{}", opts.usage(&format!("Usage: {} [options] <city>", program)));
19181915
}
19191916
```
1920-
Of course we need to adapt the argument handling code:
1917+
The next part is going to be only a little harder:
19211918

19221919
```rust,ignore
19231920
...
1924-
let mut opts = Options::new();
1925-
opts.optopt("f", "file", "Choose an input file, instead of using STDIN.", "NAME");
1926-
opts.optflag("h", "help", "Show this usage message.");
1927-
...
1928-
let data_path = matches.opt_str("f");
1929-
1930-
let city = if !matches.free.is_empty() {
1931-
&matches.free[0]
1932-
} else {
1933-
print_usage(&program, opts);
1934-
return;
1935-
};
1936-
1937-
match search(&data_path, city) {
1938-
Ok(pops) => {
1939-
for pop in pops {
1940-
println!("{}, {}: {:?}", pop.city, pop.country, pop.count);
1941-
}
1921+
let mut opts = Options::new();
1922+
opts.optopt("f", "file", "Choose an input file, instead of using STDIN.", "NAME");
1923+
opts.optflag("h", "help", "Show this usage message.");
1924+
...
1925+
let file = matches.opt_str("f");
1926+
let data_file = &file.as_ref().map(Path::new);
1927+
1928+
let city = if !matches.free.is_empty() {
1929+
&matches.free[0]
1930+
} else {
1931+
print_usage(&program, opts);
1932+
return;
1933+
};
1934+
1935+
match search(data_file, city) {
1936+
Ok(pops) => {
1937+
for pop in pops {
1938+
println!("{}, {}: {:?}", pop.city, pop.country, pop.count);
19421939
}
1943-
Err(err) => println!("{}", err)
19441940
}
1941+
Err(err) => println!("{}", err)
1942+
}
19451943
...
19461944
```
19471945

1948-
We've made the user experience a bit nicer by showing the usage message,
1949-
instead of a panic from an out-of-bounds index, when `city`, the
1950-
remaining free argument, is not present.
1946+
In this piece of code, we take `file` (which has the type
1947+
`Option<String>`), and convert it to a type that `search` can use, in
1948+
this case, `&Option<AsRef<Path>>`. To do this, we take a reference of
1949+
file, and map `Path::new` onto it. In this case, `as_ref()` converts
1950+
the `Option<String>` into an `Option<&str>`, and from there, we can
1951+
execute `Path::new` to the content of the optional, and return the
1952+
optional of the new value. Once we have that, it is a simple matter of
1953+
getting the `city` argument and executing `search`.
19511954

19521955
Modifying `search` is slightly trickier. The `csv` crate can build a
19531956
parser out of
@@ -1997,8 +2000,6 @@ enum CliError {
19972000
And now for impls on `Display` and `Error`:
19982001

19992002
```rust,ignore
2000-
use std::fmt;
2001-
20022003
impl fmt::Display for CliError {
20032004
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
20042005
match *self {
@@ -2019,13 +2020,13 @@ impl Error for CliError {
20192020
}
20202021
}
20212022
2022-
fn cause(&self) -> Option<&Error> {
2023-
match *self {
2023+
fn cause(&self) -> Option<&error::Error> {
2024+
match *self {
20242025
CliError::Io(ref err) => Some(err),
2025-
CliError::Csv(ref err) => Some(err),
2026-
// Our custom error doesn't have an underlying cause,
2027-
// but we could modify it so that it does.
2028-
CliError::NotFound => None,
2026+
CliError::Parse(ref err) => Some(err),
2027+
// Our custom error doesn't have an underlying cause, but we could
2028+
// modify it so that it does.
2029+
CliError::NotFound() => None,
20292030
}
20302031
}
20312032
}
@@ -2121,27 +2122,24 @@ string and add a flag to the Option variable. Once we've done that, Getopts does
21212122

21222123
```rust,ignore
21232124
...
2124-
let mut opts = Options::new();
2125-
opts.optopt("f", "file", "Choose an input file, instead of using STDIN.", "NAME");
2126-
opts.optflag("h", "help", "Show this usage message.");
2127-
opts.optflag("q", "quiet", "Silences errors and warnings.");
2125+
let mut opts = Options::new();
2126+
opts.optopt("f", "file", "Choose an input file, instead of using STDIN.", "NAME");
2127+
opts.optflag("h", "help", "Show this usage message.");
2128+
opts.optflag("q", "quiet", "Silences errors and warnings.");
21282129
...
21292130
```
21302131

21312132
Now we only need to implement our “quiet” functionality. This requires us to
21322133
tweak the case analysis in `main`:
21332134

21342135
```rust,ignore
2135-
use std::process;
2136-
...
2137-
match search(&data_path, city) {
2138-
Err(CliError::NotFound) if matches.opt_present("q") => process::exit(1),
2139-
Err(err) => panic!("{}", err),
2140-
Ok(pops) => for pop in pops {
2141-
println!("{}, {}: {:?}", pop.city, pop.country, pop.count);
2142-
}
2136+
match search(&args.arg_data_path, &args.arg_city) {
2137+
Err(CliError::NotFound) if args.flag_quiet => process::exit(1),
2138+
Err(err) => panic!("{}", err),
2139+
Ok(pops) => for pop in pops {
2140+
println!("{}, {}: {:?}", pop.city, pop.country, pop.count);
21432141
}
2144-
...
2142+
}
21452143
```
21462144

21472145
Certainly, we don't want to be quiet if there was an IO error or if the data

branches/auto/src/doc/nomicon/vec-alloc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ LLVM needs to work with different languages' semantics and custom allocators,
150150
it can't really intimately understand allocation. Instead, the main idea behind
151151
allocation is "doesn't overlap with other stuff". That is, heap allocations,
152152
stack allocations, and globals don't randomly overlap. Yep, it's about alias
153-
analysis. As such, Rust can technically play a bit fast and loose with the notion of
153+
analysis. As such, Rust can technically play a bit fast an loose with the notion of
154154
an allocation as long as it's *consistent*.
155155

156156
Getting back to the empty allocation case, there are a couple of places where

branches/auto/src/liballoc_system/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
form or name",
1919
issue = "27783")]
2020
#![feature(allocator)]
21+
#![feature(libc)]
2122
#![feature(staged_api)]
22-
#![cfg_attr(unix, feature(libc))]
23+
24+
extern crate libc;
2325

2426
// The minimum alignment guaranteed by the architecture. This value is used to
2527
// add fast paths for low alignment values. In practice, the alignment is a
@@ -70,10 +72,9 @@ pub extern "C" fn __rust_usable_size(size: usize, align: usize) -> usize {
7072

7173
#[cfg(unix)]
7274
mod imp {
73-
extern crate libc;
74-
7575
use core::cmp;
7676
use core::ptr;
77+
use libc;
7778
use MIN_ALIGN;
7879

7980
pub unsafe fn allocate(size: usize, align: usize) -> *mut u8 {

branches/auto/src/libcollectionstest/string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fn test_from_utf8() {
5252
String::from("ศไทย中华Việt Nam"));
5353

5454
let xs = b"hello\xFF".to_vec();
55-
let err = String::from_utf8(xs).unwrap_err();
55+
let err = String::from_utf8(xs).err().unwrap();
5656
assert_eq!(err.into_bytes(), b"hello\xff".to_vec());
5757
}
5858

branches/auto/src/libpanic_abort/Cargo.toml

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)