diff --git a/compiler/rustc_apfloat/tests/ieee.rs b/compiler/rustc_apfloat/tests/ieee.rs index 63d925cce9ad7f6e22e55388ef772b127c57bba6..22641064315926fb8d780c955420fe0ef772dbc4 100644 --- a/compiler/rustc_apfloat/tests/ieee.rs +++ b/compiler/rustc_apfloat/tests/ieee.rs @@ -1939,7 +1939,7 @@ fn add() { (m_smallest_normalized, m_smallest_normalized, "-0x1p-125", Status::OK, Category::Normal), ]; - for &(x, y, e_result, e_status, e_category) in &special_cases[..] { + for (x, y, e_result, e_status, e_category) in special_cases { let status; let result = unpack!(status=, x + y); assert_eq!(status, e_status); @@ -2262,7 +2262,7 @@ fn subtract() { (m_smallest_normalized, m_smallest_normalized, "0x0p+0", Status::OK, Category::Zero), ]; - for &(x, y, e_result, e_status, e_category) in &special_cases[..] { + for (x, y, e_result, e_status, e_category) in special_cases { let status; let result = unpack!(status=, x - y); assert_eq!(status, e_status); @@ -2538,7 +2538,7 @@ fn multiply() { (m_smallest_normalized, m_smallest_normalized, "0x0p+0", underflow_status, Category::Zero), ]; - for &(x, y, e_result, e_status, e_category) in &special_cases[..] { + for (x, y, e_result, e_status, e_category) in special_cases { let status; let result = unpack!(status=, x * y); assert_eq!(status, e_status); @@ -2814,7 +2814,7 @@ fn divide() { (m_smallest_normalized, m_smallest_normalized, "0x1p+0", Status::OK, Category::Normal), ]; - for &(x, y, e_result, e_status, e_category) in &special_cases[..] { + for (x, y, e_result, e_status, e_category) in special_cases { let status; let result = unpack!(status=, x / y); assert_eq!(status, e_status); diff --git a/compiler/rustc_apfloat/tests/ppc.rs b/compiler/rustc_apfloat/tests/ppc.rs index 5a8de71cb3490bc1fd73e6c9b912219d9ebcbdb1..c769d26543786a5ea39a637b4c512536b7c9f837 100644 --- a/compiler/rustc_apfloat/tests/ppc.rs +++ b/compiler/rustc_apfloat/tests/ppc.rs @@ -64,7 +64,7 @@ fn ppc_double_double_add_special() { (0x7ff8000000000000, 0x3ff0000000000000, Category::NaN, Round::NearestTiesToEven), ]; - for &(op1, op2, expected, round) in &data { + for (op1, op2, expected, round) in data { { let mut a1 = DoubleDouble::from_bits(op1); let a2 = DoubleDouble::from_bits(op2); @@ -135,7 +135,7 @@ fn ppc_double_double_add() { ), ]; - for &(op1, op2, expected, round) in &data { + for (op1, op2, expected, round) in data { { let mut a1 = DoubleDouble::from_bits(op1); let a2 = DoubleDouble::from_bits(op2); @@ -172,7 +172,7 @@ fn ppc_double_double_subtract() { ), ]; - for &(op1, op2, expected, round) in &data { + for (op1, op2, expected, round) in data { let mut a1 = DoubleDouble::from_bits(op1); let a2 = DoubleDouble::from_bits(op2); a1 = a1.sub_r(a2, round).value; @@ -204,7 +204,7 @@ fn ppc_double_double_multiply_special() { (0, 0x3ff0000000000000, Category::Zero, Round::NearestTiesToEven), ]; - for &(op1, op2, expected, round) in &data { + for (op1, op2, expected, round) in data { { let mut a1 = DoubleDouble::from_bits(op1); let a2 = DoubleDouble::from_bits(op2); @@ -290,7 +290,7 @@ fn ppc_double_double_multiply() { ), ]; - for &(op1, op2, expected, round) in &data { + for (op1, op2, expected, round) in data { { let mut a1 = DoubleDouble::from_bits(op1); let a2 = DoubleDouble::from_bits(op2); @@ -322,7 +322,7 @@ fn ppc_double_double_divide() { ), ]; - for &(op1, op2, expected, round) in &data { + for (op1, op2, expected, round) in data { let mut a1 = DoubleDouble::from_bits(op1); let a2 = DoubleDouble::from_bits(op2); a1 = a1.div_r(a2, round).value; @@ -348,7 +348,7 @@ fn ppc_double_double_remainder() { ), ]; - for &(op1, op2, expected) in &data { + for (op1, op2, expected) in data { let a1 = DoubleDouble::from_bits(op1); let a2 = DoubleDouble::from_bits(op2); let result = a1.ieee_rem(a2).value; @@ -376,7 +376,7 @@ fn ppc_double_double_mod() { ), ]; - for &(op1, op2, expected) in &data { + for (op1, op2, expected) in data { let a1 = DoubleDouble::from_bits(op1); let a2 = DoubleDouble::from_bits(op2); let r = (a1 % a2).value; @@ -426,7 +426,7 @@ fn ppc_double_double_compare() { (0x7ff0000000000000, 0x7ff0000000000000, Some(Ordering::Equal)), ]; - for &(op1, op2, expected) in &data { + for (op1, op2, expected) in data { let a1 = DoubleDouble::from_bits(op1); let a2 = DoubleDouble::from_bits(op2); assert_eq!(expected, a1.partial_cmp(&a2), "compare({:#x}, {:#x})", op1, op2,); @@ -448,7 +448,7 @@ fn ppc_double_double_bitwise_eq() { (0x7ff0000000000000, 0x7ff0000000000000, true), ]; - for &(op1, op2, expected) in &data { + for (op1, op2, expected) in data { let a1 = DoubleDouble::from_bits(op1); let a2 = DoubleDouble::from_bits(op2); assert_eq!(expected, a1.bitwise_eq(a2), "{:#x} = {:#x}", op1, op2); diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 0ff1efd8165eae60cc5d294a41e4f95dee9a82ec..dbab7e154845034ad69c512eb47c2786f1ff2892 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -417,7 +417,7 @@ impl MiscCollector<'_, '_, '_> { fn allocate_use_tree_hir_id_counters(&mut self, tree: &UseTree) { match tree.kind { UseTreeKind::Simple(_, id1, id2) => { - for &id in &[id1, id2] { + for id in [id1, id2] { self.lctx.allocate_hir_id_counter(id); } } diff --git a/compiler/rustc_codegen_cranelift/src/compiler_builtins.rs b/compiler/rustc_codegen_cranelift/src/compiler_builtins.rs index 177f850afb398ef6c90e8d1e161920ec56d846e0..100c3b43160bbbb3384390e4741f537db05c0e61 100644 --- a/compiler/rustc_codegen_cranelift/src/compiler_builtins.rs +++ b/compiler/rustc_codegen_cranelift/src/compiler_builtins.rs @@ -7,7 +7,7 @@ #[cfg(feature = "jit")] pub(crate) fn $register(builder: &mut cranelift_jit::JITBuilder) { - for &(name, val) in &[$((stringify!($name), $name as *const u8)),*] { + for (name, val) in [$((stringify!($name), $name as *const u8)),*] { builder.symbol(name, val); } } diff --git a/compiler/rustc_expand/src/parse/tests.rs b/compiler/rustc_expand/src/parse/tests.rs index 56f25ffdb0187cf7bc4ea2a8f8c3ea7c17d25898..288efe22982fa13cbfba4e7569549357a249f9c7 100644 --- a/compiler/rustc_expand/src/parse/tests.rs +++ b/compiler/rustc_expand/src/parse/tests.rs @@ -193,7 +193,7 @@ fn span_of_self_arg_pat_idents_are_correct() { "impl z { fn a (self: Foo, &myarg: i32) {} }", ]; - for &src in &srcs { + for src in srcs { let spans = get_spans_of_pat_idents(src); let (lo, hi) = (spans[0].lo(), spans[0].hi()); assert!( diff --git a/compiler/rustc_infer/src/infer/region_constraints/mod.rs b/compiler/rustc_infer/src/infer/region_constraints/mod.rs index 4935913016262bbabe29e320bba3c5072e77747b..7f4c33c5792cbb4d58438b49ca5abd96769711e5 100644 --- a/compiler/rustc_infer/src/infer/region_constraints/mod.rs +++ b/compiler/rustc_infer/src/infer/region_constraints/mod.rs @@ -674,7 +674,7 @@ fn combine_vars( self.combine_map(t).insert(vars, c); self.undo_log.push(AddCombination(t, vars)); let new_r = tcx.mk_region(ReVar(c)); - for &old_r in &[a, b] { + for old_r in [a, b] { match t { Glb => self.make_subregion(origin.clone(), new_r, old_r), Lub => self.make_subregion(origin.clone(), old_r, new_r), diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index f41e0e0370680f4b3cafb8eb8c0c5ef2acadd2ee..ca9b83876b4443f4c1ccd05a90a0d56adf9fcdf7 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -938,7 +938,7 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) { if !remaining_lib_features.is_empty() { check_features(&mut remaining_lib_features, &local_defined_features); - for &cnum in &*tcx.crates() { + for &cnum in tcx.crates() { if remaining_lib_features.is_empty() { break; } diff --git a/compiler/rustc_serialize/tests/json.rs b/compiler/rustc_serialize/tests/json.rs index e3a823127d93ea60621623ec8cb51e593ed4b192..a759fa1bf1a7579f4eb11f1a3eccc44bc3c7b5a3 100644 --- a/compiler/rustc_serialize/tests/json.rs +++ b/compiler/rustc_serialize/tests/json.rs @@ -437,7 +437,7 @@ fn test_decode_str() { ("\"\\uAB12\"", "\u{AB12}"), ]; - for &(i, o) in &s { + for (i, o) in s { let v: string::String = json::decode(i).unwrap(); assert_eq!(v, o); } diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 2b547f8be92286559e4d14dc2513d1b9cb3ac2df..1ed336f6ed381f089951ee8793cb74356dc67faf 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -833,7 +833,7 @@ fn default_configuration(sess: &Session) -> CrateConfig { if sess.target.has_elf_tls { ret.insert((sym::target_thread_local, None)); } - for &(i, align) in &[ + for (i, align) in [ (8, layout.i8_align.abi), (16, layout.i16_align.abi), (32, layout.i32_align.abi), @@ -1169,7 +1169,7 @@ pub fn get_cmd_lint_options( let mut lint_opts_with_position = vec![]; let mut describe_lints = false; - for &level in &[lint::Allow, lint::Warn, lint::Deny, lint::Forbid] { + for level in [lint::Allow, lint::Warn, lint::Deny, lint::Forbid] { for (passed_arg_pos, lint_name) in matches.opt_strs_pos(level.as_str()) { let arg_pos = if let lint::Forbid = level { // HACK: forbid is always specified last, so it can't be overridden. diff --git a/compiler/rustc_target/src/abi/call/x86_64.rs b/compiler/rustc_target/src/abi/call/x86_64.rs index 5f154dc1bc9f83ee78f4809cc3692363c21c5043..a55658b7a3ec6caf1b2c30a5785a1fe04b146ea9 100644 --- a/compiler/rustc_target/src/abi/call/x86_64.rs +++ b/compiler/rustc_target/src/abi/call/x86_64.rs @@ -185,7 +185,7 @@ pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>) if let Ok(cls) = cls_or_mem { let mut needed_int = 0; let mut needed_sse = 0; - for &c in &cls { + for c in cls { match c { Some(Class::Int) => needed_int += 1, Some(Class::Sse) => needed_sse += 1, diff --git a/compiler/rustc_target/src/abi/mod.rs b/compiler/rustc_target/src/abi/mod.rs index 8e71ded3d1de6a7dfbbc006d4d7e8525df3d4866..e3a721fc7369e34ac821e700967d38b7162098f3 100644 --- a/compiler/rustc_target/src/abi/mod.rs +++ b/compiler/rustc_target/src/abi/mod.rs @@ -590,7 +590,7 @@ pub fn fit_unsigned(x: u128) -> Integer { pub fn for_align(cx: &C, wanted: Align) -> Option { let dl = cx.data_layout(); - for &candidate in &[I8, I16, I32, I64, I128] { + for candidate in [I8, I16, I32, I64, I128] { if wanted == candidate.align(dl).abi && wanted.bytes() == candidate.size().bytes() { return Some(candidate); } @@ -603,7 +603,7 @@ pub fn approximate_align(cx: &C, wanted: Align) -> Integer { let dl = cx.data_layout(); // FIXME(eddyb) maybe include I128 in the future, when it works everywhere. - for &candidate in &[I64, I32, I16] { + for candidate in [I64, I32, I16] { if wanted >= candidate.align(dl).abi && wanted.bytes() >= candidate.size().bytes() { return candidate; } diff --git a/compiler/rustc_typeck/src/check/callee.rs b/compiler/rustc_typeck/src/check/callee.rs index cb8f336721ad6a4d06c1c175e493e4575e803b32..ed62899c04ebb0a47b3b6caf091f0841b7c9e3e1 100644 --- a/compiler/rustc_typeck/src/check/callee.rs +++ b/compiler/rustc_typeck/src/check/callee.rs @@ -205,7 +205,7 @@ fn try_overloaded_call_traits( opt_arg_exprs: Option<&'tcx [hir::Expr<'tcx>]>, ) -> Option<(Option>, MethodCallee<'tcx>)> { // Try the options that are least restrictive on the caller first. - for &(opt_trait_def_id, method_name, borrow) in &[ + for (opt_trait_def_id, method_name, borrow) in [ (self.tcx.lang_items().fn_trait(), Ident::with_dummy_span(sym::call), true), (self.tcx.lang_items().fn_mut_trait(), Ident::with_dummy_span(sym::call_mut), true), (self.tcx.lang_items().fn_once_trait(), Ident::with_dummy_span(sym::call_once), false), diff --git a/compiler/rustc_typeck/src/check/compare_method.rs b/compiler/rustc_typeck/src/check/compare_method.rs index 60ca562f9920068d44fc8e5635a65b7ed0a4652b..95a1bfbbb01cf89f87929d7bd72ddca6cc324950 100644 --- a/compiler/rustc_typeck/src/check/compare_method.rs +++ b/compiler/rustc_typeck/src/check/compare_method.rs @@ -579,7 +579,7 @@ fn compare_number_of_generics<'tcx>( let item_kind = assoc_item_kind_str(impl_); let mut err_occurred = false; - for &(kind, trait_count, impl_count) in &matchings { + for (kind, trait_count, impl_count) in matchings { if impl_count != trait_count { err_occurred = true; diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index 49aea19c8d099970e72e2ec57fb5ddbc58478f0c..d6989b866c1d29aa55329625596777724dcc337e 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -291,7 +291,7 @@ pub(in super::super) fn check_argument_types( // that are not closures, then we type-check the closures. This is so // that we have more information about the types of arguments when we // type-check the functions. This isn't really the right way to do this. - for &check_closures in &[false, true] { + for check_closures in [false, true] { debug!("check_closures={}", check_closures); // More awful hacks: before we check argument types, try to do diff --git a/compiler/rustc_typeck/src/check/method/probe.rs b/compiler/rustc_typeck/src/check/method/probe.rs index 440e0f4e1a2acfbbaf27c96a01fe94cf766a7db6..9037ffe49a9a26c2b3335926e2125d05e8968c9a 100644 --- a/compiler/rustc_typeck/src/check/method/probe.rs +++ b/compiler/rustc_typeck/src/check/method/probe.rs @@ -668,7 +668,7 @@ fn assemble_probe(&mut self, self_ty: &Canonical<'tcx, QueryResponse<'tcx, Ty<'t self.assemble_inherent_impl_for_primitive(lang_def_id); } ty::Slice(_) => { - for &lang_def_id in &[ + for lang_def_id in [ lang_items.slice_impl(), lang_items.slice_u8_impl(), lang_items.slice_alloc_impl(), diff --git a/compiler/rustc_typeck/src/check/place_op.rs b/compiler/rustc_typeck/src/check/place_op.rs index 652b82f1063c9c48c60d71f2f2980e47a2c750ca..055072d3a1d9d4a9cf020d6d7f999592b7029091 100644 --- a/compiler/rustc_typeck/src/check/place_op.rs +++ b/compiler/rustc_typeck/src/check/place_op.rs @@ -82,7 +82,7 @@ fn try_index_step( expr, base_expr, adjusted_ty, index_ty ); - for &unsize in &[false, true] { + for unsize in [false, true] { let mut self_ty = adjusted_ty; if unsize { // We only unsize arrays here. diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 247a020f2a20d28f3ccba04026e310384e5a774e..9db83c903abf07a374307567239bd3d7bb81485f 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -1346,7 +1346,7 @@ fn resolve_with_disambiguator( let other_ns = if expected_ns == ValueNS { TypeNS } else { ValueNS }; // FIXME: really it should be `resolution_failure` that does this, not `resolve_with_disambiguator` // See https://github.com/rust-lang/rust/pull/76955#discussion_r493953382 for a good approach - for &new_ns in &[other_ns, MacroNS] { + for new_ns in [other_ns, MacroNS] { if let Some(res) = self.check_full_res(new_ns, path_str, base_node, extra_fragment) { @@ -1444,7 +1444,7 @@ fn resolve_with_disambiguator( Ok(res) => Some((res, extra_fragment.clone())), Err(mut kind) => { // `resolve_macro` only looks in the macro namespace. Try to give a better error if possible. - for &ns in &[TypeNS, ValueNS] { + for ns in [TypeNS, ValueNS] { if let Some(res) = self.check_full_res(ns, path_str, base_node, extra_fragment) { @@ -1558,7 +1558,7 @@ fn from_str(link: &str) -> Result, (String, Range)> ("()", DefKind::Fn), ("!", DefKind::Macro(MacroKind::Bang)), ]; - for &(suffix, kind) in &suffixes { + for (suffix, kind) in suffixes { if let Some(link) = link.strip_suffix(suffix) { // Avoid turning `!` or `()` into an empty string if !link.is_empty() { @@ -1798,7 +1798,7 @@ fn split(path: &str) -> Option<(&str, &str)> { break; }; name = start; - for &ns in &[TypeNS, ValueNS, MacroNS] { + for ns in [TypeNS, ValueNS, MacroNS] { if let Some(res) = collector.check_full_res(ns, &start, module_id.into(), &None) {