@@ -7,6 +7,8 @@ use std::{io, iter};
77
88use super :: { AssertMessage , BinOp , TerminatorKind } ;
99
10+ use super :: BorrowKind ;
11+
1012pub fn function_name ( item : CrateItem ) -> String {
1113 let mut pretty_name = String :: new ( ) ;
1214 let body = item. body ( ) ;
@@ -40,7 +42,6 @@ pub fn function_body(body: &Body) -> String {
4042 pretty_body. push_str ( format ! ( "{}" , pretty_ty( local. ty. kind( ) ) ) . as_str ( ) ) ;
4143 pretty_body. push_str ( ";\n " ) ;
4244 } ) ;
43- pretty_body. push_str ( "}" ) ;
4445 pretty_body
4546}
4647
@@ -305,6 +306,7 @@ pub fn pretty_rvalue(rval: &Rvalue) -> String {
305306 pretty. push_str ( format ! ( "(*_{})" , addr. local) . as_str ( ) ) ;
306307 }
307308 Rvalue :: Aggregate ( aggregatekind, operands) => {
309+ // FIXME: Add pretty_aggregate function that returns a pretty string
308310 pretty. push_str ( format ! ( "{:#?}" , aggregatekind) . as_str ( ) ) ;
309311 pretty. push_str ( "(" ) ;
310312 operands. iter ( ) . enumerate ( ) . for_each ( |( i, op) | {
@@ -315,24 +317,26 @@ pub fn pretty_rvalue(rval: &Rvalue) -> String {
315317 } ) ;
316318 pretty. push_str ( ")" ) ;
317319 }
318- Rvalue :: BinaryOp ( bin, op, op2) => {
319- pretty. push_str ( & pretty_operand ( op) ) ;
320- pretty. push_str ( " " ) ;
320+ Rvalue :: BinaryOp ( bin, op1, op2) => {
321321 pretty. push_str ( format ! ( "{:#?}" , bin) . as_str ( ) ) ;
322- pretty. push_str ( " " ) ;
323- pretty. push_str ( & pretty_operand ( op2) ) ;
322+ pretty. push_str ( "(" ) ;
323+ pretty. push_str ( format ! ( "_{}" , & pretty_operand( op1) ) . as_str ( ) ) ;
324+ pretty. push_str ( ", " ) ;
325+ pretty. push_str ( format ! ( "{}" , & pretty_operand( op2) ) . as_str ( ) ) ;
326+ pretty. push_str ( ")" ) ;
324327 }
325328 Rvalue :: Cast ( _, op, ty) => {
326329 pretty. push_str ( & pretty_operand ( op) ) ;
327330 pretty. push_str ( " as " ) ;
328331 pretty. push_str ( & pretty_ty ( ty. kind ( ) ) ) ;
329332 }
330333 Rvalue :: CheckedBinaryOp ( bin, op1, op2) => {
331- pretty. push_str ( & pretty_operand ( op1) ) ;
332- pretty. push_str ( " " ) ;
333- pretty. push_str ( format ! ( "{:#?}" , bin) . as_str ( ) ) ;
334- pretty. push_str ( " " ) ;
335- pretty. push_str ( & pretty_operand ( op2) ) ;
334+ pretty. push_str ( format ! ( "Checked{:#?}" , bin) . as_str ( ) ) ;
335+ pretty. push_str ( "(" ) ;
336+ pretty. push_str ( format ! ( "_{}" , & pretty_operand( op1) ) . as_str ( ) ) ;
337+ pretty. push_str ( ", " ) ;
338+ pretty. push_str ( format ! ( "{}" , & pretty_operand( op2) ) . as_str ( ) ) ;
339+ pretty. push_str ( ")" ) ;
336340 }
337341 Rvalue :: CopyForDeref ( deref) => {
338342 pretty. push_str ( "CopyForDeref" ) ;
@@ -347,8 +351,11 @@ pub fn pretty_rvalue(rval: &Rvalue) -> String {
347351 pretty. push_str ( format ! ( "{}" , len. local) . as_str ( ) ) ;
348352 }
349353 Rvalue :: Ref ( _, borrowkind, place) => {
350- pretty. push_str ( "ref" ) ;
351- pretty. push_str ( format ! ( "{:#?}" , borrowkind) . as_str ( ) ) ;
354+ match borrowkind {
355+ BorrowKind :: Shared => pretty. push_str ( "&" ) ,
356+ BorrowKind :: Fake => pretty. push_str ( "&fake " ) ,
357+ BorrowKind :: Mut { .. } => pretty. push_str ( "&mut " ) ,
358+ }
352359 pretty. push_str ( format ! ( "{}" , place. local) . as_str ( ) ) ;
353360 }
354361 Rvalue :: Repeat ( op, cnst) => {
@@ -403,7 +410,7 @@ pub fn pretty_ty(ty: TyKind) -> String {
403410 FloatTy :: F64 => "f64" . to_string ( ) ,
404411 } ,
405412 RigidTy :: Adt ( def, _) => {
406- format ! ( "{:#? }" , with( |cx| cx. def_ty ( def. 0 ) ) )
413+ format ! ( "{}" , with( |cx| cx. adt_literal ( & def) ) )
407414 }
408415 RigidTy :: Str => "str" . to_string ( ) ,
409416 RigidTy :: Array ( ty, len) => {
0 commit comments