Skip to content

Commit 6936ca8

Browse files
committed
Auto merge of rust-lang#86311 - LeSeulArtichaut:cleanup-array-iter, r=jackh726
Use the now available implementation of `IntoIterator` for arrays
2 parents 9089771 + e3ca81f commit 6936ca8

File tree

17 files changed

+34
-34
lines changed

17 files changed

+34
-34
lines changed

compiler/rustc_apfloat/tests/ieee.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1939,7 +1939,7 @@ fn add() {
19391939
(m_smallest_normalized, m_smallest_normalized, "-0x1p-125", Status::OK, Category::Normal),
19401940
];
19411941

1942-
for &(x, y, e_result, e_status, e_category) in &special_cases[..] {
1942+
for (x, y, e_result, e_status, e_category) in special_cases {
19431943
let status;
19441944
let result = unpack!(status=, x + y);
19451945
assert_eq!(status, e_status);
@@ -2262,7 +2262,7 @@ fn subtract() {
22622262
(m_smallest_normalized, m_smallest_normalized, "0x0p+0", Status::OK, Category::Zero),
22632263
];
22642264

2265-
for &(x, y, e_result, e_status, e_category) in &special_cases[..] {
2265+
for (x, y, e_result, e_status, e_category) in special_cases {
22662266
let status;
22672267
let result = unpack!(status=, x - y);
22682268
assert_eq!(status, e_status);
@@ -2538,7 +2538,7 @@ fn multiply() {
25382538
(m_smallest_normalized, m_smallest_normalized, "0x0p+0", underflow_status, Category::Zero),
25392539
];
25402540

2541-
for &(x, y, e_result, e_status, e_category) in &special_cases[..] {
2541+
for (x, y, e_result, e_status, e_category) in special_cases {
25422542
let status;
25432543
let result = unpack!(status=, x * y);
25442544
assert_eq!(status, e_status);
@@ -2814,7 +2814,7 @@ fn divide() {
28142814
(m_smallest_normalized, m_smallest_normalized, "0x1p+0", Status::OK, Category::Normal),
28152815
];
28162816

2817-
for &(x, y, e_result, e_status, e_category) in &special_cases[..] {
2817+
for (x, y, e_result, e_status, e_category) in special_cases {
28182818
let status;
28192819
let result = unpack!(status=, x / y);
28202820
assert_eq!(status, e_status);

compiler/rustc_apfloat/tests/ppc.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fn ppc_double_double_add_special() {
6464
(0x7ff8000000000000, 0x3ff0000000000000, Category::NaN, Round::NearestTiesToEven),
6565
];
6666

67-
for &(op1, op2, expected, round) in &data {
67+
for (op1, op2, expected, round) in data {
6868
{
6969
let mut a1 = DoubleDouble::from_bits(op1);
7070
let a2 = DoubleDouble::from_bits(op2);
@@ -135,7 +135,7 @@ fn ppc_double_double_add() {
135135
),
136136
];
137137

138-
for &(op1, op2, expected, round) in &data {
138+
for (op1, op2, expected, round) in data {
139139
{
140140
let mut a1 = DoubleDouble::from_bits(op1);
141141
let a2 = DoubleDouble::from_bits(op2);
@@ -172,7 +172,7 @@ fn ppc_double_double_subtract() {
172172
),
173173
];
174174

175-
for &(op1, op2, expected, round) in &data {
175+
for (op1, op2, expected, round) in data {
176176
let mut a1 = DoubleDouble::from_bits(op1);
177177
let a2 = DoubleDouble::from_bits(op2);
178178
a1 = a1.sub_r(a2, round).value;
@@ -204,7 +204,7 @@ fn ppc_double_double_multiply_special() {
204204
(0, 0x3ff0000000000000, Category::Zero, Round::NearestTiesToEven),
205205
];
206206

207-
for &(op1, op2, expected, round) in &data {
207+
for (op1, op2, expected, round) in data {
208208
{
209209
let mut a1 = DoubleDouble::from_bits(op1);
210210
let a2 = DoubleDouble::from_bits(op2);
@@ -290,7 +290,7 @@ fn ppc_double_double_multiply() {
290290
),
291291
];
292292

293-
for &(op1, op2, expected, round) in &data {
293+
for (op1, op2, expected, round) in data {
294294
{
295295
let mut a1 = DoubleDouble::from_bits(op1);
296296
let a2 = DoubleDouble::from_bits(op2);
@@ -322,7 +322,7 @@ fn ppc_double_double_divide() {
322322
),
323323
];
324324

325-
for &(op1, op2, expected, round) in &data {
325+
for (op1, op2, expected, round) in data {
326326
let mut a1 = DoubleDouble::from_bits(op1);
327327
let a2 = DoubleDouble::from_bits(op2);
328328
a1 = a1.div_r(a2, round).value;
@@ -348,7 +348,7 @@ fn ppc_double_double_remainder() {
348348
),
349349
];
350350

351-
for &(op1, op2, expected) in &data {
351+
for (op1, op2, expected) in data {
352352
let a1 = DoubleDouble::from_bits(op1);
353353
let a2 = DoubleDouble::from_bits(op2);
354354
let result = a1.ieee_rem(a2).value;
@@ -376,7 +376,7 @@ fn ppc_double_double_mod() {
376376
),
377377
];
378378

379-
for &(op1, op2, expected) in &data {
379+
for (op1, op2, expected) in data {
380380
let a1 = DoubleDouble::from_bits(op1);
381381
let a2 = DoubleDouble::from_bits(op2);
382382
let r = (a1 % a2).value;
@@ -426,7 +426,7 @@ fn ppc_double_double_compare() {
426426
(0x7ff0000000000000, 0x7ff0000000000000, Some(Ordering::Equal)),
427427
];
428428

429-
for &(op1, op2, expected) in &data {
429+
for (op1, op2, expected) in data {
430430
let a1 = DoubleDouble::from_bits(op1);
431431
let a2 = DoubleDouble::from_bits(op2);
432432
assert_eq!(expected, a1.partial_cmp(&a2), "compare({:#x}, {:#x})", op1, op2,);
@@ -448,7 +448,7 @@ fn ppc_double_double_bitwise_eq() {
448448
(0x7ff0000000000000, 0x7ff0000000000000, true),
449449
];
450450

451-
for &(op1, op2, expected) in &data {
451+
for (op1, op2, expected) in data {
452452
let a1 = DoubleDouble::from_bits(op1);
453453
let a2 = DoubleDouble::from_bits(op2);
454454
assert_eq!(expected, a1.bitwise_eq(a2), "{:#x} = {:#x}", op1, op2);

compiler/rustc_ast_lowering/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
417417
fn allocate_use_tree_hir_id_counters(&mut self, tree: &UseTree) {
418418
match tree.kind {
419419
UseTreeKind::Simple(_, id1, id2) => {
420-
for &id in &[id1, id2] {
420+
for id in [id1, id2] {
421421
self.lctx.allocate_hir_id_counter(id);
422422
}
423423
}

compiler/rustc_codegen_cranelift/src/compiler_builtins.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ macro builtin_functions($register:ident; $(fn $name:ident($($arg_name:ident: $ar
77

88
#[cfg(feature = "jit")]
99
pub(crate) fn $register(builder: &mut cranelift_jit::JITBuilder) {
10-
for &(name, val) in &[$((stringify!($name), $name as *const u8)),*] {
10+
for (name, val) in [$((stringify!($name), $name as *const u8)),*] {
1111
builder.symbol(name, val);
1212
}
1313
}

compiler/rustc_expand/src/parse/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ fn span_of_self_arg_pat_idents_are_correct() {
193193
"impl z { fn a (self: Foo, &myarg: i32) {} }",
194194
];
195195

196-
for &src in &srcs {
196+
for src in srcs {
197197
let spans = get_spans_of_pat_idents(src);
198198
let (lo, hi) = (spans[0].lo(), spans[0].hi());
199199
assert!(

compiler/rustc_infer/src/infer/region_constraints/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
674674
self.combine_map(t).insert(vars, c);
675675
self.undo_log.push(AddCombination(t, vars));
676676
let new_r = tcx.mk_region(ReVar(c));
677-
for &old_r in &[a, b] {
677+
for old_r in [a, b] {
678678
match t {
679679
Glb => self.make_subregion(origin.clone(), new_r, old_r),
680680
Lub => self.make_subregion(origin.clone(), old_r, new_r),

compiler/rustc_passes/src/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
938938
if !remaining_lib_features.is_empty() {
939939
check_features(&mut remaining_lib_features, &local_defined_features);
940940

941-
for &cnum in &*tcx.crates() {
941+
for &cnum in tcx.crates() {
942942
if remaining_lib_features.is_empty() {
943943
break;
944944
}

compiler/rustc_serialize/tests/json.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ fn test_decode_str() {
437437
("\"\\uAB12\"", "\u{AB12}"),
438438
];
439439

440-
for &(i, o) in &s {
440+
for (i, o) in s {
441441
let v: string::String = json::decode(i).unwrap();
442442
assert_eq!(v, o);
443443
}

compiler/rustc_session/src/config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ fn default_configuration(sess: &Session) -> CrateConfig {
833833
if sess.target.has_elf_tls {
834834
ret.insert((sym::target_thread_local, None));
835835
}
836-
for &(i, align) in &[
836+
for (i, align) in [
837837
(8, layout.i8_align.abi),
838838
(16, layout.i16_align.abi),
839839
(32, layout.i32_align.abi),
@@ -1169,7 +1169,7 @@ pub fn get_cmd_lint_options(
11691169
let mut lint_opts_with_position = vec![];
11701170
let mut describe_lints = false;
11711171

1172-
for &level in &[lint::Allow, lint::Warn, lint::Deny, lint::Forbid] {
1172+
for level in [lint::Allow, lint::Warn, lint::Deny, lint::Forbid] {
11731173
for (passed_arg_pos, lint_name) in matches.opt_strs_pos(level.as_str()) {
11741174
let arg_pos = if let lint::Forbid = level {
11751175
// HACK: forbid is always specified last, so it can't be overridden.

compiler/rustc_target/src/abi/call/x86_64.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ where
185185
if let Ok(cls) = cls_or_mem {
186186
let mut needed_int = 0;
187187
let mut needed_sse = 0;
188-
for &c in &cls {
188+
for c in cls {
189189
match c {
190190
Some(Class::Int) => needed_int += 1,
191191
Some(Class::Sse) => needed_sse += 1,

compiler/rustc_target/src/abi/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ impl Integer {
590590
pub fn for_align<C: HasDataLayout>(cx: &C, wanted: Align) -> Option<Integer> {
591591
let dl = cx.data_layout();
592592

593-
for &candidate in &[I8, I16, I32, I64, I128] {
593+
for candidate in [I8, I16, I32, I64, I128] {
594594
if wanted == candidate.align(dl).abi && wanted.bytes() == candidate.size().bytes() {
595595
return Some(candidate);
596596
}
@@ -603,7 +603,7 @@ impl Integer {
603603
let dl = cx.data_layout();
604604

605605
// FIXME(eddyb) maybe include I128 in the future, when it works everywhere.
606-
for &candidate in &[I64, I32, I16] {
606+
for candidate in [I64, I32, I16] {
607607
if wanted >= candidate.align(dl).abi && wanted.bytes() >= candidate.size().bytes() {
608608
return candidate;
609609
}

compiler/rustc_typeck/src/check/callee.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
205205
opt_arg_exprs: Option<&'tcx [hir::Expr<'tcx>]>,
206206
) -> Option<(Option<Adjustment<'tcx>>, MethodCallee<'tcx>)> {
207207
// Try the options that are least restrictive on the caller first.
208-
for &(opt_trait_def_id, method_name, borrow) in &[
208+
for (opt_trait_def_id, method_name, borrow) in [
209209
(self.tcx.lang_items().fn_trait(), Ident::with_dummy_span(sym::call), true),
210210
(self.tcx.lang_items().fn_mut_trait(), Ident::with_dummy_span(sym::call_mut), true),
211211
(self.tcx.lang_items().fn_once_trait(), Ident::with_dummy_span(sym::call_once), false),

compiler/rustc_typeck/src/check/compare_method.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ fn compare_number_of_generics<'tcx>(
579579
let item_kind = assoc_item_kind_str(impl_);
580580

581581
let mut err_occurred = false;
582-
for &(kind, trait_count, impl_count) in &matchings {
582+
for (kind, trait_count, impl_count) in matchings {
583583
if impl_count != trait_count {
584584
err_occurred = true;
585585

compiler/rustc_typeck/src/check/fn_ctxt/checks.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
291291
// that are not closures, then we type-check the closures. This is so
292292
// that we have more information about the types of arguments when we
293293
// type-check the functions. This isn't really the right way to do this.
294-
for &check_closures in &[false, true] {
294+
for check_closures in [false, true] {
295295
debug!("check_closures={}", check_closures);
296296

297297
// More awful hacks: before we check argument types, try to do

compiler/rustc_typeck/src/check/method/probe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
668668
self.assemble_inherent_impl_for_primitive(lang_def_id);
669669
}
670670
ty::Slice(_) => {
671-
for &lang_def_id in &[
671+
for lang_def_id in [
672672
lang_items.slice_impl(),
673673
lang_items.slice_u8_impl(),
674674
lang_items.slice_alloc_impl(),

compiler/rustc_typeck/src/check/place_op.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
8282
expr, base_expr, adjusted_ty, index_ty
8383
);
8484

85-
for &unsize in &[false, true] {
85+
for unsize in [false, true] {
8686
let mut self_ty = adjusted_ty;
8787
if unsize {
8888
// We only unsize arrays here.

src/librustdoc/passes/collect_intra_doc_links.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ impl LinkCollector<'_, '_> {
13461346
let other_ns = if expected_ns == ValueNS { TypeNS } else { ValueNS };
13471347
// FIXME: really it should be `resolution_failure` that does this, not `resolve_with_disambiguator`
13481348
// See https://github.com/rust-lang/rust/pull/76955#discussion_r493953382 for a good approach
1349-
for &new_ns in &[other_ns, MacroNS] {
1349+
for new_ns in [other_ns, MacroNS] {
13501350
if let Some(res) =
13511351
self.check_full_res(new_ns, path_str, base_node, extra_fragment)
13521352
{
@@ -1444,7 +1444,7 @@ impl LinkCollector<'_, '_> {
14441444
Ok(res) => Some((res, extra_fragment.clone())),
14451445
Err(mut kind) => {
14461446
// `resolve_macro` only looks in the macro namespace. Try to give a better error if possible.
1447-
for &ns in &[TypeNS, ValueNS] {
1447+
for ns in [TypeNS, ValueNS] {
14481448
if let Some(res) =
14491449
self.check_full_res(ns, path_str, base_node, extra_fragment)
14501450
{
@@ -1558,7 +1558,7 @@ impl Disambiguator {
15581558
("()", DefKind::Fn),
15591559
("!", DefKind::Macro(MacroKind::Bang)),
15601560
];
1561-
for &(suffix, kind) in &suffixes {
1561+
for (suffix, kind) in suffixes {
15621562
if let Some(link) = link.strip_suffix(suffix) {
15631563
// Avoid turning `!` or `()` into an empty string
15641564
if !link.is_empty() {
@@ -1798,7 +1798,7 @@ fn resolution_failure(
17981798
break;
17991799
};
18001800
name = start;
1801-
for &ns in &[TypeNS, ValueNS, MacroNS] {
1801+
for ns in [TypeNS, ValueNS, MacroNS] {
18021802
if let Some(res) =
18031803
collector.check_full_res(ns, &start, module_id.into(), &None)
18041804
{

0 commit comments

Comments
 (0)