Skip to content

Commit 2a08c63

Browse files
committed
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 #1116.
2 parents 20e843f + e325ad2 commit 2a08c63

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/eval.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
6262
// Setup first stack-frame
6363
let main_instance = ty::Instance::mono(tcx, main_id);
6464
let main_mir = ecx.load_mir(main_instance.def, None)?;
65-
66-
if !main_mir.return_ty().is_unit() || main_mir.arg_count != 0 {
67-
throw_unsup_format!("miri does not support main functions without `fn()` type signatures");
65+
if main_mir.arg_count != 0 {
66+
bug!("main function must not take any arguments");
6867
}
6968

7069
let start_id = tcx.lang_items().start_fn().unwrap();

tests/run-pass/main_result.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() -> Result<(), Box<dyn std::error::Error>> {
2+
Ok(())
3+
}

0 commit comments

Comments
 (0)