Skip to content

stabilize core::{option, result} #16664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/compiletest/procsrv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub fn run(lib_path: &str,
match cmd.spawn() {
Ok(mut process) => {
for input in input.iter() {
process.stdin.get_mut_ref().write(input.as_bytes()).unwrap();
process.stdin.as_mut().unwrap().write(input.as_bytes()).unwrap();
}
let ProcessOutput { status, output, error } =
process.wait_with_output().unwrap();
Expand Down Expand Up @@ -79,7 +79,7 @@ pub fn run_background(lib_path: &str,
match cmd.spawn() {
Ok(mut process) => {
for input in input.iter() {
process.stdin.get_mut_ref().write(input.as_bytes()).unwrap();
process.stdin.as_mut().unwrap().write(input.as_bytes()).unwrap();
}

Some(process)
Expand Down
6 changes: 3 additions & 3 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,7 @@ fn compile_cc_with_clang_and_save_bitcode(config: &Config, _props: &TestProps,
let testcc = testfile.with_extension("cc");
let proc_args = ProcArgs {
// FIXME (#9639): This needs to handle non-utf8 paths
prog: config.clang_path.get_ref().as_str().unwrap().to_string(),
prog: config.clang_path.as_ref().unwrap().as_str().unwrap().to_string(),
args: vec!("-c".to_string(),
"-emit-llvm".to_string(),
"-o".to_string(),
Expand All @@ -1542,7 +1542,7 @@ fn extract_function_from_bitcode(config: &Config, _props: &TestProps,
let bitcodefile = output_base_name(config, testfile).with_extension("bc");
let bitcodefile = append_suffix_to_stem(&bitcodefile, suffix);
let extracted_bc = append_suffix_to_stem(&bitcodefile, "extract");
let prog = config.llvm_bin_path.get_ref().join("llvm-extract");
let prog = config.llvm_bin_path.as_ref().unwrap().join("llvm-extract");
let proc_args = ProcArgs {
// FIXME (#9639): This needs to handle non-utf8 paths
prog: prog.as_str().unwrap().to_string(),
Expand All @@ -1559,7 +1559,7 @@ fn disassemble_extract(config: &Config, _props: &TestProps,
let bitcodefile = append_suffix_to_stem(&bitcodefile, suffix);
let extracted_bc = append_suffix_to_stem(&bitcodefile, "extract");
let extracted_ll = extracted_bc.with_extension("ll");
let prog = config.llvm_bin_path.get_ref().join("llvm-dis");
let prog = config.llvm_bin_path.as_ref().unwrap().join("llvm-dis");
let proc_args = ProcArgs {
// FIXME (#9639): This needs to handle non-utf8 paths
prog: prog.as_str().unwrap().to_string(),
Expand Down
6 changes: 3 additions & 3 deletions src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ impl<T> TypedArena<T> {
/// Grows the arena.
#[inline(never)]
fn grow(&self) {
let chunk = self.first.borrow_mut().take_unwrap();
let chunk = self.first.borrow_mut().take().unwrap();
let new_capacity = chunk.capacity.checked_mul(&2).unwrap();
let chunk = TypedArenaChunk::<T>::new(Some(chunk), new_capacity);
self.ptr.set(chunk.start() as *const T);
Expand All @@ -489,13 +489,13 @@ impl<T> TypedArena<T> {
impl<T> Drop for TypedArena<T> {
fn drop(&mut self) {
// Determine how much was filled.
let start = self.first.borrow().get_ref().start() as uint;
let start = self.first.borrow().as_ref().unwrap().start() as uint;
let end = self.ptr.get() as uint;
let diff = (end - start) / mem::size_of::<T>();

// Pass that to the `destroy` method.
unsafe {
self.first.borrow_mut().get_mut_ref().destroy(diff)
self.first.borrow_mut().as_mut().unwrap().destroy(diff)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ impl<'a, A> MutItems<'a, A> {
None => return self.list.push_front_node(ins_node),
Some(prev) => prev,
};
let node_own = prev_node.next.take_unwrap();
let node_own = prev_node.next.take().unwrap();
ins_node.next = link_with_prev(node_own, Rawlink::some(&mut *ins_node));
prev_node.next = link_with_prev(ins_node, Rawlink::some(prev_node));
self.list.length += 1;
Expand Down
6 changes: 3 additions & 3 deletions src/libcollections/ringbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ impl<'a, T> Iterator<&'a T> for Items<'a, T> {
}
let raw_index = raw_index(self.lo, self.elts.len(), self.index);
self.index += 1;
Some(self.elts[raw_index].get_ref())
Some(self.elts[raw_index].as_ref().unwrap())
}

#[inline]
Expand All @@ -327,7 +327,7 @@ impl<'a, T> DoubleEndedIterator<&'a T> for Items<'a, T> {
}
self.rindex -= 1;
let raw_index = raw_index(self.lo, self.elts.len(), self.rindex);
Some(self.elts[raw_index].get_ref())
Some(self.elts[raw_index].as_ref().unwrap())
}
}

Expand All @@ -343,7 +343,7 @@ impl<'a, T> RandomAccessIterator<&'a T> for Items<'a, T> {
None
} else {
let raw_index = raw_index(self.lo, self.elts.len(), self.index + j);
Some(self.elts[raw_index].get_ref())
Some(self.elts[raw_index].as_ref().unwrap())
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/libcollections/treemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ impl<K: Ord, V> TreeNode<K, V> {
// Remove left horizontal link by rotating right
fn skew<K: Ord, V>(node: &mut Box<TreeNode<K, V>>) {
if node.left.as_ref().map_or(false, |x| x.level == node.level) {
let mut save = node.left.take_unwrap();
let mut save = node.left.take().unwrap();
swap(&mut node.left, &mut save.right); // save.right now None
swap(node, &mut save);
node.right = Some(save);
Expand All @@ -1459,7 +1459,7 @@ fn skew<K: Ord, V>(node: &mut Box<TreeNode<K, V>>) {
fn split<K: Ord, V>(node: &mut Box<TreeNode<K, V>>) {
if node.right.as_ref().map_or(false,
|x| x.right.as_ref().map_or(false, |y| y.level == node.level)) {
let mut save = node.right.take_unwrap();
let mut save = node.right.take().unwrap();
swap(&mut node.right, &mut save.left); // save.left now None
save.level += 1;
swap(node, &mut save);
Expand Down Expand Up @@ -1563,7 +1563,7 @@ fn remove<K: Ord, V>(node: &mut Option<Box<TreeNode<K, V>>>,
Equal => {
if save.left.is_some() {
if save.right.is_some() {
let mut left = save.left.take_unwrap();
let mut left = save.left.take().unwrap();
if left.right.is_some() {
heir_swap(save, &mut left.right);
} else {
Expand All @@ -1573,13 +1573,13 @@ fn remove<K: Ord, V>(node: &mut Option<Box<TreeNode<K, V>>>,
save.left = Some(left);
(remove(&mut save.left, key), true)
} else {
let new = save.left.take_unwrap();
let new = save.left.take().unwrap();
let box TreeNode{value, ..} = replace(save, new);
*save = save.left.take_unwrap();
*save = save.left.take().unwrap();
(Some(value), true)
}
} else if save.right.is_some() {
let new = save.right.take_unwrap();
let new = save.right.take().unwrap();
let box TreeNode{value, ..} = replace(save, new);
(Some(value), true)
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
//! // Take a reference to the inside of cache cell
//! let mut cache = self.span_tree_cache.borrow_mut();
//! if cache.is_some() {
//! return cache.get_ref().clone();
//! return cache.as_ref().unwrap().clone();
//! }
//!
//! let span_tree = self.calc_span_tree();
Expand Down
7 changes: 6 additions & 1 deletion src/libcore/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2191,7 +2191,12 @@ pub fn iterate<'a, T: Clone>(f: |T|: 'a -> T, seed: T) -> Iterate<'a, T> {
if *first {
*first = false;
} else {
val.mutate(|x| (*f)(x));
match val.take() {
Some(x) => {
*val = Some((*f)(x))
}
None => {}
}
}
val.clone()
})
Expand Down
Loading