Merge pull request #3308 from killerswan/modes7
Remove deprecated modes
This commit is contained in:
commit
afc1ccd282
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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<T>() {
|
||||
rustrt::debug_tydesc(sys::get_type_desc::<T>());
|
||||
}
|
||||
|
||||
fn debug_opaque<T>(x: T) {
|
||||
fn debug_opaque<T>(+x: T) {
|
||||
rustrt::debug_opaque(sys::get_type_desc::<T>(), ptr::addr_of(x) as *());
|
||||
}
|
||||
|
||||
@ -34,11 +36,11 @@ fn debug_box<T>(x: @T) {
|
||||
rustrt::debug_box(sys::get_type_desc::<T>(), ptr::addr_of(x) as *());
|
||||
}
|
||||
|
||||
fn debug_tag<T>(x: T) {
|
||||
fn debug_tag<T>(+x: T) {
|
||||
rustrt::debug_tag(sys::get_type_desc::<T>(), ptr::addr_of(x) as *());
|
||||
}
|
||||
|
||||
fn debug_fn<T>(x: T) {
|
||||
fn debug_fn<T>(+x: T) {
|
||||
rustrt::debug_fn(sys::get_type_desc::<T>(), ptr::addr_of(x) as *());
|
||||
}
|
||||
|
||||
|
@ -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<T: copy>(v: &[T]) -> @list<T> {
|
||||
* * z - The initial value
|
||||
* * f - The function to apply
|
||||
*/
|
||||
fn foldl<T: copy, U>(z: T, ls: @list<U>, f: fn(T, U) -> T) -> T {
|
||||
fn foldl<T: copy, U>(+z: T, ls: @list<U>, 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<T: copy, U>(z: T, ls: @list<U>, 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<T: copy>(ls: @list<T>, f: fn(T) -> bool) -> Option<T> {
|
||||
fn find<T: copy>(ls: @list<T>, f: fn((&T)) -> bool) -> Option<T> {
|
||||
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<T: copy>(ls: @list<T>, f: fn(T) -> bool) -> Option<T> {
|
||||
}
|
||||
|
||||
/// Returns true if a list contains an element with the given value
|
||||
fn has<T: copy Eq>(ls: @list<T>, elt: T) -> bool {
|
||||
fn has<T: copy Eq>(ls: @list<T>, +elt: T) -> bool {
|
||||
for each(ls) |e| {
|
||||
if e == elt { return true; }
|
||||
}
|
||||
@ -110,10 +112,13 @@ pure fn append<T: copy>(l: @list<T>, m: @list<T>) -> @list<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Push an element to the front of a list
|
||||
fn push<T: copy>(&l: list<T>, 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<T: copy>(ll: &mut @list<T>, +vv: T) {
|
||||
ll = &mut @cons(vv, *ll)
|
||||
}
|
||||
*/
|
||||
|
||||
/// Iterate over a list
|
||||
fn iter<T>(l: @list<T>, 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::<int>;
|
||||
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::<int>;
|
||||
assert (list::find(l, match_) == option::None::<int>);
|
||||
@ -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:
|
||||
|
@ -1,3 +1,6 @@
|
||||
#[forbid(deprecated_mode)];
|
||||
#[forbid(deprecated_pattern)];
|
||||
|
||||
import io::Writer;
|
||||
import io::WriterUtil;
|
||||
import serialization::serializer;
|
||||
|
@ -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<node::leaf> {
|
||||
fn next(it: &node::leaf_iterator::t) -> Option<node::leaf> {
|
||||
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<char> {
|
||||
fn next(it: &node::char_iterator::t) -> Option<char> {
|
||||
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<leaf> {
|
||||
fn next(it: &t) -> Option<leaf> {
|
||||
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<char> {
|
||||
fn next(it: &t) -> Option<char> {
|
||||
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<leaf> {
|
||||
match (it.leaf) {
|
||||
option::Some(_) => return it.leaf,
|
||||
fn get_current_or_next_leaf(it: &t) -> Option<leaf> {
|
||||
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<char> {
|
||||
match copy it.leaf {
|
||||
fn get_next_char_in_leaf(it: &t) -> Option<char> {
|
||||
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
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
//! Temporary files and directories
|
||||
|
||||
#[forbid(deprecated_mode)];
|
||||
#[forbid(deprecated_pattern)];
|
||||
|
||||
import core::option;
|
||||
import option::{None, Some};
|
||||
import rand;
|
||||
|
@ -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| {
|
||||
|
Loading…
x
Reference in New Issue
Block a user