Skip to content

Commit 9a5cef4

Browse files
committed
Address fallout
1 parent fce6af2 commit 9a5cef4

File tree

16 files changed

+44
-83
lines changed

16 files changed

+44
-83
lines changed

src/liballoc/rc.rs

+2-31
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl<T> Rc<T> {
320320
#[inline]
321321
#[stable(feature = "rc_unique", since = "1.4.0")]
322322
pub fn try_unwrap(this: Self) -> Result<T, Self> {
323-
if Rc::would_unwrap(&this) {
323+
if Rc::strong_count(&this) == 1 {
324324
unsafe {
325325
let val = ptr::read(&*this); // copy the contained object
326326

@@ -343,23 +343,6 @@ impl<T> Rc<T> {
343343
///
344344
/// [try_unwrap]: struct.Rc.html#method.try_unwrap
345345
/// [`Ok`]: ../../std/result/enum.Result.html#variant.Ok
346-
///
347-
/// # Examples
348-
///
349-
/// ```
350-
/// #![feature(rc_would_unwrap)]
351-
///
352-
/// use std::rc::Rc;
353-
///
354-
/// let x = Rc::new(3);
355-
/// assert!(Rc::would_unwrap(&x));
356-
/// assert_eq!(Rc::try_unwrap(x), Ok(3));
357-
///
358-
/// let x = Rc::new(4);
359-
/// let _y = x.clone();
360-
/// assert!(!Rc::would_unwrap(&x));
361-
/// assert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
362-
/// ```
363346
#[unstable(feature = "rc_would_unwrap",
364347
reason = "just added for niche usecase",
365348
issue = "28356")]
@@ -518,20 +501,8 @@ impl<T: ?Sized> Rc<T> {
518501
/// this inner value.
519502
///
520503
/// [weak]: struct.Weak.html
521-
///
522-
/// # Examples
523-
///
524-
/// ```
525-
/// #![feature(rc_counts)]
526-
///
527-
/// use std::rc::Rc;
528-
///
529-
/// let five = Rc::new(5);
530-
///
531-
/// assert!(Rc::is_unique(&five));
532-
/// ```
533504
#[inline]
534-
#[unstable(feature = "rc_counts", reason = "uniqueness has unclear meaning",
505+
#[unstable(feature = "is_unique", reason = "uniqueness has unclear meaning",
535506
issue = "28356")]
536507
#[rustc_deprecated(since = "1.15.0",
537508
reason = "too niche; use `strong_count` and `weak_count` instead")]

src/libcollectionstest/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#![feature(test)]
3030
#![feature(unboxed_closures)]
3131
#![feature(unicode)]
32-
#![feature(vec_into_iter_as_slice)]
3332

3433
extern crate collections;
3534
extern crate test;

src/libcore/cell.rs

+2
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ pub struct RefCell<T: ?Sized> {
394394
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
395395
#[unstable(feature = "borrow_state", issue = "27733")]
396396
#[rustc_deprecated(since = "1.15.0", reason = "use `try_borrow` instead")]
397+
#[allow(deprecated)]
397398
pub enum BorrowState {
398399
/// The cell is currently being read, there is at least one active `borrow`.
399400
Reading,
@@ -513,6 +514,7 @@ impl<T: ?Sized> RefCell<T> {
513514
/// ```
514515
#[unstable(feature = "borrow_state", issue = "27733")]
515516
#[rustc_deprecated(since = "1.15.0", reason = "use `try_borrow` instead")]
517+
#[allow(deprecated)]
516518
#[inline]
517519
pub fn borrow_state(&self) -> BorrowState {
518520
match self.borrow.get() {

src/libcore/fmt/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
1414

15-
use cell::{UnsafeCell, Cell, RefCell, Ref, RefMut, BorrowState};
15+
use cell::{UnsafeCell, Cell, RefCell, Ref, RefMut};
1616
use marker::PhantomData;
1717
use mem;
1818
use num::flt2dec;
@@ -1634,13 +1634,13 @@ impl<T: Copy + Debug> Debug for Cell<T> {
16341634
#[stable(feature = "rust1", since = "1.0.0")]
16351635
impl<T: ?Sized + Debug> Debug for RefCell<T> {
16361636
fn fmt(&self, f: &mut Formatter) -> Result {
1637-
match self.borrow_state() {
1638-
BorrowState::Unused | BorrowState::Reading => {
1637+
match self.try_borrow() {
1638+
Ok(borrow) => {
16391639
f.debug_struct("RefCell")
1640-
.field("value", &self.borrow())
1640+
.field("value", &borrow)
16411641
.finish()
16421642
}
1643-
BorrowState::Writing => {
1643+
Err(_) => {
16441644
f.debug_struct("RefCell")
16451645
.field("value", &"<borrowed>")
16461646
.finish()

src/libcore/iter/iterator.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1696,7 +1696,6 @@ pub trait Iterator {
16961696
/// # Examples
16971697
///
16981698
/// ```
1699-
/// #![feature(iter_max_by)]
17001699
/// let a = [-3_i32, 0, 1, 5, -10];
17011700
/// assert_eq!(*a.iter().max_by(|x, y| x.cmp(y)).unwrap(), 5);
17021701
/// ```
@@ -1746,7 +1745,6 @@ pub trait Iterator {
17461745
/// # Examples
17471746
///
17481747
/// ```
1749-
/// #![feature(iter_min_by)]
17501748
/// let a = [-3_i32, 0, 1, 5, -10];
17511749
/// assert_eq!(*a.iter().min_by(|x, y| x.cmp(y)).unwrap(), -10);
17521750
/// ```

src/libcoretest/cell.rs

+22-15
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,22 @@ fn double_imm_borrow() {
5959
fn no_mut_then_imm_borrow() {
6060
let x = RefCell::new(0);
6161
let _b1 = x.borrow_mut();
62-
assert_eq!(x.borrow_state(), BorrowState::Writing);
62+
assert!(x.try_borrow().is_err());
6363
}
6464

6565
#[test]
6666
fn no_imm_then_borrow_mut() {
6767
let x = RefCell::new(0);
6868
let _b1 = x.borrow();
69-
assert_eq!(x.borrow_state(), BorrowState::Reading);
69+
assert!(x.try_borrow_mut().is_err());
7070
}
7171

7272
#[test]
7373
fn no_double_borrow_mut() {
7474
let x = RefCell::new(0);
75-
assert_eq!(x.borrow_state(), BorrowState::Unused);
75+
assert!(x.try_borrow().is_ok());
7676
let _b1 = x.borrow_mut();
77-
assert_eq!(x.borrow_state(), BorrowState::Writing);
77+
assert!(x.try_borrow().is_err());
7878
}
7979

8080
#[test]
@@ -102,7 +102,8 @@ fn double_borrow_single_release_no_borrow_mut() {
102102
{
103103
let _b2 = x.borrow();
104104
}
105-
assert_eq!(x.borrow_state(), BorrowState::Reading);
105+
assert!(x.try_borrow().is_ok());
106+
assert!(x.try_borrow_mut().is_err());
106107
}
107108

108109
#[test]
@@ -119,30 +120,38 @@ fn ref_clone_updates_flag() {
119120
let x = RefCell::new(0);
120121
{
121122
let b1 = x.borrow();
122-
assert_eq!(x.borrow_state(), BorrowState::Reading);
123+
assert!(x.try_borrow().is_ok());
124+
assert!(x.try_borrow_mut().is_err());
123125
{
124126
let _b2 = Ref::clone(&b1);
125-
assert_eq!(x.borrow_state(), BorrowState::Reading);
127+
assert!(x.try_borrow().is_ok());
128+
assert!(x.try_borrow_mut().is_err());
126129
}
127-
assert_eq!(x.borrow_state(), BorrowState::Reading);
130+
assert!(x.try_borrow().is_ok());
131+
assert!(x.try_borrow_mut().is_err());
128132
}
129-
assert_eq!(x.borrow_state(), BorrowState::Unused);
133+
assert!(x.try_borrow().is_ok());
134+
assert!(x.try_borrow_mut().is_ok());
130135
}
131136

132137
#[test]
133138
fn ref_map_does_not_update_flag() {
134139
let x = RefCell::new(Some(5));
135140
{
136141
let b1: Ref<Option<u32>> = x.borrow();
137-
assert_eq!(x.borrow_state(), BorrowState::Reading);
142+
assert!(x.try_borrow().is_ok());
143+
assert!(x.try_borrow_mut().is_err());
138144
{
139145
let b2: Ref<u32> = Ref::map(b1, |o| o.as_ref().unwrap());
140146
assert_eq!(*b2, 5);
141-
assert_eq!(x.borrow_state(), BorrowState::Reading);
147+
assert!(x.try_borrow().is_ok());
148+
assert!(x.try_borrow_mut().is_err());
142149
}
143-
assert_eq!(x.borrow_state(), BorrowState::Unused);
150+
assert!(x.try_borrow().is_ok());
151+
assert!(x.try_borrow_mut().is_ok());
144152
}
145-
assert_eq!(x.borrow_state(), BorrowState::Unused);
153+
assert!(x.try_borrow().is_ok());
154+
assert!(x.try_borrow_mut().is_ok());
146155
}
147156

148157
#[test]
@@ -247,5 +256,3 @@ fn refcell_ref_coercion() {
247256
assert_eq!(&*coerced, comp);
248257
}
249258
}
250-
251-

src/libcoretest/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010

1111
#![deny(warnings)]
1212

13-
#![feature(borrow_state)]
1413
#![feature(box_syntax)]
15-
#![feature(cell_extras)]
1614
#![feature(char_escape_debug)]
1715
#![feature(const_fn)]
1816
#![feature(core_private_bignum)]
@@ -32,8 +30,6 @@
3230
#![feature(try_from)]
3331
#![feature(unicode)]
3432
#![feature(unique)]
35-
#![feature(iter_max_by)]
36-
#![feature(iter_min_by)]
3733
#![feature(ordering_chaining)]
3834
#![feature(result_unwrap_or_default)]
3935
#![feature(ptr_unaligned)]

src/librustc/dep_graph/shadow.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
//! created. See `./README.md` for details.
2828
2929
use hir::def_id::DefId;
30-
use std::cell::{BorrowState, RefCell};
30+
use std::cell::RefCell;
3131
use std::env;
3232

3333
use super::DepNode;
@@ -71,15 +71,11 @@ impl ShadowGraph {
7171

7272
pub fn enqueue(&self, message: &DepMessage) {
7373
if ENABLED {
74-
match self.stack.borrow_state() {
75-
BorrowState::Unused => {}
76-
_ => {
77-
// When we apply edge filters, that invokes the
78-
// Debug trait on DefIds, which in turn reads from
79-
// various bits of state and creates reads! Ignore
80-
// those recursive reads.
81-
return;
82-
}
74+
if self.stack.try_borrow().is_err() {
75+
// When we apply edge filters, that invokes the Debug trait on
76+
// DefIds, which in turn reads from various bits of state and
77+
// creates reads! Ignore those recursive reads.
78+
return;
8379
}
8480

8581
let mut stack = self.stack.borrow_mut();

src/librustc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#![cfg_attr(not(stage0), deny(warnings))]
2525

2626
#![feature(associated_consts)]
27-
#![feature(borrow_state)]
2827
#![feature(box_patterns)]
2928
#![feature(box_syntax)]
3029
#![feature(collections)]

src/librustc_resolve/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#![cfg_attr(not(stage0), deny(warnings))]
1919

2020
#![feature(associated_consts)]
21-
#![feature(borrow_state)]
2221
#![feature(rustc_diagnostic_macros)]
2322
#![feature(rustc_private)]
2423
#![feature(staged_api)]

src/librustc_resolve/resolve_imports.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,9 @@ impl<'a> Resolver<'a> {
144144
-> Result<&'a NameBinding<'a>, Determinacy> {
145145
self.populate_module_if_necessary(module);
146146

147-
let resolution = self.resolution(module, name, ns);
148-
let resolution = match resolution.borrow_state() {
149-
::std::cell::BorrowState::Unused => resolution.borrow_mut(),
150-
_ => return Err(Determined), // This happens when there is a cycle of imports
151-
};
147+
let resolution = self.resolution(module, name, ns)
148+
.try_borrow_mut()
149+
.map_err(|_| Determined)?; // This happens when there is a cycle of imports
152150

153151
if let Some(span) = record_used {
154152
if let Some(binding) = resolution.binding {

src/librustc_trans/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#![feature(associated_consts)]
2727
#![feature(box_patterns)]
2828
#![feature(box_syntax)]
29-
#![feature(cell_extras)]
3029
#![feature(const_fn)]
3130
#![feature(custom_attribute)]
3231
#![allow(unused_attributes)]

src/libstd/io/stdio.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use io::prelude::*;
1212

13-
use cell::{RefCell, BorrowState};
13+
use cell::RefCell;
1414
use fmt;
1515
use io::lazy::Lazy;
1616
use io::{self, BufReader, LineWriter};
@@ -638,8 +638,8 @@ pub fn _print(args: fmt::Arguments) {
638638
LocalKeyState::Destroyed => stdout().write_fmt(args),
639639
LocalKeyState::Valid => {
640640
LOCAL_STDOUT.with(|s| {
641-
if s.borrow_state() == BorrowState::Unused {
642-
if let Some(w) = s.borrow_mut().as_mut() {
641+
if let Ok(mut borrowed) = s.try_borrow_mut() {
642+
if let Some(w) = borrowed.as_mut() {
643643
return w.write_fmt(args);
644644
}
645645
}

src/libstd/sys/redox/ext/process.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub trait CommandExt {
5656
/// When this closure is run, aspects such as the stdio file descriptors and
5757
/// working directory have successfully been changed, so output to these
5858
/// locations may not appear where intended.
59-
#[unstable(feature = "process_exec", issue = "31398")]
59+
#[stable(feature = "process_exec", since = "1.15.0")]
6060
fn before_exec<F>(&mut self, f: F) -> &mut process::Command
6161
where F: FnMut() -> io::Result<()> + Send + Sync + 'static;
6262

src/libstd_unicode/char.rs

-2
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,6 @@ impl char {
460460
/// A buffer that's too small:
461461
///
462462
/// ```
463-
/// #![feature(unicode)]
464463
/// use std::thread;
465464
///
466465
/// let result = thread::spawn(|| {
@@ -501,7 +500,6 @@ impl char {
501500
/// A buffer that's too small:
502501
///
503502
/// ```
504-
/// #![feature(unicode)]
505503
/// use std::thread;
506504
///
507505
/// let result = thread::spawn(|| {

src/libstd_unicode/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#![feature(lang_items)]
4040
#![feature(staged_api)]
4141
#![feature(try_from)]
42-
#![feature(unicode)]
4342

4443
mod tables;
4544
mod u_str;

0 commit comments

Comments
 (0)