1414
1515use prelude:: v1:: * ;
1616
17- use cell:: { Cell , RefCell , Ref , RefMut , BorrowState } ;
17+ use cell:: { UnsafeCell , Cell , RefCell , Ref , RefMut , BorrowState } ;
1818use marker:: PhantomData ;
1919use mem;
2020use num:: flt2dec;
@@ -25,6 +25,7 @@ use str;
2525
2626#[ unstable( feature = "fmt_flags_align" , issue = "27726" ) ]
2727/// Possible alignments returned by `Formatter::align`
28+ #[ derive( Debug ) ]
2829pub enum Alignment {
2930 /// Indication that contents should be left-aligned.
3031 Left ,
@@ -152,6 +153,7 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W {
152153/// A struct to represent both where to emit formatting strings to and how they
153154/// should be formatted. A mutable version of this is passed to all formatting
154155/// traits.
156+ #[ allow( missing_debug_implementations) ]
155157#[ stable( feature = "rust1" , since = "1.0.0" ) ]
156158pub struct Formatter < ' a > {
157159 flags : u32 ,
@@ -175,6 +177,7 @@ enum Void {}
175177/// compile time it is ensured that the function and the value have the correct
176178/// types, and then this struct is used to canonicalize arguments to one type.
177179#[ derive( Copy ) ]
180+ #[ allow( missing_debug_implementations) ]
178181#[ unstable( feature = "fmt_internals" , reason = "internal to format_args!" ,
179182 issue = "0" ) ]
180183#[ doc( hidden) ]
@@ -1585,7 +1588,9 @@ impl<T: ?Sized> Debug for PhantomData<T> {
15851588#[ stable( feature = "rust1" , since = "1.0.0" ) ]
15861589impl < T : Copy + Debug > Debug for Cell < T > {
15871590 fn fmt ( & self , f : & mut Formatter ) -> Result {
1588- write ! ( f, "Cell {{ value: {:?} }}" , self . get( ) )
1591+ f. debug_struct ( "Cell" )
1592+ . field ( "value" , & self . get ( ) )
1593+ . finish ( )
15891594 }
15901595}
15911596
@@ -1594,9 +1599,15 @@ impl<T: ?Sized + Debug> Debug for RefCell<T> {
15941599 fn fmt ( & self , f : & mut Formatter ) -> Result {
15951600 match self . borrow_state ( ) {
15961601 BorrowState :: Unused | BorrowState :: Reading => {
1597- write ! ( f, "RefCell {{ value: {:?} }}" , self . borrow( ) )
1602+ f. debug_struct ( "RefCell" )
1603+ . field ( "value" , & self . borrow ( ) )
1604+ . finish ( )
1605+ }
1606+ BorrowState :: Writing => {
1607+ f. debug_struct ( "RefCell" )
1608+ . field ( "value" , & "<borrowed>" )
1609+ . finish ( )
15981610 }
1599- BorrowState :: Writing => write ! ( f, "RefCell {{ <borrowed> }}" ) ,
16001611 }
16011612 }
16021613}
@@ -1615,5 +1626,12 @@ impl<'b, T: ?Sized + Debug> Debug for RefMut<'b, T> {
16151626 }
16161627}
16171628
1629+ #[ stable( feature = "core_impl_debug" , since = "1.9.0" ) ]
1630+ impl < T : ?Sized + Debug > Debug for UnsafeCell < T > {
1631+ fn fmt ( & self , f : & mut Formatter ) -> Result {
1632+ f. pad ( "UnsafeCell" )
1633+ }
1634+ }
1635+
16181636// If you expected tests to be here, look instead at the run-pass/ifmt.rs test,
16191637// it's a lot easier than creating all of the rt::Piece structures here.
0 commit comments