Skip to content

Commit f79dc3f

Browse files
committed
---
yaml --- r: 141258 b: refs/heads/try2 c: 363e672 h: refs/heads/master v: v3
1 parent 0fa03a4 commit f79dc3f

File tree

27 files changed

+540
-758
lines changed

27 files changed

+540
-758
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: d98cc9995fb5c87230f57eeffb8061df25d85190
8+
refs/heads/try2: 363e67273622285a65caa74bb63ecfa04df59055
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/compiletest/procsrv.rs

Lines changed: 69 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
use core::prelude::*;
1212

13+
use core::libc::c_int;
14+
use core::run::spawn_process;
1315
use core::run;
1416

1517
#[cfg(target_os = "win32")]
@@ -36,35 +38,86 @@ fn target_env(lib_path: &str, prog: &str) -> ~[(~str,~str)] {
3638
#[cfg(target_os = "macos")]
3739
#[cfg(target_os = "freebsd")]
3840
fn target_env(_lib_path: &str, _prog: &str) -> ~[(~str,~str)] {
39-
os::env()
41+
~[]
4042
}
4143
4244
pub struct Result {status: int, out: ~str, err: ~str}
4345
46+
// FIXME (#2659): This code is duplicated in core::run::program_output
4447
pub fn run(lib_path: &str,
4548
prog: &str,
4649
args: &[~str],
4750
env: ~[(~str, ~str)],
4851
input: Option<~str>) -> Result {
52+
let pipe_in = os::pipe();
53+
let pipe_out = os::pipe();
54+
let pipe_err = os::pipe();
55+
let pid = spawn_process(prog, args,
56+
&Some(env + target_env(lib_path, prog)),
57+
&None, pipe_in.in, pipe_out.out, pipe_err.out);
58+
59+
os::close(pipe_in.in);
60+
os::close(pipe_out.out);
61+
os::close(pipe_err.out);
62+
if pid == -1i32 {
63+
os::close(pipe_in.out);
64+
os::close(pipe_out.in);
65+
os::close(pipe_err.in);
66+
fail!();
67+
}
4968
50-
let env = env + target_env(lib_path, prog);
51-
let mut proc = run::Process::new(prog, args, run::ProcessOptions {
52-
env: Some(env.slice(0, env.len())),
53-
dir: None,
54-
in_fd: None,
55-
out_fd: None,
56-
err_fd: None
57-
});
5869
59-
for input.each |input| {
60-
proc.input().write_str(*input);
70+
writeclose(pipe_in.out, input);
71+
let p = comm::PortSet::new();
72+
let ch = p.chan();
73+
do task::spawn_sched(task::SingleThreaded) || {
74+
let errput = readclose(pipe_err.in);
75+
ch.send((2, errput));
6176
}
62-
let output = proc.finish_with_output();
77+
let ch = p.chan();
78+
do task::spawn_sched(task::SingleThreaded) || {
79+
let output = readclose(pipe_out.in);
80+
ch.send((1, output));
81+
}
82+
let status = run::waitpid(pid);
83+
let mut errs = ~"";
84+
let mut outs = ~"";
85+
let mut count = 2;
86+
while count > 0 {
87+
match p.recv() {
88+
(1, s) => {
89+
outs = s;
90+
}
91+
(2, s) => {
92+
errs = s;
93+
}
94+
_ => { fail!() }
95+
};
96+
count -= 1;
97+
};
98+
return Result {status: status, out: outs, err: errs};
99+
}
63100
64-
Result {
65-
status: output.status,
66-
out: str::from_bytes(output.output),
67-
err: str::from_bytes(output.error)
101+
fn writeclose(fd: c_int, s: Option<~str>) {
102+
if s.is_some() {
103+
let writer = io::fd_writer(fd, false);
104+
writer.write_str(s.get());
68105
}
106+
107+
os::close(fd);
69108
}
70109
110+
fn readclose(fd: c_int) -> ~str {
111+
unsafe {
112+
// Copied from run::program_output
113+
let file = os::fdopen(fd);
114+
let reader = io::FILE_reader(file, false);
115+
let mut buf = ~"";
116+
while !reader.eof() {
117+
let bytes = reader.read_bytes(4096u);
118+
str::push_str(&mut buf, str::from_bytes(bytes));
119+
}
120+
os::fclose(file);
121+
return buf;
122+
}
123+
}

branches/try2/src/etc/ctags.rust

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
--regex-rust=/[ \t]*type[ \t]+([a-zA-Z0-9_]+)/\1/T,types/
55
--regex-rust=/[ \t]*enum[ \t]+([a-zA-Z0-9_]+)/\1/T,types/
66
--regex-rust=/[ \t]*struct[ \t]+([a-zA-Z0-9_]+)/\1/m,types/
7+
--regex-rust=/[ \t]*class[ \t]+([a-zA-Z0-9_]+)/\1/m,types/
78
--regex-rust=/[ \t]*mod[ \t]+([a-zA-Z0-9_]+)/\1/m,modules/
8-
--regex-rust=/[ \t]*static[ \t]+([a-zA-Z0-9_]+)/\1/m,consts/
9+
--regex-rust=/[ \t]*const[ \t]+([a-zA-Z0-9_]+)/\1/m,consts/
910
--regex-rust=/[ \t]*trait[ \t]+([a-zA-Z0-9_]+)/\1/m,traits/
1011
--regex-rust=/[ \t]*impl[ \t]+([a-zA-Z0-9_]+)/\1/m,impls/
12+
--regex-rust=/[ \t]*impl[ \t]+of[ \t]([a-zA-Z0-9_]+)/\1/m,impls/

branches/try2/src/libextra/std.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ pub mod serialize;
123123
// A curious inner-module that's not exported that contains the binding
124124
// 'extra' so that macro-expanded references to std::serialize and such
125125
// can be resolved within libextra.
126-
#[doc(hidden)]
126+
#[doc(hidden)] // FIXME #3538
127127
pub mod std {
128128
pub use serialize;
129129
pub use test;
@@ -134,7 +134,7 @@ pub mod std {
134134
pub use core::cmp;
135135
pub use core::sys;
136136
}
137-
#[doc(hidden)]
137+
#[doc(hidden)] // FIXME #3538
138138
pub mod extra {
139139
pub use serialize;
140140
pub use test;

branches/try2/src/libextra/workcache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ fn test() {
415415
prep.declare_input("file", pth.to_str(), digest_file(&pth));
416416
do prep.exec |_exe| {
417417
let out = Path("foo.o");
418-
run::process_status("gcc", [~"foo.c", ~"-o", out.to_str()]);
418+
run::run_program("gcc", [~"foo.c", ~"-o", out.to_str()]);
419419
out.to_str()
420420
}
421421
};

branches/try2/src/libfuzzer/fuzzer.rc

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -412,20 +412,20 @@ pub fn check_whole_compiler(code: &str,
412412
pub fn removeIfExists(filename: &Path) {
413413
// So sketchy!
414414
assert!(!contains(filename.to_str(), " "));
415-
run::process_status("bash", [~"-c", ~"rm " + filename.to_str()]);
415+
run::program_output("bash", [~"-c", ~"rm " + filename.to_str()]);
416416
}
417417

418418
pub fn removeDirIfExists(filename: &Path) {
419419
// So sketchy!
420420
assert!(!contains(filename.to_str(), " "));
421-
run::process_status("bash", [~"-c", ~"rm -r " + filename.to_str()]);
421+
run::program_output("bash", [~"-c", ~"rm -r " + filename.to_str()]);
422422
}
423423

424424
pub fn check_running(exe_filename: &Path) -> happiness {
425-
let p = run::process_output(
425+
let p = run::program_output(
426426
"/Users/jruderman/scripts/timed_run_rust_program.py",
427427
[exe_filename.to_str()]);
428-
let comb = str::from_bytes(p.output) + ~"\n" + str::from_bytes(p.error);
428+
let comb = p.out + ~"\n" + p.err;
429429
if str::len(comb) > 1u {
430430
error!("comb comb comb: %?", comb);
431431
}
@@ -461,35 +461,33 @@ pub fn check_running(exe_filename: &Path) -> happiness {
461461
}
462462

463463
pub fn check_compiling(filename: &Path) -> happiness {
464-
let p = run::process_output(
465-
"/Users/jruderman/code/rust/build/x86_64-apple-darwin/stage1/bin/rustc",
464+
let p = run::program_output(
465+
"/Users/jruderman/code/rust/build/x86_64-apple-darwin/\
466+
stage1/bin/rustc",
466467
[filename.to_str()]);
467468

468-
let out = str::from_bytes(p.output);
469-
let err = str::from_bytes(p.error);
470-
471469
//error!("Status: %d", p.status);
472470
if p.status == 0 {
473471
passed
474-
} else if !err.is_empty() {
475-
if err.contains("error:") {
472+
} else if p.err != ~"" {
473+
if contains(p.err, "error:") {
476474
cleanly_rejected(~"rejected with span_error")
477475
} else {
478-
error!("Stderr: %?", err);
476+
error!("Stderr: %?", p.err);
479477
failed(~"Unfamiliar error message")
480478
}
481-
} else if out.contains("Assertion") && out.contains("failed") {
482-
error!("Stdout: %?", out);
479+
} else if contains(p.out, "Assertion") && contains(p.out, "failed") {
480+
error!("Stdout: %?", p.out);
483481
failed(~"Looks like an llvm assertion failure")
484-
} else if out.contains("internal compiler error unimplemented") {
482+
} else if contains(p.out, "internal compiler error unimplemented") {
485483
known_bug(~"Something unimplemented")
486-
} else if out.contains("internal compiler error") {
487-
error!("Stdout: %?", out);
484+
} else if contains(p.out, "internal compiler error") {
485+
error!("Stdout: %?", p.out);
488486
failed(~"internal compiler error")
489487

490488
} else {
491489
error!("%?", p.status);
492-
error!("!Stdout: %?", out);
490+
error!("!Stdout: %?", p.out);
493491
failed(~"What happened?")
494492
}
495493
}
@@ -610,7 +608,9 @@ pub fn check_roundtrip_convergence(code: @~str, maxIters: uint) {
610608
error!("Did not converge after %u iterations!", i);
611609
write_file(&Path("round-trip-a.rs"), *oldv);
612610
write_file(&Path("round-trip-b.rs"), *newv);
613-
run::process_status("diff", [~"-w", ~"-u", ~"round-trip-a.rs", ~"round-trip-b.rs"]);
611+
run::run_program("diff",
612+
[~"-w", ~"-u", ~"round-trip-a.rs",
613+
~"round-trip-b.rs"]);
614614
fail!("Mismatch");
615615
}
616616
}

branches/try2/src/librust/rust.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ fn cmd_test(args: &[~str]) -> ValidUsage {
163163
let test_exec = Path(filename).filestem().unwrap() + "test~";
164164
invoke("rustc", &[~"--test", filename.to_owned(),
165165
~"-o", test_exec.to_owned()], rustc::main);
166-
let exit_code = run::process_status(~"./" + test_exec, []);
166+
let exit_code = run::run_program(~"./" + test_exec, []);
167167
Valid(exit_code)
168168
}
169169
_ => Invalid
@@ -176,7 +176,7 @@ fn cmd_run(args: &[~str]) -> ValidUsage {
176176
let exec = Path(filename).filestem().unwrap() + "~";
177177
invoke("rustc", &[filename.to_owned(), ~"-o", exec.to_owned()],
178178
rustc::main);
179-
let exit_code = run::process_status(~"./"+exec, prog_args);
179+
let exit_code = run::run_program(~"./"+exec, prog_args);
180180
Valid(exit_code)
181181
}
182182
_ => Invalid

branches/try2/src/librustc/back/link.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -403,14 +403,14 @@ pub mod write {
403403
cc_args.push(object.to_str());
404404
cc_args.push(assembly.to_str());
405405

406-
let prog = run::process_output(cc_prog, cc_args);
406+
let prog = run::program_output(cc_prog, cc_args);
407407

408408
if prog.status != 0 {
409409
sess.err(fmt!("building with `%s` failed with code %d",
410410
cc_prog, prog.status));
411411
sess.note(fmt!("%s arguments: %s",
412412
cc_prog, str::connect(cc_args, " ")));
413-
sess.note(str::from_bytes(prog.error + prog.output));
413+
sess.note(prog.err + prog.out);
414414
sess.abort_if_errors();
415415
}
416416
}
@@ -817,19 +817,19 @@ pub fn link_binary(sess: Session,
817817
let cc_args = link_args(sess, obj_filename, out_filename, lm);
818818
debug!("%s link args: %s", cc_prog, str::connect(cc_args, " "));
819819
// We run 'cc' here
820-
let prog = run::process_output(cc_prog, cc_args);
820+
let prog = run::program_output(cc_prog, cc_args);
821821
if 0 != prog.status {
822822
sess.err(fmt!("linking with `%s` failed with code %d",
823823
cc_prog, prog.status));
824824
sess.note(fmt!("%s arguments: %s",
825825
cc_prog, str::connect(cc_args, " ")));
826-
sess.note(str::from_bytes(prog.error + prog.output));
826+
sess.note(prog.err + prog.out);
827827
sess.abort_if_errors();
828828
}
829829

830830
// Clean up on Darwin
831831
if sess.targ_cfg.os == session::os_macos {
832-
run::process_status("dsymutil", [output.to_str()]);
832+
run::run_program("dsymutil", [output.to_str()]);
833833
}
834834

835835
// Remove the temporary object file if we aren't saving temps

branches/try2/src/librustc/driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ pub fn optgroups() -> ~[getopts::groups::OptGroup] {
811811
for detail)", "FEATURE"),
812812
optopt("", "android-cross-path",
813813
"The path to the Android NDK", "PATH"),
814-
optflagopt("W", "warn",
814+
optmulti("W", "warn",
815815
"Set lint warnings", "OPT"),
816816
optmulti("A", "allow",
817817
"Set lint allowed", "OPT"),

branches/try2/src/librustc/metadata/encoder.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,10 +1470,19 @@ pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] {
14701470
// remaining % 4 bytes.
14711471
wr.write(&[0u8, 0u8, 0u8, 0u8]);
14721472

1473+
// FIXME #3396: weird bug here, for reasons unclear this emits random
1474+
// looking bytes (mostly 0x1) if we use the version byte-array constant
1475+
// above; so we use a string constant inline instead.
1476+
//
1477+
// Should be:
1478+
//
1479+
// vec::to_owned(metadata_encoding_version) +
1480+
14731481
let writer_bytes: &mut ~[u8] = wr.bytes;
14741482

1475-
vec::to_owned(metadata_encoding_version) +
1476-
flate::deflate_bytes(*writer_bytes)
1483+
(do str::as_bytes(&~"rust\x00\x00\x00\x01") |bytes| {
1484+
vec::slice(*bytes, 0, 8).to_vec()
1485+
}) + flate::deflate_bytes(*writer_bytes)
14771486
}
14781487

14791488
// Get the encoded string for a type

branches/try2/src/librustc/middle/lint.rs

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -892,14 +892,9 @@ fn lint_session(cx: @mut Context) -> visit::vt<()> {
892892
}
893893

894894
fn lint_unnecessary_allocations(cx: @mut Context) -> visit::vt<()> {
895-
// If the expression `e` has an allocated type, but `t` dictates that it's
896-
// something like a slice (doesn't need allocation), emit a warning with the
897-
// specified span.
898-
//
899-
// Currently, this only applies to string and vector literals with sigils in
900-
// front. Those can have the sigil removed to get a borrowed pointer
901-
// automatically.
902-
fn check(cx: @mut Context, e: @ast::expr, t: ty::t) {
895+
// Warn if string and vector literals with sigils are immediately borrowed.
896+
// Those can have the sigil removed.
897+
fn check(cx: @mut Context, e: @ast::expr) {
903898
match e.node {
904899
ast::expr_vstore(e2, ast::expr_vstore_uniq) |
905900
ast::expr_vstore(e2, ast::expr_vstore_box) => {
@@ -914,9 +909,9 @@ fn lint_unnecessary_allocations(cx: @mut Context) -> visit::vt<()> {
914909
_ => return
915910
}
916911

917-
match ty::get(t).sty {
918-
ty::ty_estr(ty::vstore_slice(*)) |
919-
ty::ty_evec(_, ty::vstore_slice(*)) => {
912+
match cx.tcx.adjustments.find_copy(&e.id) {
913+
Some(@ty::AutoDerefRef(ty::AutoDerefRef {
914+
autoref: Some(ty::AutoBorrowVec(*)), _ })) => {
920915
cx.span_lint(unnecessary_allocation,
921916
e.span, "unnecessary allocation, the sigil can be \
922917
removed");
@@ -927,23 +922,7 @@ fn lint_unnecessary_allocations(cx: @mut Context) -> visit::vt<()> {
927922
}
928923

929924
let visit_expr: @fn(@ast::expr) = |e| {
930-
match e.node {
931-
ast::expr_call(c, ref args, _) => {
932-
let t = ty::node_id_to_type(cx.tcx, c.id);
933-
let s = ty::ty_fn_sig(t);
934-
for vec::each2(*args, s.inputs) |e, t| {
935-
check(cx, *e, *t);
936-
}
937-
}
938-
ast::expr_method_call(_, _, _, ref args, _) => {
939-
let t = ty::node_id_to_type(cx.tcx, e.callee_id);
940-
let s = ty::ty_fn_sig(t);
941-
for vec::each2(*args, s.inputs) |e, t| {
942-
check(cx, *e, *t);
943-
}
944-
}
945-
_ => {}
946-
}
925+
check(cx, e);
947926
};
948927

949928
visit::mk_simple_visitor(@visit::SimpleVisitor {

0 commit comments

Comments
 (0)