Skip to content

Commit

Permalink
improve implementation by dogfood
Browse files Browse the repository at this point in the history
Signed-off-by: mojave2 <0109chenchen@gmail.com>
  • Loading branch information
kiscad committed Jun 26, 2023
1 parent a3a1415 commit 9845b3a
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions clippy_lints/src/non_reentrant_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,10 @@ impl EarlyLintPass for NonReentrantFunctions {

let msg: &str = "consider using the reentrant version of the function";

match expr.kind {
ExprKind::Call(ref func, _) => {
if is_reentrant_fn(func) {
span_lint(cx, NON_REENTRANT_FUNCTIONS, expr.span, msg);
}
},
_ => {},
if let ExprKind::Call(func, _) = &expr.kind {
if is_reentrant_fn(func) {
span_lint(cx, NON_REENTRANT_FUNCTIONS, expr.span, msg);
}
}
}
}
Expand All @@ -58,6 +55,6 @@ fn is_reentrant_fn(func: &Expr) -> bool {
}

fn check_reentrant_by_fn_name(func: &str) -> bool {
let name = func.split("#").next().unwrap();
let name = func.split('#').next().unwrap();
name == "strtok" || name == "localtime"
}

0 comments on commit 9845b3a

Please sign in to comment.