Skip to content

Commit d3e5177

Browse files
committed
Use .next() instead of .nth(0) on iterators.
1 parent 97b3d81 commit d3e5177

File tree

12 files changed

+14
-14
lines changed

12 files changed

+14
-14
lines changed

src/librustc/mir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,7 @@ impl<'tcx> Debug for TerminatorKind<'tcx> {
14461446
match successor_count {
14471447
0 => Ok(()),
14481448

1449-
1 => write!(fmt, " -> {:?}", self.successors().nth(0).unwrap()),
1449+
1 => write!(fmt, " -> {:?}", self.successors().next().unwrap()),
14501450

14511451
_ => {
14521452
write!(fmt, " -> [")?;

src/librustc/ty/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ impl<'tcx> TyCtxt<'tcx> {
357357
let mut dtor_did = None;
358358
let ty = self.type_of(adt_did);
359359
self.for_each_relevant_impl(drop_trait, ty, |impl_did| {
360-
if let Some(item) = self.associated_items(impl_did).in_definition_order().nth(0) {
360+
if let Some(item) = self.associated_items(impl_did).in_definition_order().next() {
361361
if validate(self, impl_did).is_ok() {
362362
dtor_did = Some(item.def_id);
363363
}

src/librustc_mir/transform/simplify.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
230230
};
231231

232232
let first_succ = {
233-
if let Some(&first_succ) = terminator.successors().nth(0) {
233+
if let Some(&first_succ) = terminator.successors().next() {
234234
if terminator.successors().all(|s| *s == first_succ) {
235235
let count = terminator.successors().count();
236236
self.pred_count[first_succ] -= (count - 1) as u32;

src/librustc_mir/util/elaborate_drops.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ where
549549
debug!("destructor_call_block({:?}, {:?})", self, succ);
550550
let tcx = self.tcx();
551551
let drop_trait = tcx.lang_items().drop_trait().unwrap();
552-
let drop_fn = tcx.associated_items(drop_trait).in_definition_order().nth(0).unwrap();
552+
let drop_fn = tcx.associated_items(drop_trait).in_definition_order().next().unwrap();
553553
let ty = self.place_ty(self.place);
554554
let substs = tcx.mk_substs_trait(ty, &[]);
555555

src/librustc_mir_build/hair/pattern/_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ impl<'tcx> Constructor<'tcx> {
10001000
PatKind::Leaf { subpatterns }
10011001
}
10021002
}
1003-
ty::Ref(..) => PatKind::Deref { subpattern: subpatterns.nth(0).unwrap() },
1003+
ty::Ref(..) => PatKind::Deref { subpattern: subpatterns.next().unwrap() },
10041004
ty::Slice(_) | ty::Array(..) => bug!("bad slice pattern {:?} {:?}", self, ty),
10051005
_ => PatKind::Wild,
10061006
},

src/librustc_parse/parser/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ impl<'a> Parser<'a> {
955955
};
956956
let kind = if es.len() == 1 && !trailing_comma {
957957
// `(e)` is parenthesized `e`.
958-
ExprKind::Paren(es.into_iter().nth(0).unwrap())
958+
ExprKind::Paren(es.into_iter().next().unwrap())
959959
} else {
960960
// `(e,)` is a tuple with only one field, `e`.
961961
ExprKind::Tup(es)

src/librustc_parse/parser/pat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ impl<'a> Parser<'a> {
479479
// Here, `(pat,)` is a tuple pattern.
480480
// For backward compatibility, `(..)` is a tuple pattern as well.
481481
Ok(if fields.len() == 1 && !(trailing_comma || fields[0].is_rest()) {
482-
PatKind::Paren(fields.into_iter().nth(0).unwrap())
482+
PatKind::Paren(fields.into_iter().next().unwrap())
483483
} else {
484484
PatKind::Tuple(fields)
485485
})

src/librustc_parse/parser/ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl<'a> Parser<'a> {
198198
})?;
199199

200200
if ts.len() == 1 && !trailing {
201-
let ty = ts.into_iter().nth(0).unwrap().into_inner();
201+
let ty = ts.into_iter().next().unwrap().into_inner();
202202
let maybe_bounds = allow_plus == AllowPlus::Yes && self.token.is_like_plus();
203203
match ty.kind {
204204
// `(TY_BOUND_NOPAREN) + BOUND + ...`.

src/librustc_span/source_map.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ impl SourceMap {
620620
/// if no character could be found or if an error occurred while retrieving the code snippet.
621621
pub fn span_extend_to_prev_char(&self, sp: Span, c: char) -> Span {
622622
if let Ok(prev_source) = self.span_to_prev_source(sp) {
623-
let prev_source = prev_source.rsplit(c).nth(0).unwrap_or("").trim_start();
623+
let prev_source = prev_source.rsplit(c).next().unwrap_or("").trim_start();
624624
if !prev_source.is_empty() && !prev_source.contains('\n') {
625625
return sp.with_lo(BytePos(sp.lo().0 - prev_source.len() as u32));
626626
}
@@ -640,7 +640,7 @@ impl SourceMap {
640640
for ws in &[" ", "\t", "\n"] {
641641
let pat = pat.to_owned() + ws;
642642
if let Ok(prev_source) = self.span_to_prev_source(sp) {
643-
let prev_source = prev_source.rsplit(&pat).nth(0).unwrap_or("").trim_start();
643+
let prev_source = prev_source.rsplit(&pat).next().unwrap_or("").trim_start();
644644
if !prev_source.is_empty() && (!prev_source.contains('\n') || accept_newlines) {
645645
return sp.with_lo(BytePos(sp.lo().0 - prev_source.len() as u32));
646646
}
@@ -655,7 +655,7 @@ impl SourceMap {
655655
pub fn span_until_char(&self, sp: Span, c: char) -> Span {
656656
match self.span_to_snippet(sp) {
657657
Ok(snippet) => {
658-
let snippet = snippet.split(c).nth(0).unwrap_or("").trim_end();
658+
let snippet = snippet.split(c).next().unwrap_or("").trim_end();
659659
if !snippet.is_empty() && !snippet.contains('\n') {
660660
sp.with_hi(BytePos(sp.lo().0 + snippet.len() as u32))
661661
} else {

src/librustc_typeck/check/closure.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
675675
// The `Future` trait has only one associted item, `Output`,
676676
// so check that this is what we see.
677677
let output_assoc_item =
678-
self.tcx.associated_items(future_trait).in_definition_order().nth(0).unwrap().def_id;
678+
self.tcx.associated_items(future_trait).in_definition_order().next().unwrap().def_id;
679679
if output_assoc_item != predicate.projection_ty.item_def_id {
680680
span_bug!(
681681
cause_span,

src/librustc_typeck/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5244,7 +5244,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
52445244
.tcx
52455245
.associated_items(future_trait)
52465246
.in_definition_order()
5247-
.nth(0)
5247+
.next()
52485248
.unwrap()
52495249
.def_id;
52505250
let predicate =

src/tools/unicode-table-generator/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ fn main() {
147147
eprintln!("Must provide path to write unicode tables to");
148148
eprintln!(
149149
"e.g. {} src/libcore/unicode/unicode_data.rs",
150-
std::env::args().nth(0).unwrap_or_default()
150+
std::env::args().next().unwrap_or_default()
151151
);
152152
std::process::exit(1);
153153
});

0 commit comments

Comments
 (0)