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

codegen_utils, driver: fix clippy errors #56566

Merged
merged 1 commit into from
Dec 7, 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
21 changes: 9 additions & 12 deletions src/librustc_codegen_utils/codegen_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ impl MetadataLoader for NoLlvmMetadataLoader {

let mut buf = Vec::new();
io::copy(&mut file, &mut buf).unwrap();
let buf: OwningRef<Vec<u8>, [u8]> = OwningRef::new(buf).into();
return Ok(rustc_erase_owner!(buf.map_owner_box()));
let buf: OwningRef<Vec<u8>, [u8]> = OwningRef::new(buf);
Ok(rustc_erase_owner!(buf.map_owner_box()))
}

fn get_dylib_metadata(&self, target: &Target, filename: &Path) -> Result<MetadataRef, String> {
Expand All @@ -103,7 +103,7 @@ pub struct OngoingCodegen {
}

impl MetadataOnlyCodegenBackend {
pub fn new() -> Box<dyn CodegenBackend> {
pub fn boxed() -> Box<dyn CodegenBackend> {
box MetadataOnlyCodegenBackend(())
}
}
Expand Down Expand Up @@ -165,23 +165,20 @@ impl CodegenBackend for MetadataOnlyCodegenBackend {
tcx,
collector::MonoItemCollectionMode::Eager
).0 {
match mono_item {
MonoItem::Fn(inst) => {
let def_id = inst.def_id();
if def_id.is_local() {
let _ = inst.def.is_inline(tcx);
let _ = tcx.codegen_fn_attrs(def_id);
}
if let MonoItem::Fn(inst) = mono_item {
let def_id = inst.def_id();
if def_id.is_local() {
let _ = inst.def.is_inline(tcx);
let _ = tcx.codegen_fn_attrs(def_id);
}
_ => {}
}
}
tcx.sess.abort_if_errors();

let metadata = tcx.encode_metadata();

box OngoingCodegen {
metadata: metadata,
metadata,
metadata_version: tcx.metadata_encoding_version().to_vec(),
crate_name: tcx.crate_name(LOCAL_CRATE),
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ pub fn get_codegen_backend(sess: &Session) -> Box<dyn CodegenBackend> {
.unwrap_or(&sess.target.target.options.codegen_backend);
let backend = match &codegen_name[..] {
"metadata_only" => {
rustc_codegen_utils::codegen_backend::MetadataOnlyCodegenBackend::new
rustc_codegen_utils::codegen_backend::MetadataOnlyCodegenBackend::boxed
}
filename if filename.contains(".") => {
load_backend_from_dylib(filename.as_ref())
Expand Down Expand Up @@ -291,7 +291,7 @@ fn get_codegen_sysroot(backend_name: &str) -> fn() -> Box<dyn CodegenBackend> {
// let's just return a dummy creation function which won't be used in
// general anyway.
if cfg!(test) {
return rustc_codegen_utils::codegen_backend::MetadataOnlyCodegenBackend::new
return rustc_codegen_utils::codegen_backend::MetadataOnlyCodegenBackend::boxed
}

let target = session::config::host_triple();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,5 @@ impl CodegenBackend for TheBackend {
/// This is the entrypoint for a hot plugged rustc_codegen_llvm
#[no_mangle]
pub fn __rustc_codegen_backend() -> Box<CodegenBackend> {
Box::new(TheBackend(MetadataOnlyCodegenBackend::new()))
Box::new(TheBackend(MetadataOnlyCodegenBackend::boxed()))
}