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

Commit b17c7cc

Browse files
committed
Fixed warnings for struct deconstruction and with some lifetimes that shadowed
1 parent 38b332a commit b17c7cc

File tree

10 files changed

+136
-136
lines changed

10 files changed

+136
-136
lines changed

compiler.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ enum Var<'a> {
7474
Newtype
7575
}
7676

77-
static unary_primitives: &'static [(&'static str, Instruction)] = &[
77+
static UNARY_PRIMITIVES: &'static [(&'static str, Instruction)] = &[
7878
("primIntToDouble", IntToDouble),
7979
("primDoubleToInt", DoubleToInt),
8080
];
8181

82-
static binary_primitives: &'static [(&'static str, Instruction)] = &[
82+
static BINARY_PRIMITIVES: &'static [(&'static str, Instruction)] = &[
8383
("primIntAdd", Add),
8484
("primIntSubtract", Sub),
8585
("primIntMultiply", Multiply),
@@ -392,10 +392,10 @@ impl <'a> Compiler<'a> {
392392
for (i, &(name, _)) in builtins().iter().enumerate() {
393393
variables.insert(Name { name: intern(name), uid: 0}, Var::Builtin(i));
394394
}
395-
for &(name, instruction) in binary_primitives.iter() {
395+
for &(name, instruction) in BINARY_PRIMITIVES.iter() {
396396
variables.insert(Name { name: intern(name), uid: 0 }, Var::Primitive(2, instruction));
397397
}
398-
for &(name, instruction) in unary_primitives.iter() {
398+
for &(name, instruction) in UNARY_PRIMITIVES.iter() {
399399
variables.insert(Name { name: intern(name), uid: 0 }, Var::Primitive(1, instruction));
400400
}
401401
Compiler { instance_dictionaries: Vec::new(),
@@ -552,7 +552,7 @@ impl <'a> Compiler<'a> {
552552
}
553553
}
554554

555-
fn find_class<'a>(&'a self, name: Name) -> Option<(&'a [Constraint<Name>], &'a TypeVariable, &'a [TypeDeclaration<Name>])> {
555+
fn find_class(&self, name: Name) -> Option<(&[Constraint<Name>], &TypeVariable, &[TypeDeclaration<Name>])> {
556556
self.module.and_then(|m| m.find_class(name))
557557
.or_else(|| {
558558
for types in self.assemblies.iter() {
@@ -697,7 +697,7 @@ impl <'a> Compiler<'a> {
697697
&Lambda(_, _) => panic!("Error: Found non-lifted lambda when compiling expression")
698698
}
699699
}
700-
fn compile_apply<'a>(&mut self, expr: &Expr<Id>, args: ArgList<'a>, instructions: &mut Vec<Instruction>, strict: bool) {
700+
fn compile_apply(&mut self, expr: &Expr<Id>, args: ArgList, instructions: &mut Vec<Instruction>, strict: bool) {
701701
//Unroll the applications until the function is found
702702
match *expr {
703703
Apply(ref func, ref arg) => {
@@ -752,7 +752,7 @@ impl <'a> Compiler<'a> {
752752
ArgList::Cons(_, _) => {
753753
//Do nothing
754754
}
755-
Nil => {
755+
ArgList::Nil => {
756756
//translate into id application
757757
let x = self.find(Name { name: intern("id"), uid: 0 })
758758
.expect("Compiler error: Prelude.id must be in scope for compilation of newtype");
@@ -784,7 +784,7 @@ impl <'a> Compiler<'a> {
784784
}
785785
}
786786

787-
fn compile_args<'a>(&mut self, args: &ArgList<'a>, instructions: &mut Vec<Instruction>, strict: bool) -> uint {
787+
fn compile_args(&mut self, args: &ArgList, instructions: &mut Vec<Instruction>, strict: bool) -> uint {
788788
match *args {
789789
ArgList::Cons(arg, rest) => {
790790
let i = self.compile_args(rest, instructions, strict);

core.rs

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ pub mod result {
350350
}
351351

352352
pub fn walk_binding<V: Visitor<Ident>, Ident>(visitor: &mut V, binding: Binding<Ident>) -> Binding<Ident> {
353-
let Binding { name: name, expression: expression } = binding;
353+
let Binding { name, expression } = binding;
354354
Binding {
355355
name: name,
356356
expression: visitor.visit_expr(expression)
@@ -383,7 +383,7 @@ pub mod result {
383383
}
384384

385385
pub fn walk_alternative<V: Visitor<Ident>, Ident>(visitor: &mut V, alt: Alternative<Ident>) -> Alternative<Ident> {
386-
let Alternative { pattern: pattern, expression: expression } = alt;
386+
let Alternative { pattern, expression } = alt;
387387
Alternative { pattern: visitor.visit_pattern(pattern), expression: visitor.visit_expr(expression) }
388388
}
389389
}
@@ -434,51 +434,51 @@ pub mod translate {
434434
fn translate_module_<'a>(translator: &mut Translator<'a>, module: module::Module<Name>) -> Module<Id<Name>> {
435435
let module::Module { name : _name,
436436
imports : _imports,
437-
bindings : bindings,
438-
typeDeclarations : _typeDeclarations,
439-
newtypes : newtypes,
440-
classes : classes,
441-
instances : instances,
442-
dataDefinitions : dataDefinitions,
437+
bindings,
438+
type_declarations : _type_declarations,
439+
newtypes,
440+
classes,
441+
instances,
442+
data_definitions,
443443
fixity_declarations : _fixity_declarations
444444
} = module;
445445

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

448448
let classes2 : Vec<Class<Id>> = classes.into_iter().map(|class| {
449449
let module::Class {
450-
constraints: cs,
451-
name : name,
452-
variable : var,
453-
declarations : decls,
454-
bindings: bindings
450+
constraints,
451+
name,
452+
variable,
453+
declarations,
454+
bindings
455455
} = class;
456456
Class {
457-
constraints: cs,
457+
constraints: constraints,
458458
name: name,
459-
variable: var,
460-
declarations: decls,
459+
variable: variable,
460+
declarations: declarations,
461461
bindings: translator.translate_bindings(bindings)
462462
}
463463
}).collect();
464464

465465
for instance in instances.into_iter() {
466466
let module::Instance {
467-
classname: classname,
468-
typ: instance_type,
469-
constraints: constraints,
470-
bindings: bindings
467+
classname,
468+
typ,
469+
constraints,
470+
bindings
471471
} = instance;
472472
let bs: Vec<Binding<Id<Name>>> = translator.translate_bindings(bindings).into_iter().collect();
473473
new_instances.push(Instance {
474474
constraints: constraints,
475-
typ: instance_type,
475+
typ: typ,
476476
classname: classname,
477477
bindings: bs
478478
});
479479
}
480480
let bs: Vec<Binding<Id<Name>>> = translator.translate_bindings(bindings).into_iter().collect();
481-
for data in dataDefinitions.iter() {
481+
for data in data_definitions.iter() {
482482
generate_deriving(&mut new_instances, data);
483483
}
484484
for instance in new_instances.iter_mut() {
@@ -491,7 +491,7 @@ pub mod translate {
491491
}
492492
Module {
493493
classes: classes2,
494-
data_definitions: dataDefinitions,
494+
data_definitions: data_definitions,
495495
newtypes: newtypes,
496496
bindings: bs,
497497
instances: new_instances
@@ -516,7 +516,7 @@ pub mod translate {
516516
.collect();
517517
typ.constraints = vec_context;
518518
}
519-
let Qualified { value: typ, constraints: constraints } = typ;
519+
let Qualified { value: typ, constraints } = typ;
520520
let default_name = module::encode_binding_identifier(instance.classname.name, decl.name.name);
521521
let typ_name = module::extract_applied_type(&instance.typ).ctor().name;
522522
let instance_fn_name = module::encode_binding_identifier(typ_name, decl.name.name);
@@ -546,7 +546,7 @@ impl <'a> Translator<'a> {
546546
_ => false
547547
};
548548
if is_lambda {
549-
let module::TypedExpr { typ: typ, expr: expr, ..} = input_expr;
549+
let module::TypedExpr { typ, expr, ..} = input_expr;
550550
match expr {
551551
module::Expr::Lambda(arg, body) => {
552552
//TODO need to make unique names for the lambdas created here
@@ -569,7 +569,7 @@ impl <'a> Translator<'a> {
569569
}
570570

571571
fn translate_expr_rest(&mut self, input_expr: module::TypedExpr<Name>) -> Expr<Id<Name>> {
572-
let module::TypedExpr { typ: typ, expr: expr, ..} = input_expr;
572+
let module::TypedExpr { typ, expr, ..} = input_expr;
573573
match expr {
574574
module::Expr::Identifier(s) => Identifier(Id::new(s, typ, vec![])),
575575
module::Expr::Apply(func, arg) => Apply(box self.translate_expr(*func), box self.translate_expr(*arg)),
@@ -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.into_iter() {
747+
for module::Alternative { pattern, matches, where_bindings } in alts.into_iter() {
748748
let bindings = where_bindings.map_or(Vec::new(), |bs| self.translate_bindings(bs));
749749
vec.push((self.unwrap_patterns(uid, dummy_var, &[pattern.node]), bindings, matches));
750750
}
@@ -765,10 +765,11 @@ impl <'a> Translator<'a> {
765765
//then we do a simple translation to preserve the names for the arguments.
766766
if bindings.len() == 1 && simple_binding(&bindings[0]) {
767767
let module::Binding {
768-
name: name,
769-
arguments: arguments, matches: matches,
770-
typ: module::Qualified { constraints: constraints, value: typ, },
771-
where_bindings: where_bindings
768+
name,
769+
arguments,
770+
matches,
771+
typ: module::Qualified { constraints, value: typ, },
772+
where_bindings
772773
} = bindings.pop().unwrap();
773774
let arg_iterator = arguments.into_iter().map(|p| {
774775
match p {
@@ -812,9 +813,9 @@ impl <'a> Translator<'a> {
812813
let uid = self.name_supply.next_id();
813814
let equations: Vec<_> = bindings.into_iter().map(|bind| {
814815
let module::Binding {
815-
arguments: arguments,
816-
matches: matches,
817-
where_bindings: where_bindings,
816+
arguments,
817+
matches,
818+
where_bindings,
818819
..
819820
} = bind;
820821
let where_bindings_binds = where_bindings.map_or(Vec::new(), |bs| self.translate_bindings(bs));

infix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl PrecedenceVisitor {
5757
let mut op_stack = Vec::new();
5858
loop {
5959
let box temp = input;
60-
let TypedExpr { typ: typ, location:location, expr: expr } = temp;
60+
let TypedExpr { typ, location, expr } = temp;
6161
match expr {
6262
Expr::OpApply(l, op, r) => {
6363
expr_stack.push(l);

interner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub fn intern(s: &str) -> InternedStr {
5353
impl Str for InternedStr {
5454
fn as_slice<'a>(&'a self) -> &'a str {
5555
let interner = get_local_interner();
56-
let mut x = (*interner).borrow_mut();
56+
let x = (*interner).borrow_mut();
5757
let r: &str = x.get_str(*self);
5858
//The interner is task local and will never remove a string so this is safe
5959
unsafe { ::std::mem::transmute(r) }

main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#![crate_id = "vm#0.0"]
21
#![crate_type = "bin"]
32
#![feature(box_syntax)]
3+
#![allow(unstable)]
44
#[macro_use]
55
extern crate log;
66
extern crate collections;

module.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ pub struct Module<Ident = InternedStr> {
1212
pub name : Ident,
1313
pub imports: Vec<Import<Ident>>,
1414
pub bindings : Vec<Binding<Ident>>,
15-
pub typeDeclarations : Vec<TypeDeclaration<Ident>>,
15+
pub type_declarations : Vec<TypeDeclaration<Ident>>,
1616
pub classes : Vec<Class<Ident>>,
1717
pub instances : Vec<Instance<Ident>>,
18-
pub dataDefinitions : Vec<DataDefinition<Ident>>,
18+
pub data_definitions : Vec<DataDefinition<Ident>>,
1919
pub newtypes : Vec<Newtype<Ident>>,
2020
pub fixity_declarations : Vec<FixityDeclaration<Ident>>
2121
}

parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ pub fn module(&mut self) -> Module {
127127
name : modulename,
128128
imports : imports,
129129
bindings : bindings,
130-
typeDeclarations : type_declarations,
130+
type_declarations : type_declarations,
131131
classes : classes,
132132
instances : instances,
133-
dataDefinitions : data_definitions,
133+
data_definitions : data_definitions,
134134
newtypes: newtypes,
135135
fixity_declarations : fixity_declarations
136136
}
@@ -1373,7 +1373,7 @@ r"data Test = A | B
13731373
dummy = 1
13741374
".chars());
13751375
let module = parser.module();
1376-
let data = &module.dataDefinitions[0];
1376+
let data = &module.data_definitions[0];
13771377
assert_eq!(data.typ, qualified(Vec::new(), Type::new_op(intern("Test"), Vec::new())));
13781378
assert_eq!(data.deriving, [intern("Eq"), intern("Show")]);
13791379
}

0 commit comments

Comments
 (0)