diff options
| author | Vytautas Astrauskas <vastrauskas@gmail.com> | 2019-11-11 16:09:03 +0100 |
|---|---|---|
| committer | Vytautas Astrauskas <vastrauskas@gmail.com> | 2019-11-11 19:29:34 +0100 |
| commit | f9f5a88bc4d2e62ea325be8a37e5811a951f234c (patch) | |
| tree | d2d626f52d37b8920230a6f1c62b4cad03e24b41 /src/librustc_interface/interface.rs | |
| parent | 2a9be46cc4b5aa09e978653aba071c7c52b531eb (diff) | |
| download | rust-f9f5a88bc4d2e62ea325be8a37e5811a951f234c.tar.gz rust-f9f5a88bc4d2e62ea325be8a37e5811a951f234c.zip | |
Add a callback that allows compiler consumers to override queries.
Diffstat (limited to 'src/librustc_interface/interface.rs')
| -rw-r--r-- | src/librustc_interface/interface.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/librustc_interface/interface.rs b/src/librustc_interface/interface.rs index 02068b2ce38..fae4eb48c4a 100644 --- a/src/librustc_interface/interface.rs +++ b/src/librustc_interface/interface.rs @@ -12,6 +12,7 @@ use rustc_data_structures::OnDrop; use rustc_data_structures::sync::Lrc; use rustc_data_structures::fx::{FxHashSet, FxHashMap}; use rustc_parse::new_parser_from_source_str; +use rustc::ty; use std::path::PathBuf; use std::result; use std::sync::{Arc, Mutex}; @@ -38,6 +39,8 @@ pub struct Compiler { pub(crate) queries: Queries, pub(crate) crate_name: Option<String>, pub(crate) register_lints: Option<Box<dyn Fn(&Session, &mut lint::LintStore) + Send + Sync>>, + pub(crate) override_queries: + Option<fn(&Session, &mut ty::query::Providers<'_>, &mut ty::query::Providers<'_>)>, } impl Compiler { @@ -131,6 +134,13 @@ pub struct Config { /// Note that if you find a Some here you probably want to call that function in the new /// function being registered. pub register_lints: Option<Box<dyn Fn(&Session, &mut lint::LintStore) + Send + Sync>>, + + /// This is a callback from the driver that is called just after we have populated + /// the list of queries. + /// + /// The second parameter is local providers and the third parameter is external providers. + pub override_queries: + Option<fn(&Session, &mut ty::query::Providers<'_>, &mut ty::query::Providers<'_>)>, } pub fn run_compiler_in_existing_thread_pool<F, R>(config: Config, f: F) -> R @@ -157,6 +167,7 @@ where queries: Default::default(), crate_name: config.crate_name, register_lints: config.register_lints, + override_queries: config.override_queries, }; let _sess_abort_error = OnDrop(|| { |
