Skip to content
This repository was archived by the owner on Apr 14, 2020. It is now read-only.

Commit f8b982e

Browse files
committed
Rename move_iter -> into_iter, mut_iter -> iter_mut, deriving -> derive
1 parent deed5b1 commit f8b982e

File tree

14 files changed

+176
-167
lines changed

14 files changed

+176
-167
lines changed

compiler.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use builtins::builtins;
1414

1515
use self::Instruction::*;
1616

17-
#[deriving(PartialEq, Clone, Show)]
17+
#[derive(PartialEq, Clone, Show)]
1818
pub enum Instruction {
1919
Add,
2020
Sub,
@@ -61,7 +61,7 @@ pub enum Instruction {
6161
ConstructDictionary(uint),
6262
PushDictionaryRange(uint, uint)
6363
}
64-
#[deriving(Show)]
64+
#[derive(Show)]
6565
enum Var<'a> {
6666
Stack(uint),
6767
Global(uint),
@@ -1100,7 +1100,7 @@ pub fn compile_module(module: &str) -> IoResult<Vec<Assembly>> {
11001100
fn compile_module_(modules: Vec<::module::Module<Name>>) -> IoResult<Vec<Assembly>> {
11011101
use compiler::Compiler;
11021102
let core_modules: Vec<Module<Id<Name>>> = translate_modules(modules)
1103-
.move_iter()
1103+
.into_iter()
11041104
.map(|module| do_lambda_lift(module))
11051105
.collect();
11061106
let mut assemblies = Vec::new();

core.rs

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl Module<Id> {
3030
}
3131
}
3232

33-
#[deriving(Clone, PartialEq)]
33+
#[derive(Clone, PartialEq)]
3434
pub struct Class<Ident> {
3535
pub constraints: Vec<Constraint<Name>>,
3636
pub name : Name,
@@ -39,43 +39,43 @@ pub struct Class<Ident> {
3939
pub bindings: Vec<Binding<Ident>>
4040
}
4141

42-
#[deriving(Clone)]
42+
#[derive(Clone)]
4343
pub struct Instance<Ident = InternedStr> {
4444
pub bindings : Vec<Binding<Ident>>,
4545
pub constraints : Vec<Constraint<Name>>,
4646
pub typ : Type,
4747
pub classname : Name
4848
}
4949

50-
#[deriving(Clone, PartialEq)]
50+
#[derive(Clone, PartialEq)]
5151
pub struct Binding<Ident> {
5252
pub name: Ident,
5353
pub expression: Expr<Ident>
5454
}
5555

56-
#[deriving(Clone, PartialEq)]
56+
#[derive(Clone, PartialEq)]
5757
pub struct Alternative<Ident> {
5858
pub pattern : Pattern<Ident>,
5959
pub expression : Expr<Ident>
6060
}
6161

62-
#[deriving(Clone, PartialEq)]
62+
#[derive(Clone, PartialEq)]
6363
pub enum Pattern<Ident> {
6464
Constructor(Ident, Vec<Ident>),
6565
Identifier(Ident),
6666
Number(int),
6767
WildCard
6868
}
6969

70-
#[deriving(Clone, PartialEq)]
70+
#[derive(Clone, PartialEq)]
7171
pub struct LiteralData {
7272
pub typ: Type,
7373
pub value: Literal_
7474
}
7575

7676
pub type Literal_ = module::LiteralData;
7777

78-
#[deriving(Clone, PartialEq)]
78+
#[derive(Clone, PartialEq)]
7979
pub enum Expr<Ident> {
8080
Identifier(Ident),
8181
Apply(Box<Expr<Ident>>, Box<Expr<Ident>>),
@@ -165,7 +165,7 @@ impl PartialEq<str> for Name {
165165
}
166166

167167
///Id is a Name combined with a type
168-
#[deriving(PartialEq, Eq, Hash, Clone)]
168+
#[derive(PartialEq, Eq, Hash, Clone)]
169169
pub struct Id<T = Name> {
170170
pub name: T,
171171
pub typ: Qualified<Type, Name>
@@ -279,7 +279,7 @@ pub mod mutable {
279279
}
280280

281281
pub fn walk_module<Ident, V: Visitor<Ident>>(visitor: &mut V, module: &mut Module<Ident>) {
282-
for bind in module.bindings.mut_iter() {
282+
for bind in module.bindings.iter_mut() {
283283
visitor.visit_binding(bind);
284284
}
285285
}
@@ -296,14 +296,14 @@ pub mod mutable {
296296
}
297297
&Lambda(_, ref mut body) => visitor.visit_expr(*body),
298298
&Let(ref mut binds, ref mut e) => {
299-
for b in binds.mut_iter() {
299+
for b in binds.iter_mut() {
300300
visitor.visit_binding(b);
301301
}
302302
visitor.visit_expr(*e);
303303
}
304304
&Case(ref mut e, ref mut alts) => {
305305
visitor.visit_expr(*e);
306-
for alt in alts.mut_iter() {
306+
for alt in alts.iter_mut() {
307307
visitor.visit_alternative(alt);
308308
}
309309
}
@@ -343,7 +343,7 @@ pub mod result {
343343
pub fn walk_module<Ident>(visitor: &mut Visitor<Ident>, mut module: Module<Ident>) -> Module<Ident> {
344344
let mut bindings = vec![];
345345
::std::mem::swap(&mut module.bindings, &mut bindings);
346-
module.bindings = bindings.move_iter()
346+
module.bindings = bindings.into_iter()
347347
.map(|bind| visitor.visit_binding(bind))
348348
.collect();
349349
module
@@ -366,14 +366,14 @@ pub mod result {
366366
}
367367
Lambda(x, body) => Lambda(x, box visitor.visit_expr(*body)),
368368
Let(binds, e) => {
369-
let bs: Vec<Binding<Ident>> = binds.move_iter().map(|b| {
369+
let bs: Vec<Binding<Ident>> = binds.into_iter().map(|b| {
370370
visitor.visit_binding(b)
371371
}).collect();
372372
Let(bs, box visitor.visit_expr(*e))
373373
}
374374
Case(e, alts) => {
375375
let e2 = visitor.visit_expr(*e);
376-
let alts2: Vec<Alternative<Ident>> = alts.move_iter()
376+
let alts2: Vec<Alternative<Ident>> = alts.into_iter()
377377
.map(|alt| visitor.visit_alternative(alt))
378378
.collect();
379379
Case(box e2, alts2)
@@ -404,7 +404,7 @@ pub mod translate {
404404
functions_in_class: &'a mut (FnMut(Name) -> (&'a TypeVariable, &'a [TypeDeclaration<Name>]) + 'a)
405405
}
406406

407-
#[deriving(Show)]
407+
#[derive(Show)]
408408
struct Equation<'a>(&'a [(Id<Name>, Pattern<Id<Name>>)], (&'a [Binding<Id<Name>>], &'a module::Match<Name>));
409409

410410
pub fn translate_expr(expr: module::TypedExpr<Name>) -> Expr<Id<Name>> {
@@ -424,7 +424,7 @@ pub mod translate {
424424
(var, decls.as_slice())
425425
}
426426
};
427-
modules.move_iter()
427+
modules.into_iter()
428428
.map(|module| translate_module_(&mut translator, module))
429429
.collect()
430430
}
@@ -445,7 +445,7 @@ pub mod translate {
445445

446446
let mut new_instances: Vec<Instance<Id<Name>>> = Vec::new();
447447

448-
let classes2 : Vec<Class<Id>> = classes.move_iter().map(|class| {
448+
let classes2 : Vec<Class<Id>> = classes.into_iter().map(|class| {
449449
let module::Class {
450450
constraints: cs,
451451
name : name,
@@ -462,31 +462,31 @@ pub mod translate {
462462
}
463463
}).collect();
464464

465-
for instance in instances.move_iter() {
465+
for instance in instances.into_iter() {
466466
let module::Instance {
467467
classname: classname,
468468
typ: instance_type,
469469
constraints: constraints,
470470
bindings: bindings
471471
} = instance;
472-
let bs: Vec<Binding<Id<Name>>> = translator.translate_bindings(bindings).move_iter().collect();
472+
let bs: Vec<Binding<Id<Name>>> = translator.translate_bindings(bindings).into_iter().collect();
473473
new_instances.push(Instance {
474474
constraints: constraints,
475475
typ: instance_type,
476476
classname: classname,
477477
bindings: bs
478478
});
479479
}
480-
let bs: Vec<Binding<Id<Name>>> = translator.translate_bindings(bindings).move_iter().collect();
480+
let bs: Vec<Binding<Id<Name>>> = translator.translate_bindings(bindings).into_iter().collect();
481481
for data in dataDefinitions.iter() {
482482
generate_deriving(&mut new_instances, data);
483483
}
484-
for instance in new_instances.mut_iter() {
484+
for instance in new_instances.iter_mut() {
485485
let (class_var, class_decls) = (translator.functions_in_class)(instance.classname);
486486
let defaults = create_default_stubs(class_var, class_decls, instance);
487487
let mut temp = box [];
488488
::std::mem::swap(&mut temp, &mut instance.bindings);
489-
let vec: Vec<Binding<Id<Name>>> = temp.move_iter().chain(defaults.move_iter()).collect();
489+
let vec: Vec<Binding<Id<Name>>> = temp.into_iter().chain(defaults.into_iter()).collect();
490490
instance.bindings = vec;
491491
}
492492
Module {
@@ -511,7 +511,7 @@ pub mod translate {
511511
{
512512
let context = ::std::mem::replace(&mut typ.constraints, box []);
513513
//Remove all constraints which refer to the class's variable
514-
let vec_context: Vec<Constraint<Name>> = context.move_iter()
514+
let vec_context: Vec<Constraint<Name>> = context.into_iter()
515515
.filter(|c| c.variables[0] != *class_var)
516516
.collect();
517517
typ.constraints = vec_context;
@@ -604,7 +604,7 @@ impl <'a> Translator<'a> {
604604
}
605605
module::Expr::Do(bindings, expr) => {
606606
let mut result = self.translate_expr(*expr);
607-
for bind in bindings.move_iter().rev() {
607+
for bind in bindings.into_iter().rev() {
608608
result = match bind {
609609
module::DoBinding::DoExpr(e) => {
610610
let core = self.translate_expr(e);
@@ -669,13 +669,13 @@ impl <'a> Translator<'a> {
669669
, Alternative { pattern: Pattern::WildCard, expression: Apply(box fail_ident, box string("Unmatched pattern in let")) } ]));
670670
let bind = Binding { name: func_ident.clone(), expression: func };
671671

672-
Let(vec![bind], box apply(bind_ident, (vec![expr, Identifier(func_ident)]).move_iter()))
672+
Let(vec![bind], box apply(bind_ident, (vec![expr, Identifier(func_ident)]).into_iter()))
673673
}
674674

675675
fn translate_bindings(&mut self, bindings: Vec<module::Binding<Name>>) -> Vec<Binding<Id<Name>>> {
676676
let mut result = Vec::new();
677677
let mut vec: Vec<module::Binding<Name>> = Vec::new();
678-
for bind in bindings.move_iter() {
678+
for bind in bindings.into_iter() {
679679
if vec.len() > 0 && vec.get(0).name != bind.name {
680680
result.push(self.translate_matching_groups(vec));
681681
vec = Vec::new();
@@ -695,7 +695,7 @@ impl <'a> Translator<'a> {
695695
let mut name = ::std::string::String::from_str(id.name.name.as_slice());
696696
let base_length = name.len();
697697
result.push((id, Pattern::Number(0)));//Dummy
698-
for (i, p) in patterns.mut_iter().enumerate() {
698+
for (i, p) in patterns.iter_mut().enumerate() {
699699
let x = match *p {
700700
module::Pattern::Constructor(..) | module::Pattern::Number(..) => {
701701
//HACK, by making the variable have the same uid as
@@ -744,7 +744,7 @@ impl <'a> Translator<'a> {
744744
let mut vec = Vec::new();
745745
let dummy_var = [Id::new(self.name_supply.anonymous(), Type::new_var(intern("a")), vec![])];
746746
let uid = self.name_supply.next_id();
747-
for module::Alternative { pattern: pattern, matches: matches, where_bindings: where_bindings } in alts.move_iter() {
747+
for module::Alternative { pattern: pattern, matches: matches, where_bindings: where_bindings } in alts.into_iter() {
748748
let bindings = where_bindings.map_or(box [], |bs| self.translate_bindings(bs));
749749
vec.push((self.unwrap_patterns(uid, dummy_var, [pattern.node]), bindings, matches));
750750
}
@@ -770,7 +770,7 @@ impl <'a> Translator<'a> {
770770
typ: module::Qualified { constraints: constraints, value: typ, },
771771
where_bindings: where_bindings
772772
} = bindings.pop().unwrap();
773-
let arg_iterator = arguments.move_iter().map(|p| {
773+
let arg_iterator = arguments.into_iter().map(|p| {
774774
match p {
775775
module::Pattern::Identifier(n) => n,
776776
module::Pattern::WildCard => Name { name: intern("_"), uid: -1 },
@@ -783,7 +783,7 @@ impl <'a> Translator<'a> {
783783
.map(|(typ, arg)| {
784784
Id::new(arg, typ.clone(), vec![])
785785
});
786-
let where_bindings_binds = where_bindings.map_or(Vec::new(), |bs| self.translate_bindings(bs).move_iter().collect());
786+
let where_bindings_binds = where_bindings.map_or(Vec::new(), |bs| self.translate_bindings(bs).into_iter().collect());
787787
make_lambda(lambda_ids, make_let(where_bindings_binds, self.translate_match(matches)))
788788
};
789789
return Binding {
@@ -810,7 +810,7 @@ impl <'a> Translator<'a> {
810810
//First we flatten all the patterns that occur in each equation
811811
//(2:xs) -> [(x:xs), 2]
812812
let uid = self.name_supply.next_id();
813-
let equations: Vec<_> = bindings.move_iter().map(|bind| {
813+
let equations: Vec<_> = bindings.into_iter().map(|bind| {
814814
let module::Binding {
815815
arguments: arguments,
816816
matches: matches,
@@ -821,7 +821,7 @@ impl <'a> Translator<'a> {
821821
(self.unwrap_patterns(uid, arg_ids.as_slice(), arguments), where_bindings_binds, matches)
822822
}).collect();
823823
let mut expr = self.translate_equations_(equations);
824-
expr = make_lambda(arg_ids.move_iter(), expr);
824+
expr = make_lambda(arg_ids.into_iter(), expr);
825825
debug!("Desugared {} :: {}\n {}", name.name, name.typ, expr);
826826
Binding {
827827
name: name,
@@ -1004,7 +1004,7 @@ impl <'a> Translator<'a> {
10041004
module::Pattern::Identifier(i) => Pattern::Identifier(Id::new(i, Type::new_var(intern("a")), vec![])),
10051005
module::Pattern::Number(n) => Pattern::Number(n),
10061006
module::Pattern::Constructor(name, patterns) => {
1007-
let ps = patterns.move_iter().map(|pat| {
1007+
let ps = patterns.into_iter().map(|pat| {
10081008
match pat {
10091009
module::Pattern::Identifier(name) => Id::new(name, Type::new_var(intern("a")), vec![]),
10101010
module::Pattern::WildCard => Id::new(Name { name: intern("_"), uid: -1 }, Type::new_var(intern("a")), vec![]),

graph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
use std::iter::repeat;
55
use std::cmp::min;
66

7-
#[deriving(PartialEq, Show)]
7+
#[derive(PartialEq, Show)]
88
pub struct VertexIndex(uint);
9-
#[deriving(PartialEq)]
9+
#[derive(PartialEq)]
1010
pub struct EdgeIndex(uint);
1111

1212
impl VertexIndex {

infix.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ r"import Prelude
126126
test = 3 * 4 - 5 * 6").unwrap();
127127
let mut modules = rename_modules(m);
128128
let mut v = PrecedenceVisitor::new();
129-
for module in modules.mut_iter() {
129+
for module in modules.iter_mut() {
130130
v.visit_module(module);
131131
}
132132
assert_eq!(modules.last().unwrap().bindings[0].matches, Simple(rename_expr(op_apply(
@@ -142,7 +142,7 @@ r"import Prelude
142142
test = 3 * 4 * (5 - 6)").unwrap();
143143
let mut modules = rename_modules(m);
144144
let mut v = PrecedenceVisitor::new();
145-
for module in modules.mut_iter() {
145+
for module in modules.iter_mut() {
146146
v.visit_module(module);
147147
}
148148
assert_eq!(modules.last().unwrap().bindings[0].matches, Simple(rename_expr(op_apply(

interner.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::rc::Rc;
33
use std::cell::RefCell;
44
use std::fmt;
55

6-
#[deriving(Eq, PartialEq, Clone, Default, Hash)]
6+
#[derive(Eq, PartialEq, Clone, Default, Hash)]
77
pub struct InternedStr(uint);
88

99
pub struct Interner {
@@ -61,6 +61,11 @@ impl Str for InternedStr {
6161
}
6262

6363
impl fmt::Show for InternedStr {
64+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
65+
write!(f, "{:?}", self.as_slice())
66+
}
67+
}
68+
impl fmt::String for InternedStr {
6469
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
6570
write!(f, "{}", self.as_slice())
6671
}

lambda_lift.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn free_variables(&mut self, variables: &mut HashMap<Name, int>, free_vars: &mut
5656
variables.insert_or_update_with(bind.name.name.clone(), 1, |_, v| *v += 1);
5757
}
5858
let mut free_vars2 = HashMap::new();
59-
for bind in bindings.mut_iter() {
59+
for bind in bindings.iter_mut() {
6060
free_vars2.clear();
6161
self.free_variables(variables, &mut free_vars2, &mut bind.expression);
6262
//free_vars2 is the free variables for this binding
@@ -73,7 +73,7 @@ fn free_variables(&mut self, variables: &mut HashMap<Name, int>, free_vars: &mut
7373
}
7474
Case(ref mut expr, ref mut alts) => {
7575
self.free_variables(variables, free_vars, *expr);
76-
for alt in alts.mut_iter() {
76+
for alt in alts.iter_mut() {
7777
each_pattern_variables(&alt.pattern, &mut |name| {
7878
variables.insert_or_update_with(name.clone(), 1, |_, v| *v += 1);
7979
});
@@ -125,7 +125,7 @@ pub fn lift_lambdas<T>(mut module: Module<T>) -> Module<T> {
125125
let mut new_binds = Vec::new();
126126
let mut bs = vec![];
127127
::std::mem::swap(&mut bs, bindings);
128-
for mut bind in bs.move_iter() {
128+
for mut bind in bs.into_iter() {
129129
let is_lambda = match bind.expression {
130130
Lambda(..) => true,
131131
_ => false
@@ -150,8 +150,8 @@ pub fn lift_lambdas<T>(mut module: Module<T>) -> Module<T> {
150150
visitor.visit_module(&mut module);
151151
let mut temp = box [];
152152
::std::mem::swap(&mut temp, &mut module.bindings);
153-
let vec : Vec<Binding<T>> = temp.move_iter()
154-
.chain(visitor.out_lambdas.move_iter())
153+
let vec : Vec<Binding<T>> = temp.into_iter()
154+
.chain(visitor.out_lambdas.into_iter())
155155
.collect();
156156
module.bindings = vec;
157157
module

0 commit comments

Comments
 (0)