Skip to content

Commit

Permalink
chore(lints): Update ast-grep rules and update deny.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
uttarayan21 committed Oct 25, 2024
1 parent ea77e6f commit 2fdec58
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 34 deletions.
11 changes: 11 additions & 0 deletions .rules/no-println.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
id: no_println
message: Do not use println! use `tracing::info`/`tracing::trace`/`tracing::debug` instead
severity: warning
language: Rust
rule:
all:
- kind: macro_invocation
- pattern: println!($$$ITEMS)
fix: tracing::info!($$$ITEMS)
ignores:
- ./*build.rs
8 changes: 8 additions & 0 deletions .rules/no-unwrap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
id: no_unwrap
message: Do not use unwrap
description: Do not use unwrap
severity: warning
language: Rust
rule:
pattern: $ITEM.unwrap()
exclude: ./*build.rs
2 changes: 1 addition & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ ignore = [
# List of explicitly allowed licenses
# See https://spdx.org/licenses/ for list of possible licenses
# [possible values: any SPDX 3.11 short identifier (+ optional exception)].
allow = ["MIT", "Apache-2.0", "BSD-3-Clause", "ISC", "Unicode-DFS-2016"]
allow = ["MIT", "Apache-2.0", "BSD-3-Clause", "ISC", "Unicode-DFS-2016", "Zlib"]
# The confidence threshold for detecting a license from license text.
# The higher the value, the more closely the license text must be to the
# canonical license text of a valid SPDX license file.
Expand Down
56 changes: 28 additions & 28 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -160,34 +160,34 @@
partitionType = "count";
cargoExtraArgs = "-p mnn-sys";
});
mnn-lints = sgLib.scan ./.;
mnn-asan = let
rustPlatform = pkgs.makeRustPlatform {
cargo = nightlyToolchain;
rustc = nightlyToolchain;
};
in
rustPlatform.buildRustPackage (
commonArgs
// {
inherit src;
name = "mnn-leaks";
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"cmake-0.1.50" = "sha256-GM2D7dpb2i2S6qYVM4HYk5B40TwKCmGQnUPfXksyf0M=";
};
};

buildPhase = ''
cargo test --target aarch64-apple-darwin
'';
RUSTFLAGS = "-Zsanitizer=address";
ASAN_OPTIONS = "detect_leaks=1";
# MNN_COMPILE = "NO";
# MNN_LIB_DIR = "${pkgs.mnn}/lib";
}
);
# mnn-lints = sgLib.scan ./.;
# mnn-asan = let
# rustPlatform = pkgs.makeRustPlatform {
# cargo = nightlyToolchain;
# rustc = nightlyToolchain;
# };
# in
# rustPlatform.buildRustPackage (
# commonArgs
# // {
# inherit src;
# name = "mnn-leaks";
# cargoLock = {
# lockFile = ./Cargo.lock;
# outputHashes = {
# "cmake-0.1.50" = "sha256-GM2D7dpb2i2S6qYVM4HYk5B40TwKCmGQnUPfXksyf0M=";
# };
# };
#
# buildPhase = ''
# cargo test --target aarch64-apple-darwin
# '';
# RUSTFLAGS = "-Zsanitizer=address";
# ASAN_OPTIONS = "detect_leaks=1";
# # MNN_COMPILE = "NO";
# # MNN_LIB_DIR = "${pkgs.mnn}/lib";
# }
# );
};
packages =
rec {
Expand Down
8 changes: 3 additions & 5 deletions mnn-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,10 @@ fn main() -> Result<()> {
"cargo:rustc-link-search=native={}",
install_dir.join("lib").display()
);
} else if let core::result::Result::Ok(lib_dir) = std::env::var("MNN_LIB_DIR") {
println!("cargo:rustc-link-search=native={}", lib_dir);
} else {
if let Some(lib_dir) = std::env::var("MNN_LIB_DIR").ok() {
println!("cargo:rustc-link-search=native={}", lib_dir);
} else {
panic!("MNN_LIB_DIR not set while MNN_COMPILE is false");
}
panic!("MNN_LIB_DIR not set while MNN_COMPILE is false");
}

mnn_c_build(PathBuf::from(MANIFEST_DIR).join("mnn_c"), &vendor)
Expand Down

0 comments on commit 2fdec58

Please sign in to comment.