Deny bare trait objects in in src/librustc_metadata

This commit is contained in:
ljedrz 2018-07-11 14:49:00 +02:00
parent ae5b629efd
commit 9cffe90fd0
6 changed files with 14 additions and 12 deletions

View File

@ -536,7 +536,7 @@ impl<'a> CrateLoader<'a> {
Ok(f) => f,
Err(err) => self.sess.span_fatal(span, &err),
};
mem::transmute::<*mut u8, fn(&mut Registry)>(sym)
mem::transmute::<*mut u8, fn(&mut dyn Registry)>(sym)
};
struct MyRegistrar {
@ -1019,7 +1019,7 @@ impl<'a> CrateLoader<'a> {
fn inject_dependency_if(&self,
krate: CrateNum,
what: &str,
needs_dep: &Fn(&cstore::CrateMetadata) -> bool) {
needs_dep: &dyn Fn(&cstore::CrateMetadata) -> bool) {
// don't perform this validation if the session has errors, as one of
// those errors may indicate a circular dependency which could cause
// this to stack overflow.

View File

@ -90,11 +90,11 @@ pub struct CStore {
metas: RwLock<IndexVec<CrateNum, Option<Lrc<CrateMetadata>>>>,
/// Map from NodeId's of local extern crate statements to crate numbers
extern_mod_crate_map: Lock<NodeMap<CrateNum>>,
pub metadata_loader: Box<MetadataLoader + Sync>,
pub metadata_loader: Box<dyn MetadataLoader + Sync>,
}
impl CStore {
pub fn new(metadata_loader: Box<MetadataLoader + Sync>) -> CStore {
pub fn new(metadata_loader: Box<dyn MetadataLoader + Sync>) -> CStore {
CStore {
// We add an empty entry for LOCAL_CRATE (which maps to zero) in
// order to make array indices in `metas` match with the

View File

@ -413,11 +413,11 @@ pub fn provide<'tcx>(providers: &mut Providers<'tcx>) {
}
impl CrateStore for cstore::CStore {
fn crate_data_as_rc_any(&self, krate: CrateNum) -> Lrc<Any> {
fn crate_data_as_rc_any(&self, krate: CrateNum) -> Lrc<dyn Any> {
self.get_crate_data(krate)
}
fn metadata_loader(&self) -> &MetadataLoader {
fn metadata_loader(&self) -> &dyn MetadataLoader {
&*self.metadata_loader
}

View File

@ -391,7 +391,7 @@ impl<'a, 'tcx> MetadataBlob {
}
pub fn list_crate_metadata(&self,
out: &mut io::Write) -> io::Result<()> {
out: &mut dyn io::Write) -> io::Result<()> {
write!(out, "=External Dependencies=\n")?;
let root = self.get_root();
for (i, dep) in root.crate_deps

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![deny(bare_trait_objects)]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]

View File

@ -273,7 +273,7 @@ pub struct Context<'a> {
pub rejected_via_filename: Vec<CrateMismatch>,
pub should_match_name: bool,
pub is_proc_macro: Option<bool>,
pub metadata_loader: &'a MetadataLoader,
pub metadata_loader: &'a dyn MetadataLoader,
}
pub struct CratePaths {
@ -842,7 +842,7 @@ impl<'a> Context<'a> {
fn get_metadata_section(target: &Target,
flavor: CrateFlavor,
filename: &Path,
loader: &MetadataLoader)
loader: &dyn MetadataLoader)
-> Result<MetadataBlob, String> {
let start = Instant::now();
let ret = get_metadata_section_imp(target, flavor, filename, loader);
@ -855,7 +855,7 @@ fn get_metadata_section(target: &Target,
fn get_metadata_section_imp(target: &Target,
flavor: CrateFlavor,
filename: &Path,
loader: &MetadataLoader)
loader: &dyn MetadataLoader)
-> Result<MetadataBlob, String> {
if !filename.exists() {
return Err(format!("no such file: '{}'", filename.display()));
@ -904,8 +904,8 @@ fn get_metadata_section_imp(target: &Target,
// A diagnostic function for dumping crate metadata to an output stream
pub fn list_file_metadata(target: &Target,
path: &Path,
loader: &MetadataLoader,
out: &mut io::Write)
loader: &dyn MetadataLoader,
out: &mut dyn io::Write)
-> io::Result<()> {
let filename = path.file_name().unwrap().to_str().unwrap();
let flavor = if filename.ends_with(".rlib") {