Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deny bare trait objects in src/librustc_metadata #52254

Merged
merged 1 commit into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/librustc_metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_metadata/cstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_metadata/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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/")]
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_metadata/locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand All @@ -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()));
Expand Down Expand Up @@ -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") {
Expand Down