Skip to content

Commit 928a006

Browse files
committed
---
yaml --- r: 12284 b: refs/heads/master c: bef7244 h: refs/heads/master v: v3
1 parent fe84ec8 commit 928a006

Some content is hidden

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

69 files changed

+710
-477
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 704ca046a13977175975cb20a77ea2fbac15d77a
2+
refs/heads/master: bef72447e75b7e37f43d3a82ce40e419c7f747d2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/AUTHORS.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ Stefan Plantikow <[email protected]>
7171
Taras Shpot <[email protected]>
7272
Ted Horst <[email protected]>
7373
Tim Chevalier <[email protected]>
74-
7574
Tomoki Aonuma <[email protected]>
7675
Tycho Sci <[email protected]>
7776
Wade Mealing <[email protected]>

trunk/doc/tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ for the parameter list, as in `{|| ...}`.
919919
Partial application is done using the `bind` keyword in Rust.
920920

921921
~~~~
922-
let daynum = bind vec::position_elem(["mo", "tu", "we", "th",
922+
let daynum = bind vec::position_elem(["mo", "tu", "we", "do",
923923
"fr", "sa", "su"], _);
924924
~~~~
925925

@@ -1551,7 +1551,7 @@ programs that just can't be typed.
15511551

15521552
~~~~
15531553
let n = option::none;
1554-
# option::with_option_do(n, fn&(&&x:int) {})
1554+
# option::may(n, fn&(&&x:int) {})
15551555
~~~~
15561556

15571557
If you never do anything else with `n`, the compiler will not be able

trunk/mk/rt.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ RUNTIME_CS_$(1) := \
6464
rt/rust_port_selector.cpp \
6565
rt/circular_buffer.cpp \
6666
rt/isaac/randport.cpp \
67+
rt/rust_srv.cpp \
6768
rt/rust_kernel.cpp \
6869
rt/rust_shape.cpp \
6970
rt/rust_abi.cpp \

trunk/src/cargo/cargo.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -478,13 +478,14 @@ fn install_one_crate(c: cargo, path: str, cf: str) {
478478
(exec_suffix == "" && !str::starts_with(path::basename(ct),
479479
"lib")) {
480480
#debug(" bin: %s", ct);
481-
copy_warn(ct, c.bindir);
481+
// FIXME: need libstd os::copy or something (Issue #1983)
482+
run::run_program("cp", [ct, c.bindir]);
482483
if c.opts.mode == system_mode {
483484
install_one_crate_to_sysroot(ct, "bin");
484485
}
485486
} else {
486487
#debug(" lib: %s", ct);
487-
copy_warn(ct, c.bindir);
488+
run::run_program("cp", [ct, c.libdir]);
488489
if c.opts.mode == system_mode {
489490
install_one_crate_to_sysroot(ct, libdir());
490491
}
@@ -498,7 +499,10 @@ fn install_one_crate_to_sysroot(ct: str, target: str) {
498499
let path = [_path, "..", target];
499500
check vec::is_not_empty(path);
500501
let target_dir = path::normalize(path::connect_many(path));
501-
copy_warn(ct, target_dir);
502+
let p = run::program_output("cp", [ct, target_dir]);
503+
if p.status != 0 {
504+
warn(#fmt["Copying %s to %s is failed", ct, target_dir]);
505+
}
502506
}
503507
none { }
504508
}
@@ -768,7 +772,7 @@ fn sync_one(c: cargo, name: str, src: source) {
768772
info(#fmt["no signature for source %s", name]);
769773
}
770774
}
771-
copy_warn(pkgfile, destpkgfile);
775+
run::run_program("cp", [pkgfile, destpkgfile]);
772776
}
773777

774778
fn cmd_sync(c: cargo) {
@@ -808,7 +812,7 @@ fn cmd_init(c: cargo) {
808812
} else {
809813
info(#fmt["signature ok for sources.json"]);
810814
}
811-
copy_warn(srcfile, destsrcfile);
815+
run::run_program("cp", [srcfile, destsrcfile]);
812816

813817
info(#fmt["Initialized .cargo in %s", c.root]);
814818
}
@@ -849,12 +853,6 @@ fn cmd_search(c: cargo) {
849853
info(#fmt["Found %d packages.", n]);
850854
}
851855

852-
fn copy_warn(src: str, dest: str) {
853-
if !os::copy_file(src, dest) {
854-
warn(#fmt["Copying %s to %s failed", src, dest]);
855-
}
856-
}
857-
858856
fn cmd_usage() {
859857
print("Usage: cargo <verb> [options] [args...]" +
860858
"

trunk/src/compiletest/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn load_props(testfile: str) -> test_props {
4040
pp_exact = parse_pp_exact(ln, testfile);
4141
}
4242

43-
option::with_option_do(parse_aux_build(ln)) {|ab|
43+
option::may(parse_aux_build(ln)) {|ab|
4444
aux_builds += [ab];
4545
}
4646
};

trunk/src/etc/snapshot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def scrub(b):
3434
"lib/libcore-*.dylib",
3535
"lib/libstd-*.dylib",
3636
"lib/librustc-*.dylib",
37-
"lib/librustsyntax-*.dylib",
37+
"lib/librustsyntax-*.so",
3838
"lib/librustrt.dylib",
3939
"lib/librustllvm.dylib"],
4040
"winnt": ["bin/rustc.exe",

trunk/src/libcore/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl<A> of iterable<A> for [A] {
2929

3030
impl<A> of iterable<A> for option<A> {
3131
fn iter(blk: fn(A)) {
32-
option::with_option_do(self, blk)
32+
option::may(self, blk)
3333
}
3434
}
3535

trunk/src/libcore/libc.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,9 +1155,6 @@ mod funcs {
11551155
fn CreateDirectoryW(lpPathName: LPCWSTR,
11561156
lpSecurityAttributes:
11571157
LPSECURITY_ATTRIBUTES) -> BOOL;
1158-
fn CopyFileW(lpExistingFileName: LPCWSTR,
1159-
lpNewFileName: LPCWSTR,
1160-
bFailIfExists: BOOL) -> BOOL;
11611158
fn DeleteFileW(lpPathName: LPCWSTR) -> BOOL;
11621159
fn RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL;
11631160
fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL;

trunk/src/libcore/option.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,19 @@ pure fn is_some<T>(opt: option<T>) -> bool {
5252
!is_none(opt)
5353
}
5454

55-
pure fn get_or_default<T: copy>(opt: option<T>, def: T) -> T {
55+
pure fn from_maybe<T: copy>(opt: option<T>, def: T) -> T {
5656
#[doc = "Returns the contained value or a default"];
5757

5858
alt opt { some(x) { x } none { def } }
5959
}
6060

61-
fn with_option<T, U: copy>(opt: option<T>, def: U, f: fn(T) -> U) -> U {
61+
fn maybe<T, U: copy>(opt: option<T>, def: U, f: fn(T) -> U) -> U {
6262
#[doc = "Applies a function to the contained value or returns a default"];
6363

6464
alt opt { none { def } some(t) { f(t) } }
6565
}
6666

67-
fn with_option_do<T>(opt: option<T>, f: fn(T)) {
67+
fn may<T>(opt: option<T>, f: fn(T)) {
6868
#[doc = "Performs an operation on the contained value or does nothing"];
6969

7070
alt opt { none { } some(t) { f(t); } }
@@ -94,12 +94,11 @@ impl extensions<T:copy> for option<T> {
9494
"]
9595
fn chain<U>(f: fn(T) -> option<U>) -> option<U> { chain(self, f) }
9696
#[doc = "Returns the contained value or a default"]
97-
fn get_or_default(def: T) -> T { get_or_default(self, def) }
97+
fn from_maybe(def: T) -> T { from_maybe(self, def) }
9898
#[doc = "Applies a function to the contained value or returns a default"]
99-
fn with_option<U: copy>(def: U, f: fn(T) -> U) -> U
100-
{ with_option(self, def, f) }
99+
fn maybe<U: copy>(def: U, f: fn(T) -> U) -> U { maybe(self, def, f) }
101100
#[doc = "Performs an operation on the contained value or does nothing"]
102-
fn with_option_do(f: fn(T)) { with_option_do(self, f) }
101+
fn may(f: fn(T)) { may(self, f) }
103102
#[doc = "
104103
Gets the value out of an option
105104

trunk/src/libcore/os.rs

Lines changed: 4 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ export env, getenv, setenv, fdopen, pipe;
3030
export getcwd, dll_filename, self_exe_path;
3131
export exe_suffix, dll_suffix, sysname;
3232
export homedir, list_dir, list_dir_path, path_is_dir, path_exists,
33-
make_absolute, make_dir, remove_dir, change_dir, remove_file,
34-
copy_file;
33+
make_absolute, make_dir, remove_dir, change_dir, remove_file;
3534

3635
// FIXME: move these to str perhaps?
3736
export as_c_charp, fill_charp_buf;
@@ -535,76 +534,13 @@ fn change_dir(p: path) -> bool {
535534
}
536535
}
537536

538-
#[doc = "Copies a file from one location to another"]
539-
fn copy_file(from: path, to: path) -> bool {
540-
ret do_copy_file(from, to);
541-
542-
#[cfg(target_os = "win32")]
543-
fn do_copy_file(from: path, to: path) -> bool {
544-
// FIXME: remove imports when export globs work properly.
545-
import libc::funcs::extra::kernel32::*;
546-
import libc::types::os::arch::extra::*;
547-
import win32::*;
548-
ret as_utf16_p(from) {|fromp|
549-
as_utf16_p(to) {|top|
550-
CopyFileW(fromp, top, (0 as BOOL)) != (0 as BOOL)
551-
}
552-
}
553-
}
554-
555-
#[cfg(target_os = "linux")]
556-
#[cfg(target_os = "macos")]
557-
#[cfg(target_os = "freebsd")]
558-
fn do_copy_file(from: path, to: path) -> bool unsafe {
559-
let istream = as_c_charp(from) {|fromp|
560-
as_c_charp("rb") {|modebuf|
561-
libc::fopen(fromp, modebuf)
562-
}
563-
};
564-
if istream as uint == 0u {
565-
ret false;
566-
}
567-
let ostream = as_c_charp(to) {|top|
568-
as_c_charp("w+b") {|modebuf|
569-
libc::fopen(top, modebuf)
570-
}
571-
};
572-
if ostream as uint == 0u {
573-
fclose(istream);
574-
ret false;
575-
}
576-
let mut buf : [mut u8] = [mut];
577-
let bufsize = 8192u;
578-
vec::reserve(buf, bufsize);
579-
let mut done = false;
580-
let mut ok = true;
581-
while !done {
582-
vec::as_mut_buf(buf) {|b|
583-
let nread = libc::fread(b as *mut c_void, 1u, bufsize, istream);
584-
if nread > 0 as size_t {
585-
if libc::fwrite(b as *c_void, 1u, nread, ostream) != nread {
586-
ok = false;
587-
done = true;
588-
}
589-
} else {
590-
done = true;
591-
}
592-
}
593-
}
594-
fclose(istream);
595-
fclose(ostream);
596-
ret ok;
597-
}
598-
}
599-
600537
#[doc = "Deletes an existing file"]
601538
fn remove_file(p: path) -> bool {
602539
ret unlink(p);
603540

604541
#[cfg(target_os = "win32")]
605542
fn unlink(p: path) -> bool {
606543
// FIXME: remove imports when export globs work properly.
607-
// (similar to Issue #2006)
608544
import libc::funcs::extra::kernel32::*;
609545
import libc::types::os::arch::extra::*;
610546
import win32::*;
@@ -766,7 +702,7 @@ mod tests {
766702
setenv("HOME", "");
767703
assert os::homedir() == none;
768704

769-
option::with_option_do(oldhome, {|s| setenv("HOME", s)});
705+
option::may(oldhome, {|s| setenv("HOME", s)});
770706
}
771707

772708
#[test]
@@ -796,9 +732,8 @@ mod tests {
796732
setenv("USERPROFILE", "/home/PaloAlto");
797733
assert os::homedir() == some("/home/MountainView");
798734

799-
option::with_option_do(oldhome, {|s| setenv("HOME", s)});
800-
option::with_option_do(olduserprofile,
801-
{|s| setenv("USERPROFILE", s)});
735+
option::may(oldhome, {|s| setenv("HOME", s)});
736+
option::may(olduserprofile, {|s| setenv("USERPROFILE", s)});
802737
}
803738

804739
// Issue #712
@@ -826,42 +761,4 @@ mod tests {
826761
assert (!os::path_exists("test/nonexistent-bogus-path"));
827762
}
828763

829-
#[test]
830-
fn copy_file_does_not_exist() {
831-
assert !os::copy_file("test/nonexistent-bogus-path",
832-
"test/other-bogus-path");
833-
assert !os::path_exists("test/other-bogus-path");
834-
}
835-
836-
#[test]
837-
fn copy_file_ok() {
838-
let tempdir = getcwd(); // would like to use $TMPDIR,
839-
// doesn't seem to work on Linux
840-
assert (str::len(tempdir) > 0u);
841-
let in = tempdir + path::path_sep() + "in.txt";
842-
let out = tempdir + path::path_sep() + "out.txt";
843-
844-
/* Write the temp input file */
845-
let ostream = as_c_charp(in) {|fromp|
846-
as_c_charp("w+b") {|modebuf|
847-
libc::fopen(fromp, modebuf)
848-
}
849-
};
850-
assert (ostream as uint != 0u);
851-
let s = "hello";
852-
let mut buf = str::bytes(s) + [0 as u8];
853-
vec::as_mut_buf(buf) {|b|
854-
assert (libc::fwrite(b as *c_void, 1u, str::len(s) + 1u, ostream) ==
855-
buf.len())};
856-
assert (libc::fclose(ostream) == (0u as c_int));
857-
let rs = os::copy_file(in, out);
858-
if (!os::path_exists(in)) {
859-
fail (#fmt("%s doesn't exist", in));
860-
}
861-
assert(rs);
862-
let rslt = run::run_program("diff", [in, out]);
863-
assert (rslt == 0);
864-
assert (remove_file(in));
865-
assert (remove_file(out));
866-
}
867764
}

trunk/src/libcore/result.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ If the result is an error
2020
pure fn get<T: copy, U>(res: result<T, U>) -> T {
2121
alt res {
2222
ok(t) { t }
23-
err(the_err) {
24-
// FIXME: have a run-fail test for this
25-
unchecked{ fail #fmt("get called on error result: %?", the_err); }
23+
err(_) {
24+
// FIXME: Serialize the error value
25+
// and include it in the fail message (maybe just note it)
26+
fail "get called on error result";
2627
}
2728
}
2829
}

0 commit comments

Comments
 (0)