@@ -11,19 +11,14 @@ use rustc_session::config::{CrateType, EntryFnType, RemapPathScopeComponents, si
11
11
use rustc_span:: symbol:: sym;
12
12
use rustc_span:: { Span , Symbol } ;
13
13
14
- use crate :: errors:: {
15
- AttrOnlyInFunctions , ExternMain , MultipleRustcMain , MultipleStartFunctions , NoMainErr ,
16
- } ;
14
+ use crate :: errors:: { AttrOnlyInFunctions , ExternMain , MultipleRustcMain , NoMainErr } ;
17
15
18
16
struct EntryContext < ' tcx > {
19
17
tcx : TyCtxt < ' tcx > ,
20
18
21
19
/// The function has the `#[rustc_main]` attribute.
22
20
rustc_main_fn : Option < ( LocalDefId , Span ) > ,
23
21
24
- /// The function that has the attribute `#[start]` on it.
25
- start_fn : Option < ( LocalDefId , Span ) > ,
26
-
27
22
/// The functions that one might think are `main` but aren't, e.g.
28
23
/// main functions not defined at the top level. For diagnostics.
29
24
non_main_fns : Vec < Span > ,
@@ -41,8 +36,7 @@ fn entry_fn(tcx: TyCtxt<'_>, (): ()) -> Option<(DefId, EntryFnType)> {
41
36
return None ;
42
37
}
43
38
44
- let mut ctxt =
45
- EntryContext { tcx, rustc_main_fn : None , start_fn : None , non_main_fns : Vec :: new ( ) } ;
39
+ let mut ctxt = EntryContext { tcx, rustc_main_fn : None , non_main_fns : Vec :: new ( ) } ;
46
40
47
41
for id in tcx. hir ( ) . items ( ) {
48
42
check_and_search_item ( id, & mut ctxt) ;
@@ -58,7 +52,7 @@ fn attr_span_by_symbol(ctxt: &EntryContext<'_>, id: ItemId, sym: Symbol) -> Opti
58
52
59
53
fn check_and_search_item ( id : ItemId , ctxt : & mut EntryContext < ' _ > ) {
60
54
if !matches ! ( ctxt. tcx. def_kind( id. owner_id) , DefKind :: Fn ) {
61
- for attr in [ sym:: start , sym :: rustc_main] {
55
+ for attr in [ sym:: rustc_main] {
62
56
if let Some ( span) = attr_span_by_symbol ( ctxt, id, attr) {
63
57
ctxt. tcx . dcx ( ) . emit_err ( AttrOnlyInFunctions { span, attr } ) ;
64
58
}
@@ -92,24 +86,11 @@ fn check_and_search_item(id: ItemId, ctxt: &mut EntryContext<'_>) {
92
86
} ) ;
93
87
}
94
88
}
95
- EntryPointType :: Start => {
96
- if ctxt. start_fn . is_none ( ) {
97
- ctxt. start_fn = Some ( ( id. owner_id . def_id , ctxt. tcx . def_span ( id. owner_id ) ) ) ;
98
- } else {
99
- ctxt. tcx . dcx ( ) . emit_err ( MultipleStartFunctions {
100
- span : ctxt. tcx . def_span ( id. owner_id ) ,
101
- labeled : ctxt. tcx . def_span ( id. owner_id . to_def_id ( ) ) ,
102
- previous : ctxt. start_fn . unwrap ( ) . 1 ,
103
- } ) ;
104
- }
105
- }
106
89
}
107
90
}
108
91
109
92
fn configure_main ( tcx : TyCtxt < ' _ > , visitor : & EntryContext < ' _ > ) -> Option < ( DefId , EntryFnType ) > {
110
- if let Some ( ( def_id, _) ) = visitor. start_fn {
111
- Some ( ( def_id. to_def_id ( ) , EntryFnType :: Start ) )
112
- } else if let Some ( ( local_def_id, _) ) = visitor. rustc_main_fn {
93
+ if let Some ( ( local_def_id, _) ) = visitor. rustc_main_fn {
113
94
let def_id = local_def_id. to_def_id ( ) ;
114
95
Some ( ( def_id, EntryFnType :: Main { sigpipe : sigpipe ( tcx) } ) )
115
96
} else {
0 commit comments