Skip to content

Commit

Permalink
style: ignore clippy warnings on generated files
Browse files Browse the repository at this point in the history
  • Loading branch information
aelesbao committed Oct 30, 2024
1 parent f373d5d commit fec8561
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions proto-build/src/commands/apply_patches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@ use crate::utils::patch_file::patch_file;
use glob::glob;
use std::path::{Path, PathBuf};

fn ignore_clippy(out_dir: &Path) -> crate::Result<()> {
const REPLACEMENTS: &[(&str, &str)] =
&[("^// @generated$", "#[allow(clippy::all)]\n// @generated")];

patch_file(&out_dir.join("mod.rs"), REPLACEMENTS)?;

Ok(())
}

/// Fix clashing type names in prost-generated code.
fn apply_cosmos_staking_patches(out_dir: &Path) {
fn apply_cosmos_staking_patches(out_dir: &Path) -> crate::Result<()> {
const REPLACEMENTS: &[(&str, &str)] = &[
("enum Validators", "enum Policy"),
(
Expand All @@ -12,8 +21,9 @@ fn apply_cosmos_staking_patches(out_dir: &Path) {
),
];

patch_file(&out_dir.join("cosmos.staking.v1beta1.rs"), REPLACEMENTS)
.expect("error patching cosmos.staking.v1beta1.rs");
patch_file(&out_dir.join("cosmos.staking.v1beta1.rs"), REPLACEMENTS)?;

Ok(())
}

pub fn apply_patches(out_dir: &Path) -> crate::Result<()> {
Expand Down Expand Up @@ -42,7 +52,8 @@ pub fn apply_patches(out_dir: &Path) -> crate::Result<()> {
patch_file(&src, REPLACEMENTS)?;
}

apply_cosmos_staking_patches(out_dir);
apply_cosmos_staking_patches(out_dir)?;
ignore_clippy(out_dir)?;

Ok(())
}

0 comments on commit fec8561

Please sign in to comment.