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

Commit f7223c0

Browse files
committed
Rename {} -> {:?} in formatting macros
1 parent f8b982e commit f7223c0

File tree

15 files changed

+186
-186
lines changed

15 files changed

+186
-186
lines changed

compiler.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ impl <'a> Compiler<'a> {
454454
}
455455

456456
fn compile_binding(&mut self, bind : &Binding<Id>) -> SuperCombinator {
457-
debug!("Compiling binding {} :: {}", bind.name, bind.name.typ);
457+
debug!("Compiling binding {:?} :: {:?}", bind.name, bind.name.typ);
458458
let dict_arg = if bind.name.typ.constraints.len() > 0 { 1 } else { 0 };
459459
self.context = bind.name.typ.constraints.clone();
460460
let mut instructions = Vec::new();
@@ -463,15 +463,15 @@ impl <'a> Compiler<'a> {
463463
if dict_arg == 1 {
464464
this.new_stack_var(Name { name: intern("$dict"), uid: 0 });
465465
}
466-
debug!("{} {}\n {}", bind.name, dict_arg, bind.expression);
466+
debug!("{:?} {:?}\n {:?}", bind.name, dict_arg, bind.expression);
467467
arity = this.compile_lambda_binding(&bind.expression, &mut instructions) + dict_arg;
468468
instructions.push(Update(0));
469469
if arity != 0 {
470470
instructions.push(Pop(arity));
471471
}
472472
instructions.push(Unwind);
473473
});
474-
debug!("{} :: {} compiled as:\n{}", bind.name, bind.name.typ, instructions);
474+
debug!("{:?} :: {:?} compiled as:\n{:?}", bind.name, bind.name.typ, instructions);
475475
SuperCombinator {
476476
assembly_id: self.assemblies.len(),
477477
typ: bind.name.typ.clone(),
@@ -720,7 +720,7 @@ impl <'a> Compiler<'a> {
720720
//might be created which is returned here and added to the assembly
721721
let mut is_primitive = false;
722722
let var = self.find(name.name)
723-
.unwrap_or_else(|| panic!("Error: Undefined variable {}", *name));
723+
.unwrap_or_else(|| panic!("Error: Undefined variable {:?}", *name));
724724
match var {
725725
Var::Primitive(..) => is_primitive = true,
726726
_ => ()
@@ -735,11 +735,11 @@ impl <'a> Compiler<'a> {
735735
}
736736
Var::Builtin(index) => { instructions.push(PushBuiltin(index)); }
737737
Var::Class(typ, constraints, var) => {
738-
debug!("Var::Class ({}, {}, {}) {}", typ, constraints, var, expr.get_type());
738+
debug!("Var::Class ({:?}, {:?}, {:?}) {:?}", typ, constraints, var, expr.get_type());
739739
self.compile_instance_variable(expr.get_type(), instructions, name.name, typ, constraints, var);
740740
}
741741
Var::Constraint(index, bind_type, constraints) => {
742-
debug!("Var::Constraint {} ({}, {}, {})", name, index, bind_type, constraints);
742+
debug!("Var::Constraint {:?} ({:?}, {:?}, {:?})", name, index, bind_type, constraints);
743743
self.compile_with_constraints(name.name, expr.get_type(), bind_type, constraints, instructions);
744744
instructions.push(PushGlobal(index));
745745
instructions.push(Mkap);
@@ -749,7 +749,7 @@ impl <'a> Compiler<'a> {
749749
instructions.push(instruction);
750750
}
751751
else {
752-
panic!("Expected {} arguments for {}, got {}", num_args, name, arg_length)
752+
panic!("Expected {:?} arguments for {:?}, got {:?}", num_args, name, arg_length)
753753
}
754754
is_function = false;
755755
}
@@ -821,7 +821,7 @@ impl <'a> Compiler<'a> {
821821
instructions.push(PushGlobal(index));
822822
instructions.push(Mkap);
823823
}
824-
_ => panic!("Unregistered instance function {}", instance_fn_name)
824+
_ => panic!("Unregistered instance function {:?}", instance_fn_name)
825825
}
826826
}
827827
None => {
@@ -853,7 +853,7 @@ impl <'a> Compiler<'a> {
853853
}
854854

855855
fn push_dictionary(&mut self, context: &[Constraint<Name>], constraints: &[(Name, Type)], instructions: &mut Vec<Instruction>) {
856-
debug!("Push dictionary {} ==> {}", context, constraints);
856+
debug!("Push dictionary {:?} ==> {:?}", context, constraints);
857857
for &(ref class, ref typ) in constraints.iter() {
858858
self.fold_dictionary(*class, typ, instructions);
859859
instructions.push(ConstructDictionary(constraints.len()));
@@ -864,13 +864,13 @@ impl <'a> Compiler<'a> {
864864
fn fold_dictionary(&mut self, class: Name, typ: &Type, instructions: &mut Vec<Instruction>) {
865865
match *typ {
866866
Type::Constructor(ref ctor) => {//Simple
867-
debug!("Simple for {}", ctor);
867+
debug!("Simple for {:?}", ctor);
868868
//Push static dictionary to the top of the stack
869869
let index = self.find_dictionary_index(&[(class.clone(), typ.clone())]);
870870
instructions.push(PushDictionary(index));
871871
}
872872
Type::Application(ref lhs, ref rhs) => {
873-
debug!("App for ({} {})", lhs, rhs);
873+
debug!("App for ({:?} {:?})", lhs, rhs);
874874
//For function in functions
875875
// Mkap function fold_dictionary(rhs)
876876
self.fold_dictionary(class, *lhs, instructions);
@@ -894,11 +894,11 @@ impl <'a> Compiler<'a> {
894894
let num_class_functions = self.find_class(class)
895895
.map(|(_, _, decls)| decls.len())
896896
.unwrap();
897-
debug!("Use previous dict for {} at {}..{}", var, index, num_class_functions);
897+
debug!("Use previous dict for {:?} at {:?}..{:?}", var, index, num_class_functions);
898898
instructions.push(PushDictionaryRange(index, num_class_functions));
899899
}
900900
else {
901-
debug!("No dict for {}", var);
901+
debug!("No dict for {:?}", var);
902902
}
903903
}
904904
_ => panic!("Did not expect generic")
@@ -908,7 +908,7 @@ impl <'a> Compiler<'a> {
908908
///Lookup which index in the instance dictionary that holds the function called 'name'
909909
fn push_dictionary_member(&self, constraints: &[Constraint<Name>], name: Name) -> Option<uint> {
910910
if constraints.len() == 0 {
911-
panic!("Attempted to push dictionary member '{}' with no constraints", name)
911+
panic!("Attempted to push dictionary member '{:?}' with no constraints", name)
912912
}
913913
let mut ii = 0;
914914
for c in constraints.iter() {
@@ -974,7 +974,7 @@ impl <'a> Compiler<'a> {
974974
for decl in declarations.iter() {
975975
let x = match extract_applied_type(typ) {
976976
&Type::Constructor(ref x) => x,
977-
_ => panic!("{}", typ)
977+
_ => panic!("{:?}", typ)
978978
};
979979
let mut b = "#".to_string();
980980
b.push_str(x.name.as_slice());
@@ -988,7 +988,7 @@ impl <'a> Compiler<'a> {
988988
Some(Var::Constraint(index, _, _)) => {
989989
function_indexes.push(index as uint);//TODO this is not really correct since this function requires a dictionary
990990
}
991-
var => panic!("Did not find function {} {}", name, var)
991+
var => panic!("Did not find function {:?} {:?}", name, var)
992992
}
993993
}
994994
None
@@ -1000,7 +1000,7 @@ impl <'a> Compiler<'a> {
10001000
///An index to the Jump instruction which is taken when the match fails is stored in the branches vector
10011001
///These instructions will need to be updated later with the correct jump location.
10021002
fn compile_pattern(&mut self, pattern: &Pattern<Id>, branches: &mut Vec<uint>, instructions: &mut Vec<Instruction>, stack_size: uint) -> uint {
1003-
debug!("Pattern {} at {}", pattern, stack_size);
1003+
debug!("Pattern {:?} at {:?}", pattern, stack_size);
10041004
match pattern {
10051005
&Pattern::Constructor(ref name, ref patterns) => {
10061006
instructions.push(Push(stack_size));
@@ -1010,7 +1010,7 @@ impl <'a> Compiler<'a> {
10101010
branches.push(instructions.len());
10111011
instructions.push(Jump(0));
10121012
}
1013-
_ => panic!("Undefined constructor {}", *name)
1013+
_ => panic!("Undefined constructor {:?}", *name)
10141014
}
10151015
instructions.push(Split(patterns.len()));
10161016
self.stackSize += patterns.len();

core.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ pub enum Expr<Ident> {
8787

8888
impl fmt::Show for LiteralData {
8989
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
90-
write!(f, "{}", self.value)
90+
write!(f, "{:?}", self.value)
9191
}
9292
}
9393

9494
impl <T: fmt::Show> fmt::Show for Binding<T> {
9595
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
96-
write!(f, "{} = {}", self.name, self.expression)
96+
write!(f, "{:?} = {:?}", self.name, self.expression)
9797
}
9898
}
9999

@@ -105,18 +105,18 @@ impl <T: fmt::Show> fmt::Show for Expr<T> {
105105
}
106106
impl <T: fmt::Show> fmt::Show for Alternative<T> {
107107
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
108-
write!(f, "{} -> {}", self.pattern, self.expression)
108+
write!(f, "{:?} -> {:?}", self.pattern, self.expression)
109109
}
110110
}
111111
impl <T: fmt::Show> fmt::Show for Pattern<T> {
112112
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
113113
match *self {
114-
Pattern::Identifier(ref s) => write!(f, "{}", s),
115-
Pattern::Number(ref i) => write!(f, "{}", i),
114+
Pattern::Identifier(ref s) => write!(f, "{:?}", s),
115+
Pattern::Number(ref i) => write!(f, "{:?}", i),
116116
Pattern::Constructor(ref name, ref patterns) => {
117-
try!(write!(f, "({} ", name));
117+
try!(write!(f, "({:?} ", name));
118118
for p in patterns.iter() {
119-
try!(write!(f, " {}", p));
119+
try!(write!(f, " {:?}", p));
120120
}
121121
write!(f, ")")
122122
}
@@ -138,7 +138,7 @@ impl <Ident: Typed> Typed for Expr<Ident> {
138138
&Expr::Apply(ref func, _) => {
139139
match func.get_type() {
140140
&Type::Application(_, ref a) => { let a2: &Type = *a; a2 }
141-
x => panic!("The function in Apply must be a type application, found {}", x)
141+
x => panic!("The function in Apply must be a type application, found {:?}", x)
142142
}
143143
}
144144
&Expr::Lambda(ref arg, _) => arg.get_type(),
@@ -173,7 +173,7 @@ pub struct Id<T = Name> {
173173

174174
impl fmt::Show for Id {
175175
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
176-
write!(f, "{}", self.name)
176+
write!(f, "{:?}", self.name)
177177
}
178178
}
179179

@@ -503,7 +503,7 @@ pub mod translate {
503503
class_decls.iter()
504504
.filter(|decl| instance.bindings.iter().find(|bind| bind.name.as_slice().ends_with(decl.name.as_slice())).is_none())
505505
.map(|decl| {
506-
debug!("Create default function for {} ({}) {}", instance.classname, instance.typ, decl.name);
506+
debug!("Create default function for {:?} ({:?}) {:?}", instance.classname, instance.typ, decl.name);
507507
//The stub functions will naturally have the same type as the function in the class but with the variable replaced
508508
//with the instance's type
509509
let mut typ = decl.typ.clone();
@@ -629,7 +629,7 @@ impl <'a> Translator<'a> {
629629
///Translates
630630
///do { expr; stmts } = expr >> do { stmts; }
631631
fn do_bind2_id(&mut self, m_a: Type, m_b: Type) -> Expr<Id<Name>> {
632-
debug!("m_a {}", m_a);
632+
debug!("m_a {:?}", m_a);
633633
let c = match *m_a.appl() {
634634
Type::Variable(ref var) => vec![Constraint { class: Name { name: intern("Monad"), uid: 0 }, variables: vec![var.clone()] }],
635635
_ => vec![]
@@ -647,7 +647,7 @@ impl <'a> Translator<'a> {
647647
let m_a = expr.get_type().clone();
648648
let a = m_a.appr().clone();
649649
let m_b = result.get_type().clone();
650-
debug!("m_a {}", m_a);
650+
debug!("m_a {:?}", m_a);
651651
let c = match *m_a.appl() {
652652
Type::Variable(ref var) => vec![Constraint { class: Name { name: intern("Monad"), uid: 0 }, variables: vec![var.clone()] }],
653653
_ => vec![]
@@ -822,7 +822,7 @@ impl <'a> Translator<'a> {
822822
}).collect();
823823
let mut expr = self.translate_equations_(equations);
824824
expr = make_lambda(arg_ids.into_iter(), expr);
825-
debug!("Desugared {} :: {}\n {}", name.name, name.typ, expr);
825+
debug!("Desugared {:?} :: {:?}\n {:?}", name.name, name.typ, expr);
826826
Binding {
827827
name: name,
828828
expression: expr
@@ -834,7 +834,7 @@ impl <'a> Translator<'a> {
834834
eqs.push(Equation(ps.as_slice(), (bs.as_slice(), e)));
835835
}
836836
for e in eqs.iter() {
837-
debug!("{}", e);
837+
debug!("{:?}", e);
838838
}
839839
self.translate_equations(eqs.as_slice())
840840
}
@@ -864,7 +864,7 @@ impl <'a> Translator<'a> {
864864
_ => true
865865
}
866866
}
867-
debug!("In {}", equations);
867+
debug!("In {:?}", equations);
868868
let &Equation(ps, (where_bindings_bindings, e)) = &equations[0];
869869
if ps.len() == 0 {
870870
assert_eq!(equations.len(), 1);//Otherwise multiple matches for this group

deriving.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn generate_deriving(instances: &mut Vec<Instance<Id<Name>>>, data: &DataDef
2222
"Ord" => {
2323
let mut bindings = Vec::new();
2424
let b = gen.generate_ord(data);
25-
debug!("Generated Ord {} ->>\n{}", data.typ, b);
25+
debug!("Generated Ord {:?} ->>\n{:?}", data.typ, b);
2626
bindings.push(b);
2727
instances.push(Instance {
2828
constraints: box [],
@@ -31,7 +31,7 @@ pub fn generate_deriving(instances: &mut Vec<Instance<Id<Name>>>, data: &DataDef
3131
bindings: bindings
3232
});
3333
}
34-
x => panic!("Cannot generate instance for class {}", x)
34+
x => panic!("Cannot generate instance for class {:?}", x)
3535
}
3636
}
3737
}

infix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl PrecedenceVisitor {
7676
reduce(&mut expr_stack, &mut op_stack);
7777
}
7878
(Assoc::Right, Assoc::Right) => {
79-
debug!("Shift op {}", op);
79+
debug!("Shift op {:?}", op);
8080
op_stack.push(op);
8181
break
8282
}

interner.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl Interner {
3434
self.strings.get(i).as_slice()
3535
}
3636
else {
37-
panic!("Invalid InternedStr {}", i)
37+
panic!("Invalid InternedStr {:?}", i)
3838
}
3939
}
4040
}
@@ -67,6 +67,6 @@ impl fmt::Show for InternedStr {
6767
}
6868
impl fmt::String for InternedStr {
6969
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
70-
write!(f, "{}", self.as_slice())
70+
write!(f, "{:?}", self.as_slice())
7171
}
7272
}

lambda_lift.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ test2 x =
275275
assert!(check_args(&binds[0].expression, args.as_slice()));
276276
assert_eq!(Identifier(binds[0].name.clone()), **body);
277277
}
278-
_ => assert!(false, "Expected Let, found {}", bind.expression)
278+
_ => assert!(false, "Expected Let, found {:?}", bind.expression)
279279
}
280280
self.count += 1;
281281
}

lexer.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ impl <T: PartialEq> PartialEq for Located<T> {
8080

8181
impl <T: fmt::Show> fmt::Show for Located<T> {
8282
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
83-
write!(f, "{}", self.node)
83+
write!(f, "{:?}", self.node)
8484
}
8585
}
8686

8787
impl fmt::Show for Location {
8888
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
89-
write!(f, "{}:{}", self.row, self.column)
89+
write!(f, "{:?}:{:?}", self.row, self.column)
9090
}
9191
}
9292

@@ -341,7 +341,7 @@ impl <Stream : Iterator<Item=char>> Lexer<Stream> {
341341
//L (t:ts) (m:ms) = } : (L (t:ts) ms) if m /= 0 and parse-error(t)
342342
let m = *self.indentLevels.get(self.indentLevels.len() - 1);
343343
if m != 0 {//If not a explicit '}'
344-
debug!("ParseError on token {}, inserting }}", self.current().token);
344+
debug!("ParseError on token {:?}, inserting }}", self.current().token);
345345
self.indentLevels.pop();
346346
let loc = self.current().location;
347347
self.tokens.push_back(Token::new(&self.interner, RBRACE, "}", loc));
@@ -532,13 +532,13 @@ impl <Stream : Iterator<Item=char>> Lexer<Stream> {
532532
else if c == '`' {
533533
let x = self.read_char().expect("Unexpected end of input");
534534
if !x.is_alphabetic() && x != '_' {
535-
panic!("Parse error on '{}'", x);
535+
panic!("Parse error on '{:?}'", x);
536536
}
537537
let mut token = self.scan_identifier(x, startLocation);
538538
let end_tick = self.read_char();
539539
match end_tick {
540540
Some('`') => (),
541-
Some(x) => panic!("Parse error on '{}'", x),
541+
Some(x) => panic!("Parse error on '{:?}'", x),
542542
None => panic!("Unexpected end of input")
543543
}
544544
token.token = OPERATOR;

0 commit comments

Comments
 (0)