1
Fork 0

Use the now available implementation of IntoIterator for arrays

This commit is contained in:
LeSeulArtichaut 2021-06-14 23:40:09 +02:00
parent a216131c35
commit e3ca81fd5a
17 changed files with 34 additions and 34 deletions

View file

@ -1939,7 +1939,7 @@ fn add() {
(m_smallest_normalized, m_smallest_normalized, "-0x1p-125", Status::OK, Category::Normal), (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 status;
let result = unpack!(status=, x + y); let result = unpack!(status=, x + y);
assert_eq!(status, e_status); assert_eq!(status, e_status);
@ -2262,7 +2262,7 @@ fn subtract() {
(m_smallest_normalized, m_smallest_normalized, "0x0p+0", Status::OK, Category::Zero), (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 status;
let result = unpack!(status=, x - y); let result = unpack!(status=, x - y);
assert_eq!(status, e_status); assert_eq!(status, e_status);
@ -2538,7 +2538,7 @@ fn multiply() {
(m_smallest_normalized, m_smallest_normalized, "0x0p+0", underflow_status, Category::Zero), (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 status;
let result = unpack!(status=, x * y); let result = unpack!(status=, x * y);
assert_eq!(status, e_status); assert_eq!(status, e_status);
@ -2814,7 +2814,7 @@ fn divide() {
(m_smallest_normalized, m_smallest_normalized, "0x1p+0", Status::OK, Category::Normal), (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 status;
let result = unpack!(status=, x / y); let result = unpack!(status=, x / y);
assert_eq!(status, e_status); assert_eq!(status, e_status);

View file

@ -64,7 +64,7 @@ fn ppc_double_double_add_special() {
(0x7ff8000000000000, 0x3ff0000000000000, Category::NaN, Round::NearestTiesToEven), (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 mut a1 = DoubleDouble::from_bits(op1);
let a2 = DoubleDouble::from_bits(op2); 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 mut a1 = DoubleDouble::from_bits(op1);
let a2 = DoubleDouble::from_bits(op2); 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 mut a1 = DoubleDouble::from_bits(op1);
let a2 = DoubleDouble::from_bits(op2); let a2 = DoubleDouble::from_bits(op2);
a1 = a1.sub_r(a2, round).value; a1 = a1.sub_r(a2, round).value;
@ -204,7 +204,7 @@ fn ppc_double_double_multiply_special() {
(0, 0x3ff0000000000000, Category::Zero, Round::NearestTiesToEven), (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 mut a1 = DoubleDouble::from_bits(op1);
let a2 = DoubleDouble::from_bits(op2); 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 mut a1 = DoubleDouble::from_bits(op1);
let a2 = DoubleDouble::from_bits(op2); 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 mut a1 = DoubleDouble::from_bits(op1);
let a2 = DoubleDouble::from_bits(op2); let a2 = DoubleDouble::from_bits(op2);
a1 = a1.div_r(a2, round).value; 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 a1 = DoubleDouble::from_bits(op1);
let a2 = DoubleDouble::from_bits(op2); let a2 = DoubleDouble::from_bits(op2);
let result = a1.ieee_rem(a2).value; 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 a1 = DoubleDouble::from_bits(op1);
let a2 = DoubleDouble::from_bits(op2); let a2 = DoubleDouble::from_bits(op2);
let r = (a1 % a2).value; let r = (a1 % a2).value;
@ -426,7 +426,7 @@ fn ppc_double_double_compare() {
(0x7ff0000000000000, 0x7ff0000000000000, Some(Ordering::Equal)), (0x7ff0000000000000, 0x7ff0000000000000, Some(Ordering::Equal)),
]; ];
for &(op1, op2, expected) in &data { for (op1, op2, expected) in data {
let a1 = DoubleDouble::from_bits(op1); let a1 = DoubleDouble::from_bits(op1);
let a2 = DoubleDouble::from_bits(op2); let a2 = DoubleDouble::from_bits(op2);
assert_eq!(expected, a1.partial_cmp(&a2), "compare({:#x}, {:#x})", op1, 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), (0x7ff0000000000000, 0x7ff0000000000000, true),
]; ];
for &(op1, op2, expected) in &data { for (op1, op2, expected) in data {
let a1 = DoubleDouble::from_bits(op1); let a1 = DoubleDouble::from_bits(op1);
let a2 = DoubleDouble::from_bits(op2); let a2 = DoubleDouble::from_bits(op2);
assert_eq!(expected, a1.bitwise_eq(a2), "{:#x} = {:#x}", op1, op2); assert_eq!(expected, a1.bitwise_eq(a2), "{:#x} = {:#x}", op1, op2);

View file

@ -417,7 +417,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
fn allocate_use_tree_hir_id_counters(&mut self, tree: &UseTree) { fn allocate_use_tree_hir_id_counters(&mut self, tree: &UseTree) {
match tree.kind { match tree.kind {
UseTreeKind::Simple(_, id1, id2) => { UseTreeKind::Simple(_, id1, id2) => {
for &id in &[id1, id2] { for id in [id1, id2] {
self.lctx.allocate_hir_id_counter(id); self.lctx.allocate_hir_id_counter(id);
} }
} }

View file

@ -7,7 +7,7 @@ macro builtin_functions($register:ident; $(fn $name:ident($($arg_name:ident: $ar
#[cfg(feature = "jit")] #[cfg(feature = "jit")]
pub(crate) fn $register(builder: &mut cranelift_jit::JITBuilder) { 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); builder.symbol(name, val);
} }
} }

View file

@ -193,7 +193,7 @@ fn span_of_self_arg_pat_idents_are_correct() {
"impl z { fn a (self: Foo, &myarg: i32) {} }", "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 spans = get_spans_of_pat_idents(src);
let (lo, hi) = (spans[0].lo(), spans[0].hi()); let (lo, hi) = (spans[0].lo(), spans[0].hi());
assert!( assert!(

View file

@ -674,7 +674,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
self.combine_map(t).insert(vars, c); self.combine_map(t).insert(vars, c);
self.undo_log.push(AddCombination(t, vars)); self.undo_log.push(AddCombination(t, vars));
let new_r = tcx.mk_region(ReVar(c)); let new_r = tcx.mk_region(ReVar(c));
for &old_r in &[a, b] { for old_r in [a, b] {
match t { match t {
Glb => self.make_subregion(origin.clone(), new_r, old_r), Glb => self.make_subregion(origin.clone(), new_r, old_r),
Lub => self.make_subregion(origin.clone(), old_r, new_r), Lub => self.make_subregion(origin.clone(), old_r, new_r),

View file

@ -938,7 +938,7 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
if !remaining_lib_features.is_empty() { if !remaining_lib_features.is_empty() {
check_features(&mut remaining_lib_features, &local_defined_features); 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() { if remaining_lib_features.is_empty() {
break; break;
} }

View file

@ -437,7 +437,7 @@ fn test_decode_str() {
("\"\\uAB12\"", "\u{AB12}"), ("\"\\uAB12\"", "\u{AB12}"),
]; ];
for &(i, o) in &s { for (i, o) in s {
let v: string::String = json::decode(i).unwrap(); let v: string::String = json::decode(i).unwrap();
assert_eq!(v, o); assert_eq!(v, o);
} }

View file

@ -833,7 +833,7 @@ fn default_configuration(sess: &Session) -> CrateConfig {
if sess.target.has_elf_tls { if sess.target.has_elf_tls {
ret.insert((sym::target_thread_local, None)); ret.insert((sym::target_thread_local, None));
} }
for &(i, align) in &[ for (i, align) in [
(8, layout.i8_align.abi), (8, layout.i8_align.abi),
(16, layout.i16_align.abi), (16, layout.i16_align.abi),
(32, layout.i32_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 lint_opts_with_position = vec![];
let mut describe_lints = false; 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()) { for (passed_arg_pos, lint_name) in matches.opt_strs_pos(level.as_str()) {
let arg_pos = if let lint::Forbid = level { let arg_pos = if let lint::Forbid = level {
// HACK: forbid is always specified last, so it can't be overridden. // HACK: forbid is always specified last, so it can't be overridden.

View file

@ -185,7 +185,7 @@ where
if let Ok(cls) = cls_or_mem { if let Ok(cls) = cls_or_mem {
let mut needed_int = 0; let mut needed_int = 0;
let mut needed_sse = 0; let mut needed_sse = 0;
for &c in &cls { for c in cls {
match c { match c {
Some(Class::Int) => needed_int += 1, Some(Class::Int) => needed_int += 1,
Some(Class::Sse) => needed_sse += 1, Some(Class::Sse) => needed_sse += 1,

View file

@ -590,7 +590,7 @@ impl Integer {
pub fn for_align<C: HasDataLayout>(cx: &C, wanted: Align) -> Option<Integer> { pub fn for_align<C: HasDataLayout>(cx: &C, wanted: Align) -> Option<Integer> {
let dl = cx.data_layout(); 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() { if wanted == candidate.align(dl).abi && wanted.bytes() == candidate.size().bytes() {
return Some(candidate); return Some(candidate);
} }
@ -603,7 +603,7 @@ impl Integer {
let dl = cx.data_layout(); let dl = cx.data_layout();
// FIXME(eddyb) maybe include I128 in the future, when it works everywhere. // 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() { if wanted >= candidate.align(dl).abi && wanted.bytes() >= candidate.size().bytes() {
return candidate; return candidate;
} }

View file

@ -205,7 +205,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
opt_arg_exprs: Option<&'tcx [hir::Expr<'tcx>]>, opt_arg_exprs: Option<&'tcx [hir::Expr<'tcx>]>,
) -> Option<(Option<Adjustment<'tcx>>, MethodCallee<'tcx>)> { ) -> Option<(Option<Adjustment<'tcx>>, MethodCallee<'tcx>)> {
// Try the options that are least restrictive on the caller first. // 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_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_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), (self.tcx.lang_items().fn_once_trait(), Ident::with_dummy_span(sym::call_once), false),

View file

@ -579,7 +579,7 @@ fn compare_number_of_generics<'tcx>(
let item_kind = assoc_item_kind_str(impl_); let item_kind = assoc_item_kind_str(impl_);
let mut err_occurred = false; 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 { if impl_count != trait_count {
err_occurred = true; err_occurred = true;

View file

@ -291,7 +291,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// that are not closures, then we type-check the closures. This is so // 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 // 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. // 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); debug!("check_closures={}", check_closures);
// More awful hacks: before we check argument types, try to do // More awful hacks: before we check argument types, try to do

View file

@ -668,7 +668,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
self.assemble_inherent_impl_for_primitive(lang_def_id); self.assemble_inherent_impl_for_primitive(lang_def_id);
} }
ty::Slice(_) => { ty::Slice(_) => {
for &lang_def_id in &[ for lang_def_id in [
lang_items.slice_impl(), lang_items.slice_impl(),
lang_items.slice_u8_impl(), lang_items.slice_u8_impl(),
lang_items.slice_alloc_impl(), lang_items.slice_alloc_impl(),

View file

@ -82,7 +82,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
expr, base_expr, adjusted_ty, index_ty expr, base_expr, adjusted_ty, index_ty
); );
for &unsize in &[false, true] { for unsize in [false, true] {
let mut self_ty = adjusted_ty; let mut self_ty = adjusted_ty;
if unsize { if unsize {
// We only unsize arrays here. // We only unsize arrays here.

View file

@ -1346,7 +1346,7 @@ impl LinkCollector<'_, '_> {
let other_ns = if expected_ns == ValueNS { TypeNS } else { ValueNS }; let other_ns = if expected_ns == ValueNS { TypeNS } else { ValueNS };
// FIXME: really it should be `resolution_failure` that does this, not `resolve_with_disambiguator` // 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 // 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) = if let Some(res) =
self.check_full_res(new_ns, path_str, base_node, extra_fragment) self.check_full_res(new_ns, path_str, base_node, extra_fragment)
{ {
@ -1444,7 +1444,7 @@ impl LinkCollector<'_, '_> {
Ok(res) => Some((res, extra_fragment.clone())), Ok(res) => Some((res, extra_fragment.clone())),
Err(mut kind) => { Err(mut kind) => {
// `resolve_macro` only looks in the macro namespace. Try to give a better error if possible. // `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) = if let Some(res) =
self.check_full_res(ns, path_str, base_node, extra_fragment) self.check_full_res(ns, path_str, base_node, extra_fragment)
{ {
@ -1558,7 +1558,7 @@ impl Disambiguator {
("()", DefKind::Fn), ("()", DefKind::Fn),
("!", DefKind::Macro(MacroKind::Bang)), ("!", DefKind::Macro(MacroKind::Bang)),
]; ];
for &(suffix, kind) in &suffixes { for (suffix, kind) in suffixes {
if let Some(link) = link.strip_suffix(suffix) { if let Some(link) = link.strip_suffix(suffix) {
// Avoid turning `!` or `()` into an empty string // Avoid turning `!` or `()` into an empty string
if !link.is_empty() { if !link.is_empty() {
@ -1798,7 +1798,7 @@ fn resolution_failure(
break; break;
}; };
name = start; name = start;
for &ns in &[TypeNS, ValueNS, MacroNS] { for ns in [TypeNS, ValueNS, MacroNS] {
if let Some(res) = if let Some(res) =
collector.check_full_res(ns, &start, module_id.into(), &None) collector.check_full_res(ns, &start, module_id.into(), &None)
{ {