Skip to content

Commit 97253fa

Browse files
committed
---
yaml --- r: 77239 b: refs/heads/snap-stage3 c: cd92d2c h: refs/heads/master i: 77237: fb8f0e5 77235: 7d3bc73 77231: 7639347 v: v3
1 parent 2cf8c09 commit 97253fa

File tree

11 files changed

+90
-168
lines changed

11 files changed

+90
-168
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: f1132496dddbdd88f321a7919eec3d65136b3f75
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 3e4e1a274a7b3bf760c7a09d1a004728c8590362
4+
refs/heads/snap-stage3: cd92d2c77fe420568045bdc41b4acc4265408eb7
55
refs/heads/try: ebfe63cd1c0b5d23f7ea60c69b4fde2e30cfd42a
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libextra/sync.rs

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,7 @@ impl<Q:Send> Sem<Q> {
135135
do task::unkillable {
136136
do (|| {
137137
self.acquire();
138-
unsafe {
139-
do task::rekillable { blk() }
140-
}
138+
do task::rekillable { blk() }
141139
}).finally {
142140
self.release();
143141
}
@@ -234,10 +232,8 @@ impl<'self> Condvar<'self> {
234232
// signaller already sent -- I mean 'unconditionally' in contrast
235233
// with acquire().)
236234
do (|| {
237-
unsafe {
238-
do task::rekillable {
239-
let _ = WaitEnd.take_unwrap().recv();
240-
}
235+
do task::rekillable {
236+
let _ = WaitEnd.take_unwrap().recv();
241237
}
242238
}).finally {
243239
// Reacquire the condvar. Note this is back in the unkillable
@@ -516,14 +512,12 @@ impl RWLock {
516512
* 'write' from other tasks will run concurrently with this one.
517513
*/
518514
pub fn write<U>(&self, blk: &fn() -> U) -> U {
519-
unsafe {
520-
do task::unkillable {
521-
(&self.order_lock).acquire();
522-
do (&self.access_lock).access {
523-
(&self.order_lock).release();
524-
do task::rekillable {
525-
blk()
526-
}
515+
do task::unkillable {
516+
(&self.order_lock).acquire();
517+
do (&self.access_lock).access {
518+
(&self.order_lock).release();
519+
do task::rekillable {
520+
blk()
527521
}
528522
}
529523
}
@@ -562,16 +556,14 @@ impl RWLock {
562556
// which can't happen until T2 finishes the downgrade-read entirely.
563557
// The astute reader will also note that making waking writers use the
564558
// order_lock is better for not starving readers.
565-
unsafe {
566-
do task::unkillable {
567-
(&self.order_lock).acquire();
568-
do (&self.access_lock).access_cond |cond| {
569-
(&self.order_lock).release();
570-
do task::rekillable {
571-
let opt_lock = Just(&self.order_lock);
572-
blk(&Condvar { sem: cond.sem, order: opt_lock,
573-
token: NonCopyable::new() })
574-
}
559+
do task::unkillable {
560+
(&self.order_lock).acquire();
561+
do (&self.access_lock).access_cond |cond| {
562+
(&self.order_lock).release();
563+
do task::rekillable {
564+
let opt_lock = Just(&self.order_lock);
565+
blk(&Condvar { sem: cond.sem, order: opt_lock,
566+
token: NonCopyable::new() })
575567
}
576568
}
577569
}
@@ -606,10 +598,8 @@ impl RWLock {
606598
(&self.access_lock).acquire();
607599
(&self.order_lock).release();
608600
do (|| {
609-
unsafe {
610-
do task::rekillable {
611-
blk(RWLockWriteMode { lock: self, token: NonCopyable::new() })
612-
}
601+
do task::rekillable {
602+
blk(RWLockWriteMode { lock: self, token: NonCopyable::new() })
613603
}
614604
}).finally {
615605
let writer_or_last_reader;

branches/snap-stage3/src/librustc/metadata/filesearch.rs

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@ use std::option;
1313
use std::os;
1414
use std::hashmap::HashSet;
1515

16-
pub enum FileMatch { FileMatches, FileDoesntMatch }
17-
1816
// A module for searching for libraries
1917
// FIXME (#2658): I'm not happy how this module turned out. Should
2018
// probably just be folded into cstore.
2119

2220
/// Functions with type `pick` take a parent directory as well as
2321
/// a file found in that directory.
24-
pub type pick<'self> = &'self fn(path: &Path) -> FileMatch;
22+
pub type pick<'self, T> = &'self fn(path: &Path) -> Option<T>;
2523

2624
pub fn pick_file(file: Path, path: &Path) -> Option<Path> {
2725
if path.file_path() == file {
@@ -33,7 +31,7 @@ pub fn pick_file(file: Path, path: &Path) -> Option<Path> {
3331

3432
pub trait FileSearch {
3533
fn sysroot(&self) -> @Path;
36-
fn for_each_lib_search_path(&self, f: &fn(&Path) -> FileMatch);
34+
fn for_each_lib_search_path(&self, f: &fn(&Path) -> bool) -> bool;
3735
fn get_target_lib_path(&self) -> Path;
3836
fn get_target_lib_file_path(&self, file: &Path) -> Path;
3937
}
@@ -49,51 +47,34 @@ pub fn mk_filesearch(maybe_sysroot: &Option<@Path>,
4947
}
5048
impl FileSearch for FileSearchImpl {
5149
fn sysroot(&self) -> @Path { self.sysroot }
52-
fn for_each_lib_search_path(&self, f: &fn(&Path) -> FileMatch) {
50+
fn for_each_lib_search_path(&self, f: &fn(&Path) -> bool) -> bool {
5351
let mut visited_dirs = HashSet::new();
54-
let mut found = false;
5552

5653
debug!("filesearch: searching additional lib search paths [%?]",
5754
self.addl_lib_search_paths.len());
5855
for path in self.addl_lib_search_paths.iter() {
59-
match f(path) {
60-
FileMatches => found = true,
61-
FileDoesntMatch => ()
62-
}
56+
f(path);
6357
visited_dirs.insert(path.to_str());
6458
}
6559

6660
debug!("filesearch: searching target lib path");
6761
let tlib_path = make_target_lib_path(self.sysroot,
6862
self.target_triple);
6963
if !visited_dirs.contains(&tlib_path.to_str()) {
70-
match f(&tlib_path) {
71-
FileMatches => found = true,
72-
FileDoesntMatch => ()
64+
if !f(&tlib_path) {
65+
return false;
7366
}
7467
}
7568
visited_dirs.insert(tlib_path.to_str());
7669
// Try RUST_PATH
77-
if !found {
78-
let rustpath = rust_path();
79-
for path in rustpath.iter() {
80-
debug!("is %s in visited_dirs? %?",
81-
path.push("lib").to_str(),
82-
visited_dirs.contains(&path.push("lib").to_str()));
83-
70+
let rustpath = rust_path();
71+
for path in rustpath.iter() {
8472
if !visited_dirs.contains(&path.push("lib").to_str()) {
73+
f(&path.push("lib"));
8574
visited_dirs.insert(path.push("lib").to_str());
86-
// Don't keep searching the RUST_PATH if one match turns up --
87-
// if we did, we'd get a "multiple matching crates" error
88-
match f(&path.push("lib")) {
89-
FileMatches => {
90-
break;
91-
}
92-
FileDoesntMatch => ()
93-
}
9475
}
95-
}
9676
}
77+
true
9778
}
9879
fn get_target_lib_path(&self) -> Path {
9980
make_target_lib_path(self.sysroot, self.target_triple)
@@ -112,26 +93,28 @@ pub fn mk_filesearch(maybe_sysroot: &Option<@Path>,
11293
} as @FileSearch
11394
}
11495

115-
pub fn search(filesearch: @FileSearch, pick: pick) {
96+
pub fn search<T>(filesearch: @FileSearch, pick: pick<T>) -> Option<T> {
97+
let mut rslt = None;
11698
do filesearch.for_each_lib_search_path() |lib_search_path| {
11799
debug!("searching %s", lib_search_path.to_str());
118100
let r = os::list_dir_path(lib_search_path);
119-
let mut rslt = FileDoesntMatch;
120101
for path in r.iter() {
121102
debug!("testing %s", path.to_str());
122103
let maybe_picked = pick(path);
123104
match maybe_picked {
124-
FileMatches => {
105+
Some(_) => {
125106
debug!("picked %s", path.to_str());
126-
rslt = FileMatches;
107+
rslt = maybe_picked;
108+
break;
127109
}
128-
FileDoesntMatch => {
110+
None => {
129111
debug!("rejected %s", path.to_str());
130112
}
131113
}
132114
}
133-
rslt
115+
rslt.is_none()
134116
};
117+
return rslt;
135118
}
136119

137120
pub fn relative_target_lib_path(target_triple: &str) -> Path {

branches/snap-stage3/src/librustc/metadata/loader.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use lib::llvm::{False, llvm, mk_object_file, mk_section_iter};
1515
use metadata::decoder;
1616
use metadata::encoder;
17-
use metadata::filesearch::{FileSearch, FileMatch, FileMatches, FileDoesntMatch};
17+
use metadata::filesearch::FileSearch;
1818
use metadata::filesearch;
1919
use syntax::codemap::span;
2020
use syntax::diagnostic::span_handler;
@@ -92,10 +92,10 @@ fn find_library_crate_aux(
9292
// want: crate_name.dir_part() + prefix + crate_name.file_part + "-"
9393
let prefix = fmt!("%s%s-", prefix, crate_name);
9494
let mut matches = ~[];
95-
filesearch::search(filesearch, |path| -> FileMatch {
95+
filesearch::search(filesearch, |path| -> Option<()> {
9696
let path_str = path.filename();
9797
match path_str {
98-
None => FileDoesntMatch,
98+
None => None,
9999
Some(path_str) =>
100100
if path_str.starts_with(prefix) && path_str.ends_with(suffix) {
101101
debug!("%s is a candidate", path.to_str());
@@ -104,20 +104,20 @@ fn find_library_crate_aux(
104104
if !crate_matches(cvec, cx.metas, cx.hash) {
105105
debug!("skipping %s, metadata doesn't match",
106106
path.to_str());
107-
FileDoesntMatch
107+
None
108108
} else {
109109
debug!("found %s with matching metadata", path.to_str());
110110
matches.push((path.to_str(), cvec));
111-
FileMatches
111+
None
112112
},
113113
_ => {
114114
debug!("could not load metadata for %s", path.to_str());
115-
FileDoesntMatch
115+
None
116116
}
117117
}
118118
}
119119
else {
120-
FileDoesntMatch
120+
None
121121
}
122122
}
123123
});

branches/snap-stage3/src/librustpkg/path_util.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ pub fn make_dir_rwx(p: &Path) -> bool { os::make_dir(p, U_RWX) }
4949
/// True if there's a directory in <workspace> with
5050
/// pkgid's short name
5151
pub fn workspace_contains_package_id(pkgid: &PkgId, workspace: &Path) -> bool {
52-
debug!("Checking in src dir of %s for %s",
53-
workspace.to_str(), pkgid.to_str());
54-
5552
let src_dir = workspace.push("src");
5653

5754
let mut found = false;
@@ -84,9 +81,6 @@ pub fn workspace_contains_package_id(pkgid: &PkgId, workspace: &Path) -> bool {
8481
}
8582
true
8683
};
87-
88-
debug!(if found { fmt!("Found %s in %s", pkgid.to_str(), workspace.to_str()) }
89-
else { fmt!("Didn't find %s in %s", pkgid.to_str(), workspace.to_str()) });
9084
found
9185
}
9286

branches/snap-stage3/src/librustpkg/rustpkg.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,6 @@ impl CtxMethods for Ctx {
250250
// argument
251251
let pkgid = PkgId::new(args[0]);
252252
let workspaces = pkg_parent_workspaces(&pkgid);
253-
debug!("package ID = %s, found it in %? workspaces",
254-
pkgid.to_str(), workspaces.len());
255253
if workspaces.is_empty() {
256254
let rp = rust_path();
257255
assert!(!rp.is_empty());

branches/snap-stage3/src/librustpkg/search.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use path_util::{installed_library_in_workspace, rust_path};
12-
use version::Version;
11+
use path_util::installed_library_in_workspace;
1312

1413
/// If a library with path `p` matching pkg_id's name exists under sroot_opt,
1514
/// return Some(p). Return None if there's no such path or if sroot_opt is None.
@@ -20,18 +19,3 @@ pub fn find_library_in_search_path(sroot_opt: Option<@Path>, short_name: &str) -
2019
installed_library_in_workspace(short_name, sroot)
2120
}
2221
}
23-
24-
/// If some workspace `p` in the RUST_PATH contains a package matching short_name,
25-
/// return Some(p) (returns the first one of there are multiple matches.) Return
26-
/// None if there's no such path.
27-
/// FIXME #8711: This ignores the desired version.
28-
pub fn find_installed_library_in_rust_path(short_name: &str, _version: &Version) -> Option<Path> {
29-
let rp = rust_path();
30-
for p in rp.iter() {
31-
match installed_library_in_workspace(short_name, p) {
32-
Some(path) => return Some(path),
33-
None => ()
34-
}
35-
}
36-
None
37-
}

branches/snap-stage3/src/librustpkg/tests.rs

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ fn package_script_with_default_build() {
686686
push("testsuite").push("pass").push("src").push("fancy-lib").push("pkg.rs");
687687
debug!("package_script_with_default_build: %s", source.to_str());
688688
if !os::copy_file(&source,
689-
&dir.push("src").push("fancy-lib-0.1").push("pkg.rs")) {
689+
& dir.push("src").push("fancy-lib-0.1").push("pkg.rs")) {
690690
fail!("Couldn't copy file");
691691
}
692692
command_line_test([~"install", ~"fancy-lib"], &dir);
@@ -890,28 +890,20 @@ fn no_rebuilding_dep() {
890890
assert!(bar_date < foo_date);
891891
}
892892
893-
// n.b. The following two tests are ignored; they worked "accidentally" before,
894-
// when the behavior was "always rebuild libraries" (now it's "never rebuild
895-
// libraries if they already exist"). They can be un-ignored once #7075 is done.
896893
#[test]
897-
#[ignore(reason = "Workcache not yet implemented -- see #7075")]
898894
fn do_rebuild_dep_dates_change() {
899895
let p_id = PkgId::new("foo");
900896
let dep_id = PkgId::new("bar");
901897
let workspace = create_local_package_with_dep(&p_id, &dep_id);
902898
command_line_test([~"build", ~"foo"], &workspace);
903-
let bar_lib_name = lib_output_file_name(&workspace, "build", "bar");
904-
let bar_date = datestamp(&bar_lib_name);
905-
debug!("Datestamp on %s is %?", bar_lib_name.to_str(), bar_date);
899+
let bar_date = datestamp(&lib_output_file_name(&workspace, "build", "bar"));
906900
touch_source_file(&workspace, &dep_id);
907901
command_line_test([~"build", ~"foo"], &workspace);
908-
let new_bar_date = datestamp(&bar_lib_name);
909-
debug!("Datestamp on %s is %?", bar_lib_name.to_str(), new_bar_date);
902+
let new_bar_date = datestamp(&lib_output_file_name(&workspace, "build", "bar"));
910903
assert!(new_bar_date > bar_date);
911904
}
912905
913906
#[test]
914-
#[ignore(reason = "Workcache not yet implemented -- see #7075")]
915907
fn do_rebuild_dep_only_contents_change() {
916908
let p_id = PkgId::new("foo");
917909
let dep_id = PkgId::new("bar");
@@ -1068,23 +1060,6 @@ fn test_macro_pkg_script() {
10681060
os::EXE_SUFFIX))));
10691061
}
10701062

1071-
#[test]
1072-
fn multiple_workspaces() {
1073-
// Make a package foo; build/install in directory A
1074-
// Copy the exact same package into directory B and install it
1075-
// Set the RUST_PATH to A:B
1076-
// Make a third package that uses foo, make sure we can build/install it
1077-
let a_loc = mk_temp_workspace(&Path("foo"), &NoVersion).pop().pop();
1078-
let b_loc = mk_temp_workspace(&Path("foo"), &NoVersion).pop().pop();
1079-
debug!("Trying to install foo in %s", a_loc.to_str());
1080-
command_line_test([~"install", ~"foo"], &a_loc);
1081-
debug!("Trying to install foo in %s", b_loc.to_str());
1082-
command_line_test([~"install", ~"foo"], &b_loc);
1083-
let env = Some(~[(~"RUST_PATH", fmt!("%s:%s", a_loc.to_str(), b_loc.to_str()))]);
1084-
let c_loc = create_local_package_with_dep(&PkgId::new("bar"), &PkgId::new("foo"));
1085-
command_line_test_with_env([~"install", ~"bar"], &c_loc, env);
1086-
}
1087-
10881063
/// Returns true if p exists and is executable
10891064
fn is_executable(p: &Path) -> bool {
10901065
use std::libc::consts::os::posix88::{S_IXUSR};

0 commit comments

Comments
 (0)