Do not panic on type ascription or try shorthand

Instead, simply format expressions involving these unstable features
as they were found.
This commit is contained in:
Marcus Klaas 2016-03-30 00:01:54 +02:00
parent 9eee93306a
commit f941646118

View File

@ -176,9 +176,6 @@ impl Rewrite for ast::Expr {
ast::ExprKind::Cast(ref expr, ref ty) => {
rewrite_pair(&**expr, &**ty, "", " as ", "", context, width, offset)
}
// TODO(#848): Handle type ascription; rust tracking issue
// https://github.com/rust-lang/rust/issues/23416
ast::ExprKind::Type(_, _) => unimplemented!(),
ast::ExprKind::Index(ref expr, ref index) => {
rewrite_pair(&**expr, &**index, "", "[", "]", context, width, offset)
}
@ -211,15 +208,16 @@ impl Rewrite for ast::Expr {
// We do not format these expressions yet, but they should still
// satisfy our width restrictions.
ast::ExprKind::InPlace(..) |
ast::ExprKind::InlineAsm(..) => {
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),
context.config.max_width,
width,
offset)
}
// TODO(#867): Handle type ascription; rust tracking issue
// https://github.com/rust-lang/rust/issues/31436
ast::ExprKind::Try(_) => unimplemented!(),
};
result.and_then(|res| recover_comment_removed(res, self.span, context, width, offset))
}