diff options
| author | Aaron Turon <aturon@mozilla.com> | 2016-12-14 13:02:00 -0800 |
|---|---|---|
| committer | Aaron Turon <aturon@mozilla.com> | 2016-12-16 19:42:17 -0800 |
| commit | 9a5cef4de51c1c90fb2d05b0c7e6feb9cf0224d6 (patch) | |
| tree | dfc7eb130baf656785761739b6808efdec694254 | |
| parent | fce6af2a6759991b8f31b6dcbee315ccacb2339d (diff) | |
| download | rust-9a5cef4de51c1c90fb2d05b0c7e6feb9cf0224d6.tar.gz rust-9a5cef4de51c1c90fb2d05b0c7e6feb9cf0224d6.zip | |
Address fallout
| -rw-r--r-- | src/liballoc/rc.rs | 33 | ||||
| -rw-r--r-- | src/libcollectionstest/lib.rs | 1 | ||||
| -rw-r--r-- | src/libcore/cell.rs | 2 | ||||
| -rw-r--r-- | src/libcore/fmt/mod.rs | 10 | ||||
| -rw-r--r-- | src/libcore/iter/iterator.rs | 2 | ||||
| -rw-r--r-- | src/libcoretest/cell.rs | 37 | ||||
| -rw-r--r-- | src/libcoretest/lib.rs | 4 | ||||
| -rw-r--r-- | src/librustc/dep_graph/shadow.rs | 16 | ||||
| -rw-r--r-- | src/librustc/lib.rs | 1 | ||||
| -rw-r--r-- | src/librustc_resolve/lib.rs | 1 | ||||
| -rw-r--r-- | src/librustc_resolve/resolve_imports.rs | 8 | ||||
| -rw-r--r-- | src/librustc_trans/lib.rs | 1 | ||||
| -rw-r--r-- | src/libstd/io/stdio.rs | 6 | ||||
| -rw-r--r-- | src/libstd/sys/redox/ext/process.rs | 2 | ||||
| -rw-r--r-- | src/libstd_unicode/char.rs | 2 | ||||
| -rw-r--r-- | src/libstd_unicode/lib.rs | 1 |
16 files changed, 44 insertions, 83 deletions
diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 8d2b1a770b2..86f8c746646 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -320,7 +320,7 @@ impl<T> Rc<T> { #[inline] #[stable(feature = "rc_unique", since = "1.4.0")] pub fn try_unwrap(this: Self) -> Result<T, Self> { - if Rc::would_unwrap(&this) { + if Rc::strong_count(&this) == 1 { unsafe { let val = ptr::read(&*this); // copy the contained object @@ -343,23 +343,6 @@ impl<T> Rc<T> { /// /// [try_unwrap]: struct.Rc.html#method.try_unwrap /// [`Ok`]: ../../std/result/enum.Result.html#variant.Ok - /// - /// # Examples - /// - /// ``` - /// #![feature(rc_would_unwrap)] - /// - /// use std::rc::Rc; - /// - /// let x = Rc::new(3); - /// assert!(Rc::would_unwrap(&x)); - /// assert_eq!(Rc::try_unwrap(x), Ok(3)); - /// - /// let x = Rc::new(4); - /// let _y = x.clone(); - /// assert!(!Rc::would_unwrap(&x)); - /// assert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4); - /// ``` #[unstable(feature = "rc_would_unwrap", reason = "just added for niche usecase", issue = "28356")] @@ -518,20 +501,8 @@ impl<T: ?Sized> Rc<T> { /// this inner value. /// /// [weak]: struct.Weak.html - /// - /// # Examples - /// - /// ``` - /// #![feature(rc_counts)] - /// - /// use std::rc::Rc; - /// - /// let five = Rc::new(5); - /// - /// assert!(Rc::is_unique(&five)); - /// ``` #[inline] - #[unstable(feature = "rc_counts", reason = "uniqueness has unclear meaning", + #[unstable(feature = "is_unique", reason = "uniqueness has unclear meaning", issue = "28356")] #[rustc_deprecated(since = "1.15.0", reason = "too niche; use `strong_count` and `weak_count` instead")] diff --git a/src/libcollectionstest/lib.rs b/src/libcollectionstest/lib.rs index 0fe0a1bad64..d4fb5ea03ad 100644 --- a/src/libcollectionstest/lib.rs +++ b/src/libcollectionstest/lib.rs @@ -29,7 +29,6 @@ #![feature(test)] #![feature(unboxed_closures)] #![feature(unicode)] -#![feature(vec_into_iter_as_slice)] extern crate collections; extern crate test; diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index efba8798309..c3f862e7c54 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -394,6 +394,7 @@ pub struct RefCell<T: ?Sized> { #[derive(Copy, Clone, PartialEq, Eq, Debug)] #[unstable(feature = "borrow_state", issue = "27733")] #[rustc_deprecated(since = "1.15.0", reason = "use `try_borrow` instead")] +#[allow(deprecated)] pub enum BorrowState { /// The cell is currently being read, there is at least one active `borrow`. Reading, @@ -513,6 +514,7 @@ impl<T: ?Sized> RefCell<T> { /// ``` #[unstable(feature = "borrow_state", issue = "27733")] #[rustc_deprecated(since = "1.15.0", reason = "use `try_borrow` instead")] + #[allow(deprecated)] #[inline] pub fn borrow_state(&self) -> BorrowState { match self.borrow.get() { diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 9167264ba9d..2ba7d6e8bd1 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -12,7 +12,7 @@ #![stable(feature = "rust1", since = "1.0.0")] -use cell::{UnsafeCell, Cell, RefCell, Ref, RefMut, BorrowState}; +use cell::{UnsafeCell, Cell, RefCell, Ref, RefMut}; use marker::PhantomData; use mem; use num::flt2dec; @@ -1634,13 +1634,13 @@ impl<T: Copy + Debug> Debug for Cell<T> { #[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized + Debug> Debug for RefCell<T> { fn fmt(&self, f: &mut Formatter) -> Result { - match self.borrow_state() { - BorrowState::Unused | BorrowState::Reading => { + match self.try_borrow() { + Ok(borrow) => { f.debug_struct("RefCell") - .field("value", &self.borrow()) + .field("value", &borrow) .finish() } - BorrowState::Writing => { + Err(_) => { f.debug_struct("RefCell") .field("value", &"<borrowed>") .finish() diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index cdc804b9ad6..ec590d2bd06 100644 --- a/src/libcore/iter/iterator.rs +++ b/src/libcore/iter/iterator.rs @@ -1696,7 +1696,6 @@ pub trait Iterator { /// # Examples /// /// ``` - /// #![feature(iter_max_by)] /// let a = [-3_i32, 0, 1, 5, -10]; /// assert_eq!(*a.iter().max_by(|x, y| x.cmp(y)).unwrap(), 5); /// ``` @@ -1746,7 +1745,6 @@ pub trait Iterator { /// # Examples /// /// ``` - /// #![feature(iter_min_by)] /// let a = [-3_i32, 0, 1, 5, -10]; /// assert_eq!(*a.iter().min_by(|x, y| x.cmp(y)).unwrap(), -10); /// ``` diff --git a/src/libcoretest/cell.rs b/src/libcoretest/cell.rs index a7c230ba979..724a312ea79 100644 --- a/src/libcoretest/cell.rs +++ b/src/libcoretest/cell.rs @@ -59,22 +59,22 @@ fn double_imm_borrow() { fn no_mut_then_imm_borrow() { let x = RefCell::new(0); let _b1 = x.borrow_mut(); - assert_eq!(x.borrow_state(), BorrowState::Writing); + assert!(x.try_borrow().is_err()); } #[test] fn no_imm_then_borrow_mut() { let x = RefCell::new(0); let _b1 = x.borrow(); - assert_eq!(x.borrow_state(), BorrowState::Reading); + assert!(x.try_borrow_mut().is_err()); } #[test] fn no_double_borrow_mut() { let x = RefCell::new(0); - assert_eq!(x.borrow_state(), BorrowState::Unused); + assert!(x.try_borrow().is_ok()); let _b1 = x.borrow_mut(); - assert_eq!(x.borrow_state(), BorrowState::Writing); + assert!(x.try_borrow().is_err()); } #[test] @@ -102,7 +102,8 @@ fn double_borrow_single_release_no_borrow_mut() { { let _b2 = x.borrow(); } - assert_eq!(x.borrow_state(), BorrowState::Reading); + assert!(x.try_borrow().is_ok()); + assert!(x.try_borrow_mut().is_err()); } #[test] @@ -119,14 +120,18 @@ fn ref_clone_updates_flag() { let x = RefCell::new(0); { let b1 = x.borrow(); - assert_eq!(x.borrow_state(), BorrowState::Reading); + assert!(x.try_borrow().is_ok()); + assert!(x.try_borrow_mut().is_err()); { let _b2 = Ref::clone(&b1); - assert_eq!(x.borrow_state(), BorrowState::Reading); + assert!(x.try_borrow().is_ok()); + assert!(x.try_borrow_mut().is_err()); } - assert_eq!(x.borrow_state(), BorrowState::Reading); + assert!(x.try_borrow().is_ok()); + assert!(x.try_borrow_mut().is_err()); } - assert_eq!(x.borrow_state(), BorrowState::Unused); + assert!(x.try_borrow().is_ok()); + assert!(x.try_borrow_mut().is_ok()); } #[test] @@ -134,15 +139,19 @@ fn ref_map_does_not_update_flag() { let x = RefCell::new(Some(5)); { let b1: Ref<Option<u32>> = x.borrow(); - assert_eq!(x.borrow_state(), BorrowState::Reading); + assert!(x.try_borrow().is_ok()); + assert!(x.try_borrow_mut().is_err()); { let b2: Ref<u32> = Ref::map(b1, |o| o.as_ref().unwrap()); assert_eq!(*b2, 5); - assert_eq!(x.borrow_state(), BorrowState::Reading); + assert!(x.try_borrow().is_ok()); + assert!(x.try_borrow_mut().is_err()); } - assert_eq!(x.borrow_state(), BorrowState::Unused); + assert!(x.try_borrow().is_ok()); + assert!(x.try_borrow_mut().is_ok()); } - assert_eq!(x.borrow_state(), BorrowState::Unused); + assert!(x.try_borrow().is_ok()); + assert!(x.try_borrow_mut().is_ok()); } #[test] @@ -247,5 +256,3 @@ fn refcell_ref_coercion() { assert_eq!(&*coerced, comp); } } - - diff --git a/src/libcoretest/lib.rs b/src/libcoretest/lib.rs index 05d98d4a212..d12616a97a6 100644 --- a/src/libcoretest/lib.rs +++ b/src/libcoretest/lib.rs @@ -10,9 +10,7 @@ #![deny(warnings)] -#![feature(borrow_state)] #![feature(box_syntax)] -#![feature(cell_extras)] #![feature(char_escape_debug)] #![feature(const_fn)] #![feature(core_private_bignum)] @@ -32,8 +30,6 @@ #![feature(try_from)] #![feature(unicode)] #![feature(unique)] -#![feature(iter_max_by)] -#![feature(iter_min_by)] #![feature(ordering_chaining)] #![feature(result_unwrap_or_default)] #![feature(ptr_unaligned)] diff --git a/src/librustc/dep_graph/shadow.rs b/src/librustc/dep_graph/shadow.rs index 06def4bf19a..5d4190a8ae1 100644 --- a/src/librustc/dep_graph/shadow.rs +++ b/src/librustc/dep_graph/shadow.rs @@ -27,7 +27,7 @@ //! created. See `./README.md` for details. use hir::def_id::DefId; -use std::cell::{BorrowState, RefCell}; +use std::cell::RefCell; use std::env; use super::DepNode; @@ -71,15 +71,11 @@ impl ShadowGraph { pub fn enqueue(&self, message: &DepMessage) { if ENABLED { - match self.stack.borrow_state() { - BorrowState::Unused => {} - _ => { - // When we apply edge filters, that invokes the - // Debug trait on DefIds, which in turn reads from - // various bits of state and creates reads! Ignore - // those recursive reads. - return; - } + if self.stack.try_borrow().is_err() { + // When we apply edge filters, that invokes the Debug trait on + // DefIds, which in turn reads from various bits of state and + // creates reads! Ignore those recursive reads. + return; } let mut stack = self.stack.borrow_mut(); diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 7c26b710a53..17cc34fcd83 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -24,7 +24,6 @@ #![cfg_attr(not(stage0), deny(warnings))] #![feature(associated_consts)] -#![feature(borrow_state)] #![feature(box_patterns)] #![feature(box_syntax)] #![feature(collections)] diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index ea5aa5be013..509ee704e2e 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -18,7 +18,6 @@ #![cfg_attr(not(stage0), deny(warnings))] #![feature(associated_consts)] -#![feature(borrow_state)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] #![feature(staged_api)] diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index b634d57a842..890891fd090 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -144,11 +144,9 @@ impl<'a> Resolver<'a> { -> Result<&'a NameBinding<'a>, Determinacy> { self.populate_module_if_necessary(module); - let resolution = self.resolution(module, name, ns); - let resolution = match resolution.borrow_state() { - ::std::cell::BorrowState::Unused => resolution.borrow_mut(), - _ => return Err(Determined), // This happens when there is a cycle of imports - }; + let resolution = self.resolution(module, name, ns) + .try_borrow_mut() + .map_err(|_| Determined)?; // This happens when there is a cycle of imports if let Some(span) = record_used { if let Some(binding) = resolution.binding { diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index e2da635b159..d842827b6fe 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -26,7 +26,6 @@ #![feature(associated_consts)] #![feature(box_patterns)] #![feature(box_syntax)] -#![feature(cell_extras)] #![feature(const_fn)] #![feature(custom_attribute)] #![allow(unused_attributes)] diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index 6419a9ff683..1a65bee13b8 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -10,7 +10,7 @@ use io::prelude::*; -use cell::{RefCell, BorrowState}; +use cell::RefCell; use fmt; use io::lazy::Lazy; use io::{self, BufReader, LineWriter}; @@ -638,8 +638,8 @@ pub fn _print(args: fmt::Arguments) { LocalKeyState::Destroyed => stdout().write_fmt(args), LocalKeyState::Valid => { LOCAL_STDOUT.with(|s| { - if s.borrow_state() == BorrowState::Unused { - if let Some(w) = s.borrow_mut().as_mut() { + if let Ok(mut borrowed) = s.try_borrow_mut() { + if let Some(w) = borrowed.as_mut() { return w.write_fmt(args); } } diff --git a/src/libstd/sys/redox/ext/process.rs b/src/libstd/sys/redox/ext/process.rs index 1472242d3db..c59524974bf 100644 --- a/src/libstd/sys/redox/ext/process.rs +++ b/src/libstd/sys/redox/ext/process.rs @@ -56,7 +56,7 @@ pub trait CommandExt { /// When this closure is run, aspects such as the stdio file descriptors and /// working directory have successfully been changed, so output to these /// locations may not appear where intended. - #[unstable(feature = "process_exec", issue = "31398")] + #[stable(feature = "process_exec", since = "1.15.0")] fn before_exec<F>(&mut self, f: F) -> &mut process::Command where F: FnMut() -> io::Result<()> + Send + Sync + 'static; diff --git a/src/libstd_unicode/char.rs b/src/libstd_unicode/char.rs index b6a502e8c1a..53dafadb5d5 100644 --- a/src/libstd_unicode/char.rs +++ b/src/libstd_unicode/char.rs @@ -460,7 +460,6 @@ impl char { /// A buffer that's too small: /// /// ``` - /// #![feature(unicode)] /// use std::thread; /// /// let result = thread::spawn(|| { @@ -501,7 +500,6 @@ impl char { /// A buffer that's too small: /// /// ``` - /// #![feature(unicode)] /// use std::thread; /// /// let result = thread::spawn(|| { diff --git a/src/libstd_unicode/lib.rs b/src/libstd_unicode/lib.rs index b086658ee0d..11724e74cda 100644 --- a/src/libstd_unicode/lib.rs +++ b/src/libstd_unicode/lib.rs @@ -39,7 +39,6 @@ #![feature(lang_items)] #![feature(staged_api)] #![feature(try_from)] -#![feature(unicode)] mod tables; mod u_str; |
