Fix manual-strip
dogfood errors
This commit is contained in:
parent
d1f0f04a48
commit
15244a88df
@ -534,7 +534,7 @@ fn check_word(cx: &LateContext<'_>, word: &str, span: Span) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let s = if s.ends_with('s') { &s[..s.len() - 1] } else { s };
|
||||
let s = s.strip_suffix('s').unwrap_or(s);
|
||||
|
||||
s.chars().all(char::is_alphanumeric)
|
||||
&& s.chars().filter(|&c| c.is_uppercase()).take(2).count() > 1
|
||||
|
@ -2601,11 +2601,9 @@ fn check_needless_collect_direct_usage<'tcx>(expr: &'tcx Expr<'_>, cx: &LateCont
|
||||
span,
|
||||
NEEDLESS_COLLECT_MSG,
|
||||
|diag| {
|
||||
let (arg, pred) = if contains_arg.starts_with('&') {
|
||||
("x", &contains_arg[1..])
|
||||
} else {
|
||||
("&x", &*contains_arg)
|
||||
};
|
||||
let (arg, pred) = contains_arg
|
||||
.strip_prefix('&')
|
||||
.map_or(("&x", &*contains_arg), |s| ("x", s));
|
||||
diag.span_suggestion(
|
||||
span,
|
||||
"replace with",
|
||||
|
@ -377,8 +377,8 @@ impl EarlyLintPass for MiscEarlyLints {
|
||||
if let PatKind::Ident(_, ident, None) = arg.pat.kind {
|
||||
let arg_name = ident.to_string();
|
||||
|
||||
if arg_name.starts_with('_') {
|
||||
if let Some(correspondence) = registered_names.get(&arg_name[1..]) {
|
||||
if let Some(arg_name) = arg_name.strip_prefix('_') {
|
||||
if let Some(correspondence) = registered_names.get(arg_name) {
|
||||
span_lint(
|
||||
cx,
|
||||
DUPLICATE_UNDERSCORE_ARGUMENT,
|
||||
@ -386,7 +386,7 @@ impl EarlyLintPass for MiscEarlyLints {
|
||||
&format!(
|
||||
"`{}` already exists, having another argument having almost the same \
|
||||
name makes code comprehension and documentation more difficult",
|
||||
arg_name[1..].to_owned()
|
||||
arg_name
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -239,10 +239,9 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClone {
|
||||
);
|
||||
let mut app = Applicability::MaybeIncorrect;
|
||||
|
||||
let mut call_snip = &snip[dot + 1..];
|
||||
let call_snip = &snip[dot + 1..];
|
||||
// Machine applicable when `call_snip` looks like `foobar()`
|
||||
if call_snip.ends_with("()") {
|
||||
call_snip = call_snip[..call_snip.len()-2].trim();
|
||||
if let Some(call_snip) = call_snip.strip_suffix("()").map(str::trim) {
|
||||
if call_snip.as_bytes().iter().all(|b| b.is_ascii_alphabetic() || *b == b'_') {
|
||||
app = Applicability::MachineApplicable;
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ fn issue985_alt() -> i32 {
|
||||
x
|
||||
}
|
||||
|
||||
#[allow(clippy::manual_strip)]
|
||||
fn issue975() -> String {
|
||||
let mut udn = "dummy".to_string();
|
||||
if udn.starts_with("uuid:") {
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: `if _ { .. } else { .. }` is an expression
|
||||
--> $DIR/let_if_seq.rs:63:5
|
||||
--> $DIR/let_if_seq.rs:64:5
|
||||
|
|
||||
LL | / let mut foo = 0;
|
||||
LL | | if f() {
|
||||
@ -11,7 +11,7 @@ LL | | }
|
||||
= note: you might not need `mut` at all
|
||||
|
||||
error: `if _ { .. } else { .. }` is an expression
|
||||
--> $DIR/let_if_seq.rs:68:5
|
||||
--> $DIR/let_if_seq.rs:69:5
|
||||
|
|
||||
LL | / let mut bar = 0;
|
||||
LL | | if f() {
|
||||
@ -25,7 +25,7 @@ LL | | }
|
||||
= note: you might not need `mut` at all
|
||||
|
||||
error: `if _ { .. } else { .. }` is an expression
|
||||
--> $DIR/let_if_seq.rs:76:5
|
||||
--> $DIR/let_if_seq.rs:77:5
|
||||
|
|
||||
LL | / let quz;
|
||||
LL | | if f() {
|
||||
@ -36,7 +36,7 @@ LL | | }
|
||||
| |_____^ help: it is more idiomatic to write: `let quz = if f() { 42 } else { 0 };`
|
||||
|
||||
error: `if _ { .. } else { .. }` is an expression
|
||||
--> $DIR/let_if_seq.rs:105:5
|
||||
--> $DIR/let_if_seq.rs:106:5
|
||||
|
|
||||
LL | / let mut baz = 0;
|
||||
LL | | if f() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user