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