Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

librustc: Copy or move upvars by value. #14501

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,11 @@ pub fn make_tests(config: &Config) -> Vec<test::TestDescAndFn> {
let file = file.clone();
debug!("inspecting file {}", file.display());
if is_test(config, &file) {
let t = make_test(config, &file, || {
let file_ptr = &file;
let t = make_test(config, file_ptr, || {
match config.mode {
Codegen => make_metrics_test_closure(config, &file),
_ => make_test_closure(config, &file)
Codegen => make_metrics_test_closure(config, file_ptr),
_ => make_test_closure(config, file_ptr)
}
});
tests.push(t)
Expand Down
96 changes: 55 additions & 41 deletions src/compiletest/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,57 +51,71 @@ pub fn load_props(testfile: &Path) -> TestProps {
let mut check_stdout = false;
let mut no_prefer_dynamic = false;
let mut no_pretty_expanded = false;
iter_header(testfile, |ln| {
match parse_error_pattern(ln) {
Some(ep) => error_patterns.push(ep),
None => ()
};

if compile_flags.is_none() {
compile_flags = parse_compile_flags(ln);
}

if run_flags.is_none() {
run_flags = parse_run_flags(ln);
}
{
let error_patterns_ptr = &mut error_patterns;
let aux_builds_ptr = &mut aux_builds;
let exec_env_ptr = &mut exec_env;
let compile_flags_ptr = &mut compile_flags;
let run_flags_ptr = &mut run_flags;
let pp_exact_ptr = &mut pp_exact;
let check_lines_ptr = &mut check_lines;
let force_host_ptr = &mut force_host;
let check_stdout_ptr = &mut check_stdout;
let no_prefer_dynamic_ptr = &mut no_prefer_dynamic;
let no_pretty_expanded_ptr = &mut no_pretty_expanded;
iter_header(testfile, |ln| {
match parse_error_pattern(ln) {
Some(ep) => error_patterns_ptr.push(ep),
None => ()
};

if compile_flags_ptr.is_none() {
*compile_flags_ptr = parse_compile_flags(ln);
}

if pp_exact.is_none() {
pp_exact = parse_pp_exact(ln, testfile);
}
if run_flags_ptr.is_none() {
*run_flags_ptr = parse_run_flags(ln);
}

if !force_host {
force_host = parse_force_host(ln);
}
if pp_exact_ptr.is_none() {
*pp_exact_ptr = parse_pp_exact(ln, testfile);
}

if !check_stdout {
check_stdout = parse_check_stdout(ln);
}
if !*force_host_ptr {
*force_host_ptr = parse_force_host(ln);
}

if !no_prefer_dynamic {
no_prefer_dynamic = parse_no_prefer_dynamic(ln);
}
if !*check_stdout_ptr {
*check_stdout_ptr = parse_check_stdout(ln);
}

if !no_pretty_expanded {
no_pretty_expanded = parse_no_pretty_expanded(ln);
}
if !*no_prefer_dynamic_ptr {
*no_prefer_dynamic_ptr = parse_no_prefer_dynamic(ln);
}

match parse_aux_build(ln) {
Some(ab) => { aux_builds.push(ab); }
None => {}
}
if !*no_pretty_expanded_ptr {
*no_pretty_expanded_ptr = parse_no_pretty_expanded(ln);
}

match parse_exec_env(ln) {
Some(ee) => { exec_env.push(ee); }
None => {}
}
match parse_aux_build(ln) {
Some(ab) => { aux_builds_ptr.push(ab); }
None => {}
}

match parse_check_line(ln) {
Some(cl) => check_lines.push(cl),
None => ()
};
match parse_exec_env(ln) {
Some(ee) => { exec_env_ptr.push(ee); }
None => {}
}

true
});
match parse_check_line(ln) {
Some(cl) => check_lines_ptr.push(cl),
None => ()
};

true
});
}

TestProps {
error_patterns: error_patterns,
Expand Down
50 changes: 28 additions & 22 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,32 +627,38 @@ fn parse_debugger_commands(file_path: &Path, debugger_prefix: &str)
let mut check_lines = vec!();
let mut counter = 1;
let mut reader = BufferedReader::new(File::open(file_path).unwrap());
for line in reader.lines() {
match line {
Ok(line) => {
if line.as_slice().contains("#break") {
breakpoint_lines.push(counter);
}

header::parse_name_value_directive(
line.as_slice(),
command_directive.to_string()).map(|cmd| {
commands.push(cmd)
});
{
let breakpoint_lines_ptr = &mut breakpoint_lines;
let commands_ptr = &mut commands;
let check_lines_ptr = &mut check_lines;
for line in reader.lines() {
match line {
Ok(line) => {
if line.as_slice().contains("#break") {
breakpoint_lines_ptr.push(counter);
}

header::parse_name_value_directive(
line.as_slice(),
check_directive.to_string()).map(|cmd| {
check_lines.push(cmd)
});
}
Err(e) => {
fatal(format_strbuf!("Error while parsing debugger commands: \
{}",
e))
header::parse_name_value_directive(
line.as_slice(),
command_directive.to_string()).map(|cmd| {
commands_ptr.push(cmd)
});

header::parse_name_value_directive(
line.as_slice(),
check_directive.to_string()).map(|cmd| {
check_lines_ptr.push(cmd)
});
}
Err(e) => {
fatal(format_strbuf!("Error while parsing debugger commands: \
{}",
e))
}
}
counter += 1;
}
counter += 1;
}

DebuggerCommands {
Expand Down
15 changes: 10 additions & 5 deletions src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,9 @@ mod tests {
#[bench]
pub fn bench_copy(b: &mut Bencher) {
let arena = TypedArena::new();
let arena_ptr = &arena;
b.iter(|| {
arena.alloc(Point {
arena_ptr.alloc(Point {
x: 1,
y: 2,
z: 3,
Expand All @@ -526,8 +527,9 @@ mod tests {
#[bench]
pub fn bench_copy_old_arena(b: &mut Bencher) {
let arena = Arena::new();
let arena_ptr = &arena;
b.iter(|| {
arena.alloc(|| {
arena_ptr.alloc(|| {
Point {
x: 1,
y: 2,
Expand All @@ -545,8 +547,9 @@ mod tests {
#[test]
pub fn test_noncopy() {
let arena = TypedArena::new();
let arena_ptr = &arena;
for _ in range(0, 100000) {
arena.alloc(Noncopy {
arena_ptr.alloc(Noncopy {
string: "hello world".to_string(),
array: vec!( 1, 2, 3, 4, 5 ),
});
Expand All @@ -556,8 +559,9 @@ mod tests {
#[bench]
pub fn bench_noncopy(b: &mut Bencher) {
let arena = TypedArena::new();
let arena_ptr = &arena;
b.iter(|| {
arena.alloc(Noncopy {
arena_ptr.alloc(Noncopy {
string: "hello world".to_string(),
array: vec!( 1, 2, 3, 4, 5 ),
})
Expand All @@ -577,8 +581,9 @@ mod tests {
#[bench]
pub fn bench_noncopy_old_arena(b: &mut Bencher) {
let arena = Arena::new();
let arena_ptr = &arena;
b.iter(|| {
arena.alloc(|| Noncopy {
arena_ptr.alloc(|| Noncopy {
string: "hello world".to_string(),
array: vec!( 1, 2, 3, 4, 5 ),
})
Expand Down
Loading