diff --git a/benches/helpers/miri_helper.rs b/benches/helpers/miri_helper.rs index 261be48aa0..8397fde946 100644 --- a/benches/helpers/miri_helper.rs +++ b/benches/helpers/miri_helper.rs @@ -26,7 +26,7 @@ impl rustc_driver::Callbacks for MiriCompilerCalls<'_> { self.bencher.iter(|| { let config = miri::MiriConfig::default(); - miri::eval_main(tcx, entry_def_id.to_def_id(), config); + miri::eval_main(tcx, entry_def_id, config); }); }); diff --git a/rust-version b/rust-version index d1505e9d84..1f61617e11 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -06f0adb34570ba83fee391abeb0bec0eec28a234 +bcd696d722c04a0f8c34d884aa4ed2322f55cdd8 diff --git a/src/bin/miri.rs b/src/bin/miri.rs index 23a58cf2d8..41776090be 100644 --- a/src/bin/miri.rs +++ b/src/bin/miri.rs @@ -50,7 +50,7 @@ impl rustc_driver::Callbacks for MiriCompilerCalls { env::set_current_dir(cwd).unwrap(); } - if let Some(return_code) = miri::eval_main(tcx, entry_def_id.to_def_id(), config) { + if let Some(return_code) = miri::eval_main(tcx, entry_def_id, config) { std::process::exit( i32::try_from(return_code).expect("Return value was too large!"), ); diff --git a/test-cargo-miri/Cargo.toml b/test-cargo-miri/Cargo.toml index ae46ebc02a..4dbe1aeff2 100644 --- a/test-cargo-miri/Cargo.toml +++ b/test-cargo-miri/Cargo.toml @@ -23,3 +23,7 @@ serde_derive = "1.0" # not actually used, but exercises some unique code path (` [lib] test = false # test that this is respected (will show in the output) + +[[test]] +name = "main" +harness = false diff --git a/test-cargo-miri/src/lib.rs b/test-cargo-miri/src/lib.rs index 5b84c454c3..9d8eb067d6 100644 --- a/test-cargo-miri/src/lib.rs +++ b/test-cargo-miri/src/lib.rs @@ -14,3 +14,7 @@ pub fn make_true() -> bool { issue_1760::use_the_dependency!(); issue_1691::use_me() } + +pub fn main() { + println!("imported main"); +} diff --git a/test-cargo-miri/test.cross-target.stdout.ref b/test-cargo-miri/test.cross-target.stdout.ref index 7079798e42..e36abd8706 100644 --- a/test-cargo-miri/test.cross-target.stdout.ref +++ b/test-cargo-miri/test.cross-target.stdout.ref @@ -3,6 +3,7 @@ running 1 test . test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out +imported main running 7 tests ..i.... diff --git a/test-cargo-miri/test.default.stdout.ref b/test-cargo-miri/test.default.stdout.ref index 6e35c374e1..470e5b36fc 100644 --- a/test-cargo-miri/test.default.stdout.ref +++ b/test-cargo-miri/test.default.stdout.ref @@ -3,6 +3,7 @@ running 1 test . test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out +imported main running 7 tests ..i.... diff --git a/test-cargo-miri/test.filter.cross-target.stdout.ref b/test-cargo-miri/test.filter.cross-target.stdout.ref index 37efb8c3ee..fb722c5e71 100644 --- a/test-cargo-miri/test.filter.cross-target.stdout.ref +++ b/test-cargo-miri/test.filter.cross-target.stdout.ref @@ -3,6 +3,7 @@ running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out +imported main running 1 test test simple1 ... ok diff --git a/test-cargo-miri/test.filter.stdout.ref b/test-cargo-miri/test.filter.stdout.ref index 11e47e8ff8..cf1b309a12 100644 --- a/test-cargo-miri/test.filter.stdout.ref +++ b/test-cargo-miri/test.filter.stdout.ref @@ -3,6 +3,7 @@ running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out +imported main running 1 test test simple1 ... ok diff --git a/test-cargo-miri/tests/main.rs b/test-cargo-miri/tests/main.rs new file mode 100644 index 0000000000..bb94c8f378 --- /dev/null +++ b/test-cargo-miri/tests/main.rs @@ -0,0 +1,3 @@ +#![feature(imported_main)] + +use cargo_miri_test::main; diff --git a/tests/run-pass/main_fn.rs b/tests/run-pass/main_fn.rs new file mode 100644 index 0000000000..3b84d1abe6 --- /dev/null +++ b/tests/run-pass/main_fn.rs @@ -0,0 +1,7 @@ +#![feature(imported_main)] + +mod foo { + pub(crate) fn bar() {} +} + +use foo::bar as main;