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