Skip to content

Commit 42e7536

Browse files
committed
Change error message
1 parent 818e5af commit 42e7536

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

clippy_lints/src/get_last_with_len.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for GetLastWithLen {
8787
cx,
8888
GET_LAST_WITH_LEN,
8989
expr.span,
90-
&format!("Use `{}.last()` instead of `{}.get({}.len() - 1)`", vec_name,
91-
vec_name, vec_name),
90+
&format!("accessing last element with `{}.get({}.len() - 1)`",
91+
vec_name,
92+
vec_name),
9293
"try",
9394
format!("{}.last()", vec_name),
9495
applicability,

tests/ui/get_last_with_len.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: Use `x.last()` instead of `x.get(x.len() - 1)`
1+
error: accessing last element with `x.get(x.len() - 1)`
22
--> $DIR/get_last_with_len.rs:7:13
33
|
44
LL | let _ = x.get(x.len() - 1); // ~ERROR Use x.last()

0 commit comments

Comments
 (0)