Skip to content

Commit afc1ccd

Browse files
committed
Merge pull request #3308 from killerswan/modes7
Remove deprecated modes
2 parents 3cd54ab + 7d57b48 commit afc1ccd

File tree

7 files changed

+71
-49
lines changed

7 files changed

+71
-49
lines changed

src/libstd/cmp.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
11
#[deny(non_camel_case_types)];
2+
#[forbid(deprecated_mode)];
3+
#[forbid(deprecated_pattern)];
24
/// Additional general-purpose comparison functionality.
35
46
const fuzzy_epsilon: float = 1.0e-6;
57

68
trait FuzzyEq {
7-
pure fn fuzzy_eq(&&other: self) -> bool;
9+
pure fn fuzzy_eq(other: &self) -> bool;
810
}
911

1012
impl float: FuzzyEq {
11-
pure fn fuzzy_eq(&&other: float) -> bool {
12-
return float::abs(self - other) < fuzzy_epsilon;
13+
pure fn fuzzy_eq(other: &float) -> bool {
14+
return float::abs(self - *other) < fuzzy_epsilon;
1315
}
1416
}
1517

1618
impl f32: FuzzyEq {
17-
pure fn fuzzy_eq(&&other: f32) -> bool {
18-
return f32::abs(self - other) < (fuzzy_epsilon as f32);
19+
pure fn fuzzy_eq(other: &f32) -> bool {
20+
return f32::abs(self - *other) < (fuzzy_epsilon as f32);
1921
}
2022
}
2123

2224
impl f64: FuzzyEq {
23-
pure fn fuzzy_eq(&&other: f64) -> bool {
24-
return f64::abs(self - other) < (fuzzy_epsilon as f64);
25+
pure fn fuzzy_eq(other: &f64) -> bool {
26+
return f64::abs(self - *other) < (fuzzy_epsilon as f64);
2527
}
2628
}
2729

2830
#[test]
2931
fn test_fuzzy_equals() {
30-
assert ((1.0).fuzzy_eq(1.0));
31-
assert ((1.0f32).fuzzy_eq(1.0f32));
32-
assert ((1.0f64).fuzzy_eq(1.0f64));
32+
assert ((&1.0).fuzzy_eq(&1.0));
33+
assert ((&1.0f32).fuzzy_eq(&1.0f32));
34+
assert ((&1.0f64).fuzzy_eq(&1.0f64));
3335
}
3436

src/libstd/dbg.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#[deny(non_camel_case_types)];
2+
#[forbid(deprecated_mode)];
3+
#[forbid(deprecated_pattern)];
24
//! Unsafe debugging functions for inspecting values.
35
46
import unsafe::reinterpret_cast;
@@ -26,19 +28,19 @@ fn debug_tydesc<T>() {
2628
rustrt::debug_tydesc(sys::get_type_desc::<T>());
2729
}
2830

29-
fn debug_opaque<T>(x: T) {
31+
fn debug_opaque<T>(+x: T) {
3032
rustrt::debug_opaque(sys::get_type_desc::<T>(), ptr::addr_of(x) as *());
3133
}
3234

3335
fn debug_box<T>(x: @T) {
3436
rustrt::debug_box(sys::get_type_desc::<T>(), ptr::addr_of(x) as *());
3537
}
3638

37-
fn debug_tag<T>(x: T) {
39+
fn debug_tag<T>(+x: T) {
3840
rustrt::debug_tag(sys::get_type_desc::<T>(), ptr::addr_of(x) as *());
3941
}
4042

41-
fn debug_fn<T>(x: T) {
43+
fn debug_fn<T>(+x: T) {
4244
rustrt::debug_fn(sys::get_type_desc::<T>(), ptr::addr_of(x) as *());
4345
}
4446

src/libstd/list.rs

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
//! A standard linked list
2+
#[forbid(deprecated_mode)];
3+
#[forbid(deprecated_pattern)];
24

35
import core::cmp::Eq;
46
import core::option;
@@ -28,9 +30,9 @@ fn from_vec<T: copy>(v: &[T]) -> @list<T> {
2830
* * z - The initial value
2931
* * f - The function to apply
3032
*/
31-
fn foldl<T: copy, U>(z: T, ls: @list<U>, f: fn(T, U) -> T) -> T {
33+
fn foldl<T: copy, U>(+z: T, ls: @list<U>, f: fn((&T), (&U)) -> T) -> T {
3234
let mut accum: T = z;
33-
do iter(ls) |elt| { accum = f(accum, elt);}
35+
do iter(ls) |elt| { accum = f(&accum, &elt);}
3436
accum
3537
}
3638

@@ -41,12 +43,12 @@ fn foldl<T: copy, U>(z: T, ls: @list<U>, f: fn(T, U) -> T) -> T {
4143
* When function `f` returns true then an option containing the element
4244
* is returned. If `f` matches no elements then none is returned.
4345
*/
44-
fn find<T: copy>(ls: @list<T>, f: fn(T) -> bool) -> Option<T> {
46+
fn find<T: copy>(ls: @list<T>, f: fn((&T)) -> bool) -> Option<T> {
4547
let mut ls = ls;
4648
loop {
4749
ls = match *ls {
4850
cons(hd, tl) => {
49-
if f(hd) { return Some(hd); }
51+
if f(&hd) { return Some(hd); }
5052
tl
5153
}
5254
nil => return None
@@ -55,7 +57,7 @@ fn find<T: copy>(ls: @list<T>, f: fn(T) -> bool) -> Option<T> {
5557
}
5658

5759
/// Returns true if a list contains an element with the given value
58-
fn has<T: copy Eq>(ls: @list<T>, elt: T) -> bool {
60+
fn has<T: copy Eq>(ls: @list<T>, +elt: T) -> bool {
5961
for each(ls) |e| {
6062
if e == elt { return true; }
6163
}
@@ -110,10 +112,13 @@ pure fn append<T: copy>(l: @list<T>, m: @list<T>) -> @list<T> {
110112
}
111113
}
112114

113-
/// Push an element to the front of a list
114-
fn push<T: copy>(&l: list<T>, v: T) {
115-
l = cons(v, @l);
115+
/*
116+
/// Push one element into the front of a list, returning a new list
117+
/// THIS VERSION DOESN'T ACTUALLY WORK
118+
pure fn push<T: copy>(ll: &mut @list<T>, +vv: T) {
119+
ll = &mut @cons(vv, *ll)
116120
}
121+
*/
117122

118123
/// Iterate over a list
119124
fn iter<T>(l: @list<T>, f: fn(T)) {
@@ -201,7 +206,7 @@ mod tests {
201206

202207
#[test]
203208
fn test_foldl() {
204-
fn add(&&a: uint, &&b: int) -> uint { return a + (b as uint); }
209+
fn add(a: &uint, b: &int) -> uint { return *a + (*b as uint); }
205210
let l = from_vec(~[0, 1, 2, 3, 4]);
206211
let empty = @list::nil::<int>;
207212
assert (list::foldl(0u, l, add) == 10u);
@@ -210,23 +215,23 @@ mod tests {
210215

211216
#[test]
212217
fn test_foldl2() {
213-
fn sub(&&a: int, &&b: int) -> int {
214-
a - b
218+
fn sub(a: &int, b: &int) -> int {
219+
*a - *b
215220
}
216221
let l = from_vec(~[1, 2, 3, 4]);
217222
assert (list::foldl(0, l, sub) == -10);
218223
}
219224

220225
#[test]
221226
fn test_find_success() {
222-
fn match_(&&i: int) -> bool { return i == 2; }
227+
fn match_(i: &int) -> bool { return *i == 2; }
223228
let l = from_vec(~[0, 1, 2]);
224229
assert (list::find(l, match_) == option::Some(2));
225230
}
226231

227232
#[test]
228233
fn test_find_fail() {
229-
fn match_(&&_i: int) -> bool { return false; }
234+
fn match_(_i: &int) -> bool { return false; }
230235
let l = from_vec(~[0, 1, 2]);
231236
let empty = @list::nil::<int>;
232237
assert (list::find(l, match_) == option::None::<int>);
@@ -251,6 +256,11 @@ mod tests {
251256
assert (list::len(empty) == 0u);
252257
}
253258

259+
#[test]
260+
fn test_append() {
261+
assert from_vec(~[1,2,3,4])
262+
== list::append(list::from_vec(~[1,2]), list::from_vec(~[3,4]));
263+
}
254264
}
255265

256266
// Local Variables:

src/libstd/prettyprint.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#[forbid(deprecated_mode)];
2+
#[forbid(deprecated_pattern)];
3+
14
import io::Writer;
25
import io::WriterUtil;
36
import serialization::serializer;

src/libstd/rope.rs

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
* * access to a character by index is logarithmic (linear in strings);
2424
*/
2525

26+
#[forbid(deprecated_mode)];
27+
#[forbid(deprecated_pattern)];
2628

2729
/// The type of ropes.
2830
type rope = node::root;
@@ -436,7 +438,7 @@ mod iterator {
436438
node::content(x) => return node::leaf_iterator::start(x)
437439
}
438440
}
439-
fn next(it: node::leaf_iterator::t) -> Option<node::leaf> {
441+
fn next(it: &node::leaf_iterator::t) -> Option<node::leaf> {
440442
return node::leaf_iterator::next(it);
441443
}
442444
}
@@ -447,7 +449,7 @@ mod iterator {
447449
node::content(x) => return node::char_iterator::start(x)
448450
}
449451
}
450-
fn next(it: node::char_iterator::t) -> Option<char> {
452+
fn next(it: &node::char_iterator::t) -> Option<char> {
451453
return node::char_iterator::next(it)
452454
}
453455
}
@@ -751,7 +753,7 @@ mod node {
751753
* * forest - The forest. This vector is progressively rewritten during
752754
* execution and should be discarded as meaningless afterwards.
753755
*/
754-
fn tree_from_forest_destructive(forest: ~[mut @node]) -> @node {
756+
fn tree_from_forest_destructive(forest: &[mut @node]) -> @node {
755757
let mut i;
756758
let mut len = vec::len(forest);
757759
while len > 1u {
@@ -800,7 +802,7 @@ mod node {
800802
let mut offset = 0u;//Current position in the buffer
801803
let it = leaf_iterator::start(node);
802804
loop {
803-
match (leaf_iterator::next(it)) {
805+
match (leaf_iterator::next(&it)) {
804806
option::None => break,
805807
option::Some(x) => {
806808
//FIXME (#2744): Replace with memcpy or something similar
@@ -861,7 +863,7 @@ mod node {
861863
let mut forest = ~[mut];
862864
let it = leaf_iterator::start(node);
863865
loop {
864-
match (leaf_iterator::next(it)) {
866+
match (leaf_iterator::next(&it)) {
865867
option::None => break,
866868
option::Some(x) => vec::push(forest, @leaf(x))
867869
}
@@ -1018,7 +1020,7 @@ mod node {
10181020
let itb = char_iterator::start(b);
10191021
let mut result = 0;
10201022
while result == 0 {
1021-
match ((char_iterator::next(ita), char_iterator::next(itb))) {
1023+
match ((char_iterator::next(&ita), char_iterator::next(&itb))) {
10221024
(option::None, option::None) => break,
10231025
(option::Some(chara), option::Some(charb)) => {
10241026
result = char::cmp(chara, charb);
@@ -1121,7 +1123,7 @@ mod node {
11211123
}
11221124
}
11231125

1124-
fn next(it: t) -> Option<leaf> {
1126+
fn next(it: &t) -> Option<leaf> {
11251127
if it.stackpos < 0 { return option::None; }
11261128
loop {
11271129
let current = it.stack[it.stackpos];
@@ -1162,7 +1164,7 @@ mod node {
11621164
}
11631165
}
11641166

1165-
fn next(it: t) -> Option<char> {
1167+
fn next(it: &t) -> Option<char> {
11661168
loop {
11671169
match (get_current_or_next_leaf(it)) {
11681170
option::None => return option::None,
@@ -1177,36 +1179,36 @@ mod node {
11771179
};
11781180
}
11791181

1180-
fn get_current_or_next_leaf(it: t) -> Option<leaf> {
1181-
match (it.leaf) {
1182-
option::Some(_) => return it.leaf,
1182+
fn get_current_or_next_leaf(it: &t) -> Option<leaf> {
1183+
match ((*it).leaf) {
1184+
option::Some(_) => return (*it).leaf,
11831185
option::None => {
1184-
let next = leaf_iterator::next(it.leaf_iterator);
1186+
let next = leaf_iterator::next(&((*it).leaf_iterator));
11851187
match (next) {
11861188
option::None => return option::None,
11871189
option::Some(_) => {
1188-
it.leaf = next;
1189-
it.leaf_byte_pos = 0u;
1190+
(*it).leaf = next;
1191+
(*it).leaf_byte_pos = 0u;
11901192
return next;
11911193
}
11921194
}
11931195
}
11941196
}
11951197
}
11961198

1197-
fn get_next_char_in_leaf(it: t) -> Option<char> {
1198-
match copy it.leaf {
1199+
fn get_next_char_in_leaf(it: &t) -> Option<char> {
1200+
match copy (*it).leaf {
11991201
option::None => return option::None,
12001202
option::Some(aleaf) => {
1201-
if it.leaf_byte_pos >= aleaf.byte_len {
1203+
if (*it).leaf_byte_pos >= aleaf.byte_len {
12021204
//We are actually past the end of the leaf
1203-
it.leaf = option::None;
1205+
(*it).leaf = option::None;
12041206
return option::None
12051207
} else {
12061208
let {ch, next} =
12071209
str::char_range_at(*aleaf.content,
1208-
it.leaf_byte_pos + aleaf.byte_offset);
1209-
it.leaf_byte_pos = next - aleaf.byte_offset;
1210+
(*it).leaf_byte_pos + aleaf.byte_offset);
1211+
(*it).leaf_byte_pos = next - aleaf.byte_offset;
12101212
return option::Some(ch)
12111213
}
12121214
}
@@ -1274,7 +1276,7 @@ mod tests {
12741276
let rope_iter = iterator::char::start(r);
12751277
let mut equal = true;
12761278
while equal {
1277-
match (node::char_iterator::next(rope_iter)) {
1279+
match (node::char_iterator::next(&rope_iter)) {
12781280
option::None => {
12791281
if string_iter < string_len {
12801282
equal = false;
@@ -1301,7 +1303,7 @@ mod tests {
13011303
let mut len = 0u;
13021304
let it = iterator::char::start(r);
13031305
loop {
1304-
match (node::char_iterator::next(it)) {
1306+
match (node::char_iterator::next(&it)) {
13051307
option::None => break,
13061308
option::Some(_) => len += 1u
13071309
}

src/libstd/tempfile.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
//! Temporary files and directories
22
3+
#[forbid(deprecated_mode)];
4+
#[forbid(deprecated_pattern)];
5+
36
import core::option;
47
import option::{None, Some};
58
import rand;

src/rustc/middle/trans/type_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ fn type_needs_inner(cx: ctx, use: uint, ty: ty::t,
140140
ty::ty_fn(_) | ty::ty_ptr(_) | ty::ty_rptr(_, _)
141141
| ty::ty_trait(_, _, _) => false,
142142
ty::ty_enum(did, substs) => {
143-
if option::is_none(list::find(enums_seen, |id| id == did)) {
143+
if option::is_none(list::find(enums_seen, |id| *id == did)) {
144144
let seen = @cons(did, enums_seen);
145145
for vec::each(*ty::enum_variants(cx.ccx.tcx, did)) |v| {
146146
for vec::each(v.args) |aty| {

0 commit comments

Comments
 (0)