@@ -68,7 +68,8 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
6868 ty:: Error ( _) => ty,
6969 ty:: FnDef ( ..) => ty,
7070 _ => {
71- tcx. dcx ( )
71+ let guar = tcx
72+ . dcx ( )
7273 . struct_span_err ( op_sp, "invalid `sym` operand" )
7374 . with_span_label (
7475 tcx. def_span ( anon_const. def_id ) ,
@@ -77,7 +78,7 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
7778 . with_help ( "`sym` operands must refer to either a function or a static" )
7879 . emit ( ) ;
7980
80- Ty :: new_error_with_message ( tcx, span , format ! ( "invalid type for `sym` operand" ) )
81+ Ty :: new_error ( tcx, guar )
8182 }
8283 }
8384 }
@@ -91,7 +92,8 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
9192 ty:: Error ( _) => ty,
9293 ty:: Int ( _) | ty:: Uint ( _) => ty,
9394 _ => {
94- tcx. dcx ( )
95+ let guar = tcx
96+ . dcx ( )
9597 . struct_span_err ( op_sp, "invalid type for `const` operand" )
9698 . with_span_label (
9799 tcx. def_span ( anon_const. def_id ) ,
@@ -100,11 +102,7 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
100102 . with_help ( "`const` operands must be of an integer type" )
101103 . emit ( ) ;
102104
103- Ty :: new_error_with_message (
104- tcx,
105- span,
106- format ! ( "invalid type for `const` operand" ) ,
107- )
105+ Ty :: new_error ( tcx, guar)
108106 }
109107 }
110108 }
0 commit comments