@@ -148,72 +148,13 @@ pub(super) fn check_fn<'a, 'tcx>(
148
148
// we have a recursive call site and do the sadly stabilized fallback to `()`.
149
149
fcx. demand_suptype ( span, ret_ty, actual_return_ty) ;
150
150
151
- // Check that a function marked as `#[panic_handler]` has signature `fn(&PanicInfo) -> !`
152
- if tcx. is_lang_item ( fn_def_id. to_def_id ( ) , LangItem :: PanicImpl ) {
153
- check_panic_info_fn ( tcx, fn_def_id, fn_sig) ;
154
- }
155
-
156
151
if tcx. is_lang_item ( fn_def_id. to_def_id ( ) , LangItem :: Start ) {
157
152
check_lang_start_fn ( tcx, fn_sig, fn_def_id) ;
158
153
}
159
154
160
155
fcx. coroutine_types
161
156
}
162
157
163
- fn check_panic_info_fn ( tcx : TyCtxt < ' _ > , fn_id : LocalDefId , fn_sig : ty:: FnSig < ' _ > ) {
164
- let span = tcx. def_span ( fn_id) ;
165
-
166
- let DefKind :: Fn = tcx. def_kind ( fn_id) else {
167
- tcx. dcx ( ) . span_err ( span, "should be a function" ) ;
168
- return ;
169
- } ;
170
-
171
- let generic_counts = tcx. generics_of ( fn_id) . own_counts ( ) ;
172
- if generic_counts. types != 0 {
173
- tcx. dcx ( ) . span_err ( span, "should have no type parameters" ) ;
174
- }
175
- if generic_counts. consts != 0 {
176
- tcx. dcx ( ) . span_err ( span, "should have no const parameters" ) ;
177
- }
178
-
179
- let panic_info_did = tcx. require_lang_item ( hir:: LangItem :: PanicInfo , Some ( span) ) ;
180
-
181
- // build type `for<'a, 'b> fn(&'a PanicInfo<'b>) -> !`
182
- let panic_info_ty = tcx. type_of ( panic_info_did) . instantiate (
183
- tcx,
184
- & [ ty:: GenericArg :: from ( ty:: Region :: new_bound (
185
- tcx,
186
- ty:: INNERMOST ,
187
- ty:: BoundRegion { var : ty:: BoundVar :: from_u32 ( 1 ) , kind : ty:: BoundRegionKind :: Anon } ,
188
- ) ) ] ,
189
- ) ;
190
- let panic_info_ref_ty = Ty :: new_imm_ref (
191
- tcx,
192
- ty:: Region :: new_bound (
193
- tcx,
194
- ty:: INNERMOST ,
195
- ty:: BoundRegion { var : ty:: BoundVar :: ZERO , kind : ty:: BoundRegionKind :: Anon } ,
196
- ) ,
197
- panic_info_ty,
198
- ) ;
199
-
200
- let bounds = tcx. mk_bound_variable_kinds ( & [
201
- ty:: BoundVariableKind :: Region ( ty:: BoundRegionKind :: Anon ) ,
202
- ty:: BoundVariableKind :: Region ( ty:: BoundRegionKind :: Anon ) ,
203
- ] ) ;
204
- let expected_sig = ty:: Binder :: bind_with_vars (
205
- tcx. mk_fn_sig ( [ panic_info_ref_ty] , tcx. types . never , false , fn_sig. safety , ExternAbi :: Rust ) ,
206
- bounds,
207
- ) ;
208
-
209
- let _ = check_function_signature (
210
- tcx,
211
- ObligationCause :: new ( span, fn_id, ObligationCauseCode :: LangFunctionType ( sym:: panic_impl) ) ,
212
- fn_id. into ( ) ,
213
- expected_sig,
214
- ) ;
215
- }
216
-
217
158
fn check_lang_start_fn < ' tcx > ( tcx : TyCtxt < ' tcx > , fn_sig : ty:: FnSig < ' tcx > , def_id : LocalDefId ) {
218
159
// build type `fn(main: fn() -> T, argc: isize, argv: *const *const u8, sigpipe: u8)`
219
160
0 commit comments