diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-08-29 20:49:04 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-29 20:49:04 +0200 |
| commit | 61c367cd1fb0ed0aca1e715cd87f9bf13fa594f0 (patch) | |
| tree | 0d85a86fd1ae70f5ecd2f7814f7385d228ca153e /tests | |
| parent | d5b12a22beaf8a8f1a403598cdb49889580b7c55 (diff) | |
| parent | c2fe0bf25347cf85205b928d132ac13d8de1c354 (diff) | |
Rollup merge of #115187 - ouz-a:smir_wrap, r=oli-obk
Add new interface to smir Removes the boiler plate from `crate-info.rs`, and creates new interface for the smir. Addressing https://github.com/rust-lang/project-stable-mir/issues/23 r? `@spastorino`
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui-fulldeps/stable-mir/crate-info.rs | 34 |
1 files changed, 3 insertions, 31 deletions
diff --git a/tests/ui-fulldeps/stable-mir/crate-info.rs b/tests/ui-fulldeps/stable-mir/crate-info.rs index f55d7d599f1..00dce3e004e 100644 --- a/tests/ui-fulldeps/stable-mir/crate-info.rs +++ b/tests/ui-fulldeps/stable-mir/crate-info.rs @@ -9,18 +9,12 @@ #![feature(rustc_private)] #![feature(assert_matches)] -extern crate rustc_driver; extern crate rustc_hir; -extern crate rustc_interface; extern crate rustc_middle; -extern crate rustc_session; extern crate rustc_smir; -use rustc_driver::{Callbacks, Compilation, RunCompiler}; use rustc_hir::def::DefKind; -use rustc_interface::{interface, Queries}; use rustc_middle::ty::TyCtxt; -use rustc_session::EarlyErrorHandler; use rustc_smir::{rustc_internal, stable_mir}; use std::assert_matches::assert_matches; use std::io::Write; @@ -130,8 +124,8 @@ fn get_item<'a>( /// 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. -/// It will invoke the compiler using a custom Callback implementation, which will -/// invoke Stable MIR APIs after the compiler has finished its analysis. +/// Then it will create a `StableMir` using custom arguments and then +/// it will run the compiler. fn main() { let path = "input.rs"; generate_input(&path).unwrap(); @@ -142,29 +136,7 @@ fn main() { CRATE_NAME.to_string(), path.to_string(), ]; - rustc_driver::catch_fatal_errors(|| { - RunCompiler::new(&args, &mut SMirCalls {}).run().unwrap(); - }) - .unwrap(); -} - -struct SMirCalls {} - -impl Callbacks for SMirCalls { - /// Called after analysis. Return value instructs the compiler whether to - /// continue the compilation afterwards (defaults to `Compilation::Continue`) - fn after_analysis<'tcx>( - &mut self, - _handler: &EarlyErrorHandler, - _compiler: &interface::Compiler, - queries: &'tcx Queries<'tcx>, - ) -> Compilation { - queries.global_ctxt().unwrap().enter(|tcx| { - rustc_smir::rustc_internal::run(tcx, || test_stable_mir(tcx)); - }); - // No need to keep going. - Compilation::Stop - } + rustc_internal::StableMir::new(args, test_stable_mir).run(); } fn generate_input(path: &str) -> std::io::Result<()> { |
