This is an automated email from the ASF dual-hosted git repository. jroesch pushed a commit to branch ci-docker-staging in repository https://gitbox.apache.org/repos/asf/tvm.git
commit 34806acef5cb991c72cedfd9bd9e7bb14c95af62 Author: Jared Roesch <[email protected]> AuthorDate: Fri Mar 26 14:41:25 2021 -0700 Format --- rust/tvm-sys/build.rs | 30 ++++++++++++++++++++++-------- rust/tvm-sys/src/byte_array.rs | 4 +--- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/rust/tvm-sys/build.rs b/rust/tvm-sys/build.rs index 107d813..5a62f22 100644 --- a/rust/tvm-sys/build.rs +++ b/rust/tvm-sys/build.rs @@ -22,7 +22,7 @@ extern crate bindgen; use std::path::{Path, PathBuf}; use anyhow::{Context, Result}; -use tvm_build::{BuildConfig}; +use tvm_build::BuildConfig; /// The necessary information for detecting a TVM installation. struct TVMInstall { @@ -41,9 +41,13 @@ fn find_using_tvm_path<P: AsRef<Path>>(tvm_path: P) -> Result<TVMInstall> { fn if_unset<K: AsRef<std::ffi::OsStr>, V: AsRef<std::ffi::OsStr>>(k: K, v: V) -> Result<()> { match std::env::var(k.as_ref()) { Ok(other) if other != "" => { - println!("cargo:warning=Using existing environment variable setting {:?}={:?}", k.as_ref(), v.as_ref()); + println!( + "cargo:warning=Using existing environment variable setting {:?}={:?}", + k.as_ref(), + v.as_ref() + ); } - _ => std::env::set_var(k, v) + _ => std::env::set_var(k, v), } Ok(()) @@ -70,7 +74,10 @@ fn find_using_tvm_build() -> Result<TVMInstall> { } fn main() -> Result<()> { - let TVMInstall { source_path, build_path } = match option_env!("TVM_HOME") { + let TVMInstall { + source_path, + build_path, + } = match option_env!("TVM_HOME") { Some(tvm_path) if tvm_path != "" => find_using_tvm_path(tvm_path), _ => find_using_tvm_build(), }?; @@ -80,13 +87,18 @@ fn main() -> Result<()> { if cfg!(feature = "static-linking") { println!("cargo:rustc-link-lib=static=tvm"); // TODO move this to tvm-build as library_path? - println!("cargo:rustc-link-search=native={}/build", build_path.display()); - + println!( + "cargo:rustc-link-search=native={}/build", + build_path.display() + ); } if cfg!(feature = "dynamic-linking") { println!("cargo:rustc-link-lib=dylib=tvm"); - println!("cargo:rustc-link-search=native={}/build", build_path.display()); + println!( + "cargo:rustc-link-search=native={}/build", + build_path.display() + ); } let runtime_api = source_path.join("include/tvm/runtime/c_runtime_api.h"); @@ -109,7 +121,9 @@ fn main() -> Result<()> { .derive_eq(true) .derive_default(true) .generate() - .map_err(|()| anyhow::anyhow!("bindgen failed to generate the Rust bindings for the C API"))? + .map_err(|()| { + anyhow::anyhow!("bindgen failed to generate the Rust bindings for the C API") + })? .write_to_file(out_file) .context("failed to write the generated Rust binding to disk")?; diff --git a/rust/tvm-sys/src/byte_array.rs b/rust/tvm-sys/src/byte_array.rs index b1b75fc..4b005ab 100644 --- a/rust/tvm-sys/src/byte_array.rs +++ b/rust/tvm-sys/src/byte_array.rs @@ -41,9 +41,7 @@ pub struct ByteArray { impl ByteArray { /// Gets the underlying byte-array pub fn data(&self) -> &'static [u8] { - unsafe { std::slice::from_raw_parts( - self.array.data as *const u8, - self.array.size as _) } + unsafe { std::slice::from_raw_parts(self.array.data as *const u8, self.array.size as _) } } /// Gets the length of the underlying byte-array
