From 84e977c3557f414b1e94968ff63e324b8be273bf Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Mon, 30 Dec 2013 17:39:14 -0800 Subject: libstd: Remove a spurious `@mut` from a disabled test --- src/libstd/io/extensions.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs index a7361fa8c37..334007a8261 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/io/extensions.rs @@ -377,9 +377,10 @@ mod test { let mut reader = ErroringLaterReader { count: 0, }; - let buf = @mut ~[8, 9]; + // FIXME (#7049): Figure out some other way to do this. + //let buf = @mut ~[8, 9]; (|| { - reader.push_bytes(&mut *buf, 4); + //reader.push_bytes(&mut *buf, 4); }).finally(|| { // NB: Using rtassert here to trigger abort on failure since this is a should_fail test // FIXME: #7049 This fails because buf is still borrowed -- cgit 1.4.1-3-g733a5 From e095889e4edaa37ad78faa6394d0ac1d3650d64d Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Mon, 30 Dec 2013 17:46:48 -0800 Subject: libstd: De-`@mut` the `heap_cycles` test --- src/libstd/rt/task.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/rt/task.rs b/src/libstd/rt/task.rs index 583a1e0657c..ae12f944f9c 100644 --- a/src/libstd/rt/task.rs +++ b/src/libstd/rt/task.rs @@ -444,16 +444,20 @@ mod test { #[test] fn heap_cycles() { + use cell::RefCell; use option::{Option, Some, None}; struct List { - next: Option<@mut List>, + next: Option<@RefCell>, } - let a = @mut List { next: None }; - let b = @mut List { next: Some(a) }; + let a = @RefCell::new(List { next: None }); + let b = @RefCell::new(List { next: Some(a) }); - a.next = Some(b); + { + let mut a = a.borrow_mut(); + a.get().next = Some(b); + } } #[test] -- cgit 1.4.1-3-g733a5 From b6e516859adc2eb0638a50677f73691f50ea9aca Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Mon, 30 Dec 2013 17:49:00 -0800 Subject: libstd: Remove all support code related to `@mut` --- src/libextra/serialize.rs | 12 ------------ src/libstd/clone.rs | 31 ------------------------------- src/libstd/default.rs | 4 ---- src/libstd/managed.rs | 38 -------------------------------------- src/libstd/num/mod.rs | 5 ----- src/libstd/repr.rs | 3 --- src/libstd/to_bytes.rs | 7 ------- 7 files changed, 100 deletions(-) (limited to 'src/libstd') diff --git a/src/libextra/serialize.rs b/src/libextra/serialize.rs index 6b298d877da..e7ccb91fb75 100644 --- a/src/libextra/serialize.rs +++ b/src/libextra/serialize.rs @@ -426,18 +426,6 @@ impl + 'static> Decodable for @T { } } -impl> Encodable for @mut T { - fn encode(&self, s: &mut S) { - (**self).encode(s) - } -} - -impl + 'static> Decodable for @mut T { - fn decode(d: &mut D) -> @mut T { - @mut Decodable::decode(d) - } -} - impl<'a, S:Encoder,T:Encodable> Encodable for &'a [T] { fn encode(&self, s: &mut S) { s.emit_seq(self.len(), |s| { diff --git a/src/libstd/clone.rs b/src/libstd/clone.rs index b383c9edf36..b26ceb799a7 100644 --- a/src/libstd/clone.rs +++ b/src/libstd/clone.rs @@ -58,12 +58,6 @@ impl Clone for @T { fn clone(&self) -> @T { *self } } -impl Clone for @mut T { - /// Return a shallow copy of the managed box. - #[inline] - fn clone(&self) -> @mut T { *self } -} - impl<'a, T> Clone for &'a T { /// Return a shallow copy of the borrowed pointer. #[inline] @@ -168,14 +162,6 @@ impl DeepClone for @T { fn deep_clone(&self) -> @T { @(**self).deep_clone() } } -// FIXME: #6525: should also be implemented for `T: Send + DeepClone` -impl DeepClone for @mut T { - /// Return a deep copy of the managed box. The `Freeze` trait is required to prevent performing - /// a deep clone of a potentially cyclical type. - #[inline] - fn deep_clone(&self) -> @mut T { @mut (**self).deep_clone() } -} - macro_rules! deep_clone_impl( ($t:ty) => { impl DeepClone for $t { @@ -239,23 +225,6 @@ fn test_managed_clone() { assert_eq!(a, b); } -#[test] -fn test_managed_mut_deep_clone() { - let x = @mut 5i; - let y: @mut int = x.deep_clone(); - *x = 20; - assert_eq!(*y, 5); -} - -#[test] -fn test_managed_mut_clone() { - let a = @mut 5i; - let b: @mut int = a.clone(); - assert_eq!(a, b); - *b = 10; - assert_eq!(a, b); -} - #[test] fn test_borrowed_clone() { let x = 5i; diff --git a/src/libstd/default.rs b/src/libstd/default.rs index aaba23c683b..60f38e3b3de 100644 --- a/src/libstd/default.rs +++ b/src/libstd/default.rs @@ -16,10 +16,6 @@ pub trait Default { fn default() -> Self; } -impl Default for @mut T { - fn default() -> @mut T { @mut Default::default() } -} - impl Default for @T { fn default() -> @T { @Default::default() } } diff --git a/src/libstd/managed.rs b/src/libstd/managed.rs index 7322f0b0647..c5705665896 100644 --- a/src/libstd/managed.rs +++ b/src/libstd/managed.rs @@ -31,13 +31,6 @@ pub fn ptr_eq(a: @T, b: @T) -> bool { a_ptr == b_ptr } -/// Determine if two mutable shared boxes point to the same object -#[inline] -pub fn mut_ptr_eq(a: @mut T, b: @mut T) -> bool { - let (a_ptr, b_ptr): (*T, *T) = (to_unsafe_ptr(&*a), to_unsafe_ptr(&*b)); - a_ptr == b_ptr -} - #[cfg(not(test))] impl Eq for @T { #[inline] @@ -46,14 +39,6 @@ impl Eq for @T { fn ne(&self, other: &@T) -> bool { *(*self) != *(*other) } } -#[cfg(not(test))] -impl Eq for @mut T { - #[inline] - fn eq(&self, other: &@mut T) -> bool { *(*self) == *(*other) } - #[inline] - fn ne(&self, other: &@mut T) -> bool { *(*self) != *(*other) } -} - #[cfg(not(test))] impl Ord for @T { #[inline] @@ -66,41 +51,18 @@ impl Ord for @T { fn gt(&self, other: &@T) -> bool { *(*self) > *(*other) } } -#[cfg(not(test))] -impl Ord for @mut T { - #[inline] - fn lt(&self, other: &@mut T) -> bool { *(*self) < *(*other) } - #[inline] - fn le(&self, other: &@mut T) -> bool { *(*self) <= *(*other) } - #[inline] - fn ge(&self, other: &@mut T) -> bool { *(*self) >= *(*other) } - #[inline] - fn gt(&self, other: &@mut T) -> bool { *(*self) > *(*other) } -} - #[cfg(not(test))] impl TotalOrd for @T { #[inline] fn cmp(&self, other: &@T) -> Ordering { (**self).cmp(*other) } } -#[cfg(not(test))] -impl TotalOrd for @mut T { - #[inline] - fn cmp(&self, other: &@mut T) -> Ordering { (**self).cmp(*other) } -} - #[cfg(not(test))] impl TotalEq for @T { #[inline] fn equals(&self, other: &@T) -> bool { (**self).equals(*other) } } -#[cfg(not(test))] -impl TotalEq for @mut T { - #[inline] - fn equals(&self, other: &@mut T) -> bool { (**self).equals(*other) } -} #[test] fn test() { let x = @3; diff --git a/src/libstd/num/mod.rs b/src/libstd/num/mod.rs index 8dbec0f63c6..d66d13657fc 100644 --- a/src/libstd/num/mod.rs +++ b/src/libstd/num/mod.rs @@ -1079,11 +1079,6 @@ pub fn pow_with_uint+Mul>(radix: uint, pow: uin total } -impl Zero for @mut T { - fn zero() -> @mut T { @mut Zero::zero() } - fn is_zero(&self) -> bool { (**self).is_zero() } -} - impl Zero for @T { fn zero() -> @T { @Zero::zero() } fn is_zero(&self) -> bool { (**self).is_zero() } diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs index 2f9478716a3..e60abed42f2 100644 --- a/src/libstd/repr.rs +++ b/src/libstd/repr.rs @@ -655,13 +655,10 @@ fn test_repr() { exact_test(&(~"he\u10f3llo"), "~\"he\\u10f3llo\""); exact_test(&(@10), "@10"); - exact_test(&(@mut 10), "@mut 10"); - exact_test(&((@mut 10, 2)), "(@mut 10, 2)"); exact_test(&(~10), "~10"); exact_test(&(&10), "&10"); let mut x = 10; exact_test(&(&mut x), "&mut 10"); - exact_test(&(@mut [1, 2]), "@mut [1, 2]"); exact_test(&(0 as *()), "(0x0 as *())"); exact_test(&(0 as *mut ()), "(0x0 as *mut ())"); diff --git a/src/libstd/to_bytes.rs b/src/libstd/to_bytes.rs index 9de812ed385..bd1c49c6c24 100644 --- a/src/libstd/to_bytes.rs +++ b/src/libstd/to_bytes.rs @@ -319,13 +319,6 @@ impl IterBytes for @A { } } -impl IterBytes for @mut A { - #[inline] - fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { - (**self).iter_bytes(lsb0, f) - } -} - impl IterBytes for Rc { #[inline] fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { -- cgit 1.4.1-3-g733a5 From 80921536343e87d2f7d7f19ad90d63f50b557e06 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 3 Jan 2014 19:24:33 -0800 Subject: libsyntax: Fix tests. --- doc/tutorial.md | 1 - src/libstd/io/extensions.rs | 1 + src/libsyntax/ext/expand.rs | 19 ++++++++++--------- src/libsyntax/fold.rs | 2 +- src/libsyntax/print/pprust.rs | 6 ------ 5 files changed, 12 insertions(+), 17 deletions(-) (limited to 'src/libstd') diff --git a/doc/tutorial.md b/doc/tutorial.md index ce21edf1b40..35abe8e87d6 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -1469,7 +1469,6 @@ let mut owned = ~20; let mut value = 30; let borrowed = &mut value; -*managed = *owned + 10; *owned = *borrowed + 100; *borrowed = *managed + 1000; ~~~ diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs index 334007a8261..1b6d1171a52 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/io/extensions.rs @@ -371,6 +371,7 @@ mod test { #[test] #[should_fail] + #[ignore] // borrow issues with RefCell fn push_bytes_fail_reset_len() { // push_bytes unsafely sets the vector length. This is testing that // upon failure the length is reset correctly. diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index eaf18a454a0..aa7c26805c3 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1292,10 +1292,11 @@ mod test { let a3_name = gensym("a3"); // a context that renames from ("a",empty) to "a2" : let ctxt2 = new_rename(ast::Ident::new(a_name),a2_name,EMPTY_CTXT); - let pending_renames = - @RefCell::new(~[(ast::Ident::new(a_name),a2_name), - (ast::Ident{name:a_name,ctxt:ctxt2},a3_name)]); - let double_renamed = renames_to_fold(pending_renames).fold_crate(item_ast); + let mut pending_renames = ~[ + (ast::Ident::new(a_name),a2_name), + (ast::Ident{name:a_name,ctxt:ctxt2},a3_name) + ]; + let double_renamed = renames_to_fold(&mut pending_renames).fold_crate(item_ast); let mut path_finder = new_path_finder(~[]); visit::walk_crate(&mut path_finder, &double_renamed, ()); match path_finder.path_accumulator { @@ -1305,11 +1306,11 @@ mod test { } } - fn fake_print_crate(crate: &ast::Crate) { - let mut out = ~std::io::stderr() as ~std::io::Writer; - let s = pprust::rust_printer(out, get_ident_interner()); - pprust::print_crate_(s, crate); - } + //fn fake_print_crate(crate: &ast::Crate) { + // let mut out = ~std::io::stderr() as ~std::io::Writer; + // let mut s = pprust::rust_printer(out, get_ident_interner()); + // pprust::print_crate_(&mut s, crate); + //} fn expand_crate_str(crate_str: @str) -> ast::Crate { let (crate_ast,ps) = string_to_crate_and_sess(crate_str); diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index dea30d181da..47130a8e355 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -866,7 +866,7 @@ mod test { use super::*; // this version doesn't care about getting comments or docstrings in. - fn fake_print_crate(s: @pprust::ps, crate: &ast::Crate) { + fn fake_print_crate(s: &mut pprust::ps, crate: &ast::Crate) { pprust::print_mod(s, &crate.module, crate.attrs); } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 15dfacc41f1..9725d6e38de 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2453,12 +2453,6 @@ mod test { use codemap; use parse::token; - fn string_check (given : &T, expected: &T) { - if !(given == expected) { - fail!("given {:?}, expected {:?}", given, expected); - } - } - #[test] fn test_fun_to_str() { let abba_ident = token::str_to_ident("abba"); -- cgit 1.4.1-3-g733a5