Skip to content

Commit 7a52154

Browse files
committed
repr: print functions as fn()
1 parent 73a28e5 commit 7a52154

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/libstd/repr.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,13 +551,19 @@ impl<'self> TyVisitor for ReprVisitor<'self> {
551551
}
552552

553553
fn visit_enter_fn(&mut self, _purity: uint, _proto: uint,
554-
_n_inputs: uint, _retstyle: uint) -> bool { true }
554+
_n_inputs: uint, _retstyle: uint) -> bool {
555+
self.writer.write("fn(".as_bytes());
556+
true
557+
}
555558

556559
fn visit_fn_input(&mut self, _i: uint, _mode: uint, _inner: *TyDesc) -> bool {
560+
// FIXME: #8917: should print out the parameter types here, separated by commas
557561
true
558562
}
559563

560564
fn visit_fn_output(&mut self, _retstyle: uint, _inner: *TyDesc) -> bool {
565+
self.writer.write(")".as_bytes());
566+
// FIXME: #8917: should print out the output type here, as `-> T`
561567
true
562568
}
563569

@@ -596,6 +602,7 @@ struct P {a: int, b: float}
596602

597603
#[test]
598604
fn test_repr() {
605+
use prelude::*;
599606
use str;
600607
use str::Str;
601608
use rt::io::Decorator;
@@ -653,6 +660,8 @@ fn test_repr() {
653660
exact_test(&(10u64, ~"hello"),
654661
"(10u64, ~\"hello\")");
655662

663+
exact_test(&(&println), "&fn()");
664+
656665
struct Foo;
657666
exact_test(&(~[Foo, Foo]), "~[repr::test_repr::Foo, repr::test_repr::Foo]");
658667
}

0 commit comments

Comments
 (0)