diff --git a/src/libstd/cmp.rs b/src/libstd/cmp.rs index fb42c69024624..6484bf298d2d9 100644 --- a/src/libstd/cmp.rs +++ b/src/libstd/cmp.rs @@ -1,34 +1,36 @@ #[deny(non_camel_case_types)]; +#[forbid(deprecated_mode)]; +#[forbid(deprecated_pattern)]; /// Additional general-purpose comparison functionality. const fuzzy_epsilon: float = 1.0e-6; trait FuzzyEq { - pure fn fuzzy_eq(&&other: self) -> bool; + pure fn fuzzy_eq(other: &self) -> bool; } impl float: FuzzyEq { - pure fn fuzzy_eq(&&other: float) -> bool { - return float::abs(self - other) < fuzzy_epsilon; + pure fn fuzzy_eq(other: &float) -> bool { + return float::abs(self - *other) < fuzzy_epsilon; } } impl f32: FuzzyEq { - pure fn fuzzy_eq(&&other: f32) -> bool { - return f32::abs(self - other) < (fuzzy_epsilon as f32); + pure fn fuzzy_eq(other: &f32) -> bool { + return f32::abs(self - *other) < (fuzzy_epsilon as f32); } } impl f64: FuzzyEq { - pure fn fuzzy_eq(&&other: f64) -> bool { - return f64::abs(self - other) < (fuzzy_epsilon as f64); + pure fn fuzzy_eq(other: &f64) -> bool { + return f64::abs(self - *other) < (fuzzy_epsilon as f64); } } #[test] fn test_fuzzy_equals() { - assert ((1.0).fuzzy_eq(1.0)); - assert ((1.0f32).fuzzy_eq(1.0f32)); - assert ((1.0f64).fuzzy_eq(1.0f64)); + assert ((&1.0).fuzzy_eq(&1.0)); + assert ((&1.0f32).fuzzy_eq(&1.0f32)); + assert ((&1.0f64).fuzzy_eq(&1.0f64)); } diff --git a/src/libstd/dbg.rs b/src/libstd/dbg.rs index 5ae16759b2fa8..386cfee1a6a78 100644 --- a/src/libstd/dbg.rs +++ b/src/libstd/dbg.rs @@ -1,4 +1,6 @@ #[deny(non_camel_case_types)]; +#[forbid(deprecated_mode)]; +#[forbid(deprecated_pattern)]; //! Unsafe debugging functions for inspecting values. import unsafe::reinterpret_cast; @@ -26,7 +28,7 @@ fn debug_tydesc() { rustrt::debug_tydesc(sys::get_type_desc::()); } -fn debug_opaque(x: T) { +fn debug_opaque(+x: T) { rustrt::debug_opaque(sys::get_type_desc::(), ptr::addr_of(x) as *()); } @@ -34,11 +36,11 @@ fn debug_box(x: @T) { rustrt::debug_box(sys::get_type_desc::(), ptr::addr_of(x) as *()); } -fn debug_tag(x: T) { +fn debug_tag(+x: T) { rustrt::debug_tag(sys::get_type_desc::(), ptr::addr_of(x) as *()); } -fn debug_fn(x: T) { +fn debug_fn(+x: T) { rustrt::debug_fn(sys::get_type_desc::(), ptr::addr_of(x) as *()); } diff --git a/src/libstd/list.rs b/src/libstd/list.rs index 651eb1ab077df..e1ff5c8b352b6 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -1,4 +1,6 @@ //! A standard linked list +#[forbid(deprecated_mode)]; +#[forbid(deprecated_pattern)]; import core::cmp::Eq; import core::option; @@ -28,9 +30,9 @@ fn from_vec(v: &[T]) -> @list { * * z - The initial value * * f - The function to apply */ -fn foldl(z: T, ls: @list, f: fn(T, U) -> T) -> T { +fn foldl(+z: T, ls: @list, f: fn((&T), (&U)) -> T) -> T { let mut accum: T = z; - do iter(ls) |elt| { accum = f(accum, elt);} + do iter(ls) |elt| { accum = f(&accum, &elt);} accum } @@ -41,12 +43,12 @@ fn foldl(z: T, ls: @list, f: fn(T, U) -> T) -> T { * When function `f` returns true then an option containing the element * is returned. If `f` matches no elements then none is returned. */ -fn find(ls: @list, f: fn(T) -> bool) -> Option { +fn find(ls: @list, f: fn((&T)) -> bool) -> Option { let mut ls = ls; loop { ls = match *ls { cons(hd, tl) => { - if f(hd) { return Some(hd); } + if f(&hd) { return Some(hd); } tl } nil => return None @@ -55,7 +57,7 @@ fn find(ls: @list, f: fn(T) -> bool) -> Option { } /// Returns true if a list contains an element with the given value -fn has(ls: @list, elt: T) -> bool { +fn has(ls: @list, +elt: T) -> bool { for each(ls) |e| { if e == elt { return true; } } @@ -110,10 +112,13 @@ pure fn append(l: @list, m: @list) -> @list { } } -/// Push an element to the front of a list -fn push(&l: list, v: T) { - l = cons(v, @l); +/* +/// Push one element into the front of a list, returning a new list +/// THIS VERSION DOESN'T ACTUALLY WORK +pure fn push(ll: &mut @list, +vv: T) { + ll = &mut @cons(vv, *ll) } +*/ /// Iterate over a list fn iter(l: @list, f: fn(T)) { @@ -201,7 +206,7 @@ mod tests { #[test] fn test_foldl() { - fn add(&&a: uint, &&b: int) -> uint { return a + (b as uint); } + fn add(a: &uint, b: &int) -> uint { return *a + (*b as uint); } let l = from_vec(~[0, 1, 2, 3, 4]); let empty = @list::nil::; assert (list::foldl(0u, l, add) == 10u); @@ -210,8 +215,8 @@ mod tests { #[test] fn test_foldl2() { - fn sub(&&a: int, &&b: int) -> int { - a - b + fn sub(a: &int, b: &int) -> int { + *a - *b } let l = from_vec(~[1, 2, 3, 4]); assert (list::foldl(0, l, sub) == -10); @@ -219,14 +224,14 @@ mod tests { #[test] fn test_find_success() { - fn match_(&&i: int) -> bool { return i == 2; } + fn match_(i: &int) -> bool { return *i == 2; } let l = from_vec(~[0, 1, 2]); assert (list::find(l, match_) == option::Some(2)); } #[test] fn test_find_fail() { - fn match_(&&_i: int) -> bool { return false; } + fn match_(_i: &int) -> bool { return false; } let l = from_vec(~[0, 1, 2]); let empty = @list::nil::; assert (list::find(l, match_) == option::None::); @@ -251,6 +256,11 @@ mod tests { assert (list::len(empty) == 0u); } + #[test] + fn test_append() { + assert from_vec(~[1,2,3,4]) + == list::append(list::from_vec(~[1,2]), list::from_vec(~[3,4])); + } } // Local Variables: diff --git a/src/libstd/prettyprint.rs b/src/libstd/prettyprint.rs index 259bb4eb612e3..d9e64d7b1a0de 100644 --- a/src/libstd/prettyprint.rs +++ b/src/libstd/prettyprint.rs @@ -1,3 +1,6 @@ +#[forbid(deprecated_mode)]; +#[forbid(deprecated_pattern)]; + import io::Writer; import io::WriterUtil; import serialization::serializer; diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index 32a97bac5086d..12676377defaf 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -23,6 +23,8 @@ * * access to a character by index is logarithmic (linear in strings); */ +#[forbid(deprecated_mode)]; +#[forbid(deprecated_pattern)]; /// The type of ropes. type rope = node::root; @@ -436,7 +438,7 @@ mod iterator { node::content(x) => return node::leaf_iterator::start(x) } } - fn next(it: node::leaf_iterator::t) -> Option { + fn next(it: &node::leaf_iterator::t) -> Option { return node::leaf_iterator::next(it); } } @@ -447,7 +449,7 @@ mod iterator { node::content(x) => return node::char_iterator::start(x) } } - fn next(it: node::char_iterator::t) -> Option { + fn next(it: &node::char_iterator::t) -> Option { return node::char_iterator::next(it) } } @@ -751,7 +753,7 @@ mod node { * * forest - The forest. This vector is progressively rewritten during * execution and should be discarded as meaningless afterwards. */ - fn tree_from_forest_destructive(forest: ~[mut @node]) -> @node { + fn tree_from_forest_destructive(forest: &[mut @node]) -> @node { let mut i; let mut len = vec::len(forest); while len > 1u { @@ -800,7 +802,7 @@ mod node { let mut offset = 0u;//Current position in the buffer let it = leaf_iterator::start(node); loop { - match (leaf_iterator::next(it)) { + match (leaf_iterator::next(&it)) { option::None => break, option::Some(x) => { //FIXME (#2744): Replace with memcpy or something similar @@ -861,7 +863,7 @@ mod node { let mut forest = ~[mut]; let it = leaf_iterator::start(node); loop { - match (leaf_iterator::next(it)) { + match (leaf_iterator::next(&it)) { option::None => break, option::Some(x) => vec::push(forest, @leaf(x)) } @@ -1018,7 +1020,7 @@ mod node { let itb = char_iterator::start(b); let mut result = 0; while result == 0 { - match ((char_iterator::next(ita), char_iterator::next(itb))) { + match ((char_iterator::next(&ita), char_iterator::next(&itb))) { (option::None, option::None) => break, (option::Some(chara), option::Some(charb)) => { result = char::cmp(chara, charb); @@ -1121,7 +1123,7 @@ mod node { } } - fn next(it: t) -> Option { + fn next(it: &t) -> Option { if it.stackpos < 0 { return option::None; } loop { let current = it.stack[it.stackpos]; @@ -1162,7 +1164,7 @@ mod node { } } - fn next(it: t) -> Option { + fn next(it: &t) -> Option { loop { match (get_current_or_next_leaf(it)) { option::None => return option::None, @@ -1177,16 +1179,16 @@ mod node { }; } - fn get_current_or_next_leaf(it: t) -> Option { - match (it.leaf) { - option::Some(_) => return it.leaf, + fn get_current_or_next_leaf(it: &t) -> Option { + match ((*it).leaf) { + option::Some(_) => return (*it).leaf, option::None => { - let next = leaf_iterator::next(it.leaf_iterator); + let next = leaf_iterator::next(&((*it).leaf_iterator)); match (next) { option::None => return option::None, option::Some(_) => { - it.leaf = next; - it.leaf_byte_pos = 0u; + (*it).leaf = next; + (*it).leaf_byte_pos = 0u; return next; } } @@ -1194,19 +1196,19 @@ mod node { } } - fn get_next_char_in_leaf(it: t) -> Option { - match copy it.leaf { + fn get_next_char_in_leaf(it: &t) -> Option { + match copy (*it).leaf { option::None => return option::None, option::Some(aleaf) => { - if it.leaf_byte_pos >= aleaf.byte_len { + if (*it).leaf_byte_pos >= aleaf.byte_len { //We are actually past the end of the leaf - it.leaf = option::None; + (*it).leaf = option::None; return option::None } else { let {ch, next} = str::char_range_at(*aleaf.content, - it.leaf_byte_pos + aleaf.byte_offset); - it.leaf_byte_pos = next - aleaf.byte_offset; + (*it).leaf_byte_pos + aleaf.byte_offset); + (*it).leaf_byte_pos = next - aleaf.byte_offset; return option::Some(ch) } } @@ -1274,7 +1276,7 @@ mod tests { let rope_iter = iterator::char::start(r); let mut equal = true; while equal { - match (node::char_iterator::next(rope_iter)) { + match (node::char_iterator::next(&rope_iter)) { option::None => { if string_iter < string_len { equal = false; @@ -1301,7 +1303,7 @@ mod tests { let mut len = 0u; let it = iterator::char::start(r); loop { - match (node::char_iterator::next(it)) { + match (node::char_iterator::next(&it)) { option::None => break, option::Some(_) => len += 1u } diff --git a/src/libstd/tempfile.rs b/src/libstd/tempfile.rs index a10e4605f615c..5d2a04c038870 100644 --- a/src/libstd/tempfile.rs +++ b/src/libstd/tempfile.rs @@ -1,5 +1,8 @@ //! Temporary files and directories +#[forbid(deprecated_mode)]; +#[forbid(deprecated_pattern)]; + import core::option; import option::{None, Some}; import rand; diff --git a/src/rustc/middle/trans/type_use.rs b/src/rustc/middle/trans/type_use.rs index 841dbe7f82add..53b150a8b6c83 100644 --- a/src/rustc/middle/trans/type_use.rs +++ b/src/rustc/middle/trans/type_use.rs @@ -140,7 +140,7 @@ fn type_needs_inner(cx: ctx, use: uint, ty: ty::t, ty::ty_fn(_) | ty::ty_ptr(_) | ty::ty_rptr(_, _) | ty::ty_trait(_, _, _) => false, ty::ty_enum(did, substs) => { - if option::is_none(list::find(enums_seen, |id| id == did)) { + if option::is_none(list::find(enums_seen, |id| *id == did)) { let seen = @cons(did, enums_seen); for vec::each(*ty::enum_variants(cx.ccx.tcx, did)) |v| { for vec::each(v.args) |aty| {