Skip to content

Commit

Permalink
Fix ui-fulldep tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Dec 6, 2024
1 parent 618d4c3 commit 85414eb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 22 deletions.
5 changes: 3 additions & 2 deletions compiler/rustc_smir/src/rustc_internal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,9 @@ macro_rules! run_driver {

/// Runs the compiler against given target and tests it with `test_function`
pub fn run(&mut self) -> Result<C, CompilerError<B>> {
let compiler_result = rustc_driver::catch_fatal_errors(|| {
RunCompiler::new(&self.args.clone(), self).run()
let compiler_result = rustc_driver::catch_fatal_errors(|| -> interface::Result::<()> {
RunCompiler::new(&self.args.clone(), self).run();
Ok(())
});
match (compiler_result, self.result.take()) {
(Ok(Ok(())), Some(ControlFlow::Continue(value))) => Ok(value),
Expand Down
22 changes: 8 additions & 14 deletions tests/ui-fulldeps/codegen-backend/auxiliary/the_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ extern crate rustc_span;
extern crate rustc_symbol_mangling;
extern crate rustc_target;

use std::any::Any;

use rustc_codegen_ssa::traits::CodegenBackend;
use rustc_codegen_ssa::{CodegenResults, CrateInfo};
use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::ErrorGuaranteed;
use rustc_metadata::EncodedMetadata;
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
use rustc_middle::ty::TyCtxt;
use rustc_session::config::OutputFilenames;
use rustc_session::Session;
use std::any::Any;
use rustc_session::config::OutputFilenames;

struct TheBackend;

Expand Down Expand Up @@ -60,17 +60,12 @@ impl CodegenBackend for TheBackend {
(*codegen_results, FxIndexMap::default())
}

fn link(
&self,
sess: &Session,
codegen_results: CodegenResults,
outputs: &OutputFilenames,
) -> Result<(), ErrorGuaranteed> {
use rustc_session::{
config::{CrateType, OutFileName},
output::out_filename,
};
fn link(&self, sess: &Session, codegen_results: CodegenResults, outputs: &OutputFilenames) {
use std::io::Write;

use rustc_session::config::{CrateType, OutFileName};
use rustc_session::output::out_filename;

let crate_name = codegen_results.crate_info.local_crate_name;
for &crate_type in sess.opts.crate_types.iter() {
if crate_type != CrateType::Rlib {
Expand All @@ -88,7 +83,6 @@ impl CodegenBackend for TheBackend {
}
}
}
Ok(())
}
}

Expand Down
3 changes: 2 additions & 1 deletion tests/ui-fulldeps/obtain-borrowck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ fn main() {
rustc_args.push("-Zpolonius".to_owned());
let mut callbacks = CompilerCalls::default();
// Call the Rust compiler with our callbacks.
rustc_driver::RunCompiler::new(&rustc_args, &mut callbacks).run()
rustc_driver::RunCompiler::new(&rustc_args, &mut callbacks).run();
Ok(())
});
std::process::exit(exit_code);
}
Expand Down
9 changes: 4 additions & 5 deletions tests/ui-fulldeps/run-compiler-twice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ extern crate rustc_span;

use std::path::{Path, PathBuf};

use rustc_interface::Linker;
use rustc_interface::interface;
use rustc_interface::{Linker, interface};
use rustc_session::config::{Input, Options, OutFileName, OutputType, OutputTypes};
use rustc_span::FileName;

Expand Down Expand Up @@ -79,11 +78,11 @@ fn compile(code: String, output: PathBuf, sysroot: PathBuf, linker: Option<&Path

interface::run_compiler(config, |compiler| {
let linker = compiler.enter(|queries| {
queries.global_ctxt()?.enter(|tcx| {
tcx.analysis(())?;
queries.global_ctxt().enter(|tcx| {
let _ = tcx.analysis(());
Linker::codegen_and_build_linker(tcx, &*compiler.codegen_backend)
})
});
linker.unwrap().link(&compiler.sess, &*compiler.codegen_backend).unwrap();
linker.link(&compiler.sess, &*compiler.codegen_backend);
});
}

0 comments on commit 85414eb

Please sign in to comment.