@@ -97,11 +97,11 @@ impl<'a, 'tcx> ExprVisitor<'a, 'tcx> {
9797 format ! ( "{} bits" , size. bits( ) )
9898 }
9999 Ok ( SizeSkeleton :: Pointer { tail, .. } ) => {
100- format ! ( "pointer to {} " , tail)
100+ format ! ( "pointer to `{}` " , tail)
101101 }
102102 Err ( LayoutError :: Unknown ( bad) ) => {
103103 if bad == ty {
104- "this type's size can vary " . to_owned ( )
104+ "this type does not have a fixed size " . to_owned ( )
105105 } else {
106106 format ! ( "size can vary because of {}" , bad)
107107 }
@@ -110,11 +110,16 @@ impl<'a, 'tcx> ExprVisitor<'a, 'tcx> {
110110 }
111111 } ;
112112
113- struct_span_err ! ( self . tcx. sess, span, E0512 ,
114- "transmute called with types of different sizes" )
115- . note ( & format ! ( "source type: {} ({})" , from, skeleton_string( from, sk_from) ) )
116- . note ( & format ! ( "target type: {} ({})" , to, skeleton_string( to, sk_to) ) )
117- . emit ( ) ;
113+ let mut err = struct_span_err ! ( self . tcx. sess, span, E0512 ,
114+ "cannot transmute between types of different sizes, \
115+ or dependently-sized types") ;
116+ if from == to {
117+ err. note ( & format ! ( "`{}` does not have a fixed size" , from) ) ;
118+ } else {
119+ err. note ( & format ! ( "source type: `{}` ({})" , from, skeleton_string( from, sk_from) ) )
120+ . note ( & format ! ( "target type: `{}` ({})" , to, skeleton_string( to, sk_to) ) ) ;
121+ }
122+ err. emit ( )
118123 }
119124}
120125
0 commit comments