diff options
| author | Nick Cameron <nrc@ncameron.org> | 2016-04-16 16:42:56 +1200 |
|---|---|---|
| committer | Nick Cameron <nrc@ncameron.org> | 2016-04-16 16:42:56 +1200 |
| commit | 41e037da7ede08d648ca196cbbba12b450aa2c8b (patch) | |
| tree | d65b1849b1e886282368ef84f1bcd37fd593fa98 | |
| parent | f70d306b838b8336bd737234184020542a8b535c (diff) | |
| parent | 45a83d18cc71fa4d7972d38c9302253ddec1c6cb (diff) | |
Merge pull request #941 from marcusklaas/type-ascription
Format type ascription
| -rw-r--r-- | src/expr.rs | 5 | ||||
| -rw-r--r-- | tests/source/type-ascription.rs | 9 | ||||
| -rw-r--r-- | tests/target/type-ascription.rs | 14 |
3 files changed, 26 insertions, 2 deletions
diff --git a/src/expr.rs b/src/expr.rs index 057a0ef1056..90ccb87e2d4 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -177,6 +177,9 @@ impl Rewrite for ast::Expr { ast::ExprKind::Cast(ref expr, ref ty) => { rewrite_pair(&**expr, &**ty, "", " as ", "", context, width, offset) } + ast::ExprKind::Type(ref expr, ref ty) => { + rewrite_pair(&**expr, &**ty, "", ": ", "", context, width, offset) + } ast::ExprKind::Index(ref expr, ref index) => { rewrite_pair(&**expr, &**index, "", "[", "]", context, width, offset) } @@ -210,8 +213,6 @@ impl Rewrite for ast::Expr { // satisfy our width restrictions. ast::ExprKind::InPlace(..) | ast::ExprKind::InlineAsm(..) | - // TODO(#848): Handle type ascription - ast::ExprKind::Type(_, _) | // TODO(#867): Handle try shorthand ast::ExprKind::Try(_) => { wrap_str(context.snippet(self.span), diff --git a/tests/source/type-ascription.rs b/tests/source/type-ascription.rs new file mode 100644 index 00000000000..3b761f4fc78 --- /dev/null +++ b/tests/source/type-ascription.rs @@ -0,0 +1,9 @@ +fn main() { + let xxxxxxxxxxx = yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy : SomeTrait<AA, BB, CC>; + + let xxxxxxxxxxxxxxx = yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA; + + let z = funk(yyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzz, wwwwww): AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA; + + x : u32 - 1u32 / 10f32 : u32 +} diff --git a/tests/target/type-ascription.rs b/tests/target/type-ascription.rs new file mode 100644 index 00000000000..22f03713388 --- /dev/null +++ b/tests/target/type-ascription.rs @@ -0,0 +1,14 @@ +fn main() { + let xxxxxxxxxxx = yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: SomeTrait<AA, + BB, + CC>; + + let xxxxxxxxxxxxxxx = + yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA; + + let z = funk(yyyyyyyyyyyyyyy, + zzzzzzzzzzzzzzzz, + wwwwww): AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA; + + x: u32 - 1u32 / 10f32: u32 +} |
