Skip to content

Commit

Permalink
Resolve redundant_closure_for_method_calls pedantic clippy lint
Browse files Browse the repository at this point in the history
    warning: redundant closure
      --> gen/src/cfg.rs:64:45
       |
    64 |             let value = string.as_ref().map(|string| string.value());
       |                                             ^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `syn::LitStr::value`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_for_method_calls
       = note: `-W clippy::redundant-closure-for-method-calls` implied by `-W clippy::pedantic`
  • Loading branch information
dtolnay committed Jul 6, 2023
1 parent a6c1419 commit a35d18b
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 5 deletions.
1 change: 0 additions & 1 deletion gen/build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
clippy::nonminimal_bool,
clippy::option_if_let_else,
clippy::or_fun_call,
clippy::redundant_closure_for_method_calls,
clippy::redundant_else,
clippy::semicolon_if_nothing_returned,
clippy::shadow_unrelated,
Expand Down
1 change: 0 additions & 1 deletion gen/cmd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
clippy::nonminimal_bool,
clippy::option_if_let_else,
clippy::or_fun_call,
clippy::redundant_closure_for_method_calls,
clippy::redundant_else,
clippy::semicolon_if_nothing_returned,
clippy::shadow_unrelated,
Expand Down
1 change: 0 additions & 1 deletion gen/lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
clippy::nonminimal_bool,
clippy::option_if_let_else,
clippy::or_fun_call,
clippy::redundant_closure_for_method_calls,
clippy::redundant_else,
clippy::semicolon_if_nothing_returned,
clippy::shadow_unrelated,
Expand Down
4 changes: 2 additions & 2 deletions gen/src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::syntax::report::Errors;
use crate::syntax::Api;
use quote::quote;
use std::collections::BTreeSet as Set;
use syn::Error;
use syn::{Error, LitStr};

pub(super) struct UnsupportedCfgEvaluator;

Expand Down Expand Up @@ -61,7 +61,7 @@ fn try_eval(cfg_evaluator: &dyn CfgEvaluator, expr: &CfgExpr) -> Result<bool, Ve
CfgExpr::Unconditional => Ok(true),
CfgExpr::Eq(ident, string) => {
let key = ident.to_string();
let value = string.as_ref().map(|string| string.value());
let value = string.as_ref().map(LitStr::value);
match cfg_evaluator.eval(&key, value.as_deref()) {
CfgResult::True => Ok(true),
CfgResult::False => Ok(false),
Expand Down

0 comments on commit a35d18b

Please sign in to comment.