Skip to content

Commit

Permalink
rustc_driver: base extern query providers on local ones.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Nov 12, 2017
1 parent 19e63bd commit 18b3a9a
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 59 deletions.
11 changes: 0 additions & 11 deletions src/librustc/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,14 +842,3 @@ pub fn provide(providers: &mut ty::maps::Providers) {
..*providers
};
}

pub fn provide_extern(providers: &mut ty::maps::Providers) {
*providers = ty::maps::Providers {
is_object_safe: object_safety::is_object_safe_provider,
specialization_graph_of: specialize::specialization_graph_provider,
specializes: specialize::specializes,
trans_fulfill_obligation: trans::trans_fulfill_obligation,
vtable_methods,
..*providers
};
}
11 changes: 0 additions & 11 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2605,17 +2605,6 @@ pub fn provide(providers: &mut ty::maps::Providers) {
};
}

pub fn provide_extern(providers: &mut ty::maps::Providers) {
*providers = ty::maps::Providers {
adt_sized_constraint,
adt_dtorck_constraint,
trait_impls_of: trait_def::trait_impls_of_provider,
param_env,
..*providers
};
}


/// A map for the local crate mapping each type to a vector of its
/// inherent impls. This is not meant to be used outside of coherence;
/// rather, you should request the vector for a specific type via
Expand Down
12 changes: 4 additions & 8 deletions src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -970,24 +970,20 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
mir::provide(&mut local_providers);
reachable::provide(&mut local_providers);
rustc_privacy::provide(&mut local_providers);
DefaultTransCrate::provide_local(&mut local_providers);
DefaultTransCrate::provide(&mut local_providers);
typeck::provide(&mut local_providers);
ty::provide(&mut local_providers);
traits::provide(&mut local_providers);
reachable::provide(&mut local_providers);
rustc_const_eval::provide(&mut local_providers);
rustc_passes::provide(&mut local_providers);
middle::region::provide(&mut local_providers);
cstore::provide_local(&mut local_providers);
cstore::provide(&mut local_providers);
lint::provide(&mut local_providers);

let mut extern_providers = ty::maps::Providers::default();
cstore::provide(&mut extern_providers);
let mut extern_providers = local_providers;
cstore::provide_extern(&mut extern_providers);
DefaultTransCrate::provide_extern(&mut extern_providers);
ty::provide_extern(&mut extern_providers);
traits::provide_extern(&mut extern_providers);
// FIXME(eddyb) get rid of this once we replace const_eval with miri.
rustc_const_eval::provide(&mut extern_providers);

// Setup the MIR passes that we want to run.
let mut passes = Passes::new();
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/cstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub use rustc::middle::cstore::{NativeLibrary, NativeLibraryKind, LinkagePrefere
pub use rustc::middle::cstore::NativeLibraryKind::*;
pub use rustc::middle::cstore::{CrateSource, LibSource};

pub use cstore_impl::{provide, provide_local};
pub use cstore_impl::{provide, provide_extern};

// A map from external crate numbers (as decoded from some crate file) to
// local crate numbers (as generated during this session). Each external
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_metadata/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use rustc::hir;
macro_rules! provide {
(<$lt:tt> $tcx:ident, $def_id:ident, $other:ident, $cdata:ident,
$($name:ident => $compute:block)*) => {
pub fn provide<$lt>(providers: &mut Providers<$lt>) {
pub fn provide_extern<$lt>(providers: &mut Providers<$lt>) {
$(fn $name<'a, $lt:$lt, T>($tcx: TyCtxt<'a, $lt, $lt>, def_id_arg: T)
-> <ty::queries::$name<$lt> as
QueryConfig>::Value
Expand Down Expand Up @@ -243,7 +243,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
has_clone_closures => { cdata.has_clone_closures(tcx.sess) }
}

pub fn provide_local<'tcx>(providers: &mut Providers<'tcx>) {
pub fn provide<'tcx>(providers: &mut Providers<'tcx>) {
fn is_const_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool {
let node_id = tcx.hir.as_local_node_id(def_id)
.expect("Non-local call to local provider is_const_fn");
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/back/symbol_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub fn crates_export_threshold(crate_types: &[config::CrateType])
}
}

pub fn provide_local(providers: &mut Providers) {
pub fn provide(providers: &mut Providers) {
providers.exported_symbol_ids = |tcx, cnum| {
let export_threshold = threshold(tcx);
Rc::new(tcx.exported_symbols(cnum)
Expand Down
6 changes: 1 addition & 5 deletions src/librustc_trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
}

pub fn provide_local(providers: &mut Providers) {
pub fn provide(providers: &mut Providers) {
providers.collect_and_partition_translation_items =
collect_and_partition_translation_items;

Expand All @@ -1400,10 +1400,6 @@ pub fn provide_local(providers: &mut Providers) {
providers.compile_codegen_unit = compile_codegen_unit;
}

pub fn provide_extern(providers: &mut Providers) {
providers.is_translated_function = is_translated_function;
}

pub fn linkage_to_llvm(linkage: Linkage) -> llvm::Linkage {
match linkage {
Linkage::External => llvm::Linkage::ExternalLinkage,
Expand Down
21 changes: 5 additions & 16 deletions src/librustc_trans/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ use rustc::middle::cstore::MetadataLoader;
use rustc::middle::cstore::{NativeLibrary, CrateSource, LibSource};
use rustc::session::Session;
use rustc::session::config::{OutputFilenames, OutputType};
use rustc::ty::maps::Providers;
use rustc::ty::{self, TyCtxt};
use rustc::util::nodemap::{FxHashSet, FxHashMap};

Expand Down Expand Up @@ -167,12 +166,14 @@ impl rustc_trans_utils::trans_crate::TransCrate for LlvmTransCrate {
box metadata::LlvmMetadataLoader
}

fn provide_local(providers: &mut ty::maps::Providers) {
provide_local(providers);
fn provide(providers: &mut ty::maps::Providers) {
back::symbol_names::provide(providers);
back::symbol_export::provide(providers);
base::provide(providers);
}

fn provide_extern(providers: &mut ty::maps::Providers) {
provide_extern(providers);
back::symbol_export::provide_extern(providers);
}

fn trans_crate<'a, 'tcx>(
Expand Down Expand Up @@ -332,15 +333,3 @@ pub struct CrateInfo {
}

__build_diagnostic_array! { librustc_trans, DIAGNOSTICS }

pub fn provide_local(providers: &mut Providers) {
back::symbol_names::provide(providers);
back::symbol_export::provide_local(providers);
base::provide_local(providers);
}

pub fn provide_extern(providers: &mut Providers) {
back::symbol_names::provide(providers);
back::symbol_export::provide_extern(providers);
base::provide_extern(providers);
}
8 changes: 4 additions & 4 deletions src/librustc_trans_utils/trans_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub trait TransCrate {
type TranslatedCrate;

fn metadata_loader() -> Box<MetadataLoaderTrait>;
fn provide_local(_providers: &mut Providers);
fn provide(_providers: &mut Providers);
fn provide_extern(_providers: &mut Providers);
fn trans_crate<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
Expand All @@ -77,8 +77,8 @@ impl TransCrate for DummyTransCrate {
box DummyMetadataLoader(())
}

fn provide_local(_providers: &mut Providers) {
bug!("DummyTransCrate::provide_local");
fn provide(_providers: &mut Providers) {
bug!("DummyTransCrate::provide");
}

fn provide_extern(_providers: &mut Providers) {
Expand Down Expand Up @@ -185,7 +185,7 @@ impl TransCrate for MetadataOnlyTransCrate {
box NoLlvmMetadataLoader
}

fn provide_local(_providers: &mut Providers) {}
fn provide(_providers: &mut Providers) {}
fn provide_extern(_providers: &mut Providers) {}

fn trans_crate<'a, 'tcx>(
Expand Down

0 comments on commit 18b3a9a

Please sign in to comment.