Skip to content

Commit 41c8501

Browse files
committed
fix suggestion code
and update stderr in tests.
1 parent 34b0d48 commit 41c8501

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

clippy_lints/src/bytes_count_to_len.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ declare_clippy_lint! {
3131
#[clippy::version = "1.62.0"]
3232
pub BYTES_COUNT_TO_LEN,
3333
complexity,
34-
"Using bytes().count() when len() performs the same functionality"
34+
"Using `bytes().count()` when `len()` performs the same functionality"
3535
}
3636

3737
declare_lint_pass!(BytesCountToLen => [BYTES_COUNT_TO_LEN]);
@@ -40,7 +40,7 @@ impl<'tcx> LateLintPass<'tcx> for BytesCountToLen {
4040
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
4141
if_chain! {
4242
if let hir::ExprKind::MethodCall(expr_method, expr_args, _) = &expr.kind;
43-
if expr_method.ident.name == rustc_span::sym::count;
43+
if expr_method.ident.name == sym::count;
4444

4545
if let [bytes_expr] = &**expr_args;
4646
if let hir::ExprKind::MethodCall(bytes_method, bytes_args, _) = &bytes_expr.kind;
@@ -57,7 +57,7 @@ impl<'tcx> LateLintPass<'tcx> for BytesCountToLen {
5757
BYTES_COUNT_TO_LEN,
5858
expr.span,
5959
"using long and hard to read `.bytes().count()`",
60-
"consider calling `.len` instead",
60+
"consider calling `.len()` instead",
6161
format!("{}.len()", snippet_with_applicability(cx, str_expr.span, "..", &mut applicability)),
6262
applicability
6363
);

tests/ui/bytes_count_to_len.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@ error: using long and hard to read `.bytes().count()`
22
--> $DIR/bytes_count_to_len.rs:8:13
33
|
44
LL | let _ = String::from("foo").bytes().count();
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.len` instead: `String::from("foo").len()`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.len()` instead: `String::from("foo").len()`
66
|
77
= note: `-D clippy::bytes-count-to-len` implied by `-D warnings`
88

99
error: using long and hard to read `.bytes().count()`
1010
--> $DIR/bytes_count_to_len.rs:11:13
1111
|
1212
LL | let _ = s1.bytes().count();
13-
| ^^^^^^^^^^^^^^^^^^ help: consider calling `.len` instead: `s1.len()`
13+
| ^^^^^^^^^^^^^^^^^^ help: consider calling `.len()` instead: `s1.len()`
1414

1515
error: using long and hard to read `.bytes().count()`
1616
--> $DIR/bytes_count_to_len.rs:14:13
1717
|
1818
LL | let _ = "foo".bytes().count();
19-
| ^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.len` instead: `"foo".len()`
19+
| ^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.len()` instead: `"foo".len()`
2020

2121
error: using long and hard to read `.bytes().count()`
2222
--> $DIR/bytes_count_to_len.rs:17:13
2323
|
2424
LL | let _ = s2.bytes().count();
25-
| ^^^^^^^^^^^^^^^^^^ help: consider calling `.len` instead: `s2.len()`
25+
| ^^^^^^^^^^^^^^^^^^ help: consider calling `.len()` instead: `s2.len()`
2626

2727
error: aborting due to 4 previous errors
2828

0 commit comments

Comments
 (0)