Skip to content

Commit c28a262

Browse files
committed
---
yaml --- r: 143922 b: refs/heads/try2 c: 0d817ee h: refs/heads/master v: v3
1 parent 1acacd8 commit c28a262

File tree

19 files changed

+571
-570
lines changed

19 files changed

+571
-570
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: 930885d5e5f817e3d7609f93d5ba89b1abebfaf4
8+
refs/heads/try2: 0d817ee869387322dec4d3f7d407dcc9f91c2632
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustpkg/package_source.rs

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,19 @@ impl PkgSrc {
5252
use conditions::nonexistent_package::cond;
5353

5454
debug!("Pushing onto root: %s | %s", self.id.path.to_str(), self.root.to_str());
55-
let dir;
55+
5656
let dirs = pkgid_src_in_workspace(&self.id, &self.root);
5757
debug!("Checking dirs: %?", dirs);
5858
let path = dirs.iter().find(|&d| os::path_exists(d));
59-
match path {
60-
Some(d) => dir = (*d).clone(),
61-
None => dir = match self.fetch_git() {
59+
60+
let dir = match path {
61+
Some(d) => (*d).clone(),
62+
None => match self.fetch_git() {
63+
Some(d) => d,
6264
None => cond.raise((self.id.clone(), ~"supplied path for package dir does not \
63-
exist, and couldn't interpret it as a URL fragment")),
64-
Some(d) => d
65+
exist, and couldn't interpret it as a URL fragment"))
6566
}
66-
}
67+
};
6768
if !os::path_is_dir(&dir) {
6869
cond.raise((self.id.clone(), ~"supplied path for package dir is a \
6970
non-directory"));
@@ -145,26 +146,26 @@ impl PkgSrc {
145146
let prefix = dir.components.len();
146147
debug!("Matching against %?", self.id.short_name);
147148
do os::walk_dir(&dir) |pth| {
148-
match pth.filename() {
149-
Some(~"lib.rs") => PkgSrc::push_crate(&mut self.libs,
150-
prefix,
151-
pth),
152-
Some(~"main.rs") => PkgSrc::push_crate(&mut self.mains,
153-
prefix,
154-
pth),
155-
Some(~"test.rs") => PkgSrc::push_crate(&mut self.tests,
156-
prefix,
157-
pth),
158-
Some(~"bench.rs") => PkgSrc::push_crate(&mut self.benchs,
159-
prefix,
160-
pth),
161-
_ => ()
149+
let maybe_known_crate_set = match pth.filename() {
150+
Some(filename) => match filename {
151+
~"lib.rs" => Some(&mut self.libs),
152+
~"main.rs" => Some(&mut self.mains),
153+
~"test.rs" => Some(&mut self.tests),
154+
~"bench.rs" => Some(&mut self.benchs),
155+
_ => None
156+
},
157+
_ => None
158+
};
159+
160+
match maybe_known_crate_set {
161+
Some(crate_set) => PkgSrc::push_crate(crate_set, prefix, pth),
162+
None => ()
162163
}
163164
true
164165
};
165166

166-
if self.libs.is_empty() && self.mains.is_empty()
167-
&& self.tests.is_empty() && self.benchs.is_empty() {
167+
let crate_sets = [&self.libs, &self.mains, &self.tests, &self.benchs];
168+
if crate_sets.iter().all(|crate_set| crate_set.is_empty()) {
168169

169170
note("Couldn't infer any crates to build.\n\
170171
Try naming a crate `main.rs`, `lib.rs`, \

branches/try2/src/librustpkg/path_util.rs

Lines changed: 49 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use std::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
1919
use std::os::mkdir_recursive;
2020
use std::os;
2121
use messages::*;
22-
use package_id::*;
2322

2423
pub fn default_workspace() -> Path {
2524
let p = rust_path();
@@ -51,35 +50,34 @@ pub fn make_dir_rwx(p: &Path) -> bool { os::make_dir(p, U_RWX) }
5150
/// pkgid's short name
5251
pub fn workspace_contains_package_id(pkgid: &PkgId, workspace: &Path) -> bool {
5352
let src_dir = workspace.push("src");
53+
5454
let mut found = false;
5555
do os::walk_dir(&src_dir) |p| {
5656
debug!("=> p = %s", p.to_str());
57-
if os::path_is_dir(p) {
57+
58+
let was_found = os::path_is_dir(p) && {
5859
debug!("p = %s, path = %s [%s]", p.to_str(), pkgid.path.to_str(),
59-
src_dir.push_rel(&pkgid.path).to_str());
60+
src_dir.push_rel(&pkgid.path).to_str());
6061

61-
if *p == src_dir.push_rel(&pkgid.path) {
62-
found = true;
63-
}
64-
else {
62+
*p == src_dir.push_rel(&pkgid.path) || {
6563
let pf = p.filename();
66-
for pf in pf.iter() {
67-
let f_ = (*pf).clone();
68-
let g = f_.to_str();
64+
do pf.iter().any |pf| {
65+
let g = pf.to_str();
6966
match split_version_general(g, '-') {
67+
None => false,
7068
Some((ref might_match, ref vers)) => {
7169
debug!("might_match = %s, vers = %s", *might_match,
72-
vers.to_str());
73-
if *might_match == pkgid.short_name
74-
&& (*vers == pkgid.version || pkgid.version == NoVersion)
75-
{
76-
found = true;
77-
}
70+
vers.to_str());
71+
*might_match == pkgid.short_name
72+
&& (pkgid.version == *vers || pkgid.version == NoVersion)
7873
}
79-
None => ()
80-
}
74+
}
8175
}
8276
}
77+
};
78+
79+
if was_found {
80+
found = true
8381
}
8482
true
8583
};
@@ -102,12 +100,9 @@ pub fn pkgid_src_in_workspace(pkgid: &PkgId, workspace: &Path) -> ~[Path] {
102100
/// Returns a src for pkgid that does exist -- None if none of them do
103101
pub fn first_pkgid_src_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option<Path> {
104102
let rs = pkgid_src_in_workspace(pkgid, workspace);
105-
for p in rs.iter() {
106-
if os::path_exists(p) {
107-
return Some((*p).clone());
108-
}
109-
}
110-
None
103+
do rs.iter().find |&p| {
104+
os::path_exists(p)
105+
}.map(|p| (**p).clone())
111106
}
112107

113108
/// Figure out what the executable name for <pkgid> in <workspace>'s build
@@ -195,22 +190,31 @@ pub fn library_in_workspace(path: &Path, short_name: &str, where: Target,
195190

196191
debug!("lib_prefix = %s and lib_filetype = %s", lib_prefix, lib_filetype);
197192

198-
let mut result_filename = None;
199-
for p in dir_contents.iter() {
200-
let mut which = 0;
201-
let mut hash = None;
202-
let p_path = Path((*p).clone());
203-
let extension = p_path.filetype();
193+
// Find a filename that matches the pattern:
194+
// (lib_prefix)-hash-(version)(lib_suffix)
195+
let paths = do dir_contents.iter().map |p| {
196+
Path((*p).clone())
197+
};
198+
199+
let mut libraries = do paths.filter |p| {
200+
let extension = p.filetype();
204201
debug!("p = %s, p's extension is %?", p.to_str(), extension);
205202
match extension {
206-
Some(ref s) if lib_filetype == *s => (),
207-
_ => loop
203+
None => false,
204+
Some(ref s) => lib_filetype == *s
208205
}
206+
};
207+
208+
let mut result_filename = None;
209+
for p_path in libraries {
209210
// Find a filename that matches the pattern: (lib_prefix)-hash-(version)(lib_suffix)
210211
// and remember what the hash was
211212
let f_name = match p_path.filename() {
212213
Some(s) => s, None => loop
213214
};
215+
216+
let mut hash = None;
217+
let mut which = 0;
214218
for piece in f_name.split_iter('-') {
215219
debug!("a piece = %s", piece);
216220
if which == 0 && piece != lib_prefix {
@@ -229,26 +233,27 @@ pub fn library_in_workspace(path: &Path, short_name: &str, where: Target,
229233
break;
230234
}
231235
}
236+
232237
if hash.is_some() {
233238
result_filename = Some(p_path);
234239
break;
235240
}
236241
}
237242

243+
if result_filename.is_none() {
244+
warn(fmt!("library_in_workspace didn't find a library in %s for %s",
245+
dir_to_search.to_str(), short_name));
246+
}
247+
238248
// Return the filename that matches, which we now know exists
239249
// (if result_filename != None)
240-
match result_filename {
241-
None => {
242-
warn(fmt!("library_in_workspace didn't find a library in %s for %s",
243-
dir_to_search.to_str(), short_name));
244-
None
245-
}
246-
Some(result_filename) => {
247-
let absolute_path = dir_to_search.push_rel(&result_filename);
248-
debug!("result_filename = %s", absolute_path.to_str());
249-
Some(absolute_path)
250-
}
251-
}
250+
let abs_path = do result_filename.map |result_filename| {
251+
let absolute_path = dir_to_search.push_rel(result_filename);
252+
debug!("result_filename = %s", absolute_path.to_str());
253+
absolute_path
254+
};
255+
256+
abs_path
252257
}
253258

254259
/// Returns the executable that would be installed for <pkgid>

branches/try2/src/librustpkg/search.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,9 @@ use path_util::installed_library_in_workspace;
1313
/// If a library with path `p` matching pkg_id's name exists under sroot_opt,
1414
/// return Some(p). Return None if there's no such path or if sroot_opt is None.
1515
pub fn find_library_in_search_path(sroot_opt: Option<@Path>, short_name: &str) -> Option<Path> {
16-
match sroot_opt {
17-
Some(sroot) => {
18-
debug!("Will search for a library with short name %s in \
19-
%s", short_name, (sroot.push("lib")).to_str());
20-
installed_library_in_workspace(short_name, sroot)
21-
}
22-
None => None
16+
do sroot_opt.chain |sroot| {
17+
debug!("Will search for a library with short name %s in \
18+
%s", short_name, (sroot.push("lib")).to_str());
19+
installed_library_in_workspace(short_name, sroot)
2320
}
2421
}

branches/try2/src/libstd/cell.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#[missing_doc];
1414

1515
use cast::transmute_mut;
16+
use unstable::finally::Finally;
1617
use prelude::*;
1718

1819
/*
@@ -65,18 +66,17 @@ impl<T> Cell<T> {
6566

6667
/// Calls a closure with a reference to the value.
6768
pub fn with_ref<R>(&self, op: &fn(v: &T) -> R) -> R {
68-
let v = self.take();
69-
let r = op(&v);
70-
self.put_back(v);
71-
r
69+
do self.with_mut_ref |ptr| { op(ptr) }
7270
}
7371

7472
/// Calls a closure with a mutable reference to the value.
7573
pub fn with_mut_ref<R>(&self, op: &fn(v: &mut T) -> R) -> R {
76-
let mut v = self.take();
77-
let r = op(&mut v);
78-
self.put_back(v);
79-
r
74+
let mut v = Some(self.take());
75+
do (|| {
76+
op(v.get_mut_ref())
77+
}).finally {
78+
self.put_back(v.take_unwrap());
79+
}
8080
}
8181
}
8282

branches/try2/src/libstd/rt/comm.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ use kinds::Send;
1818
use rt;
1919
use rt::sched::Scheduler;
2020
use rt::local::Local;
21-
use rt::select::{Select, SelectPort};
21+
use rt::select::{SelectInner, SelectPortInner};
22+
use select::{Select, SelectPort};
2223
use unstable::atomics::{AtomicUint, AtomicOption, Acquire, Relaxed, SeqCst};
2324
use unstable::sync::UnsafeAtomicRcBox;
2425
use util::Void;
@@ -113,7 +114,9 @@ impl<T> ChanOne<T> {
113114
// 'do_resched' configures whether the scheduler immediately switches to
114115
// the receiving task, or leaves the sending task still running.
115116
fn try_send_inner(self, val: T, do_resched: bool) -> bool {
116-
rtassert!(!rt::in_sched_context());
117+
if do_resched {
118+
rtassert!(!rt::in_sched_context());
119+
}
117120

118121
let mut this = self;
119122
let mut recvr_active = true;
@@ -215,7 +218,7 @@ impl<T> PortOne<T> {
215218
}
216219
}
217220

218-
impl<T> Select for PortOne<T> {
221+
impl<T> SelectInner for PortOne<T> {
219222
#[inline] #[cfg(not(test))]
220223
fn optimistic_check(&mut self) -> bool {
221224
unsafe { (*self.packet()).state.load(Acquire) == STATE_ONE }
@@ -318,7 +321,9 @@ impl<T> Select for PortOne<T> {
318321
}
319322
}
320323

321-
impl<T> SelectPort<T> for PortOne<T> {
324+
impl<T> Select for PortOne<T> { }
325+
326+
impl<T> SelectPortInner<T> for PortOne<T> {
322327
fn recv_ready(self) -> Option<T> {
323328
let mut this = self;
324329
let packet = this.packet();
@@ -349,6 +354,8 @@ impl<T> SelectPort<T> for PortOne<T> {
349354
}
350355
}
351356

357+
impl<T> SelectPort<T> for PortOne<T> { }
358+
352359
impl<T> Peekable<T> for PortOne<T> {
353360
fn peek(&self) -> bool {
354361
unsafe {
@@ -513,7 +520,7 @@ impl<T> Peekable<T> for Port<T> {
513520
// of them, but a &Port<T> should also be selectable so you can select2 on it
514521
// alongside a PortOne<U> without passing the port by value in recv_ready.
515522

516-
impl<'self, T> Select for &'self Port<T> {
523+
impl<'self, T> SelectInner for &'self Port<T> {
517524
#[inline]
518525
fn optimistic_check(&mut self) -> bool {
519526
do self.next.with_mut_ref |pone| { pone.optimistic_check() }
@@ -531,7 +538,9 @@ impl<'self, T> Select for &'self Port<T> {
531538
}
532539
}
533540

534-
impl<T> Select for Port<T> {
541+
impl<'self, T> Select for &'self Port<T> { }
542+
543+
impl<T> SelectInner for Port<T> {
535544
#[inline]
536545
fn optimistic_check(&mut self) -> bool {
537546
(&*self).optimistic_check()
@@ -548,7 +557,9 @@ impl<T> Select for Port<T> {
548557
}
549558
}
550559

551-
impl<'self, T> SelectPort<T> for &'self Port<T> {
560+
impl<T> Select for Port<T> { }
561+
562+
impl<'self, T> SelectPortInner<T> for &'self Port<T> {
552563
fn recv_ready(self) -> Option<T> {
553564
match self.next.take().recv_ready() {
554565
Some(StreamPayload { val, next }) => {
@@ -560,6 +571,8 @@ impl<'self, T> SelectPort<T> for &'self Port<T> {
560571
}
561572
}
562573

574+
impl<'self, T> SelectPort<T> for &'self Port<T> { }
575+
563576
pub struct SharedChan<T> {
564577
// Just like Chan, but a shared AtomicOption instead of Cell
565578
priv next: UnsafeAtomicRcBox<AtomicOption<StreamChanOne<T>>>

branches/try2/src/libstd/rt/kill.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,8 @@ impl Death {
488488
rtassert!(self.unkillable == 0);
489489
self.unkillable = 1;
490490

491-
// FIXME(#7544): See corresponding fixme at the callsite in task.rs.
492-
// NB(#8192): Doesn't work with "let _ = ..."
491+
// NB. See corresponding comment at the callsite in task.rs.
492+
// FIXME(#8192): Doesn't work with "let _ = ..."
493493
{ use util; util::ignore(group); }
494494

495495
// Step 1. Decide if we need to collect child failures synchronously.

branches/try2/src/libstd/rt/local.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ impl Local for Task {
4545
}
4646
unsafe fn unsafe_borrow() -> *mut Task { local_ptr::unsafe_borrow() }
4747
unsafe fn try_unsafe_borrow() -> Option<*mut Task> {
48-
if Local::exists::<Task>() {
49-
Some(Local::unsafe_borrow())
50-
} else {
51-
None
52-
}
48+
local_ptr::try_unsafe_borrow()
5349
}
5450
}
5551

0 commit comments

Comments
 (0)