diff options
| author | bors <bors@rust-lang.org> | 2023-10-23 13:57:19 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-10-23 13:57:19 +0000 |
| commit | 858a42bf46a49bc64228d69b757294fe7a9bba6c (patch) | |
| tree | 5e966ac652ba294bf527d9ec58f7e30364fe92e8 /tests | |
| parent | 8501f1c7ba440c97833ea9dec03965b4d5ef2fd7 (diff) | |
| parent | 3cc26c6aaf1357d969be2eed8c07895c80bb2b01 (diff) | |
| download | rust-858a42bf46a49bc64228d69b757294fe7a9bba6c.tar.gz rust-858a42bf46a49bc64228d69b757294fe7a9bba6c.zip | |
Auto merge of #116837 - oli-obk:smir_run_macro, r=spastorino
Avoid having `rustc_smir` depend on `rustc_interface` or `rustc_driver` This is done by moving all the logic into a macro that performs the entire "run" operation in one go. This makes https://github.com/rust-lang/rust/pull/116806 obsolete as a follow up we should make the macro usable without manually having to write ```rust #[macro_use] extern crate rustc_smir; extern crate stable_mir; extern crate rustc_driver; extern crate rustc_interface; use rustc_smir::rustc_internal; ``` in every crate that uses the macro. r? `@spastorino`
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui-fulldeps/stable-mir/check_instance.rs | 6 | ||||
| -rw-r--r-- | tests/ui-fulldeps/stable-mir/compilation-result.rs | 19 | ||||
| -rw-r--r-- | tests/ui-fulldeps/stable-mir/crate-info.rs | 6 |
3 files changed, 20 insertions, 11 deletions
diff --git a/tests/ui-fulldeps/stable-mir/check_instance.rs b/tests/ui-fulldeps/stable-mir/check_instance.rs index 288c163a6a3..c6a9e08ed02 100644 --- a/tests/ui-fulldeps/stable-mir/check_instance.rs +++ b/tests/ui-fulldeps/stable-mir/check_instance.rs @@ -4,6 +4,7 @@ // ignore-stage1 // ignore-cross-compile // ignore-remote +// ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 // edition: 2021 #![feature(rustc_private)] @@ -11,8 +12,11 @@ #![feature(control_flow_enum)] extern crate rustc_middle; +#[macro_use] extern crate rustc_smir; extern crate stable_mir; +extern crate rustc_driver; +extern crate rustc_interface; use rustc_middle::ty::TyCtxt; use mir::{mono::Instance, TerminatorKind::*}; @@ -82,7 +86,7 @@ fn main() { CRATE_NAME.to_string(), path.to_string(), ]; - rustc_internal::StableMir::new(args, test_stable_mir).run().unwrap(); + run!(args, tcx, test_stable_mir(tcx)).unwrap(); } fn generate_input(path: &str) -> std::io::Result<()> { diff --git a/tests/ui-fulldeps/stable-mir/compilation-result.rs b/tests/ui-fulldeps/stable-mir/compilation-result.rs index 3ec1519fb13..fc56e24814b 100644 --- a/tests/ui-fulldeps/stable-mir/compilation-result.rs +++ b/tests/ui-fulldeps/stable-mir/compilation-result.rs @@ -4,19 +4,22 @@ // ignore-stage1 // ignore-cross-compile // ignore-remote +// ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 // edition: 2021 #![feature(rustc_private)] #![feature(assert_matches)] extern crate rustc_middle; +#[macro_use] extern crate rustc_smir; +extern crate rustc_driver; +extern crate rustc_interface; extern crate stable_mir; use rustc_middle::ty::TyCtxt; use rustc_smir::rustc_internal; use std::io::Write; -use std::ops::ControlFlow; /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. @@ -33,28 +36,26 @@ fn main() { } fn test_continue(args: Vec<String>) { - let continue_fn = |_: TyCtxt| ControlFlow::Continue::<(), bool>(true); - let result = rustc_internal::StableMir::new(args, continue_fn).run(); + let result = run!(args, ControlFlow::Continue::<(), bool>(true)); assert_eq!(result, Ok(true)); } fn test_break(args: Vec<String>) { - let continue_fn = |_: TyCtxt| ControlFlow::Break::<bool, i32>(false); - let result = rustc_internal::StableMir::new(args, continue_fn).run(); + let result = run!(args, ControlFlow::Break::<bool, i32>(false)); assert_eq!(result, Err(stable_mir::CompilerError::Interrupted(false))); } +#[allow(unreachable_code)] fn test_skipped(mut args: Vec<String>) { args.push("--version".to_string()); - let unreach_fn = |_: TyCtxt| -> ControlFlow<()> { unreachable!() }; - let result = rustc_internal::StableMir::new(args, unreach_fn).run(); + let result = run!(args, unreachable!() as ControlFlow<()>); assert_eq!(result, Err(stable_mir::CompilerError::Skipped)); } +#[allow(unreachable_code)] fn test_failed(mut args: Vec<String>) { args.push("--cfg=broken".to_string()); - let unreach_fn = |_: TyCtxt| -> ControlFlow<()> { unreachable!() }; - let result = rustc_internal::StableMir::new(args, unreach_fn).run(); + let result = run!(args, unreachable!() as ControlFlow<()>); assert_eq!(result, Err(stable_mir::CompilerError::CompilationFailed)); } diff --git a/tests/ui-fulldeps/stable-mir/crate-info.rs b/tests/ui-fulldeps/stable-mir/crate-info.rs index 8a812bd3265..3cb71b5a025 100644 --- a/tests/ui-fulldeps/stable-mir/crate-info.rs +++ b/tests/ui-fulldeps/stable-mir/crate-info.rs @@ -4,6 +4,7 @@ // ignore-stage1 // ignore-cross-compile // ignore-remote +// ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 // edition: 2021 #![feature(rustc_private)] @@ -12,7 +13,10 @@ extern crate rustc_hir; extern crate rustc_middle; +#[macro_use] extern crate rustc_smir; +extern crate rustc_driver; +extern crate rustc_interface; extern crate stable_mir; use rustc_hir::def::DefKind; @@ -185,7 +189,7 @@ fn main() { CRATE_NAME.to_string(), path.to_string(), ]; - rustc_internal::StableMir::new(args, test_stable_mir).run().unwrap(); + run!(args, tcx, test_stable_mir(tcx)).unwrap(); } fn generate_input(path: &str) -> std::io::Result<()> { |
