rustc: Add a convenience alias for dyn MetadataLoader + Sync
This commit is contained in:
parent
175d325ccb
commit
222503a354
5 changed files with 12 additions and 10 deletions
|
@ -191,6 +191,8 @@ pub trait MetadataLoader {
|
||||||
-> Result<MetadataRef, String>;
|
-> Result<MetadataRef, String>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub type MetadataLoaderDyn = dyn MetadataLoader + Sync;
|
||||||
|
|
||||||
/// A store of Rust crates, through which their metadata can be accessed.
|
/// A store of Rust crates, through which their metadata can be accessed.
|
||||||
///
|
///
|
||||||
/// Note that this trait should probably not be expanding today. All new
|
/// Note that this trait should probably not be expanding today. All new
|
||||||
|
|
|
@ -56,7 +56,7 @@ use std::sync::Arc;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
|
|
||||||
use rustc::dep_graph::DepGraph;
|
use rustc::dep_graph::DepGraph;
|
||||||
use rustc::middle::cstore::{EncodedMetadata, MetadataLoader};
|
use rustc::middle::cstore::{EncodedMetadata, MetadataLoaderDyn};
|
||||||
use rustc::session::Session;
|
use rustc::session::Session;
|
||||||
use rustc::session::config::{OutputFilenames, OutputType, PrintRequest, OptLevel};
|
use rustc::session::config::{OutputFilenames, OutputType, PrintRequest, OptLevel};
|
||||||
use rustc::ty::{self, TyCtxt};
|
use rustc::ty::{self, TyCtxt};
|
||||||
|
@ -260,7 +260,7 @@ impl CodegenBackend for LlvmCodegenBackend {
|
||||||
target_features(sess)
|
target_features(sess)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn metadata_loader(&self) -> Box<dyn MetadataLoader + Sync> {
|
fn metadata_loader(&self) -> Box<MetadataLoaderDyn> {
|
||||||
box metadata::LlvmMetadataLoader
|
box metadata::LlvmMetadataLoader
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ use rustc::util::common::ErrorReported;
|
||||||
use rustc::session::config::{OutputFilenames, PrintRequest};
|
use rustc::session::config::{OutputFilenames, PrintRequest};
|
||||||
use rustc::ty::TyCtxt;
|
use rustc::ty::TyCtxt;
|
||||||
use rustc::ty::query::Providers;
|
use rustc::ty::query::Providers;
|
||||||
use rustc::middle::cstore::{EncodedMetadata, MetadataLoader};
|
use rustc::middle::cstore::{EncodedMetadata, MetadataLoaderDyn};
|
||||||
use rustc::dep_graph::DepGraph;
|
use rustc::dep_graph::DepGraph;
|
||||||
|
|
||||||
pub use rustc_data_structures::sync::MetadataRef;
|
pub use rustc_data_structures::sync::MetadataRef;
|
||||||
|
@ -26,7 +26,7 @@ pub trait CodegenBackend {
|
||||||
fn print_passes(&self) {}
|
fn print_passes(&self) {}
|
||||||
fn print_version(&self) {}
|
fn print_version(&self) {}
|
||||||
|
|
||||||
fn metadata_loader(&self) -> Box<dyn MetadataLoader + Sync>;
|
fn metadata_loader(&self) -> Box<MetadataLoaderDyn>;
|
||||||
fn provide(&self, _providers: &mut Providers<'_>);
|
fn provide(&self, _providers: &mut Providers<'_>);
|
||||||
fn provide_extern(&self, _providers: &mut Providers<'_>);
|
fn provide_extern(&self, _providers: &mut Providers<'_>);
|
||||||
fn codegen_crate<'tcx>(
|
fn codegen_crate<'tcx>(
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::schema;
|
||||||
use rustc::dep_graph::DepNodeIndex;
|
use rustc::dep_graph::DepNodeIndex;
|
||||||
use rustc::hir::def_id::{CrateNum, DefIndex};
|
use rustc::hir::def_id::{CrateNum, DefIndex};
|
||||||
use rustc::hir::map::definitions::DefPathTable;
|
use rustc::hir::map::definitions::DefPathTable;
|
||||||
use rustc::middle::cstore::{CrateSource, DepKind, ExternCrate, MetadataLoader};
|
use rustc::middle::cstore::{CrateSource, DepKind, ExternCrate, MetadataLoaderDyn};
|
||||||
use rustc::mir::interpret::AllocDecodingState;
|
use rustc::mir::interpret::AllocDecodingState;
|
||||||
use rustc_index::vec::IndexVec;
|
use rustc_index::vec::IndexVec;
|
||||||
use rustc::util::nodemap::FxHashMap;
|
use rustc::util::nodemap::FxHashMap;
|
||||||
|
@ -96,7 +96,7 @@ pub struct CrateMetadata {
|
||||||
|
|
||||||
pub struct CStore {
|
pub struct CStore {
|
||||||
metas: RwLock<IndexVec<CrateNum, Option<Lrc<CrateMetadata>>>>,
|
metas: RwLock<IndexVec<CrateNum, Option<Lrc<CrateMetadata>>>>,
|
||||||
crate metadata_loader: Box<dyn MetadataLoader + Sync>,
|
crate metadata_loader: Box<MetadataLoaderDyn>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum LoadedMacro {
|
pub enum LoadedMacro {
|
||||||
|
@ -105,7 +105,7 @@ pub enum LoadedMacro {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CStore {
|
impl CStore {
|
||||||
pub fn new(metadata_loader: Box<dyn MetadataLoader + Sync>) -> CStore {
|
pub fn new(metadata_loader: Box<MetadataLoaderDyn>) -> CStore {
|
||||||
CStore {
|
CStore {
|
||||||
// We add an empty entry for LOCAL_CRATE (which maps to zero) in
|
// We add an empty entry for LOCAL_CRATE (which maps to zero) in
|
||||||
// order to make array indices in `metas` match with the
|
// order to make array indices in `metas` match with the
|
||||||
|
|
|
@ -9,14 +9,14 @@ extern crate rustc_target;
|
||||||
extern crate rustc_driver;
|
extern crate rustc_driver;
|
||||||
|
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
use std::sync::{Arc, mpsc};
|
use std::sync::Arc;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use syntax::symbol::Symbol;
|
use syntax::symbol::Symbol;
|
||||||
use rustc::session::Session;
|
use rustc::session::Session;
|
||||||
use rustc::session::config::OutputFilenames;
|
use rustc::session::config::OutputFilenames;
|
||||||
use rustc::ty::TyCtxt;
|
use rustc::ty::TyCtxt;
|
||||||
use rustc::ty::query::Providers;
|
use rustc::ty::query::Providers;
|
||||||
use rustc::middle::cstore::{EncodedMetadata, MetadataLoader};
|
use rustc::middle::cstore::{EncodedMetadata, MetadataLoader, MetadataLoaderDyn};
|
||||||
use rustc::dep_graph::DepGraph;
|
use rustc::dep_graph::DepGraph;
|
||||||
use rustc::util::common::ErrorReported;
|
use rustc::util::common::ErrorReported;
|
||||||
use rustc_codegen_utils::codegen_backend::CodegenBackend;
|
use rustc_codegen_utils::codegen_backend::CodegenBackend;
|
||||||
|
@ -41,7 +41,7 @@ impl MetadataLoader for NoLlvmMetadataLoader {
|
||||||
struct TheBackend;
|
struct TheBackend;
|
||||||
|
|
||||||
impl CodegenBackend for TheBackend {
|
impl CodegenBackend for TheBackend {
|
||||||
fn metadata_loader(&self) -> Box<dyn MetadataLoader + Sync> {
|
fn metadata_loader(&self) -> Box<MetadataLoaderDyn> {
|
||||||
Box::new(NoLlvmMetadataLoader)
|
Box::new(NoLlvmMetadataLoader)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue