@@ -5,7 +5,7 @@ use rustc_hir as hir;
55use rustc_hir:: Node ;
66use rustc_infer:: infer:: TyCtxtInferExt ;
77use rustc_middle:: span_bug;
8- use rustc_middle:: ty:: { self , Ty , TyCtxt , TypingMode } ;
8+ use rustc_middle:: ty:: { self , TyCtxt , TypingMode } ;
99use rustc_session:: config:: EntryFnType ;
1010use rustc_span:: Span ;
1111use rustc_span:: def_id:: { CRATE_DEF_ID , DefId , LocalDefId } ;
@@ -19,7 +19,6 @@ use crate::errors;
1919pub ( crate ) fn check_for_entry_fn ( tcx : TyCtxt < ' _ > ) {
2020 match tcx. entry_fn ( ( ) ) {
2121 Some ( ( def_id, EntryFnType :: Main { .. } ) ) => check_main_fn_ty ( tcx, def_id) ,
22- Some ( ( def_id, EntryFnType :: Start ) ) => check_start_fn_ty ( tcx, def_id) ,
2322 _ => { }
2423 }
2524}
@@ -193,83 +192,3 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
193192 } ) ;
194193 }
195194}
196-
197- fn check_start_fn_ty ( tcx : TyCtxt < ' _ > , start_def_id : DefId ) {
198- let start_def_id = start_def_id. expect_local ( ) ;
199- let start_id = tcx. local_def_id_to_hir_id ( start_def_id) ;
200- let start_span = tcx. def_span ( start_def_id) ;
201- let start_t = tcx. type_of ( start_def_id) . instantiate_identity ( ) ;
202- match start_t. kind ( ) {
203- ty:: FnDef ( ..) => {
204- if let Node :: Item ( it) = tcx. hir_node ( start_id) {
205- if let hir:: ItemKind :: Fn ( sig, generics, _) = & it. kind {
206- let mut error = false ;
207- if !generics. params . is_empty ( ) {
208- tcx. dcx ( ) . emit_err ( errors:: StartFunctionParameters { span : generics. span } ) ;
209- error = true ;
210- }
211- if generics. has_where_clause_predicates {
212- tcx. dcx ( ) . emit_err ( errors:: StartFunctionWhere {
213- span : generics. where_clause_span ,
214- } ) ;
215- error = true ;
216- }
217- if sig. header . asyncness . is_async ( ) {
218- let span = tcx. def_span ( it. owner_id ) ;
219- tcx. dcx ( ) . emit_err ( errors:: StartAsync { span } ) ;
220- error = true ;
221- }
222-
223- let attrs = tcx. hir ( ) . attrs ( start_id) ;
224- for attr in attrs {
225- if attr. has_name ( sym:: track_caller) {
226- tcx. dcx ( ) . emit_err ( errors:: StartTrackCaller {
227- span : attr. span ,
228- start : start_span,
229- } ) ;
230- error = true ;
231- }
232- if attr. has_name ( sym:: target_feature)
233- // Calling functions with `#[target_feature]` is
234- // not unsafe on WASM, see #84988
235- && !tcx. sess . target . is_like_wasm
236- && !tcx. sess . opts . actually_rustdoc
237- {
238- tcx. dcx ( ) . emit_err ( errors:: StartTargetFeature {
239- span : attr. span ,
240- start : start_span,
241- } ) ;
242- error = true ;
243- }
244- }
245-
246- if error {
247- return ;
248- }
249- }
250- }
251-
252- let expected_sig = ty:: Binder :: dummy ( tcx. mk_fn_sig (
253- [ tcx. types . isize , Ty :: new_imm_ptr ( tcx, Ty :: new_imm_ptr ( tcx, tcx. types . u8 ) ) ] ,
254- tcx. types . isize ,
255- false ,
256- hir:: Safety :: Safe ,
257- ExternAbi :: Rust ,
258- ) ) ;
259-
260- let _ = check_function_signature (
261- tcx,
262- ObligationCause :: new (
263- start_span,
264- start_def_id,
265- ObligationCauseCode :: StartFunctionType ,
266- ) ,
267- start_def_id. into ( ) ,
268- expected_sig,
269- ) ;
270- }
271- _ => {
272- span_bug ! ( start_span, "start has a non-function type: found `{}`" , start_t) ;
273- }
274- }
275- }
0 commit comments