@@ -68,7 +68,8 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
68
68
ty:: Error ( _) => ty,
69
69
ty:: FnDef ( ..) => ty,
70
70
_ => {
71
- tcx. dcx ( )
71
+ let guar = tcx
72
+ . dcx ( )
72
73
. struct_span_err ( op_sp, "invalid `sym` operand" )
73
74
. with_span_label (
74
75
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> {
77
78
. with_help ( "`sym` operands must refer to either a function or a static" )
78
79
. emit ( ) ;
79
80
80
- Ty :: new_error_with_message ( tcx, span , format ! ( "invalid type for `sym` operand" ) )
81
+ Ty :: new_error ( tcx, guar )
81
82
}
82
83
}
83
84
}
@@ -91,7 +92,8 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
91
92
ty:: Error ( _) => ty,
92
93
ty:: Int ( _) | ty:: Uint ( _) => ty,
93
94
_ => {
94
- tcx. dcx ( )
95
+ let guar = tcx
96
+ . dcx ( )
95
97
. struct_span_err ( op_sp, "invalid type for `const` operand" )
96
98
. with_span_label (
97
99
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> {
100
102
. with_help ( "`const` operands must be of an integer type" )
101
103
. emit ( ) ;
102
104
103
- Ty :: new_error_with_message (
104
- tcx,
105
- span,
106
- format ! ( "invalid type for `const` operand" ) ,
107
- )
105
+ Ty :: new_error ( tcx, guar)
108
106
}
109
107
}
110
108
}
0 commit comments