Merge commit '6ed6f1e6a1' into clippyup
This commit is contained in:
parent
36a27ecaac
commit
f2f2a005b4
297 changed files with 15401 additions and 12253 deletions
23
clippy_lints/src/methods/single_char_pattern.rs
Normal file
23
clippy_lints/src/methods/single_char_pattern.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
use crate::methods::get_hint_if_single_char_arg;
|
||||
use crate::utils::span_lint_and_sugg;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::LateContext;
|
||||
|
||||
use super::SINGLE_CHAR_PATTERN;
|
||||
|
||||
/// lint for length-1 `str`s for methods in `PATTERN_METHODS`
|
||||
pub(super) fn check(cx: &LateContext<'_>, _expr: &hir::Expr<'_>, arg: &hir::Expr<'_>) {
|
||||
let mut applicability = Applicability::MachineApplicable;
|
||||
if let Some(hint) = get_hint_if_single_char_arg(cx, arg, &mut applicability) {
|
||||
span_lint_and_sugg(
|
||||
cx,
|
||||
SINGLE_CHAR_PATTERN,
|
||||
arg.span,
|
||||
"single-character string constant used as pattern",
|
||||
"try using a `char` instead",
|
||||
hint,
|
||||
applicability,
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue