浏览代码

ci: run clippy for nightly (#1150)

Kirill Fomichev 3 年之前
父节点
当前提交
efd37219d2

+ 2 - 0
.github/workflows/tests.yaml

@@ -35,6 +35,8 @@ jobs:
       - run: cargo build
       - run: cargo fmt -- --check
       - run: cargo clippy --all-targets -- -D warnings
+      - run: rustup toolchain install nightly --profile minimal --component clippy
+      - run: cargo +nightly clippy --all-targets -- -D warnings
       - run: cargo test
       - run: cd ts && yarn
       - run: cd ts && yarn test

+ 1 - 1
cli/src/lib.rs

@@ -1777,7 +1777,7 @@ fn validator_flags(cfg: &WithPath<Config>) -> Result<Vec<String>> {
                 if key == "ledger" {
                     continue;
                 };
-                flags.push(format!("--{}", key.replace("_", "-")));
+                flags.push(format!("--{}", key.replace('_', "-")));
                 if let serde_json::Value::String(v) = value {
                     flags.push(v.to_string());
                 } else {

+ 1 - 1
lang/attribute/account/src/lib.rs

@@ -69,7 +69,7 @@ pub fn account(
     for arg in args {
         let ns = arg
             .to_string()
-            .replace("\"", "")
+            .replace('\"', "")
             .chars()
             .filter(|c| !c.is_whitespace())
             .collect();

+ 1 - 1
lang/syn/src/codegen/accounts/constraints.rs

@@ -222,7 +222,7 @@ pub fn generate_constraint_signer(f: &Field, c: &ConstraintSigner) -> proc_macro
 pub fn generate_constraint_literal(c: &ConstraintLiteral) -> proc_macro2::TokenStream {
     let lit: proc_macro2::TokenStream = {
         let lit = &c.lit;
-        let constraint = lit.value().replace("\"", "");
+        let constraint = lit.value().replace('\"', "");
         let message = format!(
             "Deprecated. Should be used with constraint: #[account(constraint = {})]",
             constraint,

+ 1 - 1
lang/syn/src/idl/mod.rs

@@ -150,7 +150,7 @@ impl std::str::FromStr for IdlType {
                 None => {
                     let (raw_type, raw_length) = inner.rsplit_once(';').unwrap();
                     let ty = IdlType::from_str(raw_type).unwrap();
-                    let len = raw_length.replace("_", "").parse::<usize>().unwrap();
+                    let len = raw_length.replace('_', "").parse::<usize>().unwrap();
                     IdlType::Array(Box::new(ty), len)
                 }
                 Some(nested_inner) => array_from_str(&nested_inner[1..]),

+ 3 - 3
lang/syn/src/parser/accounts/mod.rs

@@ -116,7 +116,7 @@ fn ident_string(f: &syn::Field) -> ParseResult<String> {
         _ => return Err(ParseError::new(f.ty.span(), "invalid type")),
     };
     if parser::tts_to_string(&path)
-        .replace(" ", "")
+        .replace(' ', "")
         .starts_with("Box<Account<")
     {
         return Ok("Account".to_string());
@@ -177,7 +177,7 @@ fn parse_program_loader_account(path: &syn::Path) -> ParseResult<LoaderAccountTy
 fn parse_account_ty(path: &syn::Path) -> ParseResult<AccountTy> {
     let account_type_path = parse_account(path)?;
     let boxed = parser::tts_to_string(&path)
-        .replace(" ", "")
+        .replace(' ', "")
         .starts_with("Box<Account<");
     Ok(AccountTy {
         account_type_path,
@@ -193,7 +193,7 @@ fn parse_program_ty(path: &syn::Path) -> ParseResult<ProgramTy> {
 // TODO: this whole method is a hack. Do something more idiomatic.
 fn parse_account(mut path: &syn::Path) -> ParseResult<syn::TypePath> {
     if parser::tts_to_string(path)
-        .replace(" ", "")
+        .replace(' ', "")
         .starts_with("Box<Account<")
     {
         let segments = &path.segments[0];

+ 1 - 1
lang/syn/src/parser/error.rs

@@ -56,7 +56,7 @@ fn parse_error_attribute(variant: &syn::Variant) -> Option<String> {
 
             let msg = match g_stream.into_iter().next() {
                 None => panic!("Must specify a message string"),
-                Some(msg) => msg.to_string().replace("\"", ""),
+                Some(msg) => msg.to_string().replace('\"', ""),
             };
 
             Some(msg)