Skip to content

Commit 7f5b8fd

Browse files
author
Paolo Tranquilli
committed
Rust: remove clippy warnings
1 parent 1d9a9fe commit 7f5b8fd

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

.github/workflows/rust.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ jobs:
4545
- name: Clippy
4646
shell: bash
4747
run: |
48-
cargo clippy --fix
49-
git diff --exit-code
48+
cargo clippy -- -D warnings
5049
rust-code:
5150
runs-on: ubuntu-latest
5251
defaults:
@@ -65,8 +64,7 @@ jobs:
6564
- name: Clippy
6665
shell: bash
6766
run: |
68-
cargo clippy --fix
69-
git diff --exit-code
67+
cargo clippy -- -D warnings
7068
rust-codegen:
7169
runs-on: ubuntu-latest
7270
steps:

rust/ast-generator/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ write_file(
7575
'DST_DIR="$(dirname "$(rlocation "$1")")"',
7676
'mkdir -p "$DST_DIR/src/codegen/grammar"',
7777
] + [
78-
'cp "$(rlocation "$%s")" "$DST_DIR/%s"' % item
78+
'cp -f --no-preserve=mode "$(rlocation "$%s")" "$DST_DIR/%s"' % item
7979
for item in enumerate(_codegen_outs, 2)
8080
],
8181
is_executable = True,

rust/ast-generator/src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ use std::env;
99
use ungrammar::Grammar;
1010

1111
fn project_root() -> PathBuf {
12-
let dir =
13-
env::var("CARGO_MANIFEST_DIR").unwrap().to_owned();
12+
let dir = env::var("CARGO_MANIFEST_DIR").unwrap().to_owned();
1413
PathBuf::from(dir).parent().unwrap().to_owned()
1514
}
1615

@@ -593,7 +592,7 @@ impl Translator<'_> {{
593592
fn main() -> std::io::Result<()> {
594593
let grammar = PathBuf::from("..").join(env::args().nth(1).expect("grammar file path required"));
595594
let grammar: Grammar = fs::read_to_string(&grammar)
596-
.expect(&format!("Failed to parse grammar file: {}", grammar.display()))
595+
.unwrap_or_else(|_| panic!("Failed to parse grammar file: {}", grammar.display()))
597596
.parse()
598597
.expect("Failed to parse grammar");
599598
let mut grammar = codegen::grammar::lower(&grammar);

rust/lint.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
cargo = shutil.which("cargo")
1111
assert cargo, "no cargo binary found on `PATH`"
1212

13-
fmt = subprocess.run([cargo, "fmt", "--all", "--quiet"], cwd=this_dir)
13+
runs = []
14+
runs.append(subprocess.run([cargo, "fmt", "--all", "--quiet"], cwd=this_dir))
15+
1416
for manifest in this_dir.rglob("Cargo.toml"):
1517
if not manifest.is_relative_to(this_dir / "ql") and not manifest.is_relative_to(this_dir / "integration-tests"):
16-
clippy = subprocess.run([cargo, "clippy", "--fix", "--allow-dirty", "--allow-staged", "--quiet"],
17-
cwd=manifest.parent)
18-
sys.exit(fmt.returncode or clippy.returncode)
18+
runs.append(subprocess.run([cargo, "clippy", "--fix", "--allow-dirty", "--allow-staged", "--quiet", "--", "-D", "warnings"],
19+
cwd=manifest.parent))
20+
sys.exit(max(r.returncode for r in runs))

0 commit comments

Comments
 (0)