Skip to content

Commit 9b0edb7

Browse files
committed
Auto merge of rust-lang#83580 - Dylan-DPC:rollup-1zod4p7, r=Dylan-DPC
Rollup of 8 pull requests Successful merges: - rust-lang#81351 (combine: stop eagerly evaluating consts) - rust-lang#82525 (make unaligned_references future-incompat lint warn-by-default) - rust-lang#82626 (update array missing `IntoIterator` msg) - rust-lang#82917 (Add function core::iter::zip) - rust-lang#82993 (rustdoc: Use diagnostics for error when including sources) - rust-lang#83522 (Improve fs error open_from unix) - rust-lang#83548 (Always preserve `None`-delimited groups in a captured `TokenStream`) - rust-lang#83555 (Add #[inline] to io::Error methods) Failed merges: - rust-lang#83130 (escape_ascii take 2) r? `@ghost` `@rustbot` modify labels: rollup
2 parents afaf33d + 7d6af67 commit 9b0edb7

File tree

165 files changed

+884
-815
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+884
-815
lines changed

compiler/rustc_apfloat/src/ieee.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2273,6 +2273,7 @@ impl Loss {
22732273
mod sig {
22742274
use super::{limbs_for_bits, ExpInt, Limb, Loss, LIMB_BITS};
22752275
use core::cmp::Ordering;
2276+
use core::iter;
22762277
use core::mem;
22772278

22782279
pub(super) fn is_all_zeros(limbs: &[Limb]) -> bool {
@@ -2483,7 +2484,7 @@ mod sig {
24832484
pub(super) fn add(a: &mut [Limb], b: &[Limb], mut c: Limb) -> Limb {
24842485
assert!(c <= 1);
24852486

2486-
for (a, &b) in a.iter_mut().zip(b) {
2487+
for (a, &b) in iter::zip(a, b) {
24872488
let (r, overflow) = a.overflowing_add(b);
24882489
let (r, overflow2) = r.overflowing_add(c);
24892490
*a = r;
@@ -2497,7 +2498,7 @@ mod sig {
24972498
pub(super) fn sub(a: &mut [Limb], b: &[Limb], mut c: Limb) -> Limb {
24982499
assert!(c <= 1);
24992500

2500-
for (a, &b) in a.iter_mut().zip(b) {
2501+
for (a, &b) in iter::zip(a, b) {
25012502
let (r, overflow) = a.overflowing_sub(b);
25022503
let (r, overflow2) = r.overflowing_sub(c);
25032504
*a = r;

compiler/rustc_apfloat/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
3434
#![no_std]
3535
#![forbid(unsafe_code)]
36+
#![feature(iter_zip)]
3637
#![feature(nll)]
3738
#![cfg_attr(bootstrap, feature(or_patterns))]
3839

compiler/rustc_ast/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#![feature(const_fn_transmute)]
1515
#![feature(const_panic)]
1616
#![feature(crate_visibility_modifier)]
17+
#![feature(iter_zip)]
1718
#![feature(label_break_value)]
1819
#![feature(nll)]
1920
#![cfg_attr(bootstrap, feature(or_patterns))]

compiler/rustc_ast/src/tokenstream.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ impl TokenStream {
341341
pub fn eq_unspanned(&self, other: &TokenStream) -> bool {
342342
let mut t1 = self.trees();
343343
let mut t2 = other.trees();
344-
for (t1, t2) in t1.by_ref().zip(t2.by_ref()) {
344+
for (t1, t2) in iter::zip(&mut t1, &mut t2) {
345345
if !t1.eq_unspanned(&t2) {
346346
return false;
347347
}

compiler/rustc_ast_lowering/src/item.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use rustc_target::spec::abi;
1818
use smallvec::{smallvec, SmallVec};
1919
use tracing::debug;
2020

21+
use std::iter;
2122
use std::mem;
2223

2324
pub(super) struct ItemLowerer<'a, 'lowering, 'hir> {
@@ -206,7 +207,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
206207
UseTreeKind::Glob => {}
207208
UseTreeKind::Simple(_, id1, id2) => {
208209
for (_, &id) in
209-
self.expect_full_res_from_use(base_id).skip(1).zip([id1, id2].iter())
210+
iter::zip(self.expect_full_res_from_use(base_id).skip(1), &[id1, id2])
210211
{
211212
vec.push(id);
212213
}
@@ -537,7 +538,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
537538
// won't be dealing with macros in the rest of the compiler.
538539
// Essentially a single `use` which imports two names is desugared into
539540
// two imports.
540-
for (res, &new_node_id) in resolutions.zip([id1, id2].iter()) {
541+
for (res, &new_node_id) in iter::zip(resolutions, &[id1, id2]) {
541542
let ident = *ident;
542543
let mut path = path.clone();
543544
for seg in &mut path.segments {

compiler/rustc_ast_lowering/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#![feature(crate_visibility_modifier)]
3434
#![cfg_attr(bootstrap, feature(or_patterns))]
3535
#![feature(box_patterns)]
36+
#![feature(iter_zip)]
3637
#![recursion_limit = "256"]
3738

3839
use rustc_ast::node_id::NodeMap;

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ impl<'a> MethodDef<'a> {
10341034
// make a series of nested matches, to destructure the
10351035
// structs. This is actually right-to-left, but it shouldn't
10361036
// matter.
1037-
for (arg_expr, pat) in self_args.iter().zip(patterns) {
1037+
for (arg_expr, pat) in iter::zip(self_args, patterns) {
10381038
body = cx.expr_match(
10391039
trait_.span,
10401040
arg_expr.clone(),
@@ -1351,7 +1351,7 @@ impl<'a> MethodDef<'a> {
13511351
let mut discriminant_test = cx.expr_bool(sp, true);
13521352

13531353
let mut first_ident = None;
1354-
for (&ident, self_arg) in vi_idents.iter().zip(&self_args) {
1354+
for (&ident, self_arg) in iter::zip(&vi_idents, &self_args) {
13551355
let self_addr = cx.expr_addr_of(sp, self_arg.clone());
13561356
let variant_value =
13571357
deriving::call_intrinsic(cx, sp, sym::discriminant_value, vec![self_addr]);
@@ -1571,9 +1571,7 @@ impl<'a> TraitDef<'a> {
15711571
let subpats = self.create_subpatterns(cx, paths, mutbl, use_temporaries);
15721572
let pattern = match *struct_def {
15731573
VariantData::Struct(..) => {
1574-
let field_pats = subpats
1575-
.into_iter()
1576-
.zip(&ident_exprs)
1574+
let field_pats = iter::zip(subpats, &ident_exprs)
15771575
.map(|(pat, &(sp, ident, ..))| {
15781576
if ident.is_none() {
15791577
cx.span_bug(sp, "a braced struct with unnamed fields in `derive`");

compiler/rustc_builtin_macros/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#![feature(bool_to_option)]
88
#![feature(crate_visibility_modifier)]
99
#![feature(decl_macro)]
10+
#![feature(iter_zip)]
1011
#![feature(nll)]
1112
#![cfg_attr(bootstrap, feature(or_patterns))]
1213
#![feature(proc_macro_internals)]

compiler/rustc_codegen_llvm/src/back/lto.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use tracing::{debug, info};
2424
use std::ffi::{CStr, CString};
2525
use std::fs::File;
2626
use std::io;
27+
use std::iter;
2728
use std::path::Path;
2829
use std::ptr;
2930
use std::slice;
@@ -916,9 +917,7 @@ impl ThinLTOKeysMap {
916917
modules: &[llvm::ThinLTOModule],
917918
names: &[CString],
918919
) -> Self {
919-
let keys = modules
920-
.iter()
921-
.zip(names.iter())
920+
let keys = iter::zip(modules, names)
922921
.map(|(module, name)| {
923922
let key = build_string(|rust_str| unsafe {
924923
llvm::LLVMRustComputeLTOCacheKey(rust_str, module.identifier, data.0);

compiler/rustc_codegen_llvm/src/builder.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use rustc_target::abi::{self, Align, Size};
2121
use rustc_target::spec::{HasTargetSpec, Target};
2222
use std::borrow::Cow;
2323
use std::ffi::CStr;
24+
use std::iter;
2425
use std::ops::{Deref, Range};
2526
use std::ptr;
2627
use tracing::debug;
@@ -1352,18 +1353,14 @@ impl Builder<'a, 'll, 'tcx> {
13521353

13531354
let param_tys = self.cx.func_params_types(fn_ty);
13541355

1355-
let all_args_match = param_tys
1356-
.iter()
1357-
.zip(args.iter().map(|&v| self.val_ty(v)))
1356+
let all_args_match = iter::zip(&param_tys, args.iter().map(|&v| self.val_ty(v)))
13581357
.all(|(expected_ty, actual_ty)| *expected_ty == actual_ty);
13591358

13601359
if all_args_match {
13611360
return Cow::Borrowed(args);
13621361
}
13631362

1364-
let casted_args: Vec<_> = param_tys
1365-
.into_iter()
1366-
.zip(args.iter())
1363+
let casted_args: Vec<_> = iter::zip(param_tys, args)
13671364
.enumerate()
13681365
.map(|(i, (expected_ty, &actual_val))| {
13691366
let actual_ty = self.val_ty(actual_val);

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1962,9 +1962,7 @@ fn prepare_enum_metadata(
19621962

19631963
let discriminant_type_metadata = |discr: Primitive| {
19641964
let enumerators_metadata: Vec<_> = match enum_type.kind() {
1965-
ty::Adt(def, _) => def
1966-
.discriminants(tcx)
1967-
.zip(&def.variants)
1965+
ty::Adt(def, _) => iter::zip(def.discriminants(tcx), &def.variants)
19681966
.map(|((_, discr), v)| {
19691967
let name = v.ident.as_str();
19701968
let is_unsigned = match discr.ty.kind() {
@@ -2336,9 +2334,7 @@ fn compute_type_parameters(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>) -> &'ll DIAr
23362334
if substs.types().next().is_some() {
23372335
let generics = cx.tcx.generics_of(def.did);
23382336
let names = get_parameter_names(cx, generics);
2339-
let template_params: Vec<_> = substs
2340-
.iter()
2341-
.zip(names)
2337+
let template_params: Vec<_> = iter::zip(substs, names)
23422338
.filter_map(|(kind, name)| {
23432339
if let GenericArgKind::Type(ty) = kind.unpack() {
23442340
let actual_type =

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ use rustc_target::abi::{LayoutOf, Primitive, Size};
3737
use libc::c_uint;
3838
use smallvec::SmallVec;
3939
use std::cell::RefCell;
40+
use std::iter;
4041
use tracing::debug;
4142

4243
mod create_scope_map;
@@ -448,9 +449,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
448449
// Again, only create type information if full debuginfo is enabled
449450
let template_params: Vec<_> = if cx.sess().opts.debuginfo == DebugInfo::Full {
450451
let names = get_parameter_names(cx, generics);
451-
substs
452-
.iter()
453-
.zip(names)
452+
iter::zip(substs, names)
454453
.filter_map(|(kind, name)| {
455454
if let GenericArgKind::Type(ty) = kind.unpack() {
456455
let actual_type =

compiler/rustc_codegen_llvm/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#![feature(extended_key_value_attributes)]
1212
#![feature(extern_types)]
1313
#![feature(in_band_lifetimes)]
14+
#![feature(iter_zip)]
1415
#![feature(nll)]
1516
#![cfg_attr(bootstrap, feature(or_patterns))]
1617
#![recursion_limit = "256"]

compiler/rustc_codegen_ssa/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#![feature(nll)]
99
#![cfg_attr(bootstrap, feature(or_patterns))]
1010
#![feature(associated_type_bounds)]
11+
#![feature(iter_zip)]
1112
#![recursion_limit = "256"]
1213
#![feature(box_syntax)]
1314

compiler/rustc_codegen_ssa/src/mir/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,7 @@ fn create_funclets<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
282282
IndexVec<mir::BasicBlock, Option<Bx::BasicBlock>>,
283283
IndexVec<mir::BasicBlock, Option<Bx::Funclet>>,
284284
) {
285-
block_bxs
286-
.iter_enumerated()
287-
.zip(cleanup_kinds)
285+
iter::zip(block_bxs.iter_enumerated(), cleanup_kinds)
288286
.map(|((bb, &llbb), cleanup_kind)| {
289287
match *cleanup_kind {
290288
CleanupKind::Funclet if base::wants_msvc_seh(bx.sess()) => {}

compiler/rustc_errors/src/emitter.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -2214,9 +2214,7 @@ pub fn is_case_difference(sm: &SourceMap, suggested: &str, sp: Span) -> bool {
22142214
};
22152215
let ascii_confusables = &['c', 'f', 'i', 'k', 'o', 's', 'u', 'v', 'w', 'x', 'y', 'z'];
22162216
// All the chars that differ in capitalization are confusable (above):
2217-
let confusable = found
2218-
.chars()
2219-
.zip(suggested.chars())
2217+
let confusable = iter::zip(found.chars(), suggested.chars())
22202218
.filter(|(f, s)| f != s)
22212219
.all(|(f, s)| (ascii_confusables.contains(&f) || ascii_confusables.contains(&s)));
22222220
confusable && found.to_lowercase() == suggested.to_lowercase()

compiler/rustc_errors/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#![feature(crate_visibility_modifier)]
77
#![feature(backtrace)]
88
#![feature(extended_key_value_attributes)]
9+
#![feature(iter_zip)]
910
#![feature(nll)]
1011

1112
#[macro_use]

compiler/rustc_errors/src/styled_buffer.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Code for creating styled buffers
22

33
use crate::snippet::{Style, StyledString};
4+
use std::iter;
45

56
#[derive(Debug)]
67
pub struct StyledBuffer {
@@ -20,11 +21,11 @@ impl StyledBuffer {
2021
let mut output: Vec<Vec<StyledString>> = vec![];
2122
let mut styled_vec: Vec<StyledString> = vec![];
2223

23-
for (row, row_style) in self.text.iter().zip(&self.styles) {
24+
for (row, row_style) in iter::zip(&self.text, &self.styles) {
2425
let mut current_style = Style::NoStyle;
2526
let mut current_text = String::new();
2627

27-
for (&c, &s) in row.iter().zip(row_style) {
28+
for (&c, &s) in iter::zip(row, row_style) {
2829
if s != current_style {
2930
if !current_text.is_empty() {
3031
styled_vec.push(StyledString { text: current_text, style: current_style });

compiler/rustc_expand/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#![feature(crate_visibility_modifier)]
33
#![feature(decl_macro)]
44
#![feature(destructuring_assignment)]
5+
#![feature(iter_zip)]
56
#![cfg_attr(bootstrap, feature(or_patterns))]
67
#![feature(proc_macro_diagnostic)]
78
#![feature(proc_macro_internals)]

compiler/rustc_expand/src/mbe/macro_check.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ use rustc_span::{symbol::MacroRulesNormalizedIdent, MultiSpan, Span};
116116

117117
use smallvec::SmallVec;
118118

119+
use std::iter;
120+
119121
/// Stack represented as linked list.
120122
///
121123
/// Those are used for environments because they grow incrementally and are not mutable.
@@ -204,7 +206,7 @@ pub(super) fn check_meta_variables(
204206
sess.span_diagnostic.span_bug(span, "length mismatch between LHSes and RHSes")
205207
}
206208
let mut valid = true;
207-
for (lhs, rhs) in lhses.iter().zip(rhses.iter()) {
209+
for (lhs, rhs) in iter::zip(lhses, rhses) {
208210
let mut binders = Binders::default();
209211
check_binders(sess, node_id, lhs, &Stack::Empty, &mut binders, &Stack::Empty, &mut valid);
210212
check_occurrences(sess, node_id, rhs, &Stack::Empty, &binders, &Stack::Empty, &mut valid);

compiler/rustc_index/src/bit_set.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ where
356356
{
357357
assert_eq!(out_vec.len(), in_vec.len());
358358
let mut changed = false;
359-
for (out_elem, in_elem) in out_vec.iter_mut().zip(in_vec.iter()) {
359+
for (out_elem, in_elem) in iter::zip(out_vec, in_vec) {
360360
let old_val = *out_elem;
361361
let new_val = op(old_val, *in_elem);
362362
*out_elem = new_val;
@@ -842,7 +842,7 @@ impl<R: Idx, C: Idx> BitMatrix<R, C> {
842842
let (write_start, write_end) = self.range(write);
843843
let words = &mut self.words[..];
844844
let mut changed = false;
845-
for (read_index, write_index) in (read_start..read_end).zip(write_start..write_end) {
845+
for (read_index, write_index) in iter::zip(read_start..read_end, write_start..write_end) {
846846
let word = words[write_index];
847847
let new_word = word | words[read_index];
848848
words[write_index] = new_word;
@@ -858,7 +858,7 @@ impl<R: Idx, C: Idx> BitMatrix<R, C> {
858858
assert_eq!(with.domain_size(), self.num_columns);
859859
let (write_start, write_end) = self.range(write);
860860
let mut changed = false;
861-
for (read_index, write_index) in (0..with.words().len()).zip(write_start..write_end) {
861+
for (read_index, write_index) in iter::zip(0..with.words().len(), write_start..write_end) {
862862
let word = self.words[write_index];
863863
let new_word = word | with.words()[read_index];
864864
self.words[write_index] = new_word;

compiler/rustc_index/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#![feature(const_fn)]
33
#![feature(const_panic)]
44
#![feature(extend_one)]
5+
#![feature(iter_zip)]
56
#![feature(unboxed_closures)]
67
#![feature(test)]
78
#![feature(fn_traits)]

compiler/rustc_infer/src/infer/canonical/query_response.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use rustc_middle::ty::relate::TypeRelation;
2727
use rustc_middle::ty::subst::{GenericArg, GenericArgKind};
2828
use rustc_middle::ty::{self, BoundVar, Const, ToPredicate, Ty, TyCtxt};
2929
use std::fmt::Debug;
30+
use std::iter;
3031

3132
impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
3233
/// This method is meant to be invoked as the final step of a canonical query
@@ -418,7 +419,8 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
418419

419420
// In terms of our example above, we are iterating over pairs like:
420421
// [(?A, Vec<?0>), ('static, '?1), (?B, ?0)]
421-
for (original_value, result_value) in original_values.var_values.iter().zip(result_values) {
422+
for (original_value, result_value) in iter::zip(&original_values.var_values, result_values)
423+
{
422424
match result_value.unpack() {
423425
GenericArgKind::Type(result_value) => {
424426
// e.g., here `result_value` might be `?0` in the example above...

0 commit comments

Comments
 (0)