Implement type ascription.
This commit is contained in:
committed by
Vadim Petrochenkov
parent
ce7bc51933
commit
b8157cc67f
@@ -445,7 +445,7 @@ fn needs_parentheses(expr: &ast::Expr) -> bool {
|
||||
ast::ExprAssign(..) | ast::ExprBinary(..) |
|
||||
ast::ExprClosure(..) |
|
||||
ast::ExprAssignOp(..) | ast::ExprCast(..) |
|
||||
ast::ExprInPlace(..) => true,
|
||||
ast::ExprInPlace(..) | ast::ExprType(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@@ -2036,6 +2036,11 @@ impl<'a> State<'a> {
|
||||
try!(self.word_space("as"));
|
||||
try!(self.print_type(&**ty));
|
||||
}
|
||||
ast::ExprType(ref expr, ref ty) => {
|
||||
try!(self.print_expr(&**expr));
|
||||
try!(self.word_space(":"));
|
||||
try!(self.print_type(&**ty));
|
||||
}
|
||||
ast::ExprIf(ref test, ref blk, ref elseopt) => {
|
||||
try!(self.print_if(&**test, &**blk, elseopt.as_ref().map(|e| &**e)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user