Skip to content

Commit

Permalink
Revert "Dogfood double_ended_iterator_last"
Browse files Browse the repository at this point in the history
This reverts commit 09c5d34.
  • Loading branch information
qsantos committed Jan 1, 2025
1 parent 7331cc0 commit 0d213aa
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/attrs/mixed_attributes_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.next_back()) {
let span = if let (Some(first), Some(last)) = (attrs_iter.next(), attrs_iter.last()) {
first.span.with_hi(last.span.hi())
} else {
return;
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/collapsible_if.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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().next_back() {
let requires_space = if let Some(c) = snippet(cx, up_to_else, "..").chars().last() {
!c.is_whitespace()
} else {
false
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/doc/empty_line_after.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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().next_back().unwrap()),
first_gap.prev_stop.span.to(empty_lines().last().unwrap()),
format!("empty {lines} after {kind_desc}"),
|diag| {
if let Some(owner) = cx.last_node_with_lint_attrs.as_owner() {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/doc/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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().next_back(), Some('S' | 'X'))
&& matches!(prefix.chars().last(), Some('S' | 'X'))
{
prefix
} else if let Some(prefix) = s.strip_suffix("ified")
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/let_if_seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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().next_back()
&& let Some(expr) = block.stmts.iter().last()
&& let hir::StmtKind::Semi(expr) = expr.kind
&& let hir::ExprKind::Assign(var, value, _) = expr.kind
&& path_to_local_id(var, decl)
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/returns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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().next_back()
&& let Some(stmt) = block.stmts.iter().last()
&& let StmtKind::Let(local) = &stmt.kind
&& local.ty.is_none()
&& cx.tcx.hir().attrs(local.hir_id).is_empty()
Expand Down Expand Up @@ -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().next_back() {
} else if let Some(stmt) = block.stmts.iter().last() {
match stmt.kind {
StmtKind::Expr(expr) => {
check_final_expr(cx, expr, semi_spans, RetReplacement::Empty, None);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/unit_types/unit_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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().next_back()
&& let Some(last_stmt) = block.stmts.iter().last()
&& let StmtKind::Semi(last_expr) = last_stmt.kind
&& let Some(snip) = last_expr.span.get_source_text(cx)
{
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl UselessVec {
}
},
higher::VecArgs::Vec(args) => {
let args_span = if let Some(last) = args.iter().next_back() {
let args_span = if let Some(last) = args.iter().last() {
if args.len() as u64 * size_of(cx, last) > self.too_large_for_stack {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_utils/src/msrvs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.next_back() {
if let Some(duplicate) = msrv_attrs.last() {
sess.dcx()
.struct_span_err(duplicate.span(), "`clippy::msrv` is defined multiple times")
.with_span_note(msrv_attr.span(), "first definition found here")
Expand Down

0 comments on commit 0d213aa

Please sign in to comment.