@@ -86,17 +86,16 @@ impl<'a, 'tcx> ExprVisitor<'a, 'tcx> {
86
86
// Special-case transmutting from `typeof(function)` and
87
87
// `Option<typeof(function)>` to present a clearer error.
88
88
let from = unpack_option_like ( self . tcx . global_tcx ( ) , from) ;
89
- match ( & from. sty , sk_to) {
90
- ( & ty:: TyFnDef ( ..) , SizeSkeleton :: Known ( size_to) )
91
- if size_to == Pointer . size ( self . tcx ) => {
89
+ if let ( & ty:: TyFnDef ( ..) , SizeSkeleton :: Known ( size_to) ) = ( & from. sty , sk_to) {
90
+ if size_to == Pointer . size ( self . tcx ) {
92
91
struct_span_err ! ( self . tcx. sess, span, E0591 ,
93
- "`{}` is zero-sized and can't be transmuted to `{}`" ,
94
- from, to)
95
- . span_note ( span, "cast with `as` to a pointer instead" )
92
+ "can't transmute zero-sized type" )
93
+ . note ( & format ! ( "source type: {}" , from) )
94
+ . note ( & format ! ( "target type: {}" , to) )
95
+ . help ( "cast with `as` to a pointer instead" )
96
96
. emit ( ) ;
97
97
return ;
98
98
}
99
- _ => { }
100
99
}
101
100
}
102
101
@@ -111,7 +110,7 @@ impl<'a, 'tcx> ExprVisitor<'a, 'tcx> {
111
110
}
112
111
Err ( LayoutError :: Unknown ( bad) ) => {
113
112
if bad == ty {
114
- format ! ( "size can vary" )
113
+ format ! ( "this type's size can vary" )
115
114
} else {
116
115
format ! ( "size can vary because of {}" , bad)
117
116
}
@@ -121,14 +120,9 @@ impl<'a, 'tcx> ExprVisitor<'a, 'tcx> {
121
120
} ;
122
121
123
122
struct_span_err ! ( self . tcx. sess, span, E0512 ,
124
- "transmute called with differently sized types: \
125
- {} ({}) to {} ({})",
126
- from, skeleton_string( from, sk_from) ,
127
- to, skeleton_string( to, sk_to) )
128
- . span_label ( span,
129
- format ! ( "transmuting between {} and {}" ,
130
- skeleton_string( from, sk_from) ,
131
- skeleton_string( to, sk_to) ) )
123
+ "transmute called with types of different sizes" )
124
+ . note ( & format ! ( "source type: {} ({})" , from, skeleton_string( from, sk_from) ) )
125
+ . note ( & format ! ( "target type: {} ({})" , to, skeleton_string( to, sk_to) ) )
132
126
. emit ( ) ;
133
127
}
134
128
}
0 commit comments