Skip to content

Commit 276b8b1

Browse files
committed
Fallout from stabilizing core::option
1 parent 3a52ef4 commit 276b8b1

Some content is hidden

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

46 files changed

+121
-116
lines changed

src/compiletest/procsrv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub fn run(lib_path: &str,
4747
match cmd.spawn() {
4848
Ok(mut process) => {
4949
for input in input.iter() {
50-
process.stdin.get_mut_ref().write(input.as_bytes()).unwrap();
50+
process.stdin.as_mut().unwrap().write(input.as_bytes()).unwrap();
5151
}
5252
let ProcessOutput { status, output, error } =
5353
process.wait_with_output().unwrap();
@@ -79,7 +79,7 @@ pub fn run_background(lib_path: &str,
7979
match cmd.spawn() {
8080
Ok(mut process) => {
8181
for input in input.iter() {
82-
process.stdin.get_mut_ref().write(input.as_bytes()).unwrap();
82+
process.stdin.as_mut().unwrap().write(input.as_bytes()).unwrap();
8383
}
8484

8585
Some(process)

src/compiletest/runtest.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,7 @@ fn compile_cc_with_clang_and_save_bitcode(config: &Config, _props: &TestProps,
15261526
let testcc = testfile.with_extension("cc");
15271527
let proc_args = ProcArgs {
15281528
// FIXME (#9639): This needs to handle non-utf8 paths
1529-
prog: config.clang_path.get_ref().as_str().unwrap().to_string(),
1529+
prog: config.clang_path.as_ref().unwrap().as_str().unwrap().to_string(),
15301530
args: vec!("-c".to_string(),
15311531
"-emit-llvm".to_string(),
15321532
"-o".to_string(),
@@ -1542,7 +1542,7 @@ fn extract_function_from_bitcode(config: &Config, _props: &TestProps,
15421542
let bitcodefile = output_base_name(config, testfile).with_extension("bc");
15431543
let bitcodefile = append_suffix_to_stem(&bitcodefile, suffix);
15441544
let extracted_bc = append_suffix_to_stem(&bitcodefile, "extract");
1545-
let prog = config.llvm_bin_path.get_ref().join("llvm-extract");
1545+
let prog = config.llvm_bin_path.as_ref().unwrap().join("llvm-extract");
15461546
let proc_args = ProcArgs {
15471547
// FIXME (#9639): This needs to handle non-utf8 paths
15481548
prog: prog.as_str().unwrap().to_string(),
@@ -1559,7 +1559,7 @@ fn disassemble_extract(config: &Config, _props: &TestProps,
15591559
let bitcodefile = append_suffix_to_stem(&bitcodefile, suffix);
15601560
let extracted_bc = append_suffix_to_stem(&bitcodefile, "extract");
15611561
let extracted_ll = extracted_bc.with_extension("ll");
1562-
let prog = config.llvm_bin_path.get_ref().join("llvm-dis");
1562+
let prog = config.llvm_bin_path.as_ref().unwrap().join("llvm-dis");
15631563
let proc_args = ProcArgs {
15641564
// FIXME (#9639): This needs to handle non-utf8 paths
15651565
prog: prog.as_str().unwrap().to_string(),

src/libarena/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ impl<T> TypedArena<T> {
476476
/// Grows the arena.
477477
#[inline(never)]
478478
fn grow(&self) {
479-
let chunk = self.first.borrow_mut().take_unwrap();
479+
let chunk = self.first.borrow_mut().take().unwrap();
480480
let new_capacity = chunk.capacity.checked_mul(&2).unwrap();
481481
let chunk = TypedArenaChunk::<T>::new(Some(chunk), new_capacity);
482482
self.ptr.set(chunk.start() as *const T);
@@ -489,13 +489,13 @@ impl<T> TypedArena<T> {
489489
impl<T> Drop for TypedArena<T> {
490490
fn drop(&mut self) {
491491
// Determine how much was filled.
492-
let start = self.first.borrow().get_ref().start() as uint;
492+
let start = self.first.borrow().as_ref().unwrap().start() as uint;
493493
let end = self.ptr.get() as uint;
494494
let diff = (end - start) / mem::size_of::<T>();
495495

496496
// Pass that to the `destroy` method.
497497
unsafe {
498-
self.first.borrow_mut().get_mut_ref().destroy(diff)
498+
self.first.borrow_mut().as_mut().unwrap().destroy(diff)
499499
}
500500
}
501501
}

src/libcollections/dlist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ impl<'a, A> MutItems<'a, A> {
630630
None => return self.list.push_front_node(ins_node),
631631
Some(prev) => prev,
632632
};
633-
let node_own = prev_node.next.take_unwrap();
633+
let node_own = prev_node.next.take().unwrap();
634634
ins_node.next = link_with_prev(node_own, Rawlink::some(&mut *ins_node));
635635
prev_node.next = link_with_prev(ins_node, Rawlink::some(prev_node));
636636
self.list.length += 1;

src/libcollections/ringbuf.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ impl<'a, T> Iterator<&'a T> for Items<'a, T> {
309309
}
310310
let raw_index = raw_index(self.lo, self.elts.len(), self.index);
311311
self.index += 1;
312-
Some(self.elts[raw_index].get_ref())
312+
Some(self.elts[raw_index].as_ref().unwrap())
313313
}
314314

315315
#[inline]
@@ -327,7 +327,7 @@ impl<'a, T> DoubleEndedIterator<&'a T> for Items<'a, T> {
327327
}
328328
self.rindex -= 1;
329329
let raw_index = raw_index(self.lo, self.elts.len(), self.rindex);
330-
Some(self.elts[raw_index].get_ref())
330+
Some(self.elts[raw_index].as_ref().unwrap())
331331
}
332332
}
333333

@@ -343,7 +343,7 @@ impl<'a, T> RandomAccessIterator<&'a T> for Items<'a, T> {
343343
None
344344
} else {
345345
let raw_index = raw_index(self.lo, self.elts.len(), self.index + j);
346-
Some(self.elts[raw_index].get_ref())
346+
Some(self.elts[raw_index].as_ref().unwrap())
347347
}
348348
}
349349
}

src/libcollections/treemap.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,7 @@ impl<K: Ord, V> TreeNode<K, V> {
14471447
// Remove left horizontal link by rotating right
14481448
fn skew<K: Ord, V>(node: &mut Box<TreeNode<K, V>>) {
14491449
if node.left.as_ref().map_or(false, |x| x.level == node.level) {
1450-
let mut save = node.left.take_unwrap();
1450+
let mut save = node.left.take().unwrap();
14511451
swap(&mut node.left, &mut save.right); // save.right now None
14521452
swap(node, &mut save);
14531453
node.right = Some(save);
@@ -1459,7 +1459,7 @@ fn skew<K: Ord, V>(node: &mut Box<TreeNode<K, V>>) {
14591459
fn split<K: Ord, V>(node: &mut Box<TreeNode<K, V>>) {
14601460
if node.right.as_ref().map_or(false,
14611461
|x| x.right.as_ref().map_or(false, |y| y.level == node.level)) {
1462-
let mut save = node.right.take_unwrap();
1462+
let mut save = node.right.take().unwrap();
14631463
swap(&mut node.right, &mut save.left); // save.left now None
14641464
save.level += 1;
14651465
swap(node, &mut save);
@@ -1563,7 +1563,7 @@ fn remove<K: Ord, V>(node: &mut Option<Box<TreeNode<K, V>>>,
15631563
Equal => {
15641564
if save.left.is_some() {
15651565
if save.right.is_some() {
1566-
let mut left = save.left.take_unwrap();
1566+
let mut left = save.left.take().unwrap();
15671567
if left.right.is_some() {
15681568
heir_swap(save, &mut left.right);
15691569
} else {
@@ -1573,13 +1573,13 @@ fn remove<K: Ord, V>(node: &mut Option<Box<TreeNode<K, V>>>,
15731573
save.left = Some(left);
15741574
(remove(&mut save.left, key), true)
15751575
} else {
1576-
let new = save.left.take_unwrap();
1576+
let new = save.left.take().unwrap();
15771577
let box TreeNode{value, ..} = replace(save, new);
1578-
*save = save.left.take_unwrap();
1578+
*save = save.left.take().unwrap();
15791579
(Some(value), true)
15801580
}
15811581
} else if save.right.is_some() {
1582-
let new = save.right.take_unwrap();
1582+
let new = save.right.take().unwrap();
15831583
let box TreeNode{value, ..} = replace(save, new);
15841584
(Some(value), true)
15851585
} else {

src/libcore/cell.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
//! // Take a reference to the inside of cache cell
100100
//! let mut cache = self.span_tree_cache.borrow_mut();
101101
//! if cache.is_some() {
102-
//! return cache.get_ref().clone();
102+
//! return cache.as_ref().unwrap().clone();
103103
//! }
104104
//!
105105
//! let span_tree = self.calc_span_tree();

src/libcore/iter.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2191,7 +2191,12 @@ pub fn iterate<'a, T: Clone>(f: |T|: 'a -> T, seed: T) -> Iterate<'a, T> {
21912191
if *first {
21922192
*first = false;
21932193
} else {
2194-
val.mutate(|x| (*f)(x));
2194+
match val.take() {
2195+
Some(x) => {
2196+
*val = Some((*f)(x))
2197+
}
2198+
None => {}
2199+
}
21952200
}
21962201
val.clone()
21972202
})

src/libcore/option.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ impl<T> Option<T> {
341341
#[deprecated = "removed due to lack of use"]
342342
pub fn mutate(&mut self, f: |T| -> T) -> bool {
343343
if self.is_some() {
344-
*self = Some(f(self.take_unwrap()));
344+
*self = Some(f(self.take().unwrap()));
345345
true
346346
} else { false }
347347
}
@@ -353,7 +353,7 @@ impl<T> Option<T> {
353353
#[deprecated = "removed due to lack of use"]
354354
pub fn mutate_or_set(&mut self, def: T, f: |T| -> T) -> bool {
355355
if self.is_some() {
356-
*self = Some(f(self.take_unwrap()));
356+
*self = Some(f(self.take().unwrap()));
357357
true
358358
} else {
359359
*self = Some(def);

src/libcoretest/option.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fn test_option_dance() {
7373
let mut y = Some(5i);
7474
let mut y2 = 0;
7575
for _x in x.iter() {
76-
y2 = y.take_unwrap();
76+
y2 = y.take().unwrap();
7777
}
7878
assert_eq!(y2, 5);
7979
assert!(y.is_none());
@@ -82,8 +82,8 @@ fn test_option_dance() {
8282
#[test] #[should_fail]
8383
fn test_option_too_much_dance() {
8484
let mut y = Some(marker::NoCopy);
85-
let _y2 = y.take_unwrap();
86-
let _y3 = y.take_unwrap();
85+
let _y2 = y.take().unwrap();
86+
let _y3 = y.take().unwrap();
8787
}
8888

8989
#[test]

src/libglob/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> Paths {
106106
let mut root = os::getcwd();
107107
let pat_root = Path::new(pattern).root_path();
108108
if pat_root.is_some() {
109-
if check_windows_verbatim(pat_root.get_ref()) {
109+
if check_windows_verbatim(pat_root.as_ref().unwrap()) {
110110
// FIXME: How do we want to handle verbatim paths? I'm inclined to return nothing,
111111
// since we can't very well find all UNC shares with a 1-letter server name.
112112
return Paths {
@@ -116,7 +116,7 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> Paths {
116116
todo: Vec::new(),
117117
};
118118
}
119-
root.push(pat_root.get_ref());
119+
root.push(pat_root.as_ref().unwrap());
120120
}
121121

122122
let root_len = pat_root.map_or(0u, |p| p.as_vec().len());

src/libgreen/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ pub fn start(argc: int, argv: *const *const u8,
305305
let mut main = Some(main);
306306
let mut ret = None;
307307
simple::task().run(|| {
308-
ret = Some(run(event_loop_factory, main.take_unwrap()));
308+
ret = Some(run(event_loop_factory, main.take().unwrap()));
309309
}).destroy();
310310
// unsafe is ok b/c we're sure that the runtime is gone
311311
unsafe { rt::cleanup() }

src/libgreen/sched.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl Scheduler {
203203
let mut sched_task = self.run(sched_task);
204204

205205
// Close the idle callback.
206-
let mut sched = sched_task.sched.take_unwrap();
206+
let mut sched = sched_task.sched.take().unwrap();
207207
sched.idle_callback.take();
208208
// Make one go through the loop to run the close callback.
209209
let mut stask = sched.run(sched_task);
@@ -702,7 +702,7 @@ impl Scheduler {
702702
assert!(sched.sched_task.is_none());
703703
sched.sched_task = Some(stask);
704704
});
705-
(cur.sched.take_unwrap(), cur)
705+
(cur.sched.take().unwrap(), cur)
706706
}
707707

708708
fn resume_task_immediately_cl(sched: Box<Scheduler>,
@@ -738,7 +738,7 @@ impl Scheduler {
738738
f: |&mut Scheduler, BlockedTask|) {
739739
// Trickier - we need to get the scheduler task out of self
740740
// and use it as the destination.
741-
let stask = self.sched_task.take_unwrap();
741+
let stask = self.sched_task.take().unwrap();
742742
// Otherwise this is the same as below.
743743
self.switch_running_tasks_and_then(cur, stask, f)
744744
}
@@ -788,7 +788,7 @@ impl Scheduler {
788788
sched.enqueue_task(last_task);
789789
}
790790
});
791-
(cur.sched.take_unwrap(), cur)
791+
(cur.sched.take().unwrap(), cur)
792792
}
793793

794794
// * Task Context Helpers
@@ -800,9 +800,9 @@ impl Scheduler {
800800
-> ! {
801801
// Similar to deschedule running task and then, but cannot go through
802802
// the task-blocking path. The task is already dying.
803-
let stask = self.sched_task.take_unwrap();
803+
let stask = self.sched_task.take().unwrap();
804804
let _cur = self.change_task_context(cur, stask, |sched, mut dead_task| {
805-
let coroutine = dead_task.coroutine.take_unwrap();
805+
let coroutine = dead_task.coroutine.take().unwrap();
806806
coroutine.recycle(&mut sched.stack_pool);
807807
sched.task_state.decrement();
808808
});
@@ -818,7 +818,7 @@ impl Scheduler {
818818
}
819819

820820
pub fn run_task_later(mut cur: Box<GreenTask>, next: Box<GreenTask>) {
821-
let mut sched = cur.sched.take_unwrap();
821+
let mut sched = cur.sched.take().unwrap();
822822
sched.enqueue_task(next);
823823
cur.put_with_sched(sched);
824824
}
@@ -838,7 +838,7 @@ impl Scheduler {
838838
self.yield_check_count = reset_yield_check(&mut self.rng);
839839
// Tell the scheduler to start stealing on the next iteration
840840
self.steal_for_yield = true;
841-
let stask = self.sched_task.take_unwrap();
841+
let stask = self.sched_task.take().unwrap();
842842
let cur = self.change_task_context(cur, stask, |sched, task| {
843843
sched.enqueue_task(task);
844844
});
@@ -878,7 +878,7 @@ impl Scheduler {
878878
pub fn sched_id(&self) -> uint { self as *const Scheduler as uint }
879879

880880
pub fn run_cleanup_job(&mut self) {
881-
let cleanup_job = self.cleanup_job.take_unwrap();
881+
let cleanup_job = self.cleanup_job.take().unwrap();
882882
cleanup_job.run(self)
883883
}
884884

@@ -1235,7 +1235,7 @@ mod test {
12351235

12361236
fn run(next: Box<GreenTask>) {
12371237
let mut task = GreenTask::convert(Local::take());
1238-
let sched = task.sched.take_unwrap();
1238+
let sched = task.sched.take().unwrap();
12391239
sched.run_task(task, next)
12401240
}
12411241

src/libgreen/task.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ extern fn bootstrap_green_task(task: uint, code: *mut (), env: *mut ()) -> ! {
110110
// requested. This is the "try/catch" block for this green task and
111111
// is the wrapper for *all* code run in the task.
112112
let mut start = Some(start);
113-
let task = task.swap().run(|| start.take_unwrap()()).destroy();
113+
let task = task.swap().run(|| start.take().unwrap()()).destroy();
114114

115115
// Once the function has exited, it's time to run the termination
116116
// routine. This means we need to context switch one more time but
@@ -212,7 +212,7 @@ impl GreenTask {
212212

213213
pub fn take_unwrap_home(&mut self) -> Home {
214214
match self.task_type {
215-
TypeGreen(ref mut home) => home.take_unwrap(),
215+
TypeGreen(ref mut home) => home.take().unwrap(),
216216
TypeSched => rtabort!("type error: used SchedTask as GreenTask"),
217217
}
218218
}
@@ -277,7 +277,7 @@ impl GreenTask {
277277
}
278278

279279
pub fn swap(mut self: Box<GreenTask>) -> Box<Task> {
280-
let mut task = self.task.take_unwrap();
280+
let mut task = self.task.take().unwrap();
281281
task.put_runtime(self);
282282
return task;
283283
}
@@ -288,7 +288,7 @@ impl GreenTask {
288288
}
289289

290290
fn terminate(mut self: Box<GreenTask>) -> ! {
291-
let sched = self.sched.take_unwrap();
291+
let sched = self.sched.take().unwrap();
292292
sched.terminate_current_task(self)
293293
}
294294

@@ -324,13 +324,13 @@ impl GreenTask {
324324
impl Runtime for GreenTask {
325325
fn yield_now(mut self: Box<GreenTask>, cur_task: Box<Task>) {
326326
self.put_task(cur_task);
327-
let sched = self.sched.take_unwrap();
327+
let sched = self.sched.take().unwrap();
328328
sched.yield_now(self);
329329
}
330330

331331
fn maybe_yield(mut self: Box<GreenTask>, cur_task: Box<Task>) {
332332
self.put_task(cur_task);
333-
let sched = self.sched.take_unwrap();
333+
let sched = self.sched.take().unwrap();
334334
sched.maybe_yield(self);
335335
}
336336

@@ -339,7 +339,7 @@ impl Runtime for GreenTask {
339339
cur_task: Box<Task>,
340340
f: |BlockedTask| -> Result<(), BlockedTask>) {
341341
self.put_task(cur_task);
342-
let mut sched = self.sched.take_unwrap();
342+
let mut sched = self.sched.take().unwrap();
343343

344344
// In order for this task to be reawoken in all possible contexts, we
345345
// may need a handle back in to the current scheduler. When we're woken
@@ -418,7 +418,7 @@ impl Runtime for GreenTask {
418418
match running_task.maybe_take_runtime::<GreenTask>() {
419419
Some(mut running_green_task) => {
420420
running_green_task.put_task(running_task);
421-
let sched = running_green_task.sched.take_unwrap();
421+
let sched = running_green_task.sched.take().unwrap();
422422

423423
if sched.pool_id == self.pool_id {
424424
sched.run_task(running_green_task, self);

0 commit comments

Comments
 (0)