Commit ec92c3e 1 parent b5ac64b commit ec92c3e Copy full SHA for ec92c3e
File tree 1 file changed +12
-2
lines changed
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,13 @@ pub(crate) fn maybe_create_entry_wrapper(
70
70
} ;
71
71
72
72
let entry_name = tcx. sess . target . options . entry_name . as_ref ( ) ;
73
- let cmain_func_id = m. declare_function ( entry_name, Linkage :: Export , & cmain_sig) . unwrap ( ) ;
73
+ let cmain_func_id = match m. declare_function ( entry_name, Linkage :: Export , & cmain_sig) {
74
+ Ok ( func_id) => func_id,
75
+ Err ( err) => {
76
+ tcx. sess
77
+ . fatal ( & format ! ( "entry symbol `{entry_name}` declared multiple times: {err}" ) ) ;
78
+ }
79
+ } ;
74
80
75
81
let instance = Instance :: mono ( tcx, rust_main_def_id) . polymorphize ( tcx) ;
76
82
@@ -162,7 +168,11 @@ pub(crate) fn maybe_create_entry_wrapper(
162
168
bcx. seal_all_blocks ( ) ;
163
169
bcx. finalize ( ) ;
164
170
}
165
- m. define_function ( cmain_func_id, & mut ctx) . unwrap ( ) ;
171
+
172
+ if let Err ( err) = m. define_function ( cmain_func_id, & mut ctx) {
173
+ tcx. sess . fatal ( & format ! ( "entry symbol `{entry_name}` defined multiple times: {err}" ) ) ;
174
+ }
175
+
166
176
unwind_context. add_function ( cmain_func_id, & ctx, m. isa ( ) ) ;
167
177
}
168
178
}
You can’t perform that action at this time.
0 commit comments