Skip to content

Commit 3dc3d57

Browse files
committed
Convert pattern matches of itertools::Position into the new appropriate method calls
1 parent efce304 commit 3dc3d57

4 files changed

Lines changed: 11 additions & 11 deletions

File tree

compiler/rustc_ast_pretty/src/pprust/state/expr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::fmt::Write;
22

33
use ast::{ForLoopKind, MatchKind};
4-
use itertools::{Itertools, Position};
4+
use itertools::Itertools;
55
use rustc_ast::util::classify;
66
use rustc_ast::util::literal::escape_byte_str_symbol;
77
use rustc_ast::util::parser::{self, ExprPrecedence, Fixity};
@@ -170,8 +170,8 @@ impl<'a> State<'a> {
170170
}
171171
let cb = self.cbox(0);
172172
for (pos, field) in fields.iter().with_position() {
173-
let is_first = matches!(pos, Position::First | Position::Only);
174-
let is_last = matches!(pos, Position::Last | Position::Only);
173+
let is_first = pos.is_first();
174+
let is_last = pos.is_last();
175175
self.maybe_print_comment(field.span.hi());
176176
self.print_outer_attributes(&field.attrs);
177177
if is_first {

compiler/rustc_ast_pretty/src/pprust/state/item.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use ast::StaticItem;
2-
use itertools::{Itertools, Position};
2+
use itertools::Itertools;
33
use rustc_ast::{self as ast, EiiImpl, ModKind, Safety, TraitAlias};
44
use rustc_span::Ident;
55

@@ -923,7 +923,7 @@ impl<'a> State<'a> {
923923
self.zerobreak();
924924
let ib = self.ibox(0);
925925
for (pos, use_tree) in items.iter().with_position() {
926-
let is_last = matches!(pos, Position::Last | Position::Only);
926+
let is_last = pos.is_last();
927927
self.print_use_tree(&use_tree.0);
928928
if !is_last {
929929
self.word(",");

compiler/rustc_mir_build/src/builder/matches/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::borrow::Borrow;
99
use std::sync::Arc;
1010
use std::{debug_assert_matches, mem};
1111

12-
use itertools::{Itertools, Position};
12+
use itertools::Itertools;
1313
use rustc_abi::{FIRST_VARIANT, FieldIdx, VariantIdx};
1414
use rustc_data_structures::fx::FxIndexMap;
1515
use rustc_data_structures::stack::ensure_sufficient_stack;
@@ -551,9 +551,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
551551
// the drop order for the first sub-branch, we lower sub-branches in reverse (#142163).
552552
let target_block = self.cfg.start_new_block();
553553
for (pos, sub_branch) in branch.sub_branches.into_iter().rev().with_position() {
554-
debug_assert!(pos != Position::Only);
554+
debug_assert!(!pos.is_exactly_one());
555555
let schedule_drops =
556-
if pos == Position::Last { ScheduleDrops::Yes } else { ScheduleDrops::No };
556+
if pos.is_last() { ScheduleDrops::Yes } else { ScheduleDrops::No };
557557
let binding_end = self.bind_and_guard_matched_candidate(
558558
sub_branch,
559559
fake_borrow_temps,

src/librustdoc/html/render/sorted_template.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::fmt::{self, Write as _};
33
use std::marker::PhantomData;
44
use std::str::FromStr;
55

6-
use itertools::{Itertools as _, Position};
6+
use itertools::Itertools as _;
77
use serde::{Deserialize, Serialize};
88

99
/// Append-only templates for sorted, deduplicated lists of items.
@@ -62,7 +62,7 @@ impl<F: FileFormat> fmt::Display for SortedTemplate<F> {
6262
write!(f, "{}", self.before)?;
6363
for (p, fragment) in self.fragments.iter().with_position() {
6464
let mut f = DeltaWriter { inner: &mut f, delta: 0 };
65-
let sep = if matches!(p, Position::First | Position::Only) { "" } else { F::SEPARATOR };
65+
let sep = if p.is_first() { "" } else { F::SEPARATOR };
6666
f.write_str(sep)?;
6767
f.write_str(fragment)?;
6868
fragment_lengths.push(f.delta);
@@ -95,7 +95,7 @@ impl<F: FileFormat> FromStr for SortedTemplate<F> {
9595
let (fragment, rest) =
9696
s.split_at_checked(index).ok_or(Error("invalid fragment length: out of bounds"))?;
9797
s = rest;
98-
let sep = if matches!(p, Position::First | Position::Only) { "" } else { F::SEPARATOR };
98+
let sep = if p.is_first() { "" } else { F::SEPARATOR };
9999
let fragment = fragment
100100
.strip_prefix(sep)
101101
.ok_or(Error("invalid fragment length: expected to find separator here"))?;

0 commit comments

Comments
 (0)