mirror of https://github.com/rust-lang/rust.git
Merge `ExternProviders` into the general `Providers` struct
This commit is contained in:
parent
2ba911c832
commit
4ed4913e67
|
@ -11,10 +11,10 @@ use rustc_middle::middle::exported_symbols::{
|
|||
metadata_symbol_name, ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel,
|
||||
};
|
||||
use rustc_middle::query::LocalCrate;
|
||||
use rustc_middle::query::{ExternProviders, Providers};
|
||||
use rustc_middle::ty::Instance;
|
||||
use rustc_middle::ty::{self, SymbolName, TyCtxt};
|
||||
use rustc_middle::ty::{GenericArgKind, GenericArgsRef};
|
||||
use rustc_middle::util::Providers;
|
||||
use rustc_session::config::{CrateType, OomStrategy};
|
||||
use rustc_target::spec::SanitizerSet;
|
||||
|
||||
|
@ -457,11 +457,9 @@ pub fn provide(providers: &mut Providers) {
|
|||
providers.is_unreachable_local_definition = is_unreachable_local_definition_provider;
|
||||
providers.upstream_drop_glue_for = upstream_drop_glue_for_provider;
|
||||
providers.wasm_import_module_map = wasm_import_module_map;
|
||||
}
|
||||
|
||||
pub fn provide_extern(providers: &mut ExternProviders) {
|
||||
providers.is_reachable_non_generic = is_reachable_non_generic_provider_extern;
|
||||
providers.upstream_monomorphizations_for = upstream_monomorphizations_for_provider;
|
||||
providers.extern_queries.is_reachable_non_generic = is_reachable_non_generic_provider_extern;
|
||||
providers.extern_queries.upstream_monomorphizations_for =
|
||||
upstream_monomorphizations_for_provider;
|
||||
}
|
||||
|
||||
fn symbol_export_level(tcx: TyCtxt<'_>, sym_def_id: DefId) -> SymbolExportLevel {
|
||||
|
|
|
@ -31,7 +31,7 @@ use rustc_middle::dep_graph::WorkProduct;
|
|||
use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
|
||||
use rustc_middle::middle::dependency_format::Dependencies;
|
||||
use rustc_middle::middle::exported_symbols::SymbolExportKind;
|
||||
use rustc_middle::query::{ExternProviders, Providers};
|
||||
use rustc_middle::util::Providers;
|
||||
use rustc_serialize::opaque::{FileEncoder, MemDecoder};
|
||||
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
|
||||
use rustc_session::config::{CrateType, OutputFilenames, OutputType, RUST_CGU_EXT};
|
||||
|
@ -190,10 +190,6 @@ pub fn provide(providers: &mut Providers) {
|
|||
crate::codegen_attrs::provide(providers);
|
||||
}
|
||||
|
||||
pub fn provide_extern(providers: &mut ExternProviders) {
|
||||
crate::back::symbol_export::provide_extern(providers);
|
||||
}
|
||||
|
||||
/// Checks if the given filename ends with the `.rcgu.o` extension that `rustc`
|
||||
/// uses for the object files it generates.
|
||||
pub fn looks_like_rust_object_file(filename: &str) -> bool {
|
||||
|
|
|
@ -11,7 +11,6 @@ use rustc_data_structures::sync::{DynSend, DynSync};
|
|||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_metadata::EncodedMetadata;
|
||||
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
|
||||
use rustc_middle::query::ExternProviders;
|
||||
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, LayoutOf, TyAndLayout};
|
||||
use rustc_middle::ty::{Ty, TyCtxt};
|
||||
use rustc_middle::util::Providers;
|
||||
|
@ -86,7 +85,6 @@ pub trait CodegenBackend {
|
|||
}
|
||||
|
||||
fn provide(&self, _providers: &mut Providers) {}
|
||||
fn provide_extern(&self, _providers: &mut ExternProviders) {}
|
||||
fn codegen_crate<'tcx>(
|
||||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
|
|
@ -9,7 +9,6 @@ use rustc_data_structures::sync::Lrc;
|
|||
use rustc_errors::registry::Registry;
|
||||
use rustc_errors::{ErrorGuaranteed, Handler};
|
||||
use rustc_lint::LintStore;
|
||||
use rustc_middle::query::ExternProviders;
|
||||
use rustc_middle::util::Providers;
|
||||
use rustc_middle::{bug, ty};
|
||||
use rustc_parse::maybe_new_parser_from_source_str;
|
||||
|
@ -38,7 +37,7 @@ pub struct Compiler {
|
|||
pub(crate) sess: Lrc<Session>,
|
||||
codegen_backend: Lrc<dyn CodegenBackend>,
|
||||
pub(crate) register_lints: Option<Box<dyn Fn(&Session, &mut LintStore) + Send + Sync>>,
|
||||
pub(crate) override_queries: Option<fn(&Session, &mut Providers, &mut ExternProviders)>,
|
||||
pub(crate) override_queries: Option<fn(&Session, &mut Providers)>,
|
||||
}
|
||||
|
||||
impl Compiler {
|
||||
|
@ -272,7 +271,7 @@ pub struct Config {
|
|||
/// the list of queries.
|
||||
///
|
||||
/// The second parameter is local providers and the third parameter is external providers.
|
||||
pub override_queries: Option<fn(&Session, &mut Providers, &mut ExternProviders)>,
|
||||
pub override_queries: Option<fn(&Session, &mut Providers)>,
|
||||
|
||||
/// This is a callback from the driver that is called to create a codegen backend.
|
||||
pub make_codegen_backend:
|
||||
|
|
|
@ -25,7 +25,7 @@ pub mod util;
|
|||
|
||||
pub use callbacks::setup_callbacks;
|
||||
pub use interface::{run_compiler, Config};
|
||||
pub use passes::{DEFAULT_EXTERN_QUERY_PROVIDERS, DEFAULT_QUERY_PROVIDERS};
|
||||
pub use passes::DEFAULT_QUERY_PROVIDERS;
|
||||
pub use queries::Queries;
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -18,7 +18,6 @@ use rustc_lint::{unerased_lint_store, BufferedEarlyLint, EarlyCheckNode, LintSto
|
|||
use rustc_metadata::creader::CStore;
|
||||
use rustc_middle::arena::Arena;
|
||||
use rustc_middle::dep_graph::DepGraph;
|
||||
use rustc_middle::query::ExternProviders;
|
||||
use rustc_middle::ty::{self, GlobalCtxt, RegisteredTools, TyCtxt};
|
||||
use rustc_middle::util::Providers;
|
||||
use rustc_mir_build as mir_build;
|
||||
|
@ -676,13 +675,6 @@ pub static DEFAULT_QUERY_PROVIDERS: LazyLock<Providers> = LazyLock::new(|| {
|
|||
*providers
|
||||
});
|
||||
|
||||
pub static DEFAULT_EXTERN_QUERY_PROVIDERS: LazyLock<ExternProviders> = LazyLock::new(|| {
|
||||
let mut extern_providers = ExternProviders::default();
|
||||
rustc_metadata::provide_extern(&mut extern_providers);
|
||||
rustc_codegen_ssa::provide_extern(&mut extern_providers);
|
||||
extern_providers
|
||||
});
|
||||
|
||||
pub fn create_global_ctxt<'tcx>(
|
||||
compiler: &'tcx Compiler,
|
||||
crate_types: Vec<CrateType>,
|
||||
|
@ -706,11 +698,8 @@ pub fn create_global_ctxt<'tcx>(
|
|||
let mut providers = *DEFAULT_QUERY_PROVIDERS;
|
||||
codegen_backend.provide(&mut providers);
|
||||
|
||||
let mut extern_providers = *DEFAULT_EXTERN_QUERY_PROVIDERS;
|
||||
codegen_backend.provide_extern(&mut extern_providers);
|
||||
|
||||
if let Some(callback) = compiler.override_queries {
|
||||
callback(sess, &mut providers, &mut extern_providers);
|
||||
callback(sess, &mut providers);
|
||||
}
|
||||
|
||||
let incremental = dep_graph.is_fully_enabled();
|
||||
|
@ -729,7 +718,7 @@ pub fn create_global_ctxt<'tcx>(
|
|||
rustc_query_impl::query_callbacks(arena),
|
||||
rustc_query_impl::query_system(
|
||||
providers.queries,
|
||||
extern_providers,
|
||||
providers.extern_queries,
|
||||
query_result_on_disk_cache,
|
||||
incremental,
|
||||
),
|
||||
|
|
|
@ -26,7 +26,7 @@ extern crate rustc_middle;
|
|||
#[macro_use]
|
||||
extern crate tracing;
|
||||
|
||||
pub use rmeta::{provide, provide_extern};
|
||||
pub use rmeta::provide;
|
||||
use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
|
||||
use rustc_fluent_macro::fluent_messages;
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ use std::sync::atomic::Ordering;
|
|||
use std::{io, iter, mem};
|
||||
|
||||
pub(super) use cstore_impl::provide;
|
||||
pub use cstore_impl::provide_extern;
|
||||
use rustc_span::hygiene::HygieneDecodeContext;
|
||||
|
||||
mod cstore_impl;
|
||||
|
|
|
@ -14,10 +14,11 @@ use rustc_middle::arena::ArenaAllocatable;
|
|||
use rustc_middle::metadata::ModChild;
|
||||
use rustc_middle::middle::exported_symbols::ExportedSymbol;
|
||||
use rustc_middle::middle::stability::DeprecationEntry;
|
||||
use rustc_middle::query::ExternProviders;
|
||||
use rustc_middle::query::LocalCrate;
|
||||
use rustc_middle::query::{ExternProviders, Providers};
|
||||
use rustc_middle::ty::fast_reject::SimplifiedType;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_middle::util::Providers;
|
||||
use rustc_session::cstore::CrateStore;
|
||||
use rustc_session::{Session, StableCrateId};
|
||||
use rustc_span::hygiene::{ExpnHash, ExpnId};
|
||||
|
@ -147,7 +148,7 @@ macro_rules! provide_one {
|
|||
macro_rules! provide {
|
||||
($tcx:ident, $def_id:ident, $other:ident, $cdata:ident,
|
||||
$($name:ident => { $($compute:tt)* })*) => {
|
||||
pub fn provide_extern(providers: &mut ExternProviders) {
|
||||
fn provide_extern(providers: &mut ExternProviders) {
|
||||
$(provide_one! {
|
||||
$tcx, $def_id, $other, $cdata, $name => { $($compute)* }
|
||||
})*
|
||||
|
@ -385,7 +386,7 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
|
|||
// FIXME(#44234) - almost all of these queries have no sub-queries and
|
||||
// therefore no actual inputs, they're just reading tables calculated in
|
||||
// resolve! Does this work? Unsure! That's what the issue is about
|
||||
*providers = Providers {
|
||||
providers.queries = rustc_middle::query::Providers {
|
||||
allocator_kind: |tcx, ()| CStore::from_tcx(tcx).allocator_kind(),
|
||||
alloc_error_handler_kind: |tcx, ()| CStore::from_tcx(tcx).alloc_error_handler_kind(),
|
||||
is_private_dep: |_tcx, LocalCrate| false,
|
||||
|
@ -513,8 +514,9 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
|
|||
tcx.untracked().cstore.freeze();
|
||||
tcx.arena.alloc_from_iter(CStore::from_tcx(tcx).iter_crate_data().map(|(cnum, _)| cnum))
|
||||
},
|
||||
..*providers
|
||||
..providers.queries
|
||||
};
|
||||
provide_extern(&mut providers.extern_queries);
|
||||
}
|
||||
|
||||
impl CStore {
|
||||
|
|
|
@ -21,10 +21,10 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
|
|||
use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo};
|
||||
use rustc_middle::middle::resolve_bound_vars::ObjectLifetimeDefault;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::query::Providers;
|
||||
use rustc_middle::ty::fast_reject::SimplifiedType;
|
||||
use rustc_middle::ty::{self, ReprOptions, Ty, UnusedGenericParams};
|
||||
use rustc_middle::ty::{DeducedParamAttrs, GeneratorDiagnosticData, ParameterizedOverTcx, TyCtxt};
|
||||
use rustc_middle::util::Providers;
|
||||
use rustc_serialize::opaque::FileEncoder;
|
||||
use rustc_session::config::SymbolManglingVersion;
|
||||
use rustc_session::cstore::{CrateDepKind, ForeignModule, LinkagePreference, NativeLib};
|
||||
|
@ -38,7 +38,6 @@ use rustc_target::spec::{PanicStrategy, TargetTriple};
|
|||
use std::marker::PhantomData;
|
||||
use std::num::NonZeroUsize;
|
||||
|
||||
pub use decoder::provide_extern;
|
||||
use decoder::DecodeContext;
|
||||
pub(crate) use decoder::{CrateMetadata, CrateNumMap, MetadataBlob};
|
||||
use encoder::EncodeContext;
|
||||
|
|
|
@ -9,6 +9,7 @@ pub use find_self_call::find_self_call;
|
|||
#[derive(Default, Copy, Clone)]
|
||||
pub struct Providers {
|
||||
pub queries: rustc_middle::query::Providers,
|
||||
pub extern_queries: rustc_middle::query::ExternProviders,
|
||||
pub hooks: rustc_middle::hooks::Providers,
|
||||
}
|
||||
|
||||
|
|
|
@ -263,7 +263,7 @@ pub(crate) fn create_config(
|
|||
lint_caps,
|
||||
parse_sess_created: None,
|
||||
register_lints: Some(Box::new(crate::lint::register_lints)),
|
||||
override_queries: Some(|_sess, providers, _external_providers| {
|
||||
override_queries: Some(|_sess, providers| {
|
||||
// We do not register late module lints, so this only runs `MissingDoc`.
|
||||
// Most lints will require typechecking, so just don't run them.
|
||||
providers.lint_mod = |tcx, module_def_id| late_lint_mod(tcx, module_def_id, MissingDoc);
|
||||
|
|
|
@ -28,7 +28,8 @@ use rustc_middle::{
|
|||
middle::exported_symbols::{
|
||||
ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel,
|
||||
},
|
||||
query::{ExternProviders, LocalCrate},
|
||||
query::{LocalCrate},
|
||||
util::Providers,
|
||||
ty::TyCtxt,
|
||||
};
|
||||
use rustc_session::config::{CrateType, ErrorOutputType, OptLevel};
|
||||
|
@ -43,11 +44,11 @@ struct MiriCompilerCalls {
|
|||
|
||||
impl rustc_driver::Callbacks for MiriCompilerCalls {
|
||||
fn config(&mut self, config: &mut Config) {
|
||||
config.override_queries = Some(|_, _, external_providers| {
|
||||
external_providers.used_crate_source = |tcx, cnum| {
|
||||
let mut providers = ExternProviders::default();
|
||||
rustc_metadata::provide_extern(&mut providers);
|
||||
let mut crate_source = (providers.used_crate_source)(tcx, cnum);
|
||||
config.override_queries = Some(|_, providers| {
|
||||
providers.extern_queries.used_crate_source = |tcx, cnum| {
|
||||
let mut providers = Providers::default();
|
||||
rustc_metadata::provide(&mut providers);
|
||||
let mut crate_source = (providers.extern_queries.used_crate_source)(tcx, cnum);
|
||||
// HACK: rustc will emit "crate ... required to be available in rlib format, but
|
||||
// was not found in this form" errors once we use `tcx.dependency_formats()` if
|
||||
// there's no rlib provided, so setting a dummy path here to workaround those errors.
|
||||
|
@ -125,7 +126,7 @@ impl rustc_driver::Callbacks for MiriBeRustCompilerCalls {
|
|||
if config.opts.prints.is_empty() && self.target_crate {
|
||||
// Queries overridden here affect the data stored in `rmeta` files of dependencies,
|
||||
// which will be used later in non-`MIRI_BE_RUSTC` mode.
|
||||
config.override_queries = Some(|_, local_providers, _| {
|
||||
config.override_queries = Some(|_, local_providers| {
|
||||
// `exported_symbols` and `reachable_non_generics` provided by rustc always returns
|
||||
// an empty result if `tcx.sess.opts.output_types.should_codegen()` is false.
|
||||
local_providers.exported_symbols = |tcx, LocalCrate| {
|
||||
|
|
|
@ -25,8 +25,8 @@ use rustc_hir::def_id::LocalDefId;
|
|||
use rustc_interface::interface::Compiler;
|
||||
use rustc_interface::{Config, Queries};
|
||||
use rustc_middle::query::queries::mir_borrowck::ProvidedValue;
|
||||
use rustc_middle::query::{ExternProviders, Providers};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_middle::util::Providers;
|
||||
use rustc_session::Session;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
|
@ -110,7 +110,7 @@ impl rustc_driver::Callbacks for CompilerCalls {
|
|||
}
|
||||
}
|
||||
|
||||
fn override_queries(_session: &Session, local: &mut Providers, _external: &mut ExternProviders) {
|
||||
fn override_queries(_session: &Session, local: &mut Providers) {
|
||||
local.mir_borrowck = mir_borrowck;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue