better error on missing #[start]

This commit is contained in:
Ralf Jung 2023-07-04 13:23:05 +02:00
parent 89c2596dde
commit 812f9b2620
2 changed files with 6 additions and 2 deletions

View File

@ -67,7 +67,7 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
if tcx.sess.compile_status().is_err() {
tcx.sess.fatal("miri cannot be run on programs that fail compilation");
}
;
init_late_loggers(handler, tcx);
if !tcx.sess.crate_types().contains(&CrateType::Executable) {
tcx.sess.fatal("miri only makes sense on bin crates");

View File

@ -365,7 +365,11 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
match entry_type {
EntryFnType::Main { .. } => {
let start_id = tcx.lang_items().start_fn().unwrap();
let start_id = tcx.lang_items().start_fn().unwrap_or_else(|| {
tcx.sess.fatal(
"could not find start function. Make sure the entry point is marked with `#[start]`."
);
});
let main_ret_ty = tcx.fn_sig(entry_id).no_bound_vars().unwrap().output();
let main_ret_ty = main_ret_ty.no_bound_vars().unwrap();
let start_instance = ty::Instance::resolve(