@@ -152,26 +152,22 @@ pub(super) fn check_fn<'a, 'tcx>(
152152}
153153
154154fn check_panic_info_fn ( tcx : TyCtxt < ' _ > , fn_id : LocalDefId , fn_sig : ty:: FnSig < ' _ > ) {
155+ let span = tcx. def_span ( fn_id) ;
156+
155157 let DefKind :: Fn = tcx. def_kind ( fn_id) else {
156- let span = tcx. def_span ( fn_id) ;
157158 tcx. dcx ( ) . span_err ( span, "should be a function" ) ;
158159 return ;
159160 } ;
160161
161162 let generic_counts = tcx. generics_of ( fn_id) . own_counts ( ) ;
162163 if generic_counts. types != 0 {
163- let span = tcx. def_span ( fn_id) ;
164164 tcx. dcx ( ) . span_err ( span, "should have no type parameters" ) ;
165165 }
166166 if generic_counts. consts != 0 {
167- let span = tcx. def_span ( fn_id) ;
168167 tcx. dcx ( ) . span_err ( span, "should have no const parameters" ) ;
169168 }
170169
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) ) ;
175171
176172 // build type `for<'a, 'b> fn(&'a PanicInfo<'b>) -> !`
177173 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<'_>
203199
204200 let _ = check_function_signature (
205201 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) ) ,
211203 fn_id. into ( ) ,
212204 expected_sig,
213205 ) ;
0 commit comments