Skip to content

Commit b2b383c

Browse files
committed
auto merge of #14187 : alexcrichton/rust/rollup, r=alexcrichton
Closes #14184 (std: Move the owned module from core to std) Closes #14183 (Allow blocks in const expressions) Closes #14176 (Add tests for from_bits.) Closes #14175 (Replaced ~T by Box<T> in manual) Closes #14173 (Implements Default trait for BigInt and BigUint) Closes #14171 (Fix #8391) Closes #14159 (Clean up unicode code in libstd) Closes #14126 (docs: Add a not found page) Closes #14123 (add a line to the example to clarify semantics) Closes #14106 (Pretty printer improvements) Closes #14083 (rustllvm: Add LLVMRustArrayType) Closes #13957 (io: Implement process wait timeouts)
2 parents cb115ac + f09592a commit b2b383c

File tree

118 files changed

+2191
-930
lines changed

Some content is hidden

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

118 files changed

+2191
-930
lines changed

mk/docs.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ DOCS := index intro tutorial guide-ffi guide-macros guide-lifetimes \
3030
guide-tasks guide-container guide-pointers guide-testing \
3131
guide-runtime complement-bugreport complement-cheatsheet \
3232
complement-lang-faq complement-project-faq rust rustdoc \
33-
guide-unsafe
33+
guide-unsafe not_found
3434

3535
PDF_DOCS := tutorial rust
3636

src/compiletest/common.rs

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,52 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use std::from_str::FromStr;
12+
use std::fmt;
13+
1114
#[deriving(Clone, Eq)]
12-
pub enum mode {
13-
mode_compile_fail,
14-
mode_run_fail,
15-
mode_run_pass,
16-
mode_pretty,
17-
mode_debug_info_gdb,
18-
mode_debug_info_lldb,
19-
mode_codegen
15+
pub enum Mode {
16+
CompileFail,
17+
RunFail,
18+
RunPass,
19+
Pretty,
20+
DebugInfoGdb,
21+
DebugInfoLldb,
22+
Codegen
23+
}
24+
25+
impl FromStr for Mode {
26+
fn from_str(s: &str) -> Option<Mode> {
27+
match s {
28+
"compile-fail" => Some(CompileFail),
29+
"run-fail" => Some(RunFail),
30+
"run-pass" => Some(RunPass),
31+
"pretty" => Some(Pretty),
32+
"debuginfo-lldb" => Some(DebugInfoLldb),
33+
"debuginfo-gdb" => Some(DebugInfoGdb),
34+
"codegen" => Some(Codegen),
35+
_ => None,
36+
}
37+
}
38+
}
39+
40+
impl fmt::Show for Mode {
41+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
42+
let msg = match *self {
43+
CompileFail => "compile-fail",
44+
RunFail => "run-fail",
45+
RunPass => "run-pass",
46+
Pretty => "pretty",
47+
DebugInfoGdb => "debuginfo-gdb",
48+
DebugInfoLldb => "debuginfo-lldb",
49+
Codegen => "codegen",
50+
};
51+
write!(f.buf, "{}", msg)
52+
}
2053
}
2154

2255
#[deriving(Clone)]
23-
pub struct config {
56+
pub struct Config {
2457
// The library paths required for running the compiler
2558
pub compile_lib_path: ~str,
2659

@@ -49,7 +82,7 @@ pub struct config {
4982
pub stage_id: ~str,
5083

5184
// The test mode, compile-fail, run-fail, run-pass
52-
pub mode: mode,
85+
pub mode: Mode,
5386

5487
// Run ignored tests
5588
pub run_ignored: bool,

src/compiletest/compiletest.rs

Lines changed: 21 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
// we use our own (green) start below; do not link in libnative; issue #13247.
1515
#![no_start]
1616

17-
#![allow(non_camel_case_types)]
1817
#![deny(warnings)]
1918

2019
extern crate test;
@@ -27,9 +26,10 @@ extern crate rustuv;
2726
use std::os;
2827
use std::io;
2928
use std::io::fs;
29+
use std::from_str::FromStr;
3030
use getopts::{optopt, optflag, reqopt};
31-
use common::{config, mode_run_pass, mode_run_fail, mode_compile_fail, mode_pretty,
32-
mode_debug_info_gdb, mode_debug_info_lldb, mode_codegen, mode};
31+
use common::Config;
32+
use common::{Pretty, DebugInfoGdb, Codegen};
3333
use util::logv;
3434

3535
pub mod procsrv;
@@ -51,7 +51,7 @@ pub fn main() {
5151
run_tests(&config);
5252
}
5353

54-
pub fn parse_config(args: Vec<~str> ) -> config {
54+
pub fn parse_config(args: Vec<~str> ) -> Config {
5555

5656
let groups : Vec<getopts::OptGroup> =
5757
vec!(reqopt("", "compile-lib-path", "path to host shared libraries", "PATH"),
@@ -112,7 +112,7 @@ pub fn parse_config(args: Vec<~str> ) -> config {
112112
Path::new(m.opt_str(nm).unwrap())
113113
}
114114

115-
config {
115+
Config {
116116
compile_lib_path: matches.opt_str("compile-lib-path").unwrap(),
117117
run_lib_path: matches.opt_str("run-lib-path").unwrap(),
118118
rustc_path: opt_path(matches, "rustc-path"),
@@ -122,7 +122,7 @@ pub fn parse_config(args: Vec<~str> ) -> config {
122122
build_base: opt_path(matches, "build-base"),
123123
aux_base: opt_path(matches, "aux-base"),
124124
stage_id: matches.opt_str("stage-id").unwrap(),
125-
mode: str_mode(matches.opt_str("mode").unwrap()),
125+
mode: FromStr::from_str(matches.opt_str("mode").unwrap()).expect("invalid mode"),
126126
run_ignored: matches.opt_present("ignored"),
127127
filter:
128128
if !matches.free.is_empty() {
@@ -155,7 +155,7 @@ pub fn parse_config(args: Vec<~str> ) -> config {
155155
}
156156
}
157157

158-
pub fn log_config(config: &config) {
158+
pub fn log_config(config: &Config) {
159159
let c = config;
160160
logv(c, format!("configuration:"));
161161
logv(c, format!("compile_lib_path: {}", config.compile_lib_path));
@@ -164,7 +164,7 @@ pub fn log_config(config: &config) {
164164
logv(c, format!("src_base: {}", config.src_base.display()));
165165
logv(c, format!("build_base: {}", config.build_base.display()));
166166
logv(c, format!("stage_id: {}", config.stage_id));
167-
logv(c, format!("mode: {}", mode_str(config.mode)));
167+
logv(c, format!("mode: {}", config.mode));
168168
logv(c, format!("run_ignored: {}", config.run_ignored));
169169
logv(c, format!("filter: {}", opt_str(&config.filter)));
170170
logv(c, format!("runtool: {}", opt_str(&config.runtool)));
@@ -198,35 +198,10 @@ pub fn opt_str2(maybestr: Option<~str>) -> ~str {
198198
match maybestr { None => "(none)".to_owned(), Some(s) => { s } }
199199
}
200200

201-
pub fn str_mode(s: ~str) -> mode {
202-
match s.as_slice() {
203-
"compile-fail" => mode_compile_fail,
204-
"run-fail" => mode_run_fail,
205-
"run-pass" => mode_run_pass,
206-
"pretty" => mode_pretty,
207-
"debuginfo-gdb" => mode_debug_info_gdb,
208-
"debuginfo-lldb" => mode_debug_info_lldb,
209-
"codegen" => mode_codegen,
210-
s => fail!("invalid mode: " + s)
211-
}
212-
}
213-
214-
pub fn mode_str(mode: mode) -> ~str {
215-
match mode {
216-
mode_compile_fail => "compile-fail".to_owned(),
217-
mode_run_fail => "run-fail".to_owned(),
218-
mode_run_pass => "run-pass".to_owned(),
219-
mode_pretty => "pretty".to_owned(),
220-
mode_debug_info_gdb => "debuginfo-gdb".to_owned(),
221-
mode_debug_info_lldb => "debuginfo-lldb".to_owned(),
222-
mode_codegen => "codegen".to_owned(),
223-
}
224-
}
225-
226-
pub fn run_tests(config: &config) {
201+
pub fn run_tests(config: &Config) {
227202
if config.target == "arm-linux-androideabi".to_owned() {
228-
match config.mode{
229-
mode_debug_info_gdb => {
203+
match config.mode {
204+
DebugInfoGdb => {
230205
println!("arm-linux-androideabi debug-info \
231206
test uses tcp 5039 port. please reserve it");
232207
}
@@ -255,7 +230,7 @@ pub fn run_tests(config: &config) {
255230
}
256231
}
257232

258-
pub fn test_opts(config: &config) -> test::TestOpts {
233+
pub fn test_opts(config: &Config) -> test::TestOpts {
259234
test::TestOpts {
260235
filter: config.filter.clone(),
261236
run_ignored: config.run_ignored,
@@ -270,7 +245,7 @@ pub fn test_opts(config: &config) -> test::TestOpts {
270245
}
271246
}
272247

273-
pub fn make_tests(config: &config) -> Vec<test::TestDescAndFn> {
248+
pub fn make_tests(config: &Config) -> Vec<test::TestDescAndFn> {
274249
debug!("making tests from {}",
275250
config.src_base.display());
276251
let mut tests = Vec::new();
@@ -281,7 +256,7 @@ pub fn make_tests(config: &config) -> Vec<test::TestDescAndFn> {
281256
if is_test(config, &file) {
282257
let t = make_test(config, &file, || {
283258
match config.mode {
284-
mode_codegen => make_metrics_test_closure(config, &file),
259+
Codegen => make_metrics_test_closure(config, &file),
285260
_ => make_test_closure(config, &file)
286261
}
287262
});
@@ -291,11 +266,11 @@ pub fn make_tests(config: &config) -> Vec<test::TestDescAndFn> {
291266
tests
292267
}
293268

294-
pub fn is_test(config: &config, testfile: &Path) -> bool {
269+
pub fn is_test(config: &Config, testfile: &Path) -> bool {
295270
// Pretty-printer does not work with .rc files yet
296271
let valid_extensions =
297272
match config.mode {
298-
mode_pretty => vec!(".rs".to_owned()),
273+
Pretty => vec!(".rs".to_owned()),
299274
_ => vec!(".rc".to_owned(), ".rs".to_owned())
300275
};
301276
let invalid_prefixes = vec!(".".to_owned(), "#".to_owned(), "~".to_owned());
@@ -314,7 +289,7 @@ pub fn is_test(config: &config, testfile: &Path) -> bool {
314289
return valid;
315290
}
316291

317-
pub fn make_test(config: &config, testfile: &Path, f: || -> test::TestFn)
292+
pub fn make_test(config: &Config, testfile: &Path, f: || -> test::TestFn)
318293
-> test::TestDescAndFn {
319294
test::TestDescAndFn {
320295
desc: test::TestDesc {
@@ -326,7 +301,7 @@ pub fn make_test(config: &config, testfile: &Path, f: || -> test::TestFn)
326301
}
327302
}
328303

329-
pub fn make_test_name(config: &config, testfile: &Path) -> test::TestName {
304+
pub fn make_test_name(config: &Config, testfile: &Path) -> test::TestName {
330305

331306
// Try to elide redundant long paths
332307
fn shorten(path: &Path) -> ~str {
@@ -336,19 +311,17 @@ pub fn make_test_name(config: &config, testfile: &Path) -> test::TestName {
336311
format!("{}/{}", dir.unwrap_or(""), filename.unwrap_or(""))
337312
}
338313

339-
test::DynTestName(format!("[{}] {}",
340-
mode_str(config.mode),
341-
shorten(testfile)))
314+
test::DynTestName(format!("[{}] {}", config.mode, shorten(testfile)))
342315
}
343316

344-
pub fn make_test_closure(config: &config, testfile: &Path) -> test::TestFn {
317+
pub fn make_test_closure(config: &Config, testfile: &Path) -> test::TestFn {
345318
let config = (*config).clone();
346319
// FIXME (#9639): This needs to handle non-utf8 paths
347320
let testfile = testfile.as_str().unwrap().to_owned();
348321
test::DynTestFn(proc() { runtest::run(config, testfile) })
349322
}
350323

351-
pub fn make_metrics_test_closure(config: &config, testfile: &Path) -> test::TestFn {
324+
pub fn make_metrics_test_closure(config: &Config, testfile: &Path) -> test::TestFn {
352325
let config = (*config).clone();
353326
// FIXME (#9639): This needs to handle non-utf8 paths
354327
let testfile = testfile.as_str().unwrap().to_owned();

src/compiletest/header.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use common::config;
11+
use common::Config;
1212
use common;
1313
use util;
1414

@@ -34,6 +34,8 @@ pub struct TestProps {
3434
pub check_stdout: bool,
3535
// Don't force a --crate-type=dylib flag on the command line
3636
pub no_prefer_dynamic: bool,
37+
// Don't run --pretty expanded when running pretty printing tests
38+
pub no_pretty_expanded: bool,
3739
}
3840

3941
// Load any test directives embedded in the file
@@ -48,6 +50,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
4850
let mut force_host = false;
4951
let mut check_stdout = false;
5052
let mut no_prefer_dynamic = false;
53+
let mut no_pretty_expanded = false;
5154
iter_header(testfile, |ln| {
5255
match parse_error_pattern(ln) {
5356
Some(ep) => error_patterns.push(ep),
@@ -78,6 +81,10 @@ pub fn load_props(testfile: &Path) -> TestProps {
7881
no_prefer_dynamic = parse_no_prefer_dynamic(ln);
7982
}
8083

84+
if !no_pretty_expanded {
85+
no_pretty_expanded = parse_no_pretty_expanded(ln);
86+
}
87+
8188
match parse_aux_build(ln) {
8289
Some(ab) => { aux_builds.push(ab); }
8390
None => {}
@@ -107,22 +114,23 @@ pub fn load_props(testfile: &Path) -> TestProps {
107114
force_host: force_host,
108115
check_stdout: check_stdout,
109116
no_prefer_dynamic: no_prefer_dynamic,
117+
no_pretty_expanded: no_pretty_expanded,
110118
}
111119
}
112120

113-
pub fn is_test_ignored(config: &config, testfile: &Path) -> bool {
114-
fn ignore_target(config: &config) -> ~str {
121+
pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
122+
fn ignore_target(config: &Config) -> ~str {
115123
"ignore-".to_owned() + util::get_os(config.target)
116124
}
117-
fn ignore_stage(config: &config) -> ~str {
125+
fn ignore_stage(config: &Config) -> ~str {
118126
"ignore-".to_owned() + config.stage_id.split('-').next().unwrap()
119127
}
120128

121129
let val = iter_header(testfile, |ln| {
122130
if parse_name_directive(ln, "ignore-test") { false }
123131
else if parse_name_directive(ln, ignore_target(config)) { false }
124132
else if parse_name_directive(ln, ignore_stage(config)) { false }
125-
else if config.mode == common::mode_pretty &&
133+
else if config.mode == common::Pretty &&
126134
parse_name_directive(ln, "ignore-pretty") { false }
127135
else if config.target != config.host &&
128136
parse_name_directive(ln, "ignore-cross-compile") { false }
@@ -180,6 +188,10 @@ fn parse_no_prefer_dynamic(line: &str) -> bool {
180188
parse_name_directive(line, "no-prefer-dynamic")
181189
}
182190

191+
fn parse_no_pretty_expanded(line: &str) -> bool {
192+
parse_name_directive(line, "no-pretty-expanded")
193+
}
194+
183195
fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
184196
parse_name_value_directive(line, "exec-env".to_owned()).map(|nv| {
185197
// nv is either FOO or FOO=BAR

src/compiletest/procsrv.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,20 @@ pub fn run(lib_path: &str,
6868
input: Option<~str>) -> Option<Result> {
6969

7070
let env = env.clone().append(target_env(lib_path, prog).as_slice());
71-
let mut opt_process = Process::configure(ProcessConfig {
71+
let opt_process = Process::configure(ProcessConfig {
7272
program: prog,
7373
args: args,
7474
env: Some(env.as_slice()),
7575
.. ProcessConfig::new()
7676
});
7777

7878
match opt_process {
79-
Ok(ref mut process) => {
79+
Ok(mut process) => {
8080
for input in input.iter() {
8181
process.stdin.get_mut_ref().write(input.as_bytes()).unwrap();
8282
}
83-
let ProcessOutput { status, output, error } = process.wait_with_output();
83+
let ProcessOutput { status, output, error } =
84+
process.wait_with_output().unwrap();
8485

8586
Some(Result {
8687
status: status,

0 commit comments

Comments
 (0)