@@ -152,26 +152,22 @@ pub(super) fn check_fn<'a, 'tcx>(
152
152
}
153
153
154
154
fn check_panic_info_fn ( tcx : TyCtxt < ' _ > , fn_id : LocalDefId , fn_sig : ty:: FnSig < ' _ > ) {
155
+ let span = tcx. def_span ( fn_id) ;
156
+
155
157
let DefKind :: Fn = tcx. def_kind ( fn_id) else {
156
- let span = tcx. def_span ( fn_id) ;
157
158
tcx. dcx ( ) . span_err ( span, "should be a function" ) ;
158
159
return ;
159
160
} ;
160
161
161
162
let generic_counts = tcx. generics_of ( fn_id) . own_counts ( ) ;
162
163
if generic_counts. types != 0 {
163
- let span = tcx. def_span ( fn_id) ;
164
164
tcx. dcx ( ) . span_err ( span, "should have no type parameters" ) ;
165
165
}
166
166
if generic_counts. consts != 0 {
167
- let span = tcx. def_span ( fn_id) ;
168
167
tcx. dcx ( ) . span_err ( span, "should have no const parameters" ) ;
169
168
}
170
169
171
- let Some ( panic_info_did) = tcx. lang_items ( ) . panic_info ( ) else {
172
- tcx. dcx ( ) . err ( "language item required, but not found: `panic_info`" ) ;
173
- return ;
174
- } ;
170
+ let panic_info_did = tcx. require_lang_item ( hir:: LangItem :: PanicInfo , Some ( span) ) ;
175
171
176
172
// build type `for<'a, 'b> fn(&'a PanicInfo<'b>) -> !`
177
173
let panic_info_ty = tcx. type_of ( panic_info_did) . instantiate (
@@ -203,11 +199,7 @@ fn check_panic_info_fn(tcx: TyCtxt<'_>, fn_id: LocalDefId, fn_sig: ty::FnSig<'_>
203
199
204
200
let _ = check_function_signature (
205
201
tcx,
206
- ObligationCause :: new (
207
- tcx. def_span ( fn_id) ,
208
- fn_id,
209
- ObligationCauseCode :: LangFunctionType ( sym:: panic_impl) ,
210
- ) ,
202
+ ObligationCause :: new ( span, fn_id, ObligationCauseCode :: LangFunctionType ( sym:: panic_impl) ) ,
211
203
fn_id. into ( ) ,
212
204
expected_sig,
213
205
) ;
0 commit comments