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

Fix by cargo-clippy #86

Merged
merged 5 commits into from
Aug 27, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/openblas-src.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
if: ${{ matrix.triple == 'x64-windows-static' }}

macos:
runs-on: macos-10.15
runs-on: macos-11
strategy:
fail-fast: false
matrix:
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Rust

on:
push:
branches:
- master
pull_request: {}

jobs:
check-format:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v1
- uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check

clippy:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v1
with:
submodules: 'true'
- uses: actions-rs/cargo@v1
with:
command: clippy
25 changes: 10 additions & 15 deletions openblas-build/src/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl LinkFlags {
pub fn parse(line: &str) -> Result<Self, Error> {
let mut search_paths = HashSet::new();
let mut libs = HashSet::new();
for entry in line.split(" ") {
for entry in line.split(' ') {
if entry.starts_with("-L") {
let path = PathBuf::from(entry.trim_start_matches("-L"));
if !path.exists() {
Expand Down Expand Up @@ -79,10 +79,10 @@ impl MakeConf {
let buf = io::BufReader::new(f);
for line in buf.lines() {
let line = line.expect("Makefile.conf should not include non-UTF8 string");
if line.len() == 0 {
if line.is_empty() {
continue;
}
let entry: Vec<_> = line.split("=").collect();
let entry: Vec<_> = line.split('=').collect();
if entry.len() != 2 {
continue;
}
Expand All @@ -104,7 +104,6 @@ impl MakeConf {
/// - Global "T" symbols in the text (code) section of library using `nm -g` external command.
#[derive(Debug, Clone)]
pub struct LibInspect {
path: PathBuf,
pub libs: Vec<String>,
pub symbols: Vec<String>,
}
Expand Down Expand Up @@ -133,7 +132,7 @@ impl LibInspect {
.lines()
.flat_map(|line| {
let line = line.expect("nm output should not include non-UTF8 output");
let entry: Vec<_> = line.trim().split(" ").collect();
let entry: Vec<_> = line.trim().split(' ').collect();
if entry.len() == 3 && entry[1] == "T" {
Some(entry[2].into())
} else {
Expand All @@ -160,11 +159,7 @@ impl LibInspect {
.collect();
libs.sort();

Ok(LibInspect {
path: path.into(),
libs,
symbols,
})
Ok(LibInspect { libs, symbols })
}

pub fn has_cblas(&self) -> bool {
Expand All @@ -173,7 +168,7 @@ impl LibInspect {
return true;
}
}
return false;
false
}

pub fn has_lapack(&self) -> bool {
Expand All @@ -182,7 +177,7 @@ impl LibInspect {
return true;
}
}
return false;
false
}

pub fn has_lapacke(&self) -> bool {
Expand All @@ -191,18 +186,18 @@ impl LibInspect {
return true;
}
}
return false;
false
}

pub fn has_lib(&self, name: &str) -> bool {
for lib in &self.libs {
if let Some(stem) = lib.split(".").next() {
if let Some(stem) = lib.split('.').next() {
if stem == format!("lib{}", name) {
return true;
}
};
}
return false;
false
}
}

Expand Down
6 changes: 3 additions & 3 deletions openblas-src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ fn build() {
// It makes users not to build OpenBLAS in every `cargo build`.
let mut hasher = DefaultHasher::new();
cfg.hash(&mut hasher);
let output = dirs::data_dir()

dirs::data_dir()
.expect("Cannot get user's data directory")
.join("openblas_build")
.join(format!("{:x}", hasher.finish()));
output
.join(format!("{:x}", hasher.finish()))
} else {
PathBuf::from(env::var("OUT_DIR").unwrap())
};
Expand Down