about summary refs log tree commit diff
diff options
context:
space:
mode:
authorQuentin Santos <qsantos@qsantos.fr>2025-01-01 19:43:27 +0100
committerQuentin Santos <qsantos@qsantos.fr>2025-01-01 19:47:22 +0100
commit09c5d34f98f53d4f0b4181404608d4c1bcede4d5 (patch)
treee257c4b7b81f5e5a49f1de58caae530c2ee1e984
parent458c955ae3a6f297510a86ab7efac4c7db5cc964 (diff)
downloadrust-09c5d34f98f53d4f0b4181404608d4c1bcede4d5.tar.gz
rust-09c5d34f98f53d4f0b4181404608d4c1bcede4d5.zip
Dogfood double_ended_iterator_last
-rw-r--r--clippy_lints/src/attrs/mixed_attributes_style.rs2
-rw-r--r--clippy_lints/src/collapsible_if.rs2
-rw-r--r--clippy_lints/src/doc/empty_line_after.rs2
-rw-r--r--clippy_lints/src/doc/markdown.rs2
-rw-r--r--clippy_lints/src/let_if_seq.rs2
-rw-r--r--clippy_lints/src/returns.rs4
-rw-r--r--clippy_lints/src/unit_types/unit_arg.rs2
-rw-r--r--clippy_lints/src/vec.rs2
-rw-r--r--clippy_utils/src/msrvs.rs2
9 files changed, 10 insertions, 10 deletions
diff --git a/clippy_lints/src/attrs/mixed_attributes_style.rs b/clippy_lints/src/attrs/mixed_attributes_style.rs
index 32c28c09c36..8c91c65eaf7 100644
--- a/clippy_lints/src/attrs/mixed_attributes_style.rs
+++ b/clippy_lints/src/attrs/mixed_attributes_style.rs
@@ -66,7 +66,7 @@ pub(super) fn check(cx: &EarlyContext<'_>, item_span: Span, attrs: &[Attribute])
 
 fn lint_mixed_attrs(cx: &EarlyContext<'_>, attrs: &[Attribute]) {
     let mut attrs_iter = attrs.iter().filter(|attr| !attr.span.from_expansion());
-    let span = if let (Some(first), Some(last)) = (attrs_iter.next(), attrs_iter.last()) {
+    let span = if let (Some(first), Some(last)) = (attrs_iter.next(), attrs_iter.next_back()) {
         first.span.with_hi(last.span.hi())
     } else {
         return;
diff --git a/clippy_lints/src/collapsible_if.rs b/clippy_lints/src/collapsible_if.rs
index e73bfc6ebf7..6122fcb28da 100644
--- a/clippy_lints/src/collapsible_if.rs
+++ b/clippy_lints/src/collapsible_if.rs
@@ -110,7 +110,7 @@ fn check_collapsible_maybe_if_let(cx: &EarlyContext<'_>, then_span: Span, else_:
         // Prevent "elseif"
         // Check that the "else" is followed by whitespace
         let up_to_else = then_span.between(block.span);
-        let requires_space = if let Some(c) = snippet(cx, up_to_else, "..").chars().last() {
+        let requires_space = if let Some(c) = snippet(cx, up_to_else, "..").chars().next_back() {
             !c.is_whitespace()
         } else {
             false
diff --git a/clippy_lints/src/doc/empty_line_after.rs b/clippy_lints/src/doc/empty_line_after.rs
index 099194d4e74..74058c2fbf5 100644
--- a/clippy_lints/src/doc/empty_line_after.rs
+++ b/clippy_lints/src/doc/empty_line_after.rs
@@ -227,7 +227,7 @@ fn check_gaps(cx: &LateContext<'_>, gaps: &[Gap<'_>]) -> bool {
     span_lint_and_then(
         cx,
         lint,
-        first_gap.prev_stop.span.to(empty_lines().last().unwrap()),
+        first_gap.prev_stop.span.to(empty_lines().next_back().unwrap()),
         format!("empty {lines} after {kind_desc}"),
         |diag| {
             if let Some(owner) = cx.last_node_with_lint_attrs.as_owner() {
diff --git a/clippy_lints/src/doc/markdown.rs b/clippy_lints/src/doc/markdown.rs
index 8cdaba88e50..0c8e50445d6 100644
--- a/clippy_lints/src/doc/markdown.rs
+++ b/clippy_lints/src/doc/markdown.rs
@@ -89,7 +89,7 @@ fn check_word(cx: &LateContext<'_>, word: &str, span: Span, code_level: isize, b
 
         let s = if let Some(prefix) = s.strip_suffix("es")
             && prefix.chars().all(|c| c.is_ascii_uppercase())
-            && matches!(prefix.chars().last(), Some('S' | 'X'))
+            && matches!(prefix.chars().next_back(), Some('S' | 'X'))
         {
             prefix
         } else if let Some(prefix) = s.strip_suffix("ified")
diff --git a/clippy_lints/src/let_if_seq.rs b/clippy_lints/src/let_if_seq.rs
index 5db28e9ae9b..502e6f3a08d 100644
--- a/clippy_lints/src/let_if_seq.rs
+++ b/clippy_lints/src/let_if_seq.rs
@@ -149,7 +149,7 @@ fn check_assign<'tcx>(
     block: &'tcx hir::Block<'_>,
 ) -> Option<&'tcx hir::Expr<'tcx>> {
     if block.expr.is_none()
-        && let Some(expr) = block.stmts.iter().last()
+        && let Some(expr) = block.stmts.iter().next_back()
         && let hir::StmtKind::Semi(expr) = expr.kind
         && let hir::ExprKind::Assign(var, value, _) = expr.kind
         && path_to_local_id(var, decl)
diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs
index aeff31d02d2..5ed6e3fead5 100644
--- a/clippy_lints/src/returns.rs
+++ b/clippy_lints/src/returns.rs
@@ -228,7 +228,7 @@ impl<'tcx> LateLintPass<'tcx> for Return {
     fn check_block(&mut self, cx: &LateContext<'tcx>, block: &'tcx Block<'_>) {
         // we need both a let-binding stmt and an expr
         if let Some(retexpr) = block.expr
-            && let Some(stmt) = block.stmts.iter().last()
+            && let Some(stmt) = block.stmts.iter().next_back()
             && let StmtKind::Let(local) = &stmt.kind
             && local.ty.is_none()
             && cx.tcx.hir().attrs(local.hir_id).is_empty()
@@ -315,7 +315,7 @@ fn check_block_return<'tcx>(cx: &LateContext<'tcx>, expr_kind: &ExprKind<'tcx>,
     if let ExprKind::Block(block, _) = expr_kind {
         if let Some(block_expr) = block.expr {
             check_final_expr(cx, block_expr, semi_spans, RetReplacement::Empty, None);
-        } else if let Some(stmt) = block.stmts.iter().last() {
+        } else if let Some(stmt) = block.stmts.iter().next_back() {
             match stmt.kind {
                 StmtKind::Expr(expr) => {
                     check_final_expr(cx, expr, semi_spans, RetReplacement::Empty, None);
diff --git a/clippy_lints/src/unit_types/unit_arg.rs b/clippy_lints/src/unit_types/unit_arg.rs
index 47d6fe7db76..5e49eae1404 100644
--- a/clippy_lints/src/unit_types/unit_arg.rs
+++ b/clippy_lints/src/unit_types/unit_arg.rs
@@ -78,7 +78,7 @@ fn lint_unit_args(cx: &LateContext<'_>, expr: &Expr<'_>, args_to_recover: &[&Exp
                 .filter_map(|arg| {
                     if let ExprKind::Block(block, _) = arg.kind
                         && block.expr.is_none()
-                        && let Some(last_stmt) = block.stmts.iter().last()
+                        && let Some(last_stmt) = block.stmts.iter().next_back()
                         && let StmtKind::Semi(last_expr) = last_stmt.kind
                         && let Some(snip) = last_expr.span.get_source_text(cx)
                     {
diff --git a/clippy_lints/src/vec.rs b/clippy_lints/src/vec.rs
index ef1c46154d2..2c7e0fea17d 100644
--- a/clippy_lints/src/vec.rs
+++ b/clippy_lints/src/vec.rs
@@ -175,7 +175,7 @@ impl UselessVec {
                 }
             },
             higher::VecArgs::Vec(args) => {
-                let args_span = if let Some(last) = args.iter().last() {
+                let args_span = if let Some(last) = args.iter().next_back() {
                     if args.len() as u64 * size_of(cx, last) > self.too_large_for_stack {
                         return;
                     }
diff --git a/clippy_utils/src/msrvs.rs b/clippy_utils/src/msrvs.rs
index 98bcedecccc..2169a5fdd63 100644
--- a/clippy_utils/src/msrvs.rs
+++ b/clippy_utils/src/msrvs.rs
@@ -130,7 +130,7 @@ impl Msrv {
         let mut msrv_attrs = attrs.iter().filter(|attr| attr.path_matches(&[sym::clippy, sym_msrv]));
 
         if let Some(msrv_attr) = msrv_attrs.next() {
-            if let Some(duplicate) = msrv_attrs.last() {
+            if let Some(duplicate) = msrv_attrs.next_back() {
                 sess.dcx()
                     .struct_span_err(duplicate.span(), "`clippy::msrv` is defined multiple times")
                     .with_span_note(msrv_attr.span(), "first definition found here")