diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index cdeee92cb07..1e227b8a1a6 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -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. diff --git a/src/librustc_metadata/cstore.rs b/src/librustc_metadata/cstore.rs index 2bc5f607486..d93a7f9526e 100644 --- a/src/librustc_metadata/cstore.rs +++ b/src/librustc_metadata/cstore.rs @@ -90,11 +90,11 @@ pub struct CStore { metas: RwLock>>>, /// Map from NodeId's of local extern crate statements to crate numbers extern_mod_crate_map: Lock>, - pub metadata_loader: Box, + pub metadata_loader: Box, } impl CStore { - pub fn new(metadata_loader: Box) -> CStore { + pub fn new(metadata_loader: Box) -> 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 diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index cded812b5f0..d5078642147 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -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 { + fn crate_data_as_rc_any(&self, krate: CrateNum) -> Lrc { self.get_crate_data(krate) } - fn metadata_loader(&self) -> &MetadataLoader { + fn metadata_loader(&self) -> &dyn MetadataLoader { &*self.metadata_loader } diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 38149d1ca50..b8c64383950 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -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 diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs index dad1030cb61..5c9915e94e5 100644 --- a/src/librustc_metadata/lib.rs +++ b/src/librustc_metadata/lib.rs @@ -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/")] diff --git a/src/librustc_metadata/locator.rs b/src/librustc_metadata/locator.rs index 9b1b48efca5..b747624338c 100644 --- a/src/librustc_metadata/locator.rs +++ b/src/librustc_metadata/locator.rs @@ -273,7 +273,7 @@ pub struct Context<'a> { pub rejected_via_filename: Vec, pub should_match_name: bool, pub is_proc_macro: Option, - 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 { 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 { 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") {