Auto merge of #1125 - RalfJung:main-result, r=oli-obk

support main functions with Result return type

Turns out we already properly create the substitution to call the libstd start-fn with an appropriate `main`, we just had an overzealous check in the way.

Fixes https://github.com/rust-lang/miri/issues/1116.
This commit is contained in:
bors 2019-12-23 16:51:55 +00:00
commit 2a08c63631
2 changed files with 5 additions and 3 deletions

View file

@ -62,9 +62,8 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
// Setup first stack-frame
let main_instance = ty::Instance::mono(tcx, main_id);
let main_mir = ecx.load_mir(main_instance.def, None)?;
if !main_mir.return_ty().is_unit() || main_mir.arg_count != 0 {
throw_unsup_format!("miri does not support main functions without `fn()` type signatures");
if main_mir.arg_count != 0 {
bug!("main function must not take any arguments");
}
let start_id = tcx.lang_items().start_fn().unwrap();

View file

@ -0,0 +1,3 @@
fn main() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}