diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2013-09-01 23:36:25 -0400 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2013-09-02 00:19:34 -0400 |
| commit | 7a52154d78ff85fe87647685885e9958a50cb42e (patch) | |
| tree | 596a53e0a77e233837542210e302101cefae21a2 /src | |
| parent | 73a28e595c2aacf38c12a56807547e7cda6839ee (diff) | |
| download | rust-7a52154d78ff85fe87647685885e9958a50cb42e.tar.gz rust-7a52154d78ff85fe87647685885e9958a50cb42e.zip | |
repr: print functions as `fn()`
Diffstat (limited to 'src')
| -rw-r--r-- | src/libstd/repr.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs index 3e2c5773acc..381cd449695 100644 --- a/src/libstd/repr.rs +++ b/src/libstd/repr.rs @@ -551,13 +551,19 @@ impl<'self> TyVisitor for ReprVisitor<'self> { } fn visit_enter_fn(&mut self, _purity: uint, _proto: uint, - _n_inputs: uint, _retstyle: uint) -> bool { true } + _n_inputs: uint, _retstyle: uint) -> bool { + self.writer.write("fn(".as_bytes()); + true + } fn visit_fn_input(&mut self, _i: uint, _mode: uint, _inner: *TyDesc) -> bool { + // FIXME: #8917: should print out the parameter types here, separated by commas true } fn visit_fn_output(&mut self, _retstyle: uint, _inner: *TyDesc) -> bool { + self.writer.write(")".as_bytes()); + // FIXME: #8917: should print out the output type here, as `-> T` true } @@ -596,6 +602,7 @@ struct P {a: int, b: float} #[test] fn test_repr() { + use prelude::*; use str; use str::Str; use rt::io::Decorator; @@ -653,6 +660,8 @@ fn test_repr() { exact_test(&(10u64, ~"hello"), "(10u64, ~\"hello\")"); + exact_test(&(&println), "&fn()"); + struct Foo; exact_test(&(~[Foo, Foo]), "~[repr::test_repr::Foo, repr::test_repr::Foo]"); } |
