Pass TyCtxt instead of Queries to the after_analysis callbacks
There is no other query that may need to be called at that point anyway.
This commit is contained in:
parent
1eece7478d
commit
3b02a3309e
22 changed files with 112 additions and 107 deletions
|
@ -50,6 +50,7 @@ use rustc_interface::{Linker, Queries, interface, passes};
|
|||
use rustc_lint::unerased_lint_store;
|
||||
use rustc_metadata::creader::MetadataLoader;
|
||||
use rustc_metadata::locator;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_parse::{new_parser_from_file, new_parser_from_source_str, unwrap_or_emit_fatal};
|
||||
use rustc_session::config::{
|
||||
CG_OPTIONS, ErrorOutputType, Input, OutFileName, OutputType, UnstableOptions, Z_OPTIONS,
|
||||
|
@ -179,7 +180,7 @@ pub trait Callbacks {
|
|||
fn after_analysis<'tcx>(
|
||||
&mut self,
|
||||
_compiler: &interface::Compiler,
|
||||
_queries: &'tcx Queries<'tcx>,
|
||||
_tcx: TyCtxt<'tcx>,
|
||||
) -> Compilation {
|
||||
Compilation::Continue
|
||||
}
|
||||
|
@ -437,13 +438,11 @@ fn run_compiler(
|
|||
}
|
||||
|
||||
tcx.analysis(())?;
|
||||
})?;
|
||||
|
||||
if callbacks.after_analysis(compiler, queries) == Compilation::Stop {
|
||||
if callbacks.after_analysis(compiler, tcx) == Compilation::Stop {
|
||||
return early_exit();
|
||||
}
|
||||
|
||||
queries.global_ctxt()?.enter(|tcx| {
|
||||
Ok(Some(Linker::codegen_and_build_linker(tcx, &*compiler.codegen_backend)?))
|
||||
})
|
||||
})?;
|
||||
|
|
|
@ -313,6 +313,7 @@ macro_rules! optional {
|
|||
macro_rules! run_driver {
|
||||
($args:expr, $callback:expr $(, $with_tcx:ident)?) => {{
|
||||
use rustc_driver::{Callbacks, Compilation, RunCompiler};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_interface::{interface, Queries};
|
||||
use stable_mir::CompilerError;
|
||||
use std::ops::ControlFlow;
|
||||
|
@ -373,9 +374,8 @@ macro_rules! run_driver {
|
|||
fn after_analysis<'tcx>(
|
||||
&mut self,
|
||||
_compiler: &interface::Compiler,
|
||||
queries: &'tcx Queries<'tcx>,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
) -> Compilation {
|
||||
queries.global_ctxt().unwrap().enter(|tcx| {
|
||||
if let Some(callback) = self.callback.take() {
|
||||
rustc_internal::run(tcx, || {
|
||||
self.result = Some(callback($(optional!($with_tcx tcx))?));
|
||||
|
@ -389,7 +389,6 @@ macro_rules! run_driver {
|
|||
} else {
|
||||
Compilation::Continue
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,9 +73,8 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
|
|||
fn after_analysis<'tcx>(
|
||||
&mut self,
|
||||
_: &rustc_interface::interface::Compiler,
|
||||
queries: &'tcx rustc_interface::Queries<'tcx>,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
) -> Compilation {
|
||||
queries.global_ctxt().unwrap().enter(|tcx| {
|
||||
if tcx.sess.dcx().has_errors_or_delayed_bugs().is_some() {
|
||||
tcx.dcx().fatal("miri cannot be run on programs that fail compilation");
|
||||
}
|
||||
|
@ -112,12 +111,9 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
|
|||
}
|
||||
|
||||
if let Some(return_code) = miri::eval_entry(tcx, entry_def_id, entry_type, config) {
|
||||
std::process::exit(
|
||||
i32::try_from(return_code).expect("Return value was too large!"),
|
||||
);
|
||||
std::process::exit(i32::try_from(return_code).expect("Return value was too large!"));
|
||||
}
|
||||
tcx.dcx().abort_if_errors();
|
||||
});
|
||||
|
||||
Compilation::Stop
|
||||
}
|
||||
|
@ -193,9 +189,8 @@ impl rustc_driver::Callbacks for MiriBeRustCompilerCalls {
|
|||
fn after_analysis<'tcx>(
|
||||
&mut self,
|
||||
_: &rustc_interface::interface::Compiler,
|
||||
queries: &'tcx rustc_interface::Queries<'tcx>,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
) -> Compilation {
|
||||
queries.global_ctxt().unwrap().enter(|tcx| {
|
||||
if self.target_crate {
|
||||
// cargo-miri has patched the compiler flags to make these into check-only builds,
|
||||
// but we are still emulating regular rustc builds, which would perform post-mono
|
||||
|
@ -206,7 +201,6 @@ impl rustc_driver::Callbacks for MiriBeRustCompilerCalls {
|
|||
// builds, but we are setting `-Zalways-encode-mir` which avoids those issues.
|
||||
let _ = tcx.collect_and_partition_mono_items(());
|
||||
}
|
||||
});
|
||||
Compilation::Continue
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,19 +25,20 @@ extern crate rustc_interface;
|
|||
extern crate rustc_middle;
|
||||
extern crate rustc_session;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::thread_local;
|
||||
|
||||
use rustc_borrowck::consumers::{self, BodyWithBorrowckFacts, ConsumerOptions};
|
||||
use rustc_driver::Compilation;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_interface::Config;
|
||||
use rustc_interface::interface::Compiler;
|
||||
use rustc_interface::{Config, Queries};
|
||||
use rustc_middle::query::queries::mir_borrowck::ProvidedValue;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_middle::util::Providers;
|
||||
use rustc_session::Session;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::thread_local;
|
||||
|
||||
fn main() {
|
||||
let exit_code = rustc_driver::catch_with_exit_code(move || {
|
||||
|
@ -63,13 +64,8 @@ impl rustc_driver::Callbacks for CompilerCalls {
|
|||
|
||||
// In this callback we trigger borrow checking of all functions and obtain
|
||||
// the result.
|
||||
fn after_analysis<'tcx>(
|
||||
&mut self,
|
||||
compiler: &Compiler,
|
||||
queries: &'tcx Queries<'tcx>,
|
||||
) -> Compilation {
|
||||
compiler.sess.dcx().abort_if_errors();
|
||||
queries.global_ctxt().unwrap().enter(|tcx| {
|
||||
fn after_analysis<'tcx>(&mut self, _compiler: &Compiler, tcx: TyCtxt<'tcx>) -> Compilation {
|
||||
tcx.sess.dcx().abort_if_errors();
|
||||
// Collect definition ids of MIR bodies.
|
||||
let hir = tcx.hir();
|
||||
let mut bodies = Vec::new();
|
||||
|
@ -111,7 +107,6 @@ impl rustc_driver::Callbacks for CompilerCalls {
|
|||
println!("{}", def_id);
|
||||
assert!(body.input_facts.unwrap().cfg_edge.len() > 0);
|
||||
}
|
||||
});
|
||||
|
||||
Compilation::Continue
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#![feature(ascii_char, ascii_char_variants)]
|
||||
|
||||
extern crate rustc_hir;
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
extern crate rustc_driver;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#![feature(ascii_char, ascii_char_variants)]
|
||||
|
||||
extern crate rustc_hir;
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
extern crate rustc_driver;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#![feature(rustc_private)]
|
||||
|
||||
extern crate rustc_hir;
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
extern crate rustc_driver;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#![feature(rustc_private)]
|
||||
|
||||
extern crate rustc_hir;
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
extern crate rustc_driver;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_hir;
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
extern crate rustc_driver;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#![feature(rustc_private)]
|
||||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
extern crate rustc_driver;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#![feature(rustc_private)]
|
||||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
extern crate rustc_driver;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#![feature(rustc_private)]
|
||||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
extern crate rustc_driver;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#![feature(rustc_private)]
|
||||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
extern crate rustc_hir;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#![feature(rustc_private)]
|
||||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
extern crate rustc_driver;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#![feature(rustc_private)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
extern crate rustc_driver;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#![feature(rustc_private)]
|
||||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
extern crate rustc_driver;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#![feature(ascii_char, ascii_char_variants)]
|
||||
|
||||
extern crate rustc_hir;
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
extern crate rustc_driver;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#![feature(rustc_private)]
|
||||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
extern crate rustc_driver;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#![feature(rustc_private)]
|
||||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
extern crate rustc_driver;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_hir;
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
extern crate rustc_driver;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_hir;
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
extern crate rustc_driver;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#![feature(rustc_private)]
|
||||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
extern crate rustc_driver;
|
||||
|
|
Loading…
Add table
Reference in a new issue