Skip to content

Commit 2ea9d3e

Browse files
committed
---
yaml --- r: 145019 b: refs/heads/try2 c: 05bbb48 h: refs/heads/master i: 145017: 6ed55a7 145015: b4a0a8b v: v3
1 parent 490e3f0 commit 2ea9d3e

File tree

17 files changed

+372
-255
lines changed

17 files changed

+372
-255
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: a7215dd284a1d2e15ecbe0c71b7c978fcba5e3ec
8+
refs/heads/try2: 05bbb480a22d1f752f95591b41b584018966b136
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/mk/rt.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ RUNTIME_CXXS_$(1)_$(2) := \
7575
rt/rust_rng.cpp \
7676
rt/rust_upcall.cpp \
7777
rt/rust_uv.cpp \
78-
rt/rust_crate_map.cpp \
7978
rt/isaac/randport.cpp \
8079
rt/miniz.cpp \
8180
rt/memory_region.cpp \

branches/try2/src/libextra/fileinput.rs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -417,20 +417,23 @@ mod test {
417417

418418
use super::{FileInput, make_path_option_vec, input_vec, input_vec_state};
419419

420-
use std::io;
420+
use std::rt::io;
421+
use std::rt::io::Writer;
422+
use std::rt::io::file;
421423
use std::uint;
422424
use std::vec;
423425

424426
fn make_file(path : &Path, contents: &[~str]) {
425-
let file = io::file_writer(path, [io::Create, io::Truncate]).unwrap();
427+
let mut file = file::open(path, io::CreateOrTruncate, io::Write).unwrap();
426428

427429
for str in contents.iter() {
428-
file.write_str(*str);
429-
file.write_char('\n');
430+
file.write(str.as_bytes());
431+
file.write(['\n' as u8]);
430432
}
431433
}
432434

433435
#[test]
436+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
434437
fn test_make_path_option_vec() {
435438
let strs = [~"some/path",
436439
~"some/other/path"];
@@ -445,6 +448,7 @@ mod test {
445448
}
446449
447450
#[test]
451+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
448452
fn test_fileinput_read_byte() {
449453
let filenames = make_path_option_vec(vec::from_fn(
450454
3,
@@ -475,6 +479,7 @@ mod test {
475479
}
476480
477481
#[test]
482+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
478483
fn test_fileinput_read() {
479484
let filenames = make_path_option_vec(vec::from_fn(
480485
3,
@@ -495,6 +500,7 @@ mod test {
495500
}
496501

497502
#[test]
503+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
498504
fn test_input_vec() {
499505
let mut all_lines = ~[];
500506
let filenames = make_path_option_vec(vec::from_fn(
@@ -518,6 +524,7 @@ mod test {
518524
}
519525

520526
#[test]
527+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
521528
fn test_input_vec_state() {
522529
let filenames = make_path_option_vec(vec::from_fn(
523530
3,
@@ -540,6 +547,7 @@ mod test {
540547
}
541548

542549
#[test]
550+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
543551
fn test_empty_files() {
544552
let filenames = make_path_option_vec(vec::from_fn(
545553
3,
@@ -564,18 +572,21 @@ mod test {
564572
}
565573
566574
#[test]
575+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
567576
fn test_no_trailing_newline() {
568577
let f1 =
569578
Some(Path("tmp/lib-fileinput-test-no-trailing-newline-1.tmp"));
570579
let f2 =
571580
Some(Path("tmp/lib-fileinput-test-no-trailing-newline-2.tmp"));
572581
573-
let wr = io::file_writer(f1.get_ref(),
574-
[io::Create, io::Truncate]).unwrap();
575-
wr.write_str("1\n2");
576-
let wr = io::file_writer(f2.get_ref(),
577-
[io::Create, io::Truncate]).unwrap();
578-
wr.write_str("3\n4");
582+
{
583+
let mut wr = file::open(f1.get_ref(), io::CreateOrTruncate,
584+
io::Write).unwrap();
585+
wr.write("1\n2".as_bytes());
586+
let mut wr = file::open(f2.get_ref(), io::CreateOrTruncate,
587+
io::Write).unwrap();
588+
wr.write("3\n4".as_bytes());
589+
}
579590
580591
let mut lines = ~[];
581592
do input_vec(~[f1, f2]) |line| {
@@ -587,6 +598,7 @@ mod test {
587598
588599
589600
#[test]
601+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
590602
fn test_next_file() {
591603
let filenames = make_path_option_vec(vec::from_fn(
592604
3,
@@ -618,6 +630,7 @@ mod test {
618630
619631
#[test]
620632
#[should_fail]
633+
#[ignore(cfg(windows))] // FIXME(#8810): rt::io::file and windows don't agree
621634
fn test_input_vec_missing_file() {
622635
do input_vec(make_path_option_vec([~"this/file/doesnt/exist"], true)) |line| {
623636
println(line);

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ fn stack_check_item(v: StackCheckVisitor,
8080
visit::walk_method_helper(&mut v, method, new_cx);
8181
}
8282
}
83+
ast::item_trait(_, _, ref methods) => {
84+
for method in methods.iter() {
85+
match *method {
86+
ast::provided(@ref method) => {
87+
let safe_stack = fixed_stack_segment(method.attrs);
88+
let new_cx = Context {safe_stack: safe_stack, ..in_cx};
89+
visit::walk_method_helper(&mut v, method, new_cx);
90+
}
91+
ast::required(*) => ()
92+
}
93+
}
94+
}
8395
_ => {
8496
visit::walk_item(&mut v, item, in_cx);
8597
}

branches/try2/src/librustpkg/package_source.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use context::*;
1818
use crate::Crate;
1919
use messages::*;
2020
use source_control::{git_clone, git_clone_general};
21-
use path_util::{find_dir_using_rust_path_hack, default_workspace};
21+
use path_util::{find_dir_using_rust_path_hack, default_workspace, make_dir_rwx_recursive};
2222
use util::compile_crate;
2323
use workspace::is_workspace;
2424
use workcache_support;
@@ -197,12 +197,14 @@ impl PkgSrc {
197197
url, clone_target.to_str(), pkgid.version.to_str());
198198

199199
if git_clone_general(url, &clone_target, &pkgid.version) {
200-
// since the operation succeeded, move clone_target to local
201-
if !os::rename_file(&clone_target, local) {
202-
None
200+
// Since the operation succeeded, move clone_target to local.
201+
// First, create all ancestor directories.
202+
if make_dir_rwx_recursive(&local.pop())
203+
&& os::rename_file(&clone_target, local) {
204+
Some(local.clone())
203205
}
204206
else {
205-
Some(local.clone())
207+
None
206208
}
207209
}
208210
else {

branches/try2/src/librustpkg/path_util.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ pub static U_RWX: i32 = (S_IRUSR | S_IWUSR | S_IXUSR) as i32;
4343
/// succeeded.
4444
pub fn make_dir_rwx(p: &Path) -> bool { os::make_dir(p, U_RWX) }
4545

46+
pub fn make_dir_rwx_recursive(p: &Path) -> bool { os::mkdir_recursive(p, U_RWX) }
47+
4648
// n.b. The next three functions ignore the package version right
4749
// now. Should fix that.
4850

@@ -399,3 +401,12 @@ pub fn find_dir_using_rust_path_hack(p: &PkgId) -> Option<Path> {
399401
}
400402
None
401403
}
404+
405+
/// True if the user set RUST_PATH to something non-empty --
406+
/// as opposed to the default paths that rustpkg adds automatically
407+
pub fn user_set_rust_path() -> bool {
408+
match os::getenv("RUST_PATH") {
409+
None | Some(~"") => false,
410+
Some(_) => true
411+
}
412+
}

branches/try2/src/librustpkg/rustpkg.rs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,10 @@ pub trait CtxMethods {
181181
/// second is a list of declared and discovered inputs
182182
fn install(&self, src: PkgSrc) -> (~[Path], ~[(~str, ~str)]);
183183
/// Returns a list of installed files
184-
fn install_no_build(&self, workspace: &Path, id: &PkgId) -> ~[Path];
184+
fn install_no_build(&self,
185+
source_workspace: &Path,
186+
target_workspace: &Path,
187+
id: &PkgId) -> ~[Path];
185188
fn prefer(&self, _id: &str, _vers: Option<~str>);
186189
fn test(&self);
187190
fn uninstall(&self, _id: &str, _vers: Option<~str>);
@@ -464,28 +467,40 @@ impl CtxMethods for BuildContext {
464467
// install to the first workspace in the RUST_PATH if there's
465468
// a non-default RUST_PATH. This code installs to the same
466469
// workspace the package was built in.
467-
debug!("install: destination workspace = %s, id = %s",
468-
destination_workspace, id_str);
469-
let result = subself.install_no_build(&Path(destination_workspace), &sub_id);
470+
let actual_workspace = if path_util::user_set_rust_path() {
471+
default_workspace()
472+
}
473+
else {
474+
Path(destination_workspace)
475+
};
476+
debug!("install: destination workspace = %s, id = %s, installing to %s",
477+
destination_workspace, id_str, actual_workspace.to_str());
478+
let result = subself.install_no_build(&Path(destination_workspace),
479+
&actual_workspace,
480+
&sub_id);
470481
debug!("install: id = %s, about to call discover_outputs, %?",
471482
id_str, result.to_str());
472483

473484
discover_outputs(exec, result.clone());
474485
sub_files.write(|r| { *r = result.clone(); });
475486
sub_inputs.write(|r| { *r = *r + exec.lookup_discovered_inputs() });
487+
note(fmt!("Installed package %s to %s", id_str, actual_workspace.to_str()));
476488
}
477489
};
478490
(installed_files.unwrap(), inputs.unwrap())
479491
}
480492

481-
fn install_no_build(&self, workspace: &Path, id: &PkgId) -> ~[Path] {
493+
fn install_no_build(&self,
494+
source_workspace: &Path,
495+
target_workspace: &Path,
496+
id: &PkgId) -> ~[Path] {
482497
use conditions::copy_failed::cond;
483498

484499
// Now copy stuff into the install dirs
485-
let maybe_executable = built_executable_in_workspace(id, workspace);
486-
let maybe_library = built_library_in_workspace(id, workspace);
487-
let target_exec = target_executable_in_workspace(id, workspace);
488-
let target_lib = maybe_library.map(|_p| target_library_in_workspace(id, workspace));
500+
let maybe_executable = built_executable_in_workspace(id, source_workspace);
501+
let maybe_library = built_library_in_workspace(id, source_workspace);
502+
let target_exec = target_executable_in_workspace(id, target_workspace);
503+
let target_lib = maybe_library.map(|_p| target_library_in_workspace(id, target_workspace));
489504

490505
debug!("target_exec = %s target_lib = %? \
491506
maybe_executable = %? maybe_library = %?",

branches/try2/src/librustpkg/tests.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,25 @@ fn test_recursive_deps() {
16031603
assert_lib_exists(&b_workspace, &Path("c"), NoVersion);
16041604
}
16051605
1606+
#[test]
1607+
fn test_install_to_rust_path() {
1608+
let p_id = PkgId::new("foo");
1609+
let second_workspace = create_local_package(&p_id);
1610+
let first_workspace = mk_empty_workspace(&Path("p"), &NoVersion, "dest");
1611+
let rust_path = Some(~[(~"RUST_PATH",
1612+
fmt!("%s:%s", first_workspace.to_str(),
1613+
second_workspace.to_str()))]);
1614+
debug!("RUST_PATH=%s:%s", first_workspace.to_str(), second_workspace.to_str());
1615+
command_line_test_with_env([test_sysroot().to_str(),
1616+
~"install",
1617+
~"foo"],
1618+
&os::getcwd(), rust_path);
1619+
assert!(!built_executable_exists(&first_workspace, "foo"));
1620+
assert!(built_executable_exists(&second_workspace, "foo"));
1621+
assert_executable_exists(&first_workspace, "foo");
1622+
assert!(!executable_exists(&second_workspace, "foo"));
1623+
}
1624+
16061625
/// Returns true if p exists and is executable
16071626
fn is_executable(p: &Path) -> bool {
16081627
use std::libc::consts::os::posix88::{S_IXUSR};

branches/try2/src/libstd/hashmap.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,17 @@ impl<T:Hash + Eq> HashSet<T> {
687687
HashSet { map: HashMap::with_capacity(capacity) }
688688
}
689689

690+
/// Create an empty HashSet with space for at least `capacity`
691+
/// elements in the hash table, using `k0` and `k1` as the keys.
692+
///
693+
/// Warning: `k0` and `k1` are normally randomly generated, and
694+
/// are designed to allow HashSets to be resistant to attacks that
695+
/// cause many collisions and very poor performance. Setting them
696+
/// manually using this function can expose a DoS attack vector.
697+
pub fn with_capacity_and_keys(k0: u64, k1: u64, capacity: uint) -> HashSet<T> {
698+
HashSet { map: HashMap::with_capacity_and_keys(k0, k1, capacity) }
699+
}
700+
690701
/// Reserve space for at least `n` elements in the hash table.
691702
pub fn reserve_at_least(&mut self, n: uint) {
692703
self.map.reserve_at_least(n)

0 commit comments

Comments
 (0)