diff options
| author | Steven Fackler <sfackler@gmail.com> | 2014-03-20 19:55:52 -0700 |
|---|---|---|
| committer | Steven Fackler <sfackler@gmail.com> | 2014-03-20 19:55:52 -0700 |
| commit | 181875ca50853418abaa525614252cf46bfce10f (patch) | |
| tree | f8180978f23634cddbd5574ec6058c861d43ff63 | |
| parent | 6eae7df43cd21b76fe91eeaf6ef2af9bd2a8fafc (diff) | |
| download | rust-181875ca50853418abaa525614252cf46bfce10f.tar.gz rust-181875ca50853418abaa525614252cf46bfce10f.zip | |
Remove RefCell::{with, with_mut}
These are superfluous now that we have fixed rvalue lifetimes and Deref.
| -rw-r--r-- | src/librustc/driver/driver.rs | 4 | ||||
| -rw-r--r-- | src/librustc/metadata/cstore.rs | 10 | ||||
| -rw-r--r-- | src/libstd/cell.rs | 59 | ||||
| -rw-r--r-- | src/libstd/gc.rs | 6 | ||||
| -rw-r--r-- | src/libstd/rc.rs | 6 |
5 files changed, 11 insertions, 74 deletions
diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index ae9cd37fe69..4676ada1727 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -313,10 +313,10 @@ pub fn phase_3_run_analysis_passes(sess: Session, time(time_passes, "looking for entry point", (), |_| middle::entry::find_entry_point(&sess, krate, &ast_map)); - sess.macro_registrar_fn.with_mut(|r| *r = + *sess.macro_registrar_fn.borrow_mut() = time(time_passes, "looking for macro registrar", (), |_| syntax::ext::registrar::find_macro_registrar( - sess.diagnostic(), krate))); + sess.diagnostic(), krate)); let freevars = time(time_passes, "freevar finding", (), |_| freevars::annotate_freevars(def_map, krate)); diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs index c1d3ad76260..f1089891ea5 100644 --- a/src/librustc/metadata/cstore.rs +++ b/src/librustc/metadata/cstore.rs @@ -135,11 +135,11 @@ impl CStore { } pub fn reset(&self) { - self.metas.with_mut(|s| s.clear()); - self.extern_mod_crate_map.with_mut(|s| s.clear()); - self.used_crate_sources.with_mut(|s| s.clear()); - self.used_libraries.with_mut(|s| s.clear()); - self.used_link_args.with_mut(|s| s.clear()); + self.metas.borrow_mut().clear(); + self.extern_mod_crate_map.borrow_mut().clear(); + self.used_crate_sources.borrow_mut().clear(); + self.used_libraries.borrow_mut().clear(); + self.used_link_args.borrow_mut().clear(); } // This method is used when generating the command line to pass through to diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs index 5733504c0d1..df1c29ded6e 100644 --- a/src/libstd/cell.rs +++ b/src/libstd/cell.rs @@ -173,28 +173,6 @@ impl<T> RefCell<T> { } } - /// Immutably borrows the wrapped value and applies `blk` to it. - /// - /// # Failure - /// - /// Fails if the value is currently mutably borrowed. - #[inline] - pub fn with<U>(&self, blk: |&T| -> U) -> U { - let ptr = self.borrow(); - blk(ptr.get()) - } - - /// Mutably borrows the wrapped value and applies `blk` to it. - /// - /// # Failure - /// - /// Fails if the value is currently borrowed. - #[inline] - pub fn with_mut<U>(&self, blk: |&mut T| -> U) -> U { - let mut ptr = self.borrow_mut(); - blk(ptr.get()) - } - /// Sets the value, replacing what was there. /// /// # Failure @@ -373,43 +351,6 @@ mod test { } #[test] - fn with_ok() { - let x = RefCell::new(0); - assert_eq!(1, x.with(|x| *x+1)); - } - - #[test] - #[should_fail] - fn mut_borrow_with() { - let x = RefCell::new(0); - let _b1 = x.borrow_mut(); - x.with(|x| *x+1); - } - - #[test] - fn borrow_with() { - let x = RefCell::new(0); - let _b1 = x.borrow(); - assert_eq!(1, x.with(|x| *x+1)); - } - - #[test] - fn with_mut_ok() { - let x = RefCell::new(0); - x.with_mut(|x| *x += 1); - let b = x.borrow(); - assert_eq!(1, *b.get()); - } - - #[test] - #[should_fail] - fn borrow_with_mut() { - let x = RefCell::new(0); - let _b = x.borrow(); - x.with_mut(|x| *x += 1); - } - - #[test] #[should_fail] fn discard_doesnt_unborrow() { let x = RefCell::new(0); diff --git a/src/libstd/gc.rs b/src/libstd/gc.rs index 907a2d21b69..7fb23d77f3c 100644 --- a/src/libstd/gc.rs +++ b/src/libstd/gc.rs @@ -87,10 +87,8 @@ mod tests { fn test_clone() { let x = Gc::new(RefCell::new(5)); let y = x.clone(); - x.borrow().with_mut(|inner| { - *inner = 20; - }); - assert_eq!(y.borrow().with(|x| *x), 20); + *x.borrow().borrow_mut() = 20; + assert_eq!(*y.borrow().borrow(), 20); } #[test] diff --git a/src/libstd/rc.rs b/src/libstd/rc.rs index 605cbd3f28a..c41e3b01f47 100644 --- a/src/libstd/rc.rs +++ b/src/libstd/rc.rs @@ -198,10 +198,8 @@ mod tests { fn test_clone() { let x = Rc::new(RefCell::new(5)); let y = x.clone(); - x.deref().with_mut(|inner| { - *inner = 20; - }); - assert_eq!(y.deref().with(|v| *v), 20); + *x.borrow_mut() = 20; + assert_eq!(*y.borrow(), 20); } #[test] |
