@@ -67,7 +67,8 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
6767 ty:: Error ( _) => ty,
6868 ty:: FnDef ( ..) => ty,
6969 _ => {
70- tcx. dcx ( )
70+ let guar = tcx
71+ . dcx ( )
7172 . struct_span_err ( op_sp, "invalid `sym` operand" )
7273 . with_span_label (
7374 tcx. def_span ( anon_const. def_id ) ,
@@ -76,7 +77,7 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
7677 . with_help ( "`sym` operands must refer to either a function or a static" )
7778 . emit ( ) ;
7879
79- Ty :: new_error_with_message ( tcx, span , format ! ( "invalid type for `sym` operand" ) )
80+ Ty :: new_error ( tcx, guar )
8081 }
8182 }
8283 }
@@ -90,7 +91,8 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
9091 ty:: Error ( _) => ty,
9192 ty:: Int ( _) | ty:: Uint ( _) => ty,
9293 _ => {
93- tcx. dcx ( )
94+ let guar = tcx
95+ . dcx ( )
9496 . struct_span_err ( op_sp, "invalid type for `const` operand" )
9597 . with_span_label (
9698 tcx. def_span ( anon_const. def_id ) ,
@@ -99,11 +101,7 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
99101 . with_help ( "`const` operands must be of an integer type" )
100102 . emit ( ) ;
101103
102- Ty :: new_error_with_message (
103- tcx,
104- span,
105- format ! ( "invalid type for `const` operand" ) ,
106- )
104+ Ty :: new_error ( tcx, guar)
107105 }
108106 }
109107 }
0 commit comments