Skip to content

Commit

Permalink
Removed references to find_is_some_on_strs
Browse files Browse the repository at this point in the history
ran `tests/ui/update-references.sh`
updated lint docs for `lint_search_is_some`
  • Loading branch information
rsulli55 committed Oct 10, 2020
1 parent 0b7d440 commit b72e769
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 200 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1716,7 +1716,6 @@ Released 2018-09-13
[`filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#filter_map
[`filter_map_next`]: https://rust-lang.github.io/rust-clippy/master/index.html#filter_map_next
[`filter_next`]: https://rust-lang.github.io/rust-clippy/master/index.html#filter_next
[`find_is_some_on_strs`]: https://rust-lang.github.io/rust-clippy/master/index.html#find_is_some_on_strs
[`find_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#find_map
[`flat_map_identity`]: https://rust-lang.github.io/rust-clippy/master/index.html#flat_map_identity
[`float_arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#float_arithmetic
Expand Down
80 changes: 0 additions & 80 deletions clippy_lints/src/find_is_some_on_strs.rs

This file was deleted.

5 changes: 0 additions & 5 deletions clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ mod excessive_bools;
mod exit;
mod explicit_write;
mod fallible_impl_from;
mod find_is_some_on_strs;
mod float_equality_without_abs;
mod float_literal;
mod floating_point_arithmetic;
Expand Down Expand Up @@ -569,7 +568,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
&exit::EXIT,
&explicit_write::EXPLICIT_WRITE,
&fallible_impl_from::FALLIBLE_IMPL_FROM,
&find_is_some_on_strs::FIND_IS_SOME_ON_STRS,
&float_equality_without_abs::FLOAT_EQUALITY_WITHOUT_ABS,
&float_literal::EXCESSIVE_PRECISION,
&float_literal::LOSSY_FLOAT_LITERAL,
Expand Down Expand Up @@ -1135,7 +1133,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
store.register_late_pass(move || box disallowed_method::DisallowedMethod::new(&disallowed_methods));
store.register_early_pass(|| box asm_syntax::InlineAsmX86AttSyntax);
store.register_early_pass(|| box asm_syntax::InlineAsmX86IntelSyntax);
store.register_late_pass(|| box find_is_some_on_strs::FindIsSomeOnStrs);


store.register_group(true, "clippy::restriction", Some("clippy_restriction"), vec![
Expand Down Expand Up @@ -1320,7 +1317,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&eval_order_dependence::DIVERGING_SUB_EXPRESSION),
LintId::of(&eval_order_dependence::EVAL_ORDER_DEPENDENCE),
LintId::of(&explicit_write::EXPLICIT_WRITE),
LintId::of(&find_is_some_on_strs::FIND_IS_SOME_ON_STRS),
LintId::of(&float_equality_without_abs::FLOAT_EQUALITY_WITHOUT_ABS),
LintId::of(&float_literal::EXCESSIVE_PRECISION),
LintId::of(&format::USELESS_FORMAT),
Expand Down Expand Up @@ -1652,7 +1648,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&eval_order_dependence::DIVERGING_SUB_EXPRESSION),
LintId::of(&eval_order_dependence::EVAL_ORDER_DEPENDENCE),
LintId::of(&explicit_write::EXPLICIT_WRITE),
LintId::of(&find_is_some_on_strs::FIND_IS_SOME_ON_STRS),
LintId::of(&format::USELESS_FORMAT),
LintId::of(&functions::TOO_MANY_ARGUMENTS),
LintId::of(&get_last_with_len::GET_LAST_WITH_LEN),
Expand Down
15 changes: 7 additions & 8 deletions clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,11 +516,11 @@ declare_clippy_lint! {
}

declare_clippy_lint! {
/// **What it does:** Checks for an iterator search (such as `find()`,
/// **What it does:** Checks for an iterator or string search (such as `find()`,
/// `position()`, or `rposition()`) followed by a call to `is_some()`.
///
/// **Why is this bad?** Readability, this can be written more concisely as
/// `_.any(_)`.
/// `_.any(_)` or `_.contains(_)`.
///
/// **Known problems:** None.
///
Expand All @@ -536,7 +536,7 @@ declare_clippy_lint! {
/// ```
pub SEARCH_IS_SOME,
complexity,
"using an iterator search followed by `is_some()`, which is more succinctly expressed as a call to `any()`"
"using an iterator or string search followed by `is_some()`, which is more succinctly expressed as a call to `any()` or `contains()`"
}

declare_clippy_lint! {
Expand Down Expand Up @@ -3089,13 +3089,13 @@ fn lint_search_is_some<'tcx>(
}
}
// lint if `find()` is called by `String` or `&str`
else if search_method == "find" {
let is_string_or_str_slice = |e| {
else if search_method == "find" {
let is_string_or_str_slice = |e| {
let self_ty = cx.typeck_results().expr_ty(e).peel_refs();
if is_type_diagnostic_item(cx, self_ty, sym!(string_type)) {
true
} else {
*self_ty.kind() == ty::Str
} else {
*self_ty.kind() == ty::Str
}
};
if_chain! {
Expand All @@ -3118,7 +3118,6 @@ fn lint_search_is_some<'tcx>(
}
}
}

}

/// Used for `lint_binary_expr_with_method_call`.
Expand Down
9 changes: 1 addition & 8 deletions src/lintlist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,13 +640,6 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
deprecation: None,
module: "methods",
},
Lint {
name: "find_is_some_on_strs",
group: "complexity",
desc: "using `find()` followed by `is_some()` on strings, which is more\n succinctly expressed as a call to `contains()`",
deprecation: None,
module: "find_is_some_on_strs",
},
Lint {
name: "find_map",
group: "pedantic",
Expand Down Expand Up @@ -2036,7 +2029,7 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
Lint {
name: "search_is_some",
group: "complexity",
desc: "using an iterator search followed by `is_some()`, which is more succinctly expressed as a call to `any()`",
desc: "using an iterator or string search followed by `is_some()`, which is more succinctly expressed as a call to `any()` or `contains()`",
deprecation: None,
module: "methods",
},
Expand Down
39 changes: 0 additions & 39 deletions tests/ui/find_is_some_on_strs.rs

This file was deleted.

58 changes: 0 additions & 58 deletions tests/ui/find_is_some_on_strs.stderr

This file was deleted.

56 changes: 55 additions & 1 deletion tests/ui/methods.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,59 @@ LL | | }
LL | | ).is_some();
| |______________________________^

error: aborting due to 12 previous errors
error: called `is_some()` after calling `find()` on a string. This is more succinctly expressed by calling `contains()`.
--> $DIR/methods.rs:178:27
|
LL | let _ = "hello world".find("world").is_some();
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `contains("world")`

error: called `is_some()` after calling `find()` on a string. This is more succinctly expressed by calling `contains()`.
--> $DIR/methods.rs:179:27
|
LL | let _ = "hello world".find(&s2).is_some();
| ^^^^^^^^^^^^^^^^^^^ help: try this: `contains(&s2)`

error: called `is_some()` after calling `find()` on a string. This is more succinctly expressed by calling `contains()`.
--> $DIR/methods.rs:180:27
|
LL | let _ = "hello world".find(&s2[2..]).is_some();
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `contains(&s2[2..])`

error: called `is_some()` after calling `find()` on a string. This is more succinctly expressed by calling `contains()`.
--> $DIR/methods.rs:182:16
|
LL | let _ = s1.find("world").is_some();
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `contains("world")`

error: called `is_some()` after calling `find()` on a string. This is more succinctly expressed by calling `contains()`.
--> $DIR/methods.rs:183:16
|
LL | let _ = s1.find(&s2).is_some();
| ^^^^^^^^^^^^^^^^^^^ help: try this: `contains(&s2)`

error: called `is_some()` after calling `find()` on a string. This is more succinctly expressed by calling `contains()`.
--> $DIR/methods.rs:184:16
|
LL | let _ = s1.find(&s2[2..]).is_some();
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `contains(&s2[2..])`

error: called `is_some()` after calling `find()` on a string. This is more succinctly expressed by calling `contains()`.
--> $DIR/methods.rs:186:21
|
LL | let _ = s1[2..].find("world").is_some();
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `contains("world")`

error: called `is_some()` after calling `find()` on a string. This is more succinctly expressed by calling `contains()`.
--> $DIR/methods.rs:187:21
|
LL | let _ = s1[2..].find(&s2).is_some();
| ^^^^^^^^^^^^^^^^^^^ help: try this: `contains(&s2)`

error: called `is_some()` after calling `find()` on a string. This is more succinctly expressed by calling `contains()`.
--> $DIR/methods.rs:188:21
|
LL | let _ = s1[2..].find(&s2[2..]).is_some();
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `contains(&s2[2..])`

error: aborting due to 21 previous errors

0 comments on commit b72e769

Please sign in to comment.