From eeee0a2e91db182e0632974c21e0f1fb3719080e Mon Sep 17 00:00:00 2001
From: Tim Chevalier
Date: Fri, 25 Jan 2013 22:58:24 -0800
Subject: [PATCH 1/6] rustc: Add legacy_records field to the type context
---
src/librustc/middle/ty.rs | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs
index c82825795869a..94fd659e26848 100644
--- a/src/librustc/middle/ty.rs
+++ b/src/librustc/middle/ty.rs
@@ -416,6 +416,7 @@ type ctxt =
mut next_id: uint,
vecs_implicitly_copyable: bool,
legacy_modes: bool,
+ legacy_records: bool,
cstore: metadata::cstore::CStore,
sess: session::Session,
def_map: resolve::DefMap,
@@ -975,11 +976,16 @@ fn mk_ctxt(s: session::Session,
+lang_items: middle::lang_items::LanguageItems,
crate: @ast::crate) -> ctxt {
let mut legacy_modes = false;
+ let mut legacy_records = false;
for crate.node.attrs.each |attribute| {
match attribute.node.value.node {
ast::meta_word(ref w) if (*w) == ~"legacy_modes" => {
legacy_modes = true;
- break;
+ if legacy_records { break; }
+ }
+ ast::meta_word(ref w) if (*w) == ~"legacy_records" => {
+ legacy_records = true;
+ if legacy_modes { break; }
}
_ => {}
}
@@ -994,6 +1000,7 @@ fn mk_ctxt(s: session::Session,
mut next_id: 0u,
vecs_implicitly_copyable: vecs_implicitly_copyable,
legacy_modes: legacy_modes,
+ legacy_records: legacy_records,
cstore: s.cstore,
sess: s,
def_map: dm,
From e2f2373dfa17c423c5145657b5e4c5c03de4c867 Mon Sep 17 00:00:00 2001
From: Tim Chevalier
Date: Fri, 25 Jan 2013 22:57:29 -0800
Subject: [PATCH 2/6] rustc: In lint, forbid structural records unless
legacy_records is on
---
src/librustc/middle/lint.rs | 34 ++++++++++++++++++----------------
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs
index 515666445e3aa..f1188dce74142 100644
--- a/src/librustc/middle/lint.rs
+++ b/src/librustc/middle/lint.rs
@@ -213,7 +213,7 @@ fn get_lint_dict() -> lint_dict {
(~"structural_records",
@{lint: structural_records,
desc: "use of any structural records",
- default: allow}),
+ default: deny}),
(~"legacy modes",
@{lint: legacy_modes,
@@ -663,21 +663,23 @@ fn check_item_deprecated_self(cx: ty::ctxt, item: @ast::item) {
}
fn check_item_structural_records(cx: ty::ctxt, it: @ast::item) {
- let visit = item_stopping_visitor(
- visit::mk_simple_visitor(@visit::SimpleVisitor {
- visit_expr: |e: @ast::expr| {
- match e.node {
- ast::expr_rec(*) =>
- cx.sess.span_lint(
- structural_records, e.id, it.id,
- e.span,
- ~"structural records are deprecated"),
- _ => ()
- }
- },
- .. *visit::default_simple_visitor()
- }));
- visit::visit_item(it, (), visit);
+ if !cx.legacy_records {
+ let visit = item_stopping_visitor(
+ visit::mk_simple_visitor(@visit::SimpleVisitor {
+ visit_expr: |e: @ast::expr| {
+ match e.node {
+ ast::expr_rec(*) =>
+ cx.sess.span_lint(
+ structural_records, e.id, it.id,
+ e.span,
+ ~"structural records are deprecated"),
+ _ => ()
+ }
+ },
+ .. *visit::default_simple_visitor()
+ }));
+ visit::visit_item(it, (), visit);
+ }
}
fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {
From 0a5115962a1ed4bfeafc21ba3fc455250deb3705 Mon Sep 17 00:00:00 2001
From: Tim Chevalier
Date: Fri, 25 Jan 2013 22:58:56 -0800
Subject: [PATCH 3/6] Add #[legacy_records] crate attribute
In rustc, rustdoc, rusti, syntax, and std.
---
src/librustc/rustc.rc | 1 +
src/librustdoc/rustdoc.rc | 1 +
src/librusti/rusti.rc | 1 +
src/libstd/std.rc | 4 ++++
src/libsyntax/syntax.rc | 4 +++-
5 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/librustc/rustc.rc b/src/librustc/rustc.rc
index 818c6eb04ea88..1542e9f237bb2 100644
--- a/src/librustc/rustc.rc
+++ b/src/librustc/rustc.rc
@@ -20,6 +20,7 @@
#[legacy_modes];
#[legacy_exports];
+#[legacy_records];
#[allow(non_implicitly_copyable_typarams)];
#[allow(non_camel_case_types)];
diff --git a/src/librustdoc/rustdoc.rc b/src/librustdoc/rustdoc.rc
index 77ed564aab471..ce0524f451d88 100644
--- a/src/librustdoc/rustdoc.rc
+++ b/src/librustdoc/rustdoc.rc
@@ -21,6 +21,7 @@
#[no_core];
#[legacy_modes];
+#[legacy_records];
#[allow(vecs_implicitly_copyable)];
#[allow(non_implicitly_copyable_typarams)];
diff --git a/src/librusti/rusti.rc b/src/librusti/rusti.rc
index 828877fc4a401..a8dba459aba2f 100644
--- a/src/librusti/rusti.rc
+++ b/src/librusti/rusti.rc
@@ -17,6 +17,7 @@
#[crate_type = "lib"];
+#[legacy_records];
#[no_core];
#[allow(vecs_implicitly_copyable,
diff --git a/src/libstd/std.rc b/src/libstd/std.rc
index eea9bd0a40f7a..cac57f2ac4482 100644
--- a/src/libstd/std.rc
+++ b/src/libstd/std.rc
@@ -33,6 +33,10 @@ not required in or otherwise suitable for the core library.
#[allow(deprecated_mode)];
#[forbid(deprecated_pattern)];
+
+// Transitional
+#[legacy_records];
+
#[no_core];
extern mod core(vers = "0.6");
diff --git a/src/libsyntax/syntax.rc b/src/libsyntax/syntax.rc
index 0777269f8f7fc..c167efad18f1e 100644
--- a/src/libsyntax/syntax.rc
+++ b/src/libsyntax/syntax.rc
@@ -18,6 +18,7 @@
#[legacy_modes];
#[legacy_exports];
+#[legacy_records];
#[allow(vecs_implicitly_copyable)];
#[allow(non_camel_case_types)];
@@ -40,6 +41,7 @@ pub mod syntax {
mod attr;
#[legacy_exports]
mod diagnostic;
+#[legacy_records]
mod codemap;
#[legacy_exports]
mod ast;
@@ -107,8 +109,8 @@ mod ext {
#[legacy_exports]
mod source_util;
- #[legacy_exports]
#[path = "pipes/mod.rs"]
+ #[legacy_exports]
mod pipes;
#[legacy_exports]
From 726aea5497ac3c58b3de3ac4aa1fd6abc035d5b8 Mon Sep 17 00:00:00 2001
From: Tim Chevalier
Date: Fri, 25 Jan 2013 23:02:27 -0800
Subject: [PATCH 4/6] core: Allow legacy records in in a few modules
Because of macros, #[allow(structural_records]] in
extfmt, gc, os, pipes, and run. Will need a snapshot.
---
src/libcore/extfmt.rs | 3 +++
src/libcore/gc.rs | 2 ++
src/libcore/os.rs | 1 +
src/libcore/pipes.rs | 3 +++
src/libcore/run.rs | 1 +
5 files changed, 10 insertions(+)
diff --git a/src/libcore/extfmt.rs b/src/libcore/extfmt.rs
index 854f99be1e2d1..850d1ea842778 100644
--- a/src/libcore/extfmt.rs
+++ b/src/libcore/extfmt.rs
@@ -55,6 +55,9 @@
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
+// Transitional
+#[allow(structural_records)]; // Macros -- needs a snapshot
+
/*
Syntax Extension: fmt
diff --git a/src/libcore/gc.rs b/src/libcore/gc.rs
index 698e264b57a65..bb2e7d788fd44 100644
--- a/src/libcore/gc.rs
+++ b/src/libcore/gc.rs
@@ -38,6 +38,8 @@ with destructors.
// NB: transitionary, de-mode-ing.
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
+// Transitional
+#[allow(structural_records)];
use cast;
use io;
diff --git a/src/libcore/os.rs b/src/libcore/os.rs
index cf86f45379ca2..44e84bad73a24 100644
--- a/src/libcore/os.rs
+++ b/src/libcore/os.rs
@@ -11,6 +11,7 @@
// NB: transitionary, de-mode-ing.
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
+#[allow(structural_records)];
/*!
* Higher-level interfaces to libc::* functions and operating system services.
diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs
index 0ef30668dbce1..268c7d4f8bae8 100644
--- a/src/libcore/pipes.rs
+++ b/src/libcore/pipes.rs
@@ -87,6 +87,9 @@ bounded and unbounded protocols allows for less code duplication.
// re-forbid after snapshot
#[forbid(deprecated_pattern)];
+// Transitional -- needs snapshot
+#[allow(structural_records)];
+
use cmp::Eq;
use cast::{forget, reinterpret_cast, transmute};
use either::{Either, Left, Right};
diff --git a/src/libcore/run.rs b/src/libcore/run.rs
index 8960d40b85a24..c5d17a65074ac 100644
--- a/src/libcore/run.rs
+++ b/src/libcore/run.rs
@@ -11,6 +11,7 @@
// NB: transitionary, de-mode-ing.
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
+#[allow(structural_records)];
//! Process spawning
use io;
From ccc7eb5a5e47c4eb8625b4771d2dc230cb3fc22e Mon Sep 17 00:00:00 2001
From: Tim Chevalier
Date: Fri, 25 Jan 2013 22:51:32 -0800
Subject: [PATCH 5/6] compiletest: Allow legacy records
But also remove most uses of structural records.
---
src/compiletest/compiletest.rc | 1 +
src/compiletest/errors.rs | 11 ++-
src/compiletest/header.rs | 10 +-
src/compiletest/procsrv.rs | 5 +-
src/compiletest/runtest.rs | 176 ++++++++++++++++-----------------
5 files changed, 103 insertions(+), 100 deletions(-)
diff --git a/src/compiletest/compiletest.rc b/src/compiletest/compiletest.rc
index 82949bf200cf2..8a868e14f08e3 100644
--- a/src/compiletest/compiletest.rc
+++ b/src/compiletest/compiletest.rc
@@ -12,6 +12,7 @@
#[no_core];
#[legacy_exports];
+#[legacy_records];
#[allow(vecs_implicitly_copyable)];
#[allow(non_camel_case_types)];
diff --git a/src/compiletest/errors.rs b/src/compiletest/errors.rs
index 2a28b767d0a1a..2dc48118edd62 100644
--- a/src/compiletest/errors.rs
+++ b/src/compiletest/errors.rs
@@ -16,12 +16,12 @@ use io::ReaderUtil;
use str;
export load_errors;
-export expected_error;
+export ExpectedError;
-type expected_error = { line: uint, kind: ~str, msg: ~str };
+struct ExpectedError { line: uint, kind: ~str, msg: ~str }
// Load any test directives embedded in the file
-fn load_errors(testfile: &Path) -> ~[expected_error] {
+fn load_errors(testfile: &Path) -> ~[ExpectedError] {
let mut error_patterns = ~[];
let rdr = io::file_reader(testfile).get();
let mut line_num = 1u;
@@ -33,7 +33,7 @@ fn load_errors(testfile: &Path) -> ~[expected_error] {
return error_patterns;
}
-fn parse_expected(line_num: uint, line: ~str) -> ~[expected_error] {
+fn parse_expected(line_num: uint, line: ~str) -> ~[ExpectedError] {
unsafe {
let error_tag = ~"//~";
let mut idx;
@@ -63,6 +63,7 @@ fn parse_expected(line_num: uint, line: ~str) -> ~[expected_error] {
debug!("line=%u kind=%s msg=%s", line_num - adjust_line, kind, msg);
- return ~[{line: line_num - adjust_line, kind: kind, msg: msg}];
+ return ~[ExpectedError{line: line_num - adjust_line, kind: kind,
+ msg: msg}];
}
}
diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs
index e0a170c74455c..db6677347cc62 100644
--- a/src/compiletest/header.rs
+++ b/src/compiletest/header.rs
@@ -17,11 +17,11 @@ use io::ReaderUtil;
use os;
use str;
-export test_props;
+export TestProps;
export load_props;
export is_test_ignored;
-type test_props = {
+struct TestProps {
// Lines that should be expected, in order, on standard out
error_patterns: ~[~str],
// Extra flags to pass to the compiler
@@ -33,10 +33,10 @@ type test_props = {
aux_builds: ~[~str],
// Environment settings to use during execution
exec_env: ~[(~str,~str)]
-};
+}
// Load any test directives embedded in the file
-fn load_props(testfile: &Path) -> test_props {
+fn load_props(testfile: &Path) -> TestProps {
let mut error_patterns = ~[];
let mut aux_builds = ~[];
let mut exec_env = ~[];
@@ -64,7 +64,7 @@ fn load_props(testfile: &Path) -> test_props {
exec_env.push(*ee);
}
};
- return {
+ return TestProps {
error_patterns: error_patterns,
compile_flags: compile_flags,
pp_exact: pp_exact,
diff --git a/src/compiletest/procsrv.rs b/src/compiletest/procsrv.rs
index 6e61fcabe0bce..398820a5a6380 100644
--- a/src/compiletest/procsrv.rs
+++ b/src/compiletest/procsrv.rs
@@ -51,13 +51,14 @@ fn target_env(_lib_path: ~str, _prog: ~str) -> ~[(~str,~str)] {
~[]
}
+struct Result {status: int, out: ~str, err: ~str}
// FIXME (#2659): This code is duplicated in core::run::program_output
fn run(lib_path: ~str,
prog: ~str,
args: ~[~str],
env: ~[(~str, ~str)],
- input: Option<~str>) -> {status: int, out: ~str, err: ~str} {
+ input: Option<~str>) -> Result {
let pipe_in = os::pipe();
let pipe_out = os::pipe();
@@ -105,7 +106,7 @@ fn run(lib_path: ~str,
};
count -= 1;
};
- return {status: status, out: outs, err: errs};
+ return Result {status: status, out: outs, err: errs};
}
fn writeclose(fd: c_int, s: Option<~str>) {
diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs
index 62842d04e7830..5ccad97dce3ca 100644
--- a/src/compiletest/runtest.rs
+++ b/src/compiletest/runtest.rs
@@ -26,7 +26,7 @@ use common::config;
use errors;
use header;
use header::load_props;
-use header::test_props;
+use header::TestProps;
use procsrv;
use util;
use util::logv;
@@ -49,32 +49,32 @@ fn run(config: config, testfile: ~str) {
}
}
-fn run_cfail_test(config: config, props: test_props, testfile: &Path) {
- let procres = compile_test(config, props, testfile);
+fn run_cfail_test(config: config, props: TestProps, testfile: &Path) {
+ let ProcRes = compile_test(config, props, testfile);
- if procres.status == 0 {
- fatal_procres(~"compile-fail test compiled successfully!", procres);
+ if ProcRes.status == 0 {
+ fatal_ProcRes(~"compile-fail test compiled successfully!", ProcRes);
}
- check_correct_failure_status(procres);
+ check_correct_failure_status(ProcRes);
let expected_errors = errors::load_errors(testfile);
if !expected_errors.is_empty() {
if !props.error_patterns.is_empty() {
fatal(~"both error pattern and expected errors specified");
}
- check_expected_errors(expected_errors, testfile, procres);
+ check_expected_errors(expected_errors, testfile, ProcRes);
} else {
- check_error_patterns(props, testfile, procres);
+ check_error_patterns(props, testfile, ProcRes);
}
}
-fn run_rfail_test(config: config, props: test_props, testfile: &Path) {
- let procres = if !config.jit {
- let procres = compile_test(config, props, testfile);
+fn run_rfail_test(config: config, props: TestProps, testfile: &Path) {
+ let ProcRes = if !config.jit {
+ let ProcRes = compile_test(config, props, testfile);
- if procres.status != 0 {
- fatal_procres(~"compilation failed!", procres);
+ if ProcRes.status != 0 {
+ fatal_ProcRes(~"compilation failed!", ProcRes);
}
exec_compiled_test(config, props, testfile)
@@ -84,46 +84,46 @@ fn run_rfail_test(config: config, props: test_props, testfile: &Path) {
// The value our Makefile configures valgrind to return on failure
const valgrind_err: int = 100;
- if procres.status == valgrind_err {
- fatal_procres(~"run-fail test isn't valgrind-clean!", procres);
+ if ProcRes.status == valgrind_err {
+ fatal_ProcRes(~"run-fail test isn't valgrind-clean!", ProcRes);
}
- check_correct_failure_status(procres);
- check_error_patterns(props, testfile, procres);
+ check_correct_failure_status(ProcRes);
+ check_error_patterns(props, testfile, ProcRes);
}
-fn check_correct_failure_status(procres: procres) {
+fn check_correct_failure_status(ProcRes: ProcRes) {
// The value the rust runtime returns on failure
const rust_err: int = 101;
- if procres.status != rust_err {
- fatal_procres(
+ if ProcRes.status != rust_err {
+ fatal_ProcRes(
fmt!("failure produced the wrong error code: %d",
- procres.status),
- procres);
+ ProcRes.status),
+ ProcRes);
}
}
-fn run_rpass_test(config: config, props: test_props, testfile: &Path) {
+fn run_rpass_test(config: config, props: TestProps, testfile: &Path) {
if !config.jit {
- let mut procres = compile_test(config, props, testfile);
+ let mut ProcRes = compile_test(config, props, testfile);
- if procres.status != 0 {
- fatal_procres(~"compilation failed!", procres);
+ if ProcRes.status != 0 {
+ fatal_ProcRes(~"compilation failed!", ProcRes);
}
- procres = exec_compiled_test(config, props, testfile);
+ ProcRes = exec_compiled_test(config, props, testfile);
- if procres.status != 0 {
- fatal_procres(~"test run failed!", procres);
+ if ProcRes.status != 0 {
+ fatal_ProcRes(~"test run failed!", ProcRes);
}
} else {
- let mut procres = jit_test(config, props, testfile);
+ let mut ProcRes = jit_test(config, props, testfile);
- if procres.status != 0 { fatal_procres(~"jit failed!", procres); }
+ if ProcRes.status != 0 { fatal_ProcRes(~"jit failed!", ProcRes); }
}
}
-fn run_pretty_test(config: config, props: test_props, testfile: &Path) {
+fn run_pretty_test(config: config, props: TestProps, testfile: &Path) {
if props.pp_exact.is_some() {
logv(config, ~"testing for exact pretty-printing");
} else { logv(config, ~"testing for converging pretty-printing"); }
@@ -136,14 +136,14 @@ fn run_pretty_test(config: config, props: test_props, testfile: &Path) {
let mut round = 0;
while round < rounds {
logv(config, fmt!("pretty-printing round %d", round));
- let procres = print_source(config, testfile, srcs[round]);
+ let ProcRes = print_source(config, testfile, srcs[round]);
- if procres.status != 0 {
- fatal_procres(fmt!("pretty-printing failed in round %d", round),
- procres);
+ if ProcRes.status != 0 {
+ fatal_ProcRes(fmt!("pretty-printing failed in round %d", round),
+ ProcRes);
}
- srcs.push(procres.stdout);
+ srcs.push(ProcRes.stdout);
round += 1;
}
@@ -167,23 +167,23 @@ fn run_pretty_test(config: config, props: test_props, testfile: &Path) {
compare_source(expected, actual);
// Finally, let's make sure it actually appears to remain valid code
- let procres = typecheck_source(config, props, testfile, actual);
+ let ProcRes = typecheck_source(config, props, testfile, actual);
- if procres.status != 0 {
- fatal_procres(~"pretty-printed source does not typecheck", procres);
+ if ProcRes.status != 0 {
+ fatal_ProcRes(~"pretty-printed source does not typecheck", ProcRes);
}
return;
- fn print_source(config: config, testfile: &Path, src: ~str) -> procres {
+ fn print_source(config: config, testfile: &Path, src: ~str) -> ProcRes {
compose_and_run(config, testfile, make_pp_args(config, testfile),
~[], config.compile_lib_path, Some(src))
}
- fn make_pp_args(config: config, _testfile: &Path) -> procargs {
+ fn make_pp_args(config: config, _testfile: &Path) -> ProcArgs {
let prog = config.rustc_path;
let args = ~[~"-", ~"--pretty", ~"normal"];
- return {prog: prog.to_str(), args: args};
+ return ProcArgs {prog: prog.to_str(), args: args};
}
fn compare_source(expected: ~str, actual: ~str) {
@@ -206,15 +206,15 @@ actual:\n\
}
}
- fn typecheck_source(config: config, props: test_props,
- testfile: &Path, src: ~str) -> procres {
+ fn typecheck_source(config: config, props: TestProps,
+ testfile: &Path, src: ~str) -> ProcRes {
compose_and_run_compiler(
config, props, testfile,
make_typecheck_args(config, testfile),
Some(src))
}
- fn make_typecheck_args(config: config, testfile: &Path) -> procargs {
+ fn make_typecheck_args(config: config, testfile: &Path) -> ProcArgs {
let prog = config.rustc_path;
let mut args = ~[~"-",
~"--no-trans", ~"--lib",
@@ -222,25 +222,25 @@ actual:\n\
~"-L",
aux_output_dir_name(config, testfile).to_str()];
args += split_maybe_args(config.rustcflags);
- return {prog: prog.to_str(), args: args};
+ return ProcArgs {prog: prog.to_str(), args: args};
}
}
-fn check_error_patterns(props: test_props,
+fn check_error_patterns(props: TestProps,
testfile: &Path,
- procres: procres) {
+ ProcRes: ProcRes) {
if vec::is_empty(props.error_patterns) {
fatal(~"no error pattern specified in " + testfile.to_str());
}
- if procres.status == 0 {
+ if ProcRes.status == 0 {
fatal(~"process did not return an error status");
}
let mut next_err_idx = 0u;
let mut next_err_pat = props.error_patterns[next_err_idx];
let mut done = false;
- for str::split_char(procres.stderr, '\n').each |line| {
+ for str::split_char(ProcRes.stderr, '\n').each |line| {
if str::contains(*line, next_err_pat) {
debug!("found error pattern %s", next_err_pat);
next_err_idx += 1u;
@@ -258,25 +258,25 @@ fn check_error_patterns(props: test_props,
vec::slice(props.error_patterns, next_err_idx,
vec::len(props.error_patterns));
if vec::len(missing_patterns) == 1u {
- fatal_procres(fmt!("error pattern '%s' not found!",
- missing_patterns[0]), procres);
+ fatal_ProcRes(fmt!("error pattern '%s' not found!",
+ missing_patterns[0]), ProcRes);
} else {
for missing_patterns.each |pattern| {
error(fmt!("error pattern '%s' not found!", *pattern));
}
- fatal_procres(~"multiple error patterns not found", procres);
+ fatal_ProcRes(~"multiple error patterns not found", ProcRes);
}
}
-fn check_expected_errors(expected_errors: ~[errors::expected_error],
+fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
testfile: &Path,
- procres: procres) {
+ ProcRes: ProcRes) {
// true if we found the error in question
let found_flags = vec::cast_to_mut(vec::from_elem(
vec::len(expected_errors), false));
- if procres.status == 0 {
+ if ProcRes.status == 0 {
fatal(~"process did not return an error status");
}
@@ -290,7 +290,7 @@ fn check_expected_errors(expected_errors: ~[errors::expected_error],
// filename:line1:col1: line2:col2: *warning:* msg
// where line1:col1: is the starting point, line2:col2:
// is the ending point, and * represents ANSI color codes.
- for str::split_char(procres.stderr, '\n').each |line| {
+ for str::split_char(ProcRes.stderr, '\n').each |line| {
let mut was_expected = false;
for vec::eachi(expected_errors) |i, ee| {
if !found_flags[i] {
@@ -312,17 +312,17 @@ fn check_expected_errors(expected_errors: ~[errors::expected_error],
}
if !was_expected && is_compiler_error_or_warning(*line) {
- fatal_procres(fmt!("unexpected compiler error or warning: '%s'",
+ fatal_ProcRes(fmt!("unexpected compiler error or warning: '%s'",
*line),
- procres);
+ ProcRes);
}
}
for uint::range(0u, vec::len(found_flags)) |i| {
if !found_flags[i] {
let ee = expected_errors[i];
- fatal_procres(fmt!("expected %s on line %u not found: %s",
- ee.kind, ee.line, ee.msg), procres);
+ fatal_ProcRes(fmt!("expected %s on line %u not found: %s",
+ ee.kind, ee.line, ee.msg), ProcRes);
}
}
}
@@ -402,21 +402,21 @@ fn scan_string(haystack: ~str, needle: ~str, idx: &mut uint) -> bool {
return true;
}
-type procargs = {prog: ~str, args: ~[~str]};
+struct ProcArgs {prog: ~str, args: ~[~str]}
-type procres = {status: int, stdout: ~str, stderr: ~str, cmdline: ~str};
+struct ProcRes {status: int, stdout: ~str, stderr: ~str, cmdline: ~str}
-fn compile_test(config: config, props: test_props,
- testfile: &Path) -> procres {
+fn compile_test(config: config, props: TestProps,
+ testfile: &Path) -> ProcRes {
compile_test_(config, props, testfile, [])
}
-fn jit_test(config: config, props: test_props, testfile: &Path) -> procres {
+fn jit_test(config: config, props: TestProps, testfile: &Path) -> ProcRes {
compile_test_(config, props, testfile, [~"--jit"])
}
-fn compile_test_(config: config, props: test_props,
- testfile: &Path, extra_args: &[~str]) -> procres {
+fn compile_test_(config: config, props: TestProps,
+ testfile: &Path, extra_args: &[~str]) -> ProcRes {
let link_args = ~[~"-L", aux_output_dir_name(config, testfile).to_str()];
compose_and_run_compiler(
config, props, testfile,
@@ -425,8 +425,8 @@ fn compile_test_(config: config, props: test_props,
None)
}
-fn exec_compiled_test(config: config, props: test_props,
- testfile: &Path) -> procres {
+fn exec_compiled_test(config: config, props: TestProps,
+ testfile: &Path) -> ProcRes {
compose_and_run(config, testfile,
make_run_args(config, props, testfile),
props.exec_env,
@@ -435,10 +435,10 @@ fn exec_compiled_test(config: config, props: test_props,
fn compose_and_run_compiler(
config: config,
- props: test_props,
+ props: TestProps,
testfile: &Path,
- args: procargs,
- input: Option<~str>) -> procres {
+ args: ProcArgs,
+ input: Option<~str>) -> ProcRes {
if !props.aux_builds.is_empty() {
ensure_dir(&aux_output_dir_name(config, testfile));
@@ -455,7 +455,7 @@ fn compose_and_run_compiler(
let auxres = compose_and_run(config, &abs_ab, aux_args, ~[],
config.compile_lib_path, None);
if auxres.status != 0 {
- fatal_procres(
+ fatal_ProcRes(
fmt!("auxiliary build of %s failed to compile: ",
abs_ab.to_str()),
auxres);
@@ -474,17 +474,17 @@ fn ensure_dir(path: &Path) {
}
fn compose_and_run(config: config, testfile: &Path,
- procargs: procargs,
+ ProcArgs: ProcArgs,
procenv: ~[(~str, ~str)],
lib_path: ~str,
- input: Option<~str>) -> procres {
+ input: Option<~str>) -> ProcRes {
return program_output(config, testfile, lib_path,
- procargs.prog, procargs.args, procenv, input);
+ ProcArgs.prog, ProcArgs.args, procenv, input);
}
-fn make_compile_args(config: config, props: test_props, extras: ~[~str],
+fn make_compile_args(config: config, props: TestProps, extras: ~[~str],
xform: fn(config, (&Path)) -> Path,
- testfile: &Path) -> procargs {
+ testfile: &Path) -> ProcArgs {
let prog = config.rustc_path;
let mut args = ~[testfile.to_str(),
~"-o", xform(config, testfile).to_str(),
@@ -492,7 +492,7 @@ fn make_compile_args(config: config, props: test_props, extras: ~[~str],
+ extras;
args += split_maybe_args(config.rustcflags);
args += split_maybe_args(props.compile_flags);
- return {prog: prog.to_str(), args: args};
+ return ProcArgs {prog: prog.to_str(), args: args};
}
fn make_lib_name(config: config, auxfile: &Path, testfile: &Path) -> Path {
@@ -507,8 +507,8 @@ fn make_exe_name(config: config, testfile: &Path) -> Path {
str::from_slice(os::EXE_SUFFIX))
}
-fn make_run_args(config: config, _props: test_props, testfile: &Path) ->
- procargs {
+fn make_run_args(config: config, _props: TestProps, testfile: &Path) ->
+ ProcArgs {
let toolargs = {
// If we've got another tool to run under (valgrind),
// then split apart its command
@@ -521,7 +521,7 @@ fn make_run_args(config: config, _props: test_props, testfile: &Path) ->
};
let args = toolargs + ~[make_exe_name(config, testfile).to_str()];
- return {prog: args[0], args: vec::slice(args, 1u, vec::len(args))};
+ return ProcArgs {prog: args[0], args: vec::slice(args, 1, args.len())};
}
fn split_maybe_args(argstr: Option<~str>) -> ~[~str] {
@@ -537,7 +537,7 @@ fn split_maybe_args(argstr: Option<~str>) -> ~[~str] {
fn program_output(config: config, testfile: &Path, lib_path: ~str, prog: ~str,
args: ~[~str], env: ~[(~str, ~str)],
- input: Option<~str>) -> procres {
+ input: Option<~str>) -> ProcRes {
let cmdline =
{
let cmdline = make_cmdline(lib_path, prog, args);
@@ -546,7 +546,7 @@ fn program_output(config: config, testfile: &Path, lib_path: ~str, prog: ~str,
};
let res = procsrv::run(lib_path, prog, args, env, input);
dump_output(config, testfile, res.out, res.err);
- return {status: res.status,
+ return ProcRes {status: res.status,
stdout: res.out,
stderr: res.err,
cmdline: cmdline};
@@ -621,7 +621,7 @@ fn error(err: ~str) { io::stdout().write_line(fmt!("\nerror: %s", err)); }
fn fatal(err: ~str) -> ! { error(err); fail; }
-fn fatal_procres(err: ~str, procres: procres) -> ! {
+fn fatal_ProcRes(err: ~str, ProcRes: ProcRes) -> ! {
let msg =
fmt!("\n\
error: %s\n\
@@ -635,7 +635,7 @@ stderr:\n\
%s\n\
------------------------------------------\n\
\n",
- err, procres.cmdline, procres.stdout, procres.stderr);
+ err, ProcRes.cmdline, ProcRes.stdout, ProcRes.stderr);
io::stdout().write_str(msg);
fail;
}
From 193ce7073ab3b7ae3d6bcde04339c7b91d9fe8ff Mon Sep 17 00:00:00 2001
From: Tim Chevalier
Date: Fri, 25 Jan 2013 23:19:20 -0800
Subject: [PATCH 6/6] testsuite: Add #[allow(structural_records)] to pipes
tests
These will require a snapshot.
---
src/test/run-pass/pipe-detect-term.rs | 2 ++
src/test/run-pass/pipe-peek.rs | 1 +
src/test/run-pass/pipe-pingpong-bounded.rs | 2 ++
src/test/run-pass/pipe-pingpong-proto.rs | 2 ++
src/test/run-pass/pipe-presentation-examples.rs | 1 +
src/test/run-pass/pipe-select.rs | 2 ++
src/test/run-pass/pipe-sleep.rs | 1 +
7 files changed, 11 insertions(+)
diff --git a/src/test/run-pass/pipe-detect-term.rs b/src/test/run-pass/pipe-detect-term.rs
index c2d4be04191bc..da91c1a2e8cd6 100644
--- a/src/test/run-pass/pipe-detect-term.rs
+++ b/src/test/run-pass/pipe-detect-term.rs
@@ -14,6 +14,8 @@
// xfail-win32
+#[legacy_records];
+
extern mod std;
use std::timer::sleep;
use std::uv;
diff --git a/src/test/run-pass/pipe-peek.rs b/src/test/run-pass/pipe-peek.rs
index d7d0ccfc40440..5bf85a80f7c49 100644
--- a/src/test/run-pass/pipe-peek.rs
+++ b/src/test/run-pass/pipe-peek.rs
@@ -10,6 +10,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+#[legacy_records];
extern mod std;
use std::timer::sleep;
diff --git a/src/test/run-pass/pipe-pingpong-bounded.rs b/src/test/run-pass/pipe-pingpong-bounded.rs
index f44c54d38e4d9..d251fbf8f76fb 100644
--- a/src/test/run-pass/pipe-pingpong-bounded.rs
+++ b/src/test/run-pass/pipe-pingpong-bounded.rs
@@ -17,6 +17,8 @@
// This was generated initially by the pipe compiler, but it's been
// modified in hopefully straightforward ways.
+#[legacy_records];
+
mod pingpong {
use core::pipes::*;
use core::ptr;
diff --git a/src/test/run-pass/pipe-pingpong-proto.rs b/src/test/run-pass/pipe-pingpong-proto.rs
index 7fb77cba3bde9..840acd5b287d1 100644
--- a/src/test/run-pass/pipe-pingpong-proto.rs
+++ b/src/test/run-pass/pipe-pingpong-proto.rs
@@ -12,6 +12,8 @@
// An example to make sure the protocol parsing syntax extension works.
+#[legacy_records];
+
use core::option;
proto! pingpong (
diff --git a/src/test/run-pass/pipe-presentation-examples.rs b/src/test/run-pass/pipe-presentation-examples.rs
index 0fe845dd1f934..8bfac5d0545fa 100644
--- a/src/test/run-pass/pipe-presentation-examples.rs
+++ b/src/test/run-pass/pipe-presentation-examples.rs
@@ -15,6 +15,7 @@
// Code is easier to write in emacs, and it's good to be sure all the
// code samples compile (or not) as they should.
+#[legacy_records];
use double_buffer::client::*;
use double_buffer::give_buffer;
diff --git a/src/test/run-pass/pipe-select.rs b/src/test/run-pass/pipe-select.rs
index e71d0c4931dc7..b374516b8c629 100644
--- a/src/test/run-pass/pipe-select.rs
+++ b/src/test/run-pass/pipe-select.rs
@@ -13,6 +13,8 @@
// xfail-pretty
// xfail-win32
+#[legacy_records];
+
extern mod std;
use std::timer::sleep;
use std::uv;
diff --git a/src/test/run-pass/pipe-sleep.rs b/src/test/run-pass/pipe-sleep.rs
index 4a6e7b4ce36a8..5577035e170a0 100644
--- a/src/test/run-pass/pipe-sleep.rs
+++ b/src/test/run-pass/pipe-sleep.rs
@@ -10,6 +10,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+#[legacy_records];
extern mod std;
use std::timer::sleep;
ZW5kZW5yYWhheXU5QGdtYWlsLmNvbQ==