mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Use iter::zip in compiler/
This commit is contained in:
parent
3b1f5e3462
commit
72ebebe474
@ -2273,6 +2273,7 @@ impl Loss {
|
|||||||
mod sig {
|
mod sig {
|
||||||
use super::{limbs_for_bits, ExpInt, Limb, Loss, LIMB_BITS};
|
use super::{limbs_for_bits, ExpInt, Limb, Loss, LIMB_BITS};
|
||||||
use core::cmp::Ordering;
|
use core::cmp::Ordering;
|
||||||
|
use core::iter;
|
||||||
use core::mem;
|
use core::mem;
|
||||||
|
|
||||||
pub(super) fn is_all_zeros(limbs: &[Limb]) -> bool {
|
pub(super) fn is_all_zeros(limbs: &[Limb]) -> bool {
|
||||||
@ -2483,7 +2484,7 @@ mod sig {
|
|||||||
pub(super) fn add(a: &mut [Limb], b: &[Limb], mut c: Limb) -> Limb {
|
pub(super) fn add(a: &mut [Limb], b: &[Limb], mut c: Limb) -> Limb {
|
||||||
assert!(c <= 1);
|
assert!(c <= 1);
|
||||||
|
|
||||||
for (a, &b) in a.iter_mut().zip(b) {
|
for (a, &b) in iter::zip(a, b) {
|
||||||
let (r, overflow) = a.overflowing_add(b);
|
let (r, overflow) = a.overflowing_add(b);
|
||||||
let (r, overflow2) = r.overflowing_add(c);
|
let (r, overflow2) = r.overflowing_add(c);
|
||||||
*a = r;
|
*a = r;
|
||||||
@ -2497,7 +2498,7 @@ mod sig {
|
|||||||
pub(super) fn sub(a: &mut [Limb], b: &[Limb], mut c: Limb) -> Limb {
|
pub(super) fn sub(a: &mut [Limb], b: &[Limb], mut c: Limb) -> Limb {
|
||||||
assert!(c <= 1);
|
assert!(c <= 1);
|
||||||
|
|
||||||
for (a, &b) in a.iter_mut().zip(b) {
|
for (a, &b) in iter::zip(a, b) {
|
||||||
let (r, overflow) = a.overflowing_sub(b);
|
let (r, overflow) = a.overflowing_sub(b);
|
||||||
let (r, overflow2) = r.overflowing_sub(c);
|
let (r, overflow2) = r.overflowing_sub(c);
|
||||||
*a = r;
|
*a = r;
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![forbid(unsafe_code)]
|
#![forbid(unsafe_code)]
|
||||||
|
#![feature(iter_zip)]
|
||||||
#![feature(nll)]
|
#![feature(nll)]
|
||||||
#![cfg_attr(bootstrap, feature(or_patterns))]
|
#![cfg_attr(bootstrap, feature(or_patterns))]
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#![feature(const_fn_transmute)]
|
#![feature(const_fn_transmute)]
|
||||||
#![feature(const_panic)]
|
#![feature(const_panic)]
|
||||||
#![feature(crate_visibility_modifier)]
|
#![feature(crate_visibility_modifier)]
|
||||||
|
#![feature(iter_zip)]
|
||||||
#![feature(label_break_value)]
|
#![feature(label_break_value)]
|
||||||
#![feature(nll)]
|
#![feature(nll)]
|
||||||
#![cfg_attr(bootstrap, feature(or_patterns))]
|
#![cfg_attr(bootstrap, feature(or_patterns))]
|
||||||
|
@ -341,7 +341,7 @@ impl TokenStream {
|
|||||||
pub fn eq_unspanned(&self, other: &TokenStream) -> bool {
|
pub fn eq_unspanned(&self, other: &TokenStream) -> bool {
|
||||||
let mut t1 = self.trees();
|
let mut t1 = self.trees();
|
||||||
let mut t2 = other.trees();
|
let mut t2 = other.trees();
|
||||||
for (t1, t2) in t1.by_ref().zip(t2.by_ref()) {
|
for (t1, t2) in iter::zip(&mut t1, &mut t2) {
|
||||||
if !t1.eq_unspanned(&t2) {
|
if !t1.eq_unspanned(&t2) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ use rustc_target::spec::abi;
|
|||||||
use smallvec::{smallvec, SmallVec};
|
use smallvec::{smallvec, SmallVec};
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
|
use std::iter;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
pub(super) struct ItemLowerer<'a, 'lowering, 'hir> {
|
pub(super) struct ItemLowerer<'a, 'lowering, 'hir> {
|
||||||
@ -206,7 +207,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||||||
UseTreeKind::Glob => {}
|
UseTreeKind::Glob => {}
|
||||||
UseTreeKind::Simple(_, id1, id2) => {
|
UseTreeKind::Simple(_, id1, id2) => {
|
||||||
for (_, &id) in
|
for (_, &id) in
|
||||||
self.expect_full_res_from_use(base_id).skip(1).zip([id1, id2].iter())
|
iter::zip(self.expect_full_res_from_use(base_id).skip(1), &[id1, id2])
|
||||||
{
|
{
|
||||||
vec.push(id);
|
vec.push(id);
|
||||||
}
|
}
|
||||||
@ -537,7 +538,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||||||
// won't be dealing with macros in the rest of the compiler.
|
// won't be dealing with macros in the rest of the compiler.
|
||||||
// Essentially a single `use` which imports two names is desugared into
|
// Essentially a single `use` which imports two names is desugared into
|
||||||
// two imports.
|
// two imports.
|
||||||
for (res, &new_node_id) in resolutions.zip([id1, id2].iter()) {
|
for (res, &new_node_id) in iter::zip(resolutions, &[id1, id2]) {
|
||||||
let ident = *ident;
|
let ident = *ident;
|
||||||
let mut path = path.clone();
|
let mut path = path.clone();
|
||||||
for seg in &mut path.segments {
|
for seg in &mut path.segments {
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#![feature(crate_visibility_modifier)]
|
#![feature(crate_visibility_modifier)]
|
||||||
#![cfg_attr(bootstrap, feature(or_patterns))]
|
#![cfg_attr(bootstrap, feature(or_patterns))]
|
||||||
#![feature(box_patterns)]
|
#![feature(box_patterns)]
|
||||||
|
#![feature(iter_zip)]
|
||||||
#![recursion_limit = "256"]
|
#![recursion_limit = "256"]
|
||||||
|
|
||||||
use rustc_ast::node_id::NodeMap;
|
use rustc_ast::node_id::NodeMap;
|
||||||
|
@ -1034,7 +1034,7 @@ impl<'a> MethodDef<'a> {
|
|||||||
// make a series of nested matches, to destructure the
|
// make a series of nested matches, to destructure the
|
||||||
// structs. This is actually right-to-left, but it shouldn't
|
// structs. This is actually right-to-left, but it shouldn't
|
||||||
// matter.
|
// matter.
|
||||||
for (arg_expr, pat) in self_args.iter().zip(patterns) {
|
for (arg_expr, pat) in iter::zip(self_args, patterns) {
|
||||||
body = cx.expr_match(
|
body = cx.expr_match(
|
||||||
trait_.span,
|
trait_.span,
|
||||||
arg_expr.clone(),
|
arg_expr.clone(),
|
||||||
@ -1351,7 +1351,7 @@ impl<'a> MethodDef<'a> {
|
|||||||
let mut discriminant_test = cx.expr_bool(sp, true);
|
let mut discriminant_test = cx.expr_bool(sp, true);
|
||||||
|
|
||||||
let mut first_ident = None;
|
let mut first_ident = None;
|
||||||
for (&ident, self_arg) in vi_idents.iter().zip(&self_args) {
|
for (&ident, self_arg) in iter::zip(&vi_idents, &self_args) {
|
||||||
let self_addr = cx.expr_addr_of(sp, self_arg.clone());
|
let self_addr = cx.expr_addr_of(sp, self_arg.clone());
|
||||||
let variant_value =
|
let variant_value =
|
||||||
deriving::call_intrinsic(cx, sp, sym::discriminant_value, vec![self_addr]);
|
deriving::call_intrinsic(cx, sp, sym::discriminant_value, vec![self_addr]);
|
||||||
@ -1571,9 +1571,7 @@ impl<'a> TraitDef<'a> {
|
|||||||
let subpats = self.create_subpatterns(cx, paths, mutbl, use_temporaries);
|
let subpats = self.create_subpatterns(cx, paths, mutbl, use_temporaries);
|
||||||
let pattern = match *struct_def {
|
let pattern = match *struct_def {
|
||||||
VariantData::Struct(..) => {
|
VariantData::Struct(..) => {
|
||||||
let field_pats = subpats
|
let field_pats = iter::zip(subpats, &ident_exprs)
|
||||||
.into_iter()
|
|
||||||
.zip(&ident_exprs)
|
|
||||||
.map(|(pat, &(sp, ident, ..))| {
|
.map(|(pat, &(sp, ident, ..))| {
|
||||||
if ident.is_none() {
|
if ident.is_none() {
|
||||||
cx.span_bug(sp, "a braced struct with unnamed fields in `derive`");
|
cx.span_bug(sp, "a braced struct with unnamed fields in `derive`");
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#![feature(bool_to_option)]
|
#![feature(bool_to_option)]
|
||||||
#![feature(crate_visibility_modifier)]
|
#![feature(crate_visibility_modifier)]
|
||||||
#![feature(decl_macro)]
|
#![feature(decl_macro)]
|
||||||
|
#![feature(iter_zip)]
|
||||||
#![feature(nll)]
|
#![feature(nll)]
|
||||||
#![cfg_attr(bootstrap, feature(or_patterns))]
|
#![cfg_attr(bootstrap, feature(or_patterns))]
|
||||||
#![feature(proc_macro_internals)]
|
#![feature(proc_macro_internals)]
|
||||||
|
@ -24,6 +24,7 @@ use tracing::{debug, info};
|
|||||||
use std::ffi::{CStr, CString};
|
use std::ffi::{CStr, CString};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
use std::iter;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
@ -916,9 +917,7 @@ impl ThinLTOKeysMap {
|
|||||||
modules: &[llvm::ThinLTOModule],
|
modules: &[llvm::ThinLTOModule],
|
||||||
names: &[CString],
|
names: &[CString],
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let keys = modules
|
let keys = iter::zip(modules, names)
|
||||||
.iter()
|
|
||||||
.zip(names.iter())
|
|
||||||
.map(|(module, name)| {
|
.map(|(module, name)| {
|
||||||
let key = build_string(|rust_str| unsafe {
|
let key = build_string(|rust_str| unsafe {
|
||||||
llvm::LLVMRustComputeLTOCacheKey(rust_str, module.identifier, data.0);
|
llvm::LLVMRustComputeLTOCacheKey(rust_str, module.identifier, data.0);
|
||||||
|
@ -21,6 +21,7 @@ use rustc_target::abi::{self, Align, Size};
|
|||||||
use rustc_target::spec::{HasTargetSpec, Target};
|
use rustc_target::spec::{HasTargetSpec, Target};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
|
use std::iter;
|
||||||
use std::ops::{Deref, Range};
|
use std::ops::{Deref, Range};
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
@ -1352,18 +1353,14 @@ impl Builder<'a, 'll, 'tcx> {
|
|||||||
|
|
||||||
let param_tys = self.cx.func_params_types(fn_ty);
|
let param_tys = self.cx.func_params_types(fn_ty);
|
||||||
|
|
||||||
let all_args_match = param_tys
|
let all_args_match = iter::zip(¶m_tys, args.iter().map(|&v| self.val_ty(v)))
|
||||||
.iter()
|
|
||||||
.zip(args.iter().map(|&v| self.val_ty(v)))
|
|
||||||
.all(|(expected_ty, actual_ty)| *expected_ty == actual_ty);
|
.all(|(expected_ty, actual_ty)| *expected_ty == actual_ty);
|
||||||
|
|
||||||
if all_args_match {
|
if all_args_match {
|
||||||
return Cow::Borrowed(args);
|
return Cow::Borrowed(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
let casted_args: Vec<_> = param_tys
|
let casted_args: Vec<_> = iter::zip(param_tys, args)
|
||||||
.into_iter()
|
|
||||||
.zip(args.iter())
|
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(i, (expected_ty, &actual_val))| {
|
.map(|(i, (expected_ty, &actual_val))| {
|
||||||
let actual_ty = self.val_ty(actual_val);
|
let actual_ty = self.val_ty(actual_val);
|
||||||
|
@ -1962,9 +1962,7 @@ fn prepare_enum_metadata(
|
|||||||
|
|
||||||
let discriminant_type_metadata = |discr: Primitive| {
|
let discriminant_type_metadata = |discr: Primitive| {
|
||||||
let enumerators_metadata: Vec<_> = match enum_type.kind() {
|
let enumerators_metadata: Vec<_> = match enum_type.kind() {
|
||||||
ty::Adt(def, _) => def
|
ty::Adt(def, _) => iter::zip(def.discriminants(tcx), &def.variants)
|
||||||
.discriminants(tcx)
|
|
||||||
.zip(&def.variants)
|
|
||||||
.map(|((_, discr), v)| {
|
.map(|((_, discr), v)| {
|
||||||
let name = v.ident.as_str();
|
let name = v.ident.as_str();
|
||||||
let is_unsigned = match discr.ty.kind() {
|
let is_unsigned = match discr.ty.kind() {
|
||||||
@ -2336,9 +2334,7 @@ fn compute_type_parameters(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>) -> &'ll DIAr
|
|||||||
if substs.types().next().is_some() {
|
if substs.types().next().is_some() {
|
||||||
let generics = cx.tcx.generics_of(def.did);
|
let generics = cx.tcx.generics_of(def.did);
|
||||||
let names = get_parameter_names(cx, generics);
|
let names = get_parameter_names(cx, generics);
|
||||||
let template_params: Vec<_> = substs
|
let template_params: Vec<_> = iter::zip(substs, names)
|
||||||
.iter()
|
|
||||||
.zip(names)
|
|
||||||
.filter_map(|(kind, name)| {
|
.filter_map(|(kind, name)| {
|
||||||
if let GenericArgKind::Type(ty) = kind.unpack() {
|
if let GenericArgKind::Type(ty) = kind.unpack() {
|
||||||
let actual_type =
|
let actual_type =
|
||||||
|
@ -37,6 +37,7 @@ use rustc_target::abi::{LayoutOf, Primitive, Size};
|
|||||||
use libc::c_uint;
|
use libc::c_uint;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
use std::iter;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
mod create_scope_map;
|
mod create_scope_map;
|
||||||
@ -448,9 +449,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||||||
// Again, only create type information if full debuginfo is enabled
|
// Again, only create type information if full debuginfo is enabled
|
||||||
let template_params: Vec<_> = if cx.sess().opts.debuginfo == DebugInfo::Full {
|
let template_params: Vec<_> = if cx.sess().opts.debuginfo == DebugInfo::Full {
|
||||||
let names = get_parameter_names(cx, generics);
|
let names = get_parameter_names(cx, generics);
|
||||||
substs
|
iter::zip(substs, names)
|
||||||
.iter()
|
|
||||||
.zip(names)
|
|
||||||
.filter_map(|(kind, name)| {
|
.filter_map(|(kind, name)| {
|
||||||
if let GenericArgKind::Type(ty) = kind.unpack() {
|
if let GenericArgKind::Type(ty) = kind.unpack() {
|
||||||
let actual_type =
|
let actual_type =
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#![feature(extended_key_value_attributes)]
|
#![feature(extended_key_value_attributes)]
|
||||||
#![feature(extern_types)]
|
#![feature(extern_types)]
|
||||||
#![feature(in_band_lifetimes)]
|
#![feature(in_band_lifetimes)]
|
||||||
|
#![feature(iter_zip)]
|
||||||
#![feature(nll)]
|
#![feature(nll)]
|
||||||
#![cfg_attr(bootstrap, feature(or_patterns))]
|
#![cfg_attr(bootstrap, feature(or_patterns))]
|
||||||
#![recursion_limit = "256"]
|
#![recursion_limit = "256"]
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#![feature(nll)]
|
#![feature(nll)]
|
||||||
#![cfg_attr(bootstrap, feature(or_patterns))]
|
#![cfg_attr(bootstrap, feature(or_patterns))]
|
||||||
#![feature(associated_type_bounds)]
|
#![feature(associated_type_bounds)]
|
||||||
|
#![feature(iter_zip)]
|
||||||
#![recursion_limit = "256"]
|
#![recursion_limit = "256"]
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
|
|
||||||
|
@ -282,9 +282,7 @@ fn create_funclets<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||||||
IndexVec<mir::BasicBlock, Option<Bx::BasicBlock>>,
|
IndexVec<mir::BasicBlock, Option<Bx::BasicBlock>>,
|
||||||
IndexVec<mir::BasicBlock, Option<Bx::Funclet>>,
|
IndexVec<mir::BasicBlock, Option<Bx::Funclet>>,
|
||||||
) {
|
) {
|
||||||
block_bxs
|
iter::zip(block_bxs.iter_enumerated(), cleanup_kinds)
|
||||||
.iter_enumerated()
|
|
||||||
.zip(cleanup_kinds)
|
|
||||||
.map(|((bb, &llbb), cleanup_kind)| {
|
.map(|((bb, &llbb), cleanup_kind)| {
|
||||||
match *cleanup_kind {
|
match *cleanup_kind {
|
||||||
CleanupKind::Funclet if base::wants_msvc_seh(bx.sess()) => {}
|
CleanupKind::Funclet if base::wants_msvc_seh(bx.sess()) => {}
|
||||||
|
@ -2214,9 +2214,7 @@ pub fn is_case_difference(sm: &SourceMap, suggested: &str, sp: Span) -> bool {
|
|||||||
};
|
};
|
||||||
let ascii_confusables = &['c', 'f', 'i', 'k', 'o', 's', 'u', 'v', 'w', 'x', 'y', 'z'];
|
let ascii_confusables = &['c', 'f', 'i', 'k', 'o', 's', 'u', 'v', 'w', 'x', 'y', 'z'];
|
||||||
// All the chars that differ in capitalization are confusable (above):
|
// All the chars that differ in capitalization are confusable (above):
|
||||||
let confusable = found
|
let confusable = iter::zip(found.chars(), suggested.chars())
|
||||||
.chars()
|
|
||||||
.zip(suggested.chars())
|
|
||||||
.filter(|(f, s)| f != s)
|
.filter(|(f, s)| f != s)
|
||||||
.all(|(f, s)| (ascii_confusables.contains(&f) || ascii_confusables.contains(&s)));
|
.all(|(f, s)| (ascii_confusables.contains(&f) || ascii_confusables.contains(&s)));
|
||||||
confusable && found.to_lowercase() == suggested.to_lowercase()
|
confusable && found.to_lowercase() == suggested.to_lowercase()
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#![feature(crate_visibility_modifier)]
|
#![feature(crate_visibility_modifier)]
|
||||||
#![feature(backtrace)]
|
#![feature(backtrace)]
|
||||||
#![feature(extended_key_value_attributes)]
|
#![feature(extended_key_value_attributes)]
|
||||||
|
#![feature(iter_zip)]
|
||||||
#![feature(nll)]
|
#![feature(nll)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Code for creating styled buffers
|
// Code for creating styled buffers
|
||||||
|
|
||||||
use crate::snippet::{Style, StyledString};
|
use crate::snippet::{Style, StyledString};
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct StyledBuffer {
|
pub struct StyledBuffer {
|
||||||
@ -20,11 +21,11 @@ impl StyledBuffer {
|
|||||||
let mut output: Vec<Vec<StyledString>> = vec![];
|
let mut output: Vec<Vec<StyledString>> = vec![];
|
||||||
let mut styled_vec: Vec<StyledString> = vec![];
|
let mut styled_vec: Vec<StyledString> = vec![];
|
||||||
|
|
||||||
for (row, row_style) in self.text.iter().zip(&self.styles) {
|
for (row, row_style) in iter::zip(&self.text, &self.styles) {
|
||||||
let mut current_style = Style::NoStyle;
|
let mut current_style = Style::NoStyle;
|
||||||
let mut current_text = String::new();
|
let mut current_text = String::new();
|
||||||
|
|
||||||
for (&c, &s) in row.iter().zip(row_style) {
|
for (&c, &s) in iter::zip(row, row_style) {
|
||||||
if s != current_style {
|
if s != current_style {
|
||||||
if !current_text.is_empty() {
|
if !current_text.is_empty() {
|
||||||
styled_vec.push(StyledString { text: current_text, style: current_style });
|
styled_vec.push(StyledString { text: current_text, style: current_style });
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#![feature(crate_visibility_modifier)]
|
#![feature(crate_visibility_modifier)]
|
||||||
#![feature(decl_macro)]
|
#![feature(decl_macro)]
|
||||||
#![feature(destructuring_assignment)]
|
#![feature(destructuring_assignment)]
|
||||||
|
#![feature(iter_zip)]
|
||||||
#![cfg_attr(bootstrap, feature(or_patterns))]
|
#![cfg_attr(bootstrap, feature(or_patterns))]
|
||||||
#![feature(proc_macro_diagnostic)]
|
#![feature(proc_macro_diagnostic)]
|
||||||
#![feature(proc_macro_internals)]
|
#![feature(proc_macro_internals)]
|
||||||
|
@ -116,6 +116,8 @@ use rustc_span::{symbol::MacroRulesNormalizedIdent, MultiSpan, Span};
|
|||||||
|
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
/// Stack represented as linked list.
|
/// Stack represented as linked list.
|
||||||
///
|
///
|
||||||
/// Those are used for environments because they grow incrementally and are not mutable.
|
/// Those are used for environments because they grow incrementally and are not mutable.
|
||||||
@ -204,7 +206,7 @@ pub(super) fn check_meta_variables(
|
|||||||
sess.span_diagnostic.span_bug(span, "length mismatch between LHSes and RHSes")
|
sess.span_diagnostic.span_bug(span, "length mismatch between LHSes and RHSes")
|
||||||
}
|
}
|
||||||
let mut valid = true;
|
let mut valid = true;
|
||||||
for (lhs, rhs) in lhses.iter().zip(rhses.iter()) {
|
for (lhs, rhs) in iter::zip(lhses, rhses) {
|
||||||
let mut binders = Binders::default();
|
let mut binders = Binders::default();
|
||||||
check_binders(sess, node_id, lhs, &Stack::Empty, &mut binders, &Stack::Empty, &mut valid);
|
check_binders(sess, node_id, lhs, &Stack::Empty, &mut binders, &Stack::Empty, &mut valid);
|
||||||
check_occurrences(sess, node_id, rhs, &Stack::Empty, &binders, &Stack::Empty, &mut valid);
|
check_occurrences(sess, node_id, rhs, &Stack::Empty, &binders, &Stack::Empty, &mut valid);
|
||||||
|
@ -356,7 +356,7 @@ where
|
|||||||
{
|
{
|
||||||
assert_eq!(out_vec.len(), in_vec.len());
|
assert_eq!(out_vec.len(), in_vec.len());
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
for (out_elem, in_elem) in out_vec.iter_mut().zip(in_vec.iter()) {
|
for (out_elem, in_elem) in iter::zip(out_vec, in_vec) {
|
||||||
let old_val = *out_elem;
|
let old_val = *out_elem;
|
||||||
let new_val = op(old_val, *in_elem);
|
let new_val = op(old_val, *in_elem);
|
||||||
*out_elem = new_val;
|
*out_elem = new_val;
|
||||||
@ -842,7 +842,7 @@ impl<R: Idx, C: Idx> BitMatrix<R, C> {
|
|||||||
let (write_start, write_end) = self.range(write);
|
let (write_start, write_end) = self.range(write);
|
||||||
let words = &mut self.words[..];
|
let words = &mut self.words[..];
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
for (read_index, write_index) in (read_start..read_end).zip(write_start..write_end) {
|
for (read_index, write_index) in iter::zip(read_start..read_end, write_start..write_end) {
|
||||||
let word = words[write_index];
|
let word = words[write_index];
|
||||||
let new_word = word | words[read_index];
|
let new_word = word | words[read_index];
|
||||||
words[write_index] = new_word;
|
words[write_index] = new_word;
|
||||||
@ -858,7 +858,7 @@ impl<R: Idx, C: Idx> BitMatrix<R, C> {
|
|||||||
assert_eq!(with.domain_size(), self.num_columns);
|
assert_eq!(with.domain_size(), self.num_columns);
|
||||||
let (write_start, write_end) = self.range(write);
|
let (write_start, write_end) = self.range(write);
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
for (read_index, write_index) in (0..with.words().len()).zip(write_start..write_end) {
|
for (read_index, write_index) in iter::zip(0..with.words().len(), write_start..write_end) {
|
||||||
let word = self.words[write_index];
|
let word = self.words[write_index];
|
||||||
let new_word = word | with.words()[read_index];
|
let new_word = word | with.words()[read_index];
|
||||||
self.words[write_index] = new_word;
|
self.words[write_index] = new_word;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#![feature(const_fn)]
|
#![feature(const_fn)]
|
||||||
#![feature(const_panic)]
|
#![feature(const_panic)]
|
||||||
#![feature(extend_one)]
|
#![feature(extend_one)]
|
||||||
|
#![feature(iter_zip)]
|
||||||
#![feature(unboxed_closures)]
|
#![feature(unboxed_closures)]
|
||||||
#![feature(test)]
|
#![feature(test)]
|
||||||
#![feature(fn_traits)]
|
#![feature(fn_traits)]
|
||||||
|
@ -27,6 +27,7 @@ use rustc_middle::ty::relate::TypeRelation;
|
|||||||
use rustc_middle::ty::subst::{GenericArg, GenericArgKind};
|
use rustc_middle::ty::subst::{GenericArg, GenericArgKind};
|
||||||
use rustc_middle::ty::{self, BoundVar, Const, ToPredicate, Ty, TyCtxt};
|
use rustc_middle::ty::{self, BoundVar, Const, ToPredicate, Ty, TyCtxt};
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
||||||
/// This method is meant to be invoked as the final step of a canonical query
|
/// 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> {
|
|||||||
|
|
||||||
// In terms of our example above, we are iterating over pairs like:
|
// In terms of our example above, we are iterating over pairs like:
|
||||||
// [(?A, Vec<?0>), ('static, '?1), (?B, ?0)]
|
// [(?A, Vec<?0>), ('static, '?1), (?B, ?0)]
|
||||||
for (original_value, result_value) in original_values.var_values.iter().zip(result_values) {
|
for (original_value, result_value) in iter::zip(&original_values.var_values, result_values)
|
||||||
|
{
|
||||||
match result_value.unpack() {
|
match result_value.unpack() {
|
||||||
GenericArgKind::Type(result_value) => {
|
GenericArgKind::Type(result_value) => {
|
||||||
// e.g., here `result_value` might be `?0` in the example above...
|
// e.g., here `result_value` might be `?0` in the example above...
|
||||||
|
@ -73,7 +73,7 @@ use rustc_middle::ty::{
|
|||||||
use rustc_span::{sym, BytePos, DesugaringKind, Pos, Span};
|
use rustc_span::{sym, BytePos, DesugaringKind, Pos, Span};
|
||||||
use rustc_target::spec::abi;
|
use rustc_target::spec::abi;
|
||||||
use std::ops::ControlFlow;
|
use std::ops::ControlFlow;
|
||||||
use std::{cmp, fmt};
|
use std::{cmp, fmt, iter};
|
||||||
|
|
||||||
mod note;
|
mod note;
|
||||||
|
|
||||||
@ -963,7 +963,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
ty::GenericParamDefKind::Const { has_default: true } => Some(param.def_id),
|
ty::GenericParamDefKind::Const { has_default: true } => Some(param.def_id),
|
||||||
_ => None,
|
_ => None,
|
||||||
});
|
});
|
||||||
for (def_id, actual) in default_params.zip(substs.iter().rev()) {
|
for (def_id, actual) in iter::zip(default_params, substs.iter().rev()) {
|
||||||
match actual.unpack() {
|
match actual.unpack() {
|
||||||
GenericArgKind::Const(c) => {
|
GenericArgKind::Const(c) => {
|
||||||
if self.tcx.const_param_default(def_id).subst(self.tcx, substs) != c {
|
if self.tcx.const_param_default(def_id).subst(self.tcx, substs) != c {
|
||||||
@ -1040,7 +1040,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
let len1 = sig1.inputs().len();
|
let len1 = sig1.inputs().len();
|
||||||
let len2 = sig2.inputs().len();
|
let len2 = sig2.inputs().len();
|
||||||
if len1 == len2 {
|
if len1 == len2 {
|
||||||
for (i, (l, r)) in sig1.inputs().iter().zip(sig2.inputs().iter()).enumerate() {
|
for (i, (l, r)) in iter::zip(sig1.inputs(), sig2.inputs()).enumerate() {
|
||||||
let (x1, x2) = self.cmp(l, r);
|
let (x1, x2) = self.cmp(l, r);
|
||||||
(values.0).0.extend(x1.0);
|
(values.0).0.extend(x1.0);
|
||||||
(values.1).0.extend(x2.0);
|
(values.1).0.extend(x2.0);
|
||||||
@ -1161,12 +1161,10 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
let common_len = cmp::min(len1, len2);
|
let common_len = cmp::min(len1, len2);
|
||||||
let remainder1: Vec<_> = sub1.types().skip(common_len).collect();
|
let remainder1: Vec<_> = sub1.types().skip(common_len).collect();
|
||||||
let remainder2: Vec<_> = sub2.types().skip(common_len).collect();
|
let remainder2: Vec<_> = sub2.types().skip(common_len).collect();
|
||||||
let common_default_params = remainder1
|
let common_default_params =
|
||||||
.iter()
|
iter::zip(remainder1.iter().rev(), remainder2.iter().rev())
|
||||||
.rev()
|
.filter(|(a, b)| a == b)
|
||||||
.zip(remainder2.iter().rev())
|
.count();
|
||||||
.filter(|(a, b)| a == b)
|
|
||||||
.count();
|
|
||||||
let len = sub1.len() - common_default_params;
|
let len = sub1.len() - common_default_params;
|
||||||
let consts_offset = len - sub1.consts().count();
|
let consts_offset = len - sub1.consts().count();
|
||||||
|
|
||||||
@ -1297,12 +1295,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
|
|
||||||
const SEPARATOR: &str = "::";
|
const SEPARATOR: &str = "::";
|
||||||
let separator_len = SEPARATOR.len();
|
let separator_len = SEPARATOR.len();
|
||||||
let split_idx: usize = t1_str
|
let split_idx: usize =
|
||||||
.split(SEPARATOR)
|
iter::zip(t1_str.split(SEPARATOR), t2_str.split(SEPARATOR))
|
||||||
.zip(t2_str.split(SEPARATOR))
|
.take_while(|(mod1_str, mod2_str)| mod1_str == mod2_str)
|
||||||
.take_while(|(mod1_str, mod2_str)| mod1_str == mod2_str)
|
.map(|(mod_str, _)| mod_str.len() + separator_len)
|
||||||
.map(|(mod_str, _)| mod_str.len() + separator_len)
|
.sum();
|
||||||
.sum();
|
|
||||||
|
|
||||||
debug!(
|
debug!(
|
||||||
"cmp: separator_len={}, split_idx={}, min_len={}",
|
"cmp: separator_len={}, split_idx={}, min_len={}",
|
||||||
@ -1907,7 +1904,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
.find_map(|(path, msg)| (&path_str == path).then_some(msg))
|
.find_map(|(path, msg)| (&path_str == path).then_some(msg))
|
||||||
{
|
{
|
||||||
let mut show_suggestion = true;
|
let mut show_suggestion = true;
|
||||||
for (exp_ty, found_ty) in exp_substs.types().zip(found_substs.types()) {
|
for (exp_ty, found_ty) in
|
||||||
|
iter::zip(exp_substs.types(), found_substs.types())
|
||||||
|
{
|
||||||
match *exp_ty.kind() {
|
match *exp_ty.kind() {
|
||||||
ty::Ref(_, exp_ty, _) => {
|
ty::Ref(_, exp_ty, _) => {
|
||||||
match (exp_ty.kind(), found_ty.kind()) {
|
match (exp_ty.kind(), found_ty.kind()) {
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#![feature(const_fn)]
|
#![feature(const_fn)]
|
||||||
#![feature(const_panic)]
|
#![feature(const_panic)]
|
||||||
#![feature(extend_one)]
|
#![feature(extend_one)]
|
||||||
|
#![feature(iter_zip)]
|
||||||
#![feature(never_type)]
|
#![feature(never_type)]
|
||||||
#![cfg_attr(bootstrap, feature(or_patterns))]
|
#![cfg_attr(bootstrap, feature(or_patterns))]
|
||||||
#![feature(in_band_lifetimes)]
|
#![feature(in_band_lifetimes)]
|
||||||
|
@ -9,6 +9,7 @@ use rustc_middle::ty::TyCtxt;
|
|||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
use rustc_span::{MultiSpan, Span};
|
use rustc_span::{MultiSpan, Span};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
pub fn report_extra_impl_obligation(
|
pub fn report_extra_impl_obligation(
|
||||||
@ -94,7 +95,7 @@ pub fn report_object_safety_error(
|
|||||||
note_span
|
note_span
|
||||||
.push_span_label(trait_span, "this trait cannot be made into an object...".to_string());
|
.push_span_label(trait_span, "this trait cannot be made into an object...".to_string());
|
||||||
}
|
}
|
||||||
for (span, msg) in multi_span.into_iter().zip(messages.into_iter()) {
|
for (span, msg) in iter::zip(multi_span, messages) {
|
||||||
note_span.push_span_label(span, msg);
|
note_span.push_span_label(span, msg);
|
||||||
}
|
}
|
||||||
err.span_note(
|
err.span_note(
|
||||||
|
@ -45,6 +45,7 @@ use rustc_target::abi::LayoutOf;
|
|||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
use std::iter;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
|
|
||||||
/// Information about the registered lints.
|
/// Information about the registered lints.
|
||||||
@ -864,7 +865,7 @@ impl<'tcx> LateContext<'tcx> {
|
|||||||
pub fn match_def_path(&self, def_id: DefId, path: &[Symbol]) -> bool {
|
pub fn match_def_path(&self, def_id: DefId, path: &[Symbol]) -> bool {
|
||||||
let names = self.get_def_path(def_id);
|
let names = self.get_def_path(def_id);
|
||||||
|
|
||||||
names.len() == path.len() && names.into_iter().zip(path.iter()).all(|(a, &b)| a == b)
|
names.len() == path.len() && iter::zip(names, path).all(|(a, &b)| a == b)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the absolute path of `def_id` as a vector of `Symbol`.
|
/// Gets the absolute path of `def_id` as a vector of `Symbol`.
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#![feature(box_patterns)]
|
#![feature(box_patterns)]
|
||||||
#![feature(crate_visibility_modifier)]
|
#![feature(crate_visibility_modifier)]
|
||||||
#![feature(iter_order_by)]
|
#![feature(iter_order_by)]
|
||||||
|
#![feature(iter_zip)]
|
||||||
#![feature(never_type)]
|
#![feature(never_type)]
|
||||||
#![feature(nll)]
|
#![feature(nll)]
|
||||||
#![cfg_attr(bootstrap, feature(or_patterns))]
|
#![cfg_attr(bootstrap, feature(or_patterns))]
|
||||||
|
@ -17,6 +17,7 @@ use rustc_target::abi::{Integer, LayoutOf, TagEncoding, VariantIdx, Variants};
|
|||||||
use rustc_target::spec::abi::Abi as SpecAbi;
|
use rustc_target::spec::abi::Abi as SpecAbi;
|
||||||
|
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
|
use std::iter;
|
||||||
use std::ops::ControlFlow;
|
use std::ops::ControlFlow;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
@ -1255,7 +1256,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
|||||||
let sig = self.cx.tcx.fn_sig(def_id);
|
let sig = self.cx.tcx.fn_sig(def_id);
|
||||||
let sig = self.cx.tcx.erase_late_bound_regions(sig);
|
let sig = self.cx.tcx.erase_late_bound_regions(sig);
|
||||||
|
|
||||||
for (input_ty, input_hir) in sig.inputs().iter().zip(decl.inputs) {
|
for (input_ty, input_hir) in iter::zip(sig.inputs(), decl.inputs) {
|
||||||
self.check_type_for_ffi_and_report_errors(input_hir.span, input_ty, false, false);
|
self.check_type_for_ffi_and_report_errors(input_hir.span, input_ty, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1355,10 +1356,7 @@ impl<'tcx> LateLintPass<'tcx> for VariantSizeDifferences {
|
|||||||
layout
|
layout
|
||||||
);
|
);
|
||||||
|
|
||||||
let (largest, slargest, largest_index) = enum_definition
|
let (largest, slargest, largest_index) = iter::zip(enum_definition.variants, variants)
|
||||||
.variants
|
|
||||||
.iter()
|
|
||||||
.zip(variants)
|
|
||||||
.map(|(variant, variant_layout)| {
|
.map(|(variant, variant_layout)| {
|
||||||
// Subtract the size of the enum tag.
|
// Subtract the size of the enum tag.
|
||||||
let bytes = variant_layout.size.bytes().saturating_sub(tag_size);
|
let bytes = variant_layout.size.bytes().saturating_sub(tag_size);
|
||||||
|
@ -43,7 +43,7 @@ fn test_symbols_macro(input: TokenStream, expected_errors: &[&str]) {
|
|||||||
"Macro generated a different number of errors than expected"
|
"Macro generated a different number of errors than expected"
|
||||||
);
|
);
|
||||||
|
|
||||||
for (found_error, &expected_error) in found_errors.iter().zip(expected_errors.iter()) {
|
for (found_error, &expected_error) in found_errors.iter().zip(expected_errors) {
|
||||||
let found_error_str = format!("{}", found_error);
|
let found_error_str = format!("{}", found_error);
|
||||||
assert_eq!(found_error_str, expected_error);
|
assert_eq!(found_error_str, expected_error);
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ use crate::ty::{self, BoundVar, List, Region, TyCtxt};
|
|||||||
use rustc_index::vec::IndexVec;
|
use rustc_index::vec::IndexVec;
|
||||||
use rustc_macros::HashStable;
|
use rustc_macros::HashStable;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
use std::iter;
|
||||||
use std::ops::Index;
|
use std::ops::Index;
|
||||||
|
|
||||||
/// A "canonicalized" type `V` is one where all free inference
|
/// A "canonicalized" type `V` is one where all free inference
|
||||||
@ -315,10 +316,7 @@ impl<'tcx> CanonicalVarValues<'tcx> {
|
|||||||
use crate::ty::subst::GenericArgKind;
|
use crate::ty::subst::GenericArgKind;
|
||||||
|
|
||||||
CanonicalVarValues {
|
CanonicalVarValues {
|
||||||
var_values: self
|
var_values: iter::zip(&self.var_values, 0..)
|
||||||
.var_values
|
|
||||||
.iter()
|
|
||||||
.zip(0..)
|
|
||||||
.map(|(kind, i)| match kind.unpack() {
|
.map(|(kind, i)| match kind.unpack() {
|
||||||
GenericArgKind::Type(..) => {
|
GenericArgKind::Type(..) => {
|
||||||
tcx.mk_ty(ty::Bound(ty::INNERMOST, ty::BoundVar::from_u32(i).into())).into()
|
tcx.mk_ty(ty::Bound(ty::INNERMOST, ty::BoundVar::from_u32(i).into())).into()
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
#![feature(exclusive_range_pattern)]
|
#![feature(exclusive_range_pattern)]
|
||||||
#![feature(control_flow_enum)]
|
#![feature(control_flow_enum)]
|
||||||
#![feature(associated_type_defaults)]
|
#![feature(associated_type_defaults)]
|
||||||
|
#![feature(iter_zip)]
|
||||||
#![recursion_limit = "512"]
|
#![recursion_limit = "512"]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -2329,7 +2329,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
|
|||||||
CtorKind::Fn => fmt_tuple(fmt, &name),
|
CtorKind::Fn => fmt_tuple(fmt, &name),
|
||||||
CtorKind::Fictive => {
|
CtorKind::Fictive => {
|
||||||
let mut struct_fmt = fmt.debug_struct(&name);
|
let mut struct_fmt = fmt.debug_struct(&name);
|
||||||
for (field, place) in variant_def.fields.iter().zip(places) {
|
for (field, place) in iter::zip(&variant_def.fields, places) {
|
||||||
struct_fmt.field(&field.ident.as_str(), place);
|
struct_fmt.field(&field.ident.as_str(), place);
|
||||||
}
|
}
|
||||||
struct_fmt.finish()
|
struct_fmt.finish()
|
||||||
@ -2353,7 +2353,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
|
|||||||
let mut struct_fmt = fmt.debug_struct(&name);
|
let mut struct_fmt = fmt.debug_struct(&name);
|
||||||
|
|
||||||
if let Some(upvars) = tcx.upvars_mentioned(def_id) {
|
if let Some(upvars) = tcx.upvars_mentioned(def_id) {
|
||||||
for (&var_id, place) in upvars.keys().zip(places) {
|
for (&var_id, place) in iter::zip(upvars.keys(), places) {
|
||||||
let var_name = tcx.hir().name(var_id);
|
let var_name = tcx.hir().name(var_id);
|
||||||
struct_fmt.field(&var_name.as_str(), place);
|
struct_fmt.field(&var_name.as_str(), place);
|
||||||
}
|
}
|
||||||
@ -2372,7 +2372,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
|
|||||||
let mut struct_fmt = fmt.debug_struct(&name);
|
let mut struct_fmt = fmt.debug_struct(&name);
|
||||||
|
|
||||||
if let Some(upvars) = tcx.upvars_mentioned(def_id) {
|
if let Some(upvars) = tcx.upvars_mentioned(def_id) {
|
||||||
for (&var_id, place) in upvars.keys().zip(places) {
|
for (&var_id, place) in iter::zip(upvars.keys(), places) {
|
||||||
let var_name = tcx.hir().name(var_id);
|
let var_name = tcx.hir().name(var_id);
|
||||||
struct_fmt.field(&var_name.as_str(), place);
|
struct_fmt.field(&var_name.as_str(), place);
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ impl SwitchTargets {
|
|||||||
///
|
///
|
||||||
/// Note that this may yield 0 elements. Only the `otherwise` branch is mandatory.
|
/// Note that this may yield 0 elements. Only the `otherwise` branch is mandatory.
|
||||||
pub fn iter(&self) -> SwitchTargetsIter<'_> {
|
pub fn iter(&self) -> SwitchTargetsIter<'_> {
|
||||||
SwitchTargetsIter { inner: self.values.iter().zip(self.targets.iter()) }
|
SwitchTargetsIter { inner: iter::zip(&self.values, &self.targets) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a slice with all possible jump targets (including the fallback target).
|
/// Returns a slice with all possible jump targets (including the fallback target).
|
||||||
|
@ -789,7 +789,7 @@ impl CanonicalUserType<'tcx> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
user_substs.substs.iter().zip(BoundVar::new(0)..).all(|(kind, cvar)| {
|
iter::zip(user_substs.substs, BoundVar::new(0)..).all(|(kind, cvar)| {
|
||||||
match kind.unpack() {
|
match kind.unpack() {
|
||||||
GenericArgKind::Type(ty) => match ty.kind() {
|
GenericArgKind::Type(ty) => match ty.kind() {
|
||||||
ty::Bound(debruijn, b) => {
|
ty::Bound(debruijn, b) => {
|
||||||
|
@ -1251,13 +1251,13 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
|
|||||||
} else {
|
} else {
|
||||||
// Try to use a ScalarPair for all tagged enums.
|
// Try to use a ScalarPair for all tagged enums.
|
||||||
let mut common_prim = None;
|
let mut common_prim = None;
|
||||||
for (field_layouts, layout_variant) in variants.iter().zip(&layout_variants) {
|
for (field_layouts, layout_variant) in iter::zip(&variants, &layout_variants) {
|
||||||
let offsets = match layout_variant.fields {
|
let offsets = match layout_variant.fields {
|
||||||
FieldsShape::Arbitrary { ref offsets, .. } => offsets,
|
FieldsShape::Arbitrary { ref offsets, .. } => offsets,
|
||||||
_ => bug!(),
|
_ => bug!(),
|
||||||
};
|
};
|
||||||
let mut fields =
|
let mut fields =
|
||||||
field_layouts.iter().zip(offsets).filter(|p| !p.0.is_zst());
|
iter::zip(field_layouts, offsets).filter(|p| !p.0.is_zst());
|
||||||
let (field, offset) = match (fields.next(), fields.next()) {
|
let (field, offset) = match (fields.next(), fields.next()) {
|
||||||
(None, None) => continue,
|
(None, None) => continue,
|
||||||
(Some(pair), None) => pair,
|
(Some(pair), None) => pair,
|
||||||
@ -1626,7 +1626,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
|
|||||||
const INVALID_FIELD_IDX: u32 = !0;
|
const INVALID_FIELD_IDX: u32 = !0;
|
||||||
let mut combined_inverse_memory_index =
|
let mut combined_inverse_memory_index =
|
||||||
vec![INVALID_FIELD_IDX; promoted_memory_index.len() + memory_index.len()];
|
vec![INVALID_FIELD_IDX; promoted_memory_index.len() + memory_index.len()];
|
||||||
let mut offsets_and_memory_index = offsets.into_iter().zip(memory_index);
|
let mut offsets_and_memory_index = iter::zip(offsets, memory_index);
|
||||||
let combined_offsets = variant_fields
|
let combined_offsets = variant_fields
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
|
@ -19,6 +19,7 @@ use std::char;
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::fmt::{self, Write as _};
|
use std::fmt::{self, Write as _};
|
||||||
|
use std::iter;
|
||||||
use std::ops::{ControlFlow, Deref, DerefMut};
|
use std::ops::{ControlFlow, Deref, DerefMut};
|
||||||
|
|
||||||
// `pretty` is a separate module only for organization.
|
// `pretty` is a separate module only for organization.
|
||||||
@ -1223,7 +1224,7 @@ pub trait PrettyPrinter<'tcx>:
|
|||||||
CtorKind::Fictive => {
|
CtorKind::Fictive => {
|
||||||
p!(" {{ ");
|
p!(" {{ ");
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
for (field_def, field) in variant_def.fields.iter().zip(fields) {
|
for (field_def, field) in iter::zip(&variant_def.fields, fields) {
|
||||||
if !first {
|
if !first {
|
||||||
p!(", ");
|
p!(", ");
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ pub fn relate_substs<R: TypeRelation<'tcx>>(
|
|||||||
) -> RelateResult<'tcx, SubstsRef<'tcx>> {
|
) -> RelateResult<'tcx, SubstsRef<'tcx>> {
|
||||||
let tcx = relation.tcx();
|
let tcx = relation.tcx();
|
||||||
|
|
||||||
let params = a_subst.iter().zip(b_subst).enumerate().map(|(i, (a, b))| {
|
let params = iter::zip(a_subst, b_subst).enumerate().map(|(i, (a, b))| {
|
||||||
let variance = variances.map_or(ty::Invariant, |v| v[i]);
|
let variance = variances.map_or(ty::Invariant, |v| v[i]);
|
||||||
relation.relate_with_variance(variance, a, b)
|
relation.relate_with_variance(variance, a, b)
|
||||||
});
|
});
|
||||||
@ -179,12 +179,8 @@ impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> {
|
|||||||
return Err(TypeError::ArgCount);
|
return Err(TypeError::ArgCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
let inputs_and_output = a
|
let inputs_and_output = iter::zip(a.inputs(), b.inputs())
|
||||||
.inputs()
|
.map(|(&a, &b)| ((a, b), false))
|
||||||
.iter()
|
|
||||||
.cloned()
|
|
||||||
.zip(b.inputs().iter().cloned())
|
|
||||||
.map(|x| (x, false))
|
|
||||||
.chain(iter::once(((a.output(), b.output()), true)))
|
.chain(iter::once(((a.output(), b.output()), true)))
|
||||||
.map(|((a, b), is_output)| {
|
.map(|((a, b), is_output)| {
|
||||||
if is_output {
|
if is_output {
|
||||||
@ -308,7 +304,7 @@ impl<'tcx> Relate<'tcx> for GeneratorWitness<'tcx> {
|
|||||||
) -> RelateResult<'tcx, GeneratorWitness<'tcx>> {
|
) -> RelateResult<'tcx, GeneratorWitness<'tcx>> {
|
||||||
assert_eq!(a.0.len(), b.0.len());
|
assert_eq!(a.0.len(), b.0.len());
|
||||||
let tcx = relation.tcx();
|
let tcx = relation.tcx();
|
||||||
let types = tcx.mk_type_list(a.0.iter().zip(b.0).map(|(a, b)| relation.relate(a, b)))?;
|
let types = tcx.mk_type_list(iter::zip(a.0, b.0).map(|(a, b)| relation.relate(a, b)))?;
|
||||||
Ok(GeneratorWitness(types))
|
Ok(GeneratorWitness(types))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -449,7 +445,7 @@ pub fn super_relate_tys<R: TypeRelation<'tcx>>(
|
|||||||
(&ty::Tuple(as_), &ty::Tuple(bs)) => {
|
(&ty::Tuple(as_), &ty::Tuple(bs)) => {
|
||||||
if as_.len() == bs.len() {
|
if as_.len() == bs.len() {
|
||||||
Ok(tcx.mk_tup(
|
Ok(tcx.mk_tup(
|
||||||
as_.iter().zip(bs).map(|(a, b)| relation.relate(a.expect_ty(), b.expect_ty())),
|
iter::zip(as_, bs).map(|(a, b)| relation.relate(a.expect_ty(), b.expect_ty())),
|
||||||
)?)
|
)?)
|
||||||
} else if !(as_.is_empty() || bs.is_empty()) {
|
} else if !(as_.is_empty() || bs.is_empty()) {
|
||||||
Err(TypeError::TupleSize(expected_found(relation, as_.len(), bs.len())))
|
Err(TypeError::TupleSize(expected_found(relation, as_.len(), bs.len())))
|
||||||
@ -593,9 +589,7 @@ fn check_const_value_eq<R: TypeRelation<'tcx>>(
|
|||||||
|
|
||||||
// Both the variant and each field have to be equal.
|
// Both the variant and each field have to be equal.
|
||||||
if a_destructured.variant == b_destructured.variant {
|
if a_destructured.variant == b_destructured.variant {
|
||||||
for (a_field, b_field) in
|
for (a_field, b_field) in iter::zip(a_destructured.fields, b_destructured.fields) {
|
||||||
a_destructured.fields.iter().zip(b_destructured.fields.iter())
|
|
||||||
{
|
|
||||||
relation.consts(a_field, b_field)?;
|
relation.consts(a_field, b_field)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -631,7 +625,7 @@ impl<'tcx> Relate<'tcx> for &'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'
|
|||||||
return Err(TypeError::ExistentialMismatch(expected_found(relation, a, b)));
|
return Err(TypeError::ExistentialMismatch(expected_found(relation, a, b)));
|
||||||
}
|
}
|
||||||
|
|
||||||
let v = a_v.into_iter().zip(b_v.into_iter()).map(|(ep_a, ep_b)| {
|
let v = iter::zip(a_v, b_v).map(|(ep_a, ep_b)| {
|
||||||
use crate::ty::ExistentialPredicate::*;
|
use crate::ty::ExistentialPredicate::*;
|
||||||
match (ep_a.skip_binder(), ep_b.skip_binder()) {
|
match (ep_a.skip_binder(), ep_b.skip_binder()) {
|
||||||
(Trait(a), Trait(b)) => Ok(ty::Binder::bind(Trait(
|
(Trait(a), Trait(b)) => Ok(ty::Binder::bind(Trait(
|
||||||
|
@ -21,7 +21,7 @@ use rustc_macros::HashStable;
|
|||||||
use rustc_span::{Span, DUMMY_SP};
|
use rustc_span::{Span, DUMMY_SP};
|
||||||
use rustc_target::abi::{Integer, Size, TargetDataLayout};
|
use rustc_target::abi::{Integer, Size, TargetDataLayout};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::{cmp, fmt};
|
use std::{cmp, fmt, iter};
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct Discr<'tcx> {
|
pub struct Discr<'tcx> {
|
||||||
@ -414,9 +414,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
_ => bug!(),
|
_ => bug!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = item_substs
|
let result = iter::zip(item_substs, impl_substs)
|
||||||
.iter()
|
|
||||||
.zip(impl_substs.iter())
|
|
||||||
.filter(|&(_, k)| {
|
.filter(|&(_, k)| {
|
||||||
match k.unpack() {
|
match k.unpack() {
|
||||||
GenericArgKind::Lifetime(&ty::RegionKind::ReEarlyBound(ref ebr)) => {
|
GenericArgKind::Lifetime(&ty::RegionKind::ReEarlyBound(ref ebr)) => {
|
||||||
|
@ -18,6 +18,7 @@ use rustc_span::{
|
|||||||
Span,
|
Span,
|
||||||
};
|
};
|
||||||
use rustc_target::abi::VariantIdx;
|
use rustc_target::abi::VariantIdx;
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
use super::borrow_set::BorrowData;
|
use super::borrow_set::BorrowData;
|
||||||
use super::MirBorrowckCtxt;
|
use super::MirBorrowckCtxt;
|
||||||
@ -970,13 +971,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
let expr = &self.infcx.tcx.hir().expect_expr(hir_id).kind;
|
let expr = &self.infcx.tcx.hir().expect_expr(hir_id).kind;
|
||||||
debug!("closure_span: hir_id={:?} expr={:?}", hir_id, expr);
|
debug!("closure_span: hir_id={:?} expr={:?}", hir_id, expr);
|
||||||
if let hir::ExprKind::Closure(.., body_id, args_span, _) = expr {
|
if let hir::ExprKind::Closure(.., body_id, args_span, _) = expr {
|
||||||
for (captured_place, place) in self
|
for (captured_place, place) in iter::zip(
|
||||||
.infcx
|
self.infcx.tcx.typeck(def_id.expect_local()).closure_min_captures_flattened(def_id),
|
||||||
.tcx
|
places,
|
||||||
.typeck(def_id.expect_local())
|
) {
|
||||||
.closure_min_captures_flattened(def_id)
|
|
||||||
.zip(places)
|
|
||||||
{
|
|
||||||
let upvar_hir_id = captured_place.get_root_variable();
|
let upvar_hir_id = captured_place.get_root_variable();
|
||||||
//FIXME(project-rfc-2229#8): Use better span from captured_place
|
//FIXME(project-rfc-2229#8): Use better span from captured_place
|
||||||
let span = self.infcx.tcx.upvars_mentioned(local_did)?[&upvar_hir_id].span;
|
let span = self.infcx.tcx.upvars_mentioned(local_did)?[&upvar_hir_id].span;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use std::fmt::{self, Display};
|
use std::fmt::{self, Display};
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
use rustc_errors::DiagnosticBuilder;
|
use rustc_errors::DiagnosticBuilder;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
@ -536,7 +537,8 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
|
|||||||
// just worry about trying to match up the rustc type
|
// just worry about trying to match up the rustc type
|
||||||
// with the HIR types:
|
// with the HIR types:
|
||||||
(ty::Tuple(elem_tys), hir::TyKind::Tup(elem_hir_tys)) => {
|
(ty::Tuple(elem_tys), hir::TyKind::Tup(elem_hir_tys)) => {
|
||||||
search_stack.extend(elem_tys.iter().map(|k| k.expect_ty()).zip(*elem_hir_tys));
|
search_stack
|
||||||
|
.extend(iter::zip(elem_tys.iter().map(|k| k.expect_ty()), *elem_hir_tys));
|
||||||
}
|
}
|
||||||
|
|
||||||
(ty::Slice(elem_ty), hir::TyKind::Slice(elem_hir_ty))
|
(ty::Slice(elem_ty), hir::TyKind::Slice(elem_hir_ty))
|
||||||
@ -611,7 +613,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
|
|||||||
args: &'hir hir::GenericArgs<'hir>,
|
args: &'hir hir::GenericArgs<'hir>,
|
||||||
search_stack: &mut Vec<(Ty<'tcx>, &'hir hir::Ty<'hir>)>,
|
search_stack: &mut Vec<(Ty<'tcx>, &'hir hir::Ty<'hir>)>,
|
||||||
) -> Option<&'hir hir::Lifetime> {
|
) -> Option<&'hir hir::Lifetime> {
|
||||||
for (kind, hir_arg) in substs.iter().zip(args.args) {
|
for (kind, hir_arg) in iter::zip(substs, args.args) {
|
||||||
match (kind.unpack(), hir_arg) {
|
match (kind.unpack(), hir_arg) {
|
||||||
(GenericArgKind::Lifetime(r), hir::GenericArg::Lifetime(lt)) => {
|
(GenericArgKind::Lifetime(r), hir::GenericArg::Lifetime(lt)) => {
|
||||||
if r.to_region_vid() == needle_fr {
|
if r.to_region_vid() == needle_fr {
|
||||||
|
@ -5,6 +5,7 @@ use rustc_middle::mir::{BorrowKind, Mutability, Operand};
|
|||||||
use rustc_middle::mir::{InlineAsmOperand, Terminator, TerminatorKind};
|
use rustc_middle::mir::{InlineAsmOperand, Terminator, TerminatorKind};
|
||||||
use rustc_middle::mir::{Statement, StatementKind};
|
use rustc_middle::mir::{Statement, StatementKind};
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
use crate::dataflow::indexes::BorrowIndex;
|
use crate::dataflow::indexes::BorrowIndex;
|
||||||
|
|
||||||
@ -69,7 +70,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
|
|||||||
self.mutate_place(location, **place, Shallow(None), JustWrite);
|
self.mutate_place(location, **place, Shallow(None), JustWrite);
|
||||||
}
|
}
|
||||||
StatementKind::LlvmInlineAsm(asm) => {
|
StatementKind::LlvmInlineAsm(asm) => {
|
||||||
for (o, output) in asm.asm.outputs.iter().zip(asm.outputs.iter()) {
|
for (o, output) in iter::zip(&asm.asm.outputs, &*asm.outputs) {
|
||||||
if o.is_indirect {
|
if o.is_indirect {
|
||||||
// FIXME(eddyb) indirect inline asm outputs should
|
// FIXME(eddyb) indirect inline asm outputs should
|
||||||
// be encoded through MIR place derefs instead.
|
// be encoded through MIR place derefs instead.
|
||||||
|
@ -25,6 +25,7 @@ use either::Either;
|
|||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
use std::iter;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
@ -595,7 +596,7 @@ impl<'cx, 'tcx> dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tc
|
|||||||
self.mutate_place(location, (**place, span), Shallow(None), JustWrite, flow_state);
|
self.mutate_place(location, (**place, span), Shallow(None), JustWrite, flow_state);
|
||||||
}
|
}
|
||||||
StatementKind::LlvmInlineAsm(ref asm) => {
|
StatementKind::LlvmInlineAsm(ref asm) => {
|
||||||
for (o, output) in asm.asm.outputs.iter().zip(asm.outputs.iter()) {
|
for (o, output) in iter::zip(&asm.asm.outputs, &*asm.outputs) {
|
||||||
if o.is_indirect {
|
if o.is_indirect {
|
||||||
// FIXME(eddyb) indirect inline asm outputs should
|
// FIXME(eddyb) indirect inline asm outputs should
|
||||||
// be encoded through MIR place derefs instead.
|
// be encoded through MIR place derefs instead.
|
||||||
|
@ -5,6 +5,7 @@ use rustc_hir as hir;
|
|||||||
use rustc_middle::mir::{Body, BorrowKind, Local, Place, PlaceElem, PlaceRef, ProjectionElem};
|
use rustc_middle::mir::{Body, BorrowKind, Local, Place, PlaceElem, PlaceRef, ProjectionElem};
|
||||||
use rustc_middle::ty::{self, TyCtxt};
|
use rustc_middle::ty::{self, TyCtxt};
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
/// When checking if a place conflicts with another place, this enum is used to influence decisions
|
/// When checking if a place conflicts with another place, this enum is used to influence decisions
|
||||||
/// where a place might be equal or disjoint with another place, such as if `a[i] == a[j]`.
|
/// where a place might be equal or disjoint with another place, such as if `a[i] == a[j]`.
|
||||||
@ -139,7 +140,7 @@ fn place_components_conflict<'tcx>(
|
|||||||
|
|
||||||
// loop invariant: borrow_c is always either equal to access_c or disjoint from it.
|
// loop invariant: borrow_c is always either equal to access_c or disjoint from it.
|
||||||
for (i, (borrow_c, &access_c)) in
|
for (i, (borrow_c, &access_c)) in
|
||||||
borrow_place.projection.iter().zip(access_place.projection.iter()).enumerate()
|
iter::zip(borrow_place.projection, access_place.projection).enumerate()
|
||||||
{
|
{
|
||||||
debug!("borrow_conflicts_with_place: borrow_c = {:?}", borrow_c);
|
debug!("borrow_conflicts_with_place: borrow_c = {:?}", borrow_c);
|
||||||
let borrow_proj_base = &borrow_place.projection[..i];
|
let borrow_proj_base = &borrow_place.projection[..i];
|
||||||
|
@ -1770,7 +1770,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||||||
if args.len() < sig.inputs().len() || (args.len() > sig.inputs().len() && !sig.c_variadic) {
|
if args.len() < sig.inputs().len() || (args.len() > sig.inputs().len() && !sig.c_variadic) {
|
||||||
span_mirbug!(self, term, "call to {:?} with wrong # of args", sig);
|
span_mirbug!(self, term, "call to {:?} with wrong # of args", sig);
|
||||||
}
|
}
|
||||||
for (n, (fn_arg, op_arg)) in sig.inputs().iter().zip(args).enumerate() {
|
for (n, (fn_arg, op_arg)) in iter::zip(sig.inputs(), args).enumerate() {
|
||||||
let op_arg_ty = op_arg.ty(body, self.tcx());
|
let op_arg_ty = op_arg.ty(body, self.tcx());
|
||||||
let op_arg_ty = self.normalize(op_arg_ty, term_location);
|
let op_arg_ty = self.normalize(op_arg_ty, term_location);
|
||||||
let category = if from_hir_call {
|
let category = if from_hir_call {
|
||||||
|
@ -580,7 +580,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
|
|||||||
|
|
||||||
let global_mapping = iter::once((tcx.lifetimes.re_static, fr_static));
|
let global_mapping = iter::once((tcx.lifetimes.re_static, fr_static));
|
||||||
let subst_mapping =
|
let subst_mapping =
|
||||||
identity_substs.regions().zip(fr_substs.regions().map(|r| r.to_region_vid()));
|
iter::zip(identity_substs.regions(), fr_substs.regions().map(|r| r.to_region_vid()));
|
||||||
|
|
||||||
UniversalRegionIndices { indices: global_mapping.chain(subst_mapping).collect() }
|
UniversalRegionIndices { indices: global_mapping.chain(subst_mapping).collect() }
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
|
|
||||||
use rustc_index::bit_set::BitSet;
|
use rustc_index::bit_set::BitSet;
|
||||||
use rustc_index::vec::{Idx, IndexVec};
|
use rustc_index::vec::{Idx, IndexVec};
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
/// A [partially ordered set][poset] that has a [least upper bound][lub] for any pair of elements
|
/// A [partially ordered set][poset] that has a [least upper bound][lub] for any pair of elements
|
||||||
/// in the set.
|
/// in the set.
|
||||||
@ -110,7 +111,7 @@ impl<I: Idx, T: JoinSemiLattice> JoinSemiLattice for IndexVec<I, T> {
|
|||||||
assert_eq!(self.len(), other.len());
|
assert_eq!(self.len(), other.len());
|
||||||
|
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
for (a, b) in self.iter_mut().zip(other.iter()) {
|
for (a, b) in iter::zip(self, other) {
|
||||||
changed |= a.join(b);
|
changed |= a.join(b);
|
||||||
}
|
}
|
||||||
changed
|
changed
|
||||||
@ -122,7 +123,7 @@ impl<I: Idx, T: MeetSemiLattice> MeetSemiLattice for IndexVec<I, T> {
|
|||||||
assert_eq!(self.len(), other.len());
|
assert_eq!(self.len(), other.len());
|
||||||
|
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
for (a, b) in self.iter_mut().zip(other.iter()) {
|
for (a, b) in iter::zip(self, other) {
|
||||||
changed |= a.meet(b);
|
changed |= a.meet(b);
|
||||||
}
|
}
|
||||||
changed
|
changed
|
||||||
|
@ -11,6 +11,7 @@ use crate::borrow_check::{
|
|||||||
use crate::dataflow::{self, fmt::DebugWithContext, GenKill};
|
use crate::dataflow::{self, fmt::DebugWithContext, GenKill};
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
rustc_index::newtype_index! {
|
rustc_index::newtype_index! {
|
||||||
pub struct BorrowIndex {
|
pub struct BorrowIndex {
|
||||||
@ -292,7 +293,7 @@ impl<'tcx> dataflow::GenKillAnalysis<'tcx> for Borrows<'_, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mir::StatementKind::LlvmInlineAsm(ref asm) => {
|
mir::StatementKind::LlvmInlineAsm(ref asm) => {
|
||||||
for (output, kind) in asm.outputs.iter().zip(&asm.asm.outputs) {
|
for (output, kind) in iter::zip(&*asm.outputs, &asm.asm.outputs) {
|
||||||
if !kind.is_indirect && !kind.is_rw {
|
if !kind.is_indirect && !kind.is_rw {
|
||||||
self.kill_borrows_on_place(trans, *output);
|
self.kill_borrows_on_place(trans, *output);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ use rustc_middle::mir::*;
|
|||||||
use rustc_middle::ty::{self, TyCtxt};
|
use rustc_middle::ty::{self, TyCtxt};
|
||||||
use smallvec::{smallvec, SmallVec};
|
use smallvec::{smallvec, SmallVec};
|
||||||
|
|
||||||
|
use std::iter;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
use super::abs_domain::Lift;
|
use super::abs_domain::Lift;
|
||||||
@ -296,7 +297,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
|
|||||||
self.create_move_path(**place);
|
self.create_move_path(**place);
|
||||||
}
|
}
|
||||||
StatementKind::LlvmInlineAsm(ref asm) => {
|
StatementKind::LlvmInlineAsm(ref asm) => {
|
||||||
for (output, kind) in asm.outputs.iter().zip(&asm.asm.outputs) {
|
for (output, kind) in iter::zip(&*asm.outputs, &asm.asm.outputs) {
|
||||||
if !kind.is_indirect {
|
if !kind.is_indirect {
|
||||||
self.gather_init(output.as_ref(), InitKind::Deep);
|
self.gather_init(output.as_ref(), InitKind::Deep);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ Rust MIR: a lowered representation of Rust.
|
|||||||
#![feature(decl_macro)]
|
#![feature(decl_macro)]
|
||||||
#![feature(exact_size_is_empty)]
|
#![feature(exact_size_is_empty)]
|
||||||
#![feature(exhaustive_patterns)]
|
#![feature(exhaustive_patterns)]
|
||||||
|
#![feature(iter_zip)]
|
||||||
#![feature(never_type)]
|
#![feature(never_type)]
|
||||||
#![feature(map_try_insert)]
|
#![feature(map_try_insert)]
|
||||||
#![feature(min_specialization)]
|
#![feature(min_specialization)]
|
||||||
|
@ -121,6 +121,7 @@ use rustc_middle::mir::coverage::*;
|
|||||||
use rustc_middle::mir::{self, BasicBlock, TerminatorKind};
|
use rustc_middle::mir::{self, BasicBlock, TerminatorKind};
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
|
|
||||||
|
use std::iter;
|
||||||
use std::lazy::SyncOnceCell;
|
use std::lazy::SyncOnceCell;
|
||||||
|
|
||||||
pub const NESTED_INDENT: &str = " ";
|
pub const NESTED_INDENT: &str = " ";
|
||||||
@ -703,9 +704,7 @@ pub(super) fn dump_coverage_graphviz(
|
|||||||
let edge_counters = from_terminator
|
let edge_counters = from_terminator
|
||||||
.successors()
|
.successors()
|
||||||
.map(|&successor_bb| graphviz_data.get_edge_counter(from_bcb, successor_bb));
|
.map(|&successor_bb| graphviz_data.get_edge_counter(from_bcb, successor_bb));
|
||||||
edge_labels
|
iter::zip(&edge_labels, edge_counters)
|
||||||
.iter()
|
|
||||||
.zip(edge_counters)
|
|
||||||
.map(|(label, some_counter)| {
|
.map(|(label, some_counter)| {
|
||||||
if let Some(counter) = some_counter {
|
if let Some(counter) = some_counter {
|
||||||
format!("{}\n{}", label, debug_counters.format_counter(counter))
|
format!("{}\n{}", label, debug_counters.format_counter(counter))
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//! This pass finds basic blocks that are completely equal,
|
//! This pass finds basic blocks that are completely equal,
|
||||||
//! and replaces all uses with just one of them.
|
//! and replaces all uses with just one of them.
|
||||||
|
|
||||||
use std::{collections::hash_map::Entry, hash::Hash, hash::Hasher};
|
use std::{collections::hash_map::Entry, hash::Hash, hash::Hasher, iter};
|
||||||
|
|
||||||
use crate::transform::MirPass;
|
use crate::transform::MirPass;
|
||||||
|
|
||||||
@ -115,11 +115,7 @@ impl<'tcx, 'a> PartialEq for BasicBlockHashable<'tcx, 'a> {
|
|||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
self.basic_block_data.statements.len() == other.basic_block_data.statements.len()
|
self.basic_block_data.statements.len() == other.basic_block_data.statements.len()
|
||||||
&& &self.basic_block_data.terminator().kind == &other.basic_block_data.terminator().kind
|
&& &self.basic_block_data.terminator().kind == &other.basic_block_data.terminator().kind
|
||||||
&& self
|
&& iter::zip(&self.basic_block_data.statements, &other.basic_block_data.statements)
|
||||||
.basic_block_data
|
|
||||||
.statements
|
|
||||||
.iter()
|
|
||||||
.zip(&other.basic_block_data.statements)
|
|
||||||
.all(|(x, y)| statement_eq(&x.kind, &y.kind))
|
.all(|(x, y)| statement_eq(&x.kind, &y.kind))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use crate::transform::MirPass;
|
use crate::transform::MirPass;
|
||||||
use rustc_middle::mir::*;
|
use rustc_middle::mir::*;
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
use super::simplify::simplify_cfg;
|
use super::simplify::simplify_cfg;
|
||||||
|
|
||||||
@ -83,7 +84,7 @@ impl<'tcx> MirPass<'tcx> for MatchBranchSimplification {
|
|||||||
if first_stmts.len() != scnd_stmts.len() {
|
if first_stmts.len() != scnd_stmts.len() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (f, s) in first_stmts.iter().zip(scnd_stmts.iter()) {
|
for (f, s) in iter::zip(first_stmts, scnd_stmts) {
|
||||||
match (&f.kind, &s.kind) {
|
match (&f.kind, &s.kind) {
|
||||||
// If two statements are exactly the same, we can optimize.
|
// If two statements are exactly the same, we can optimize.
|
||||||
(f_s, s_s) if f_s == s_s => {}
|
(f_s, s_s) if f_s == s_s => {}
|
||||||
@ -113,7 +114,7 @@ impl<'tcx> MirPass<'tcx> for MatchBranchSimplification {
|
|||||||
// and bb_idx has a different terminator from both of them.
|
// and bb_idx has a different terminator from both of them.
|
||||||
let (from, first, second) = bbs.pick3_mut(bb_idx, first, second);
|
let (from, first, second) = bbs.pick3_mut(bb_idx, first, second);
|
||||||
|
|
||||||
let new_stmts = first.statements.iter().zip(second.statements.iter()).map(|(f, s)| {
|
let new_stmts = iter::zip(&first.statements, &second.statements).map(|(f, s)| {
|
||||||
match (&f.kind, &s.kind) {
|
match (&f.kind, &s.kind) {
|
||||||
(f_s, s_s) if f_s == s_s => (*f).clone(),
|
(f_s, s_s) if f_s == s_s => (*f).clone(),
|
||||||
|
|
||||||
|
@ -17,6 +17,8 @@ use rustc_target::abi::VariantIdx;
|
|||||||
|
|
||||||
use rustc_index::vec::Idx;
|
use rustc_index::vec::Idx;
|
||||||
|
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
/// The "outermost" place that holds this value.
|
/// The "outermost" place that holds this value.
|
||||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
crate enum PlaceBase {
|
crate enum PlaceBase {
|
||||||
@ -140,7 +142,7 @@ fn is_ancestor_or_same_capture(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
proj_possible_ancestor.iter().zip(proj_capture).all(|(a, b)| a == b)
|
iter::zip(proj_possible_ancestor, proj_capture).all(|(a, b)| a == b)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Computes the index of a capture within the desugared closure provided the closure's
|
/// Computes the index of a capture within the desugared closure provided the closure's
|
||||||
|
@ -10,6 +10,7 @@ use rustc_hir as hir;
|
|||||||
use rustc_index::vec::Idx;
|
use rustc_index::vec::Idx;
|
||||||
use rustc_middle::mir::*;
|
use rustc_middle::mir::*;
|
||||||
use rustc_middle::ty::{self, CanonicalUserTypeAnnotation};
|
use rustc_middle::ty::{self, CanonicalUserTypeAnnotation};
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
impl<'a, 'tcx> Builder<'a, 'tcx> {
|
impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||||
/// Compile `expr`, storing the result into `destination`, which
|
/// Compile `expr`, storing the result into `destination`, which
|
||||||
@ -286,9 +287,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
// MIR does not natively support FRU, so for each
|
// MIR does not natively support FRU, so for each
|
||||||
// base-supplied field, generate an operand that
|
// base-supplied field, generate an operand that
|
||||||
// reads it from the base.
|
// reads it from the base.
|
||||||
field_names
|
iter::zip(field_names, *field_types)
|
||||||
.into_iter()
|
|
||||||
.zip(field_types.into_iter())
|
|
||||||
.map(|(n, ty)| match fields_map.get(&n) {
|
.map(|(n, ty)| match fields_map.get(&n) {
|
||||||
Some(v) => v.clone(),
|
Some(v) => v.clone(),
|
||||||
None => {
|
None => {
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#![feature(control_flow_enum)]
|
#![feature(control_flow_enum)]
|
||||||
#![feature(crate_visibility_modifier)]
|
#![feature(crate_visibility_modifier)]
|
||||||
#![feature(bool_to_option)]
|
#![feature(bool_to_option)]
|
||||||
|
#![feature(iter_zip)]
|
||||||
#![feature(once_cell)]
|
#![feature(once_cell)]
|
||||||
#![cfg_attr(bootstrap, feature(or_patterns))]
|
#![cfg_attr(bootstrap, feature(or_patterns))]
|
||||||
#![recursion_limit = "256"]
|
#![recursion_limit = "256"]
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#![feature(const_panic)]
|
#![feature(const_panic)]
|
||||||
#![feature(crate_visibility_modifier)]
|
#![feature(crate_visibility_modifier)]
|
||||||
#![feature(in_band_lifetimes)]
|
#![feature(in_band_lifetimes)]
|
||||||
|
#![feature(iter_zip)]
|
||||||
#![feature(nll)]
|
#![feature(nll)]
|
||||||
#![cfg_attr(bootstrap, feature(or_patterns))]
|
#![cfg_attr(bootstrap, feature(or_patterns))]
|
||||||
#![recursion_limit = "256"]
|
#![recursion_limit = "256"]
|
||||||
|
@ -103,6 +103,7 @@ use rustc_span::Span;
|
|||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
|
use std::iter;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
mod rwu_table;
|
mod rwu_table;
|
||||||
@ -1093,7 +1094,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||||||
let ia = &asm.inner;
|
let ia = &asm.inner;
|
||||||
let outputs = asm.outputs_exprs;
|
let outputs = asm.outputs_exprs;
|
||||||
let inputs = asm.inputs_exprs;
|
let inputs = asm.inputs_exprs;
|
||||||
let succ = ia.outputs.iter().zip(outputs).rev().fold(succ, |succ, (o, output)| {
|
let succ = iter::zip(&ia.outputs, outputs).rev().fold(succ, |succ, (o, output)| {
|
||||||
// see comment on places
|
// see comment on places
|
||||||
// in propagate_through_place_components()
|
// in propagate_through_place_components()
|
||||||
if o.is_indirect {
|
if o.is_indirect {
|
||||||
@ -1344,7 +1345,7 @@ fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr<'tcx>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Output operands must be places
|
// Output operands must be places
|
||||||
for (o, output) in asm.inner.outputs.iter().zip(asm.outputs_exprs) {
|
for (o, output) in iter::zip(&asm.inner.outputs, asm.outputs_exprs) {
|
||||||
if !o.is_indirect {
|
if !o.is_indirect {
|
||||||
this.check_place(output);
|
this.check_place(output);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use crate::liveness::{LiveNode, Variable};
|
use crate::liveness::{LiveNode, Variable};
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub(super) struct RWU {
|
pub(super) struct RWU {
|
||||||
@ -91,7 +92,7 @@ impl RWUTable {
|
|||||||
|
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
let (dst_row, src_row) = self.pick2_rows_mut(dst, src);
|
let (dst_row, src_row) = self.pick2_rows_mut(dst, src);
|
||||||
for (dst_word, src_word) in dst_row.iter_mut().zip(src_row.iter()) {
|
for (dst_word, src_word) in iter::zip(dst_row, &*src_row) {
|
||||||
let old = *dst_word;
|
let old = *dst_word;
|
||||||
let new = *dst_word | src_word;
|
let new = *dst_word | src_word;
|
||||||
*dst_word = new;
|
*dst_word = new;
|
||||||
|
@ -22,6 +22,7 @@ use rustc_span::symbol::{sym, Symbol};
|
|||||||
use rustc_span::{Span, DUMMY_SP};
|
use rustc_span::{Span, DUMMY_SP};
|
||||||
|
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
|
use std::iter;
|
||||||
use std::mem::replace;
|
use std::mem::replace;
|
||||||
use std::num::NonZeroU32;
|
use std::num::NonZeroU32;
|
||||||
|
|
||||||
@ -214,7 +215,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
|
|||||||
{
|
{
|
||||||
// Explicit version of iter::order::lt to handle parse errors properly
|
// Explicit version of iter::order::lt to handle parse errors properly
|
||||||
for (dep_v, stab_v) in
|
for (dep_v, stab_v) in
|
||||||
dep_since.as_str().split('.').zip(stab_since.as_str().split('.'))
|
iter::zip(dep_since.as_str().split('.'), stab_since.as_str().split('.'))
|
||||||
{
|
{
|
||||||
match stab_v.parse::<u64>() {
|
match stab_v.parse::<u64>() {
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#![feature(const_panic)]
|
#![feature(const_panic)]
|
||||||
#![feature(core_intrinsics)]
|
#![feature(core_intrinsics)]
|
||||||
#![feature(hash_raw_entry)]
|
#![feature(hash_raw_entry)]
|
||||||
|
#![feature(iter_zip)]
|
||||||
#![feature(min_specialization)]
|
#![feature(min_specialization)]
|
||||||
#![feature(stmt_expr_attributes)]
|
#![feature(stmt_expr_attributes)]
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ use {
|
|||||||
rustc_data_structures::{jobserver, OnDrop},
|
rustc_data_structures::{jobserver, OnDrop},
|
||||||
rustc_rayon_core as rayon_core,
|
rustc_rayon_core as rayon_core,
|
||||||
rustc_span::DUMMY_SP,
|
rustc_span::DUMMY_SP,
|
||||||
std::iter::FromIterator,
|
std::iter::{self, FromIterator},
|
||||||
std::{mem, process},
|
std::{mem, process},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -463,7 +463,7 @@ fn remove_cycle<D: DepKind>(
|
|||||||
spans.rotate_right(1);
|
spans.rotate_right(1);
|
||||||
|
|
||||||
// Zip them back together
|
// Zip them back together
|
||||||
let mut stack: Vec<_> = spans.into_iter().zip(queries).collect();
|
let mut stack: Vec<_> = iter::zip(spans, queries).collect();
|
||||||
|
|
||||||
// Remove the queries in our cycle from the list of jobs to look at
|
// Remove the queries in our cycle from the list of jobs to look at
|
||||||
for r in &stack {
|
for r in &stack {
|
||||||
|
@ -22,6 +22,8 @@ use rustc_span::lev_distance::find_best_match_for_name;
|
|||||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||||
use rustc_span::{BytePos, MultiSpan, Span, DUMMY_SP};
|
use rustc_span::{BytePos, MultiSpan, Span, DUMMY_SP};
|
||||||
|
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
type Res = def::Res<ast::NodeId>;
|
type Res = def::Res<ast::NodeId>;
|
||||||
@ -1004,9 +1006,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||||||
if let Some(spans) =
|
if let Some(spans) =
|
||||||
field_spans.filter(|spans| spans.len() > 0 && fields.len() == spans.len())
|
field_spans.filter(|spans| spans.len() > 0 && fields.len() == spans.len())
|
||||||
{
|
{
|
||||||
let non_visible_spans: Vec<Span> = fields
|
let non_visible_spans: Vec<Span> = iter::zip(&fields, &spans)
|
||||||
.iter()
|
|
||||||
.zip(spans.iter())
|
|
||||||
.filter(|(vis, _)| {
|
.filter(|(vis, _)| {
|
||||||
!self.r.is_accessible_from(**vis, self.parent_scope.module)
|
!self.r.is_accessible_from(**vis, self.parent_scope.module)
|
||||||
})
|
})
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#![feature(control_flow_enum)]
|
#![feature(control_flow_enum)]
|
||||||
#![feature(crate_visibility_modifier)]
|
#![feature(crate_visibility_modifier)]
|
||||||
#![feature(format_args_capture)]
|
#![feature(format_args_capture)]
|
||||||
|
#![feature(iter_zip)]
|
||||||
#![feature(nll)]
|
#![feature(nll)]
|
||||||
#![cfg_attr(bootstrap, feature(or_patterns))]
|
#![cfg_attr(bootstrap, feature(or_patterns))]
|
||||||
#![recursion_limit = "256"]
|
#![recursion_limit = "256"]
|
||||||
|
@ -413,7 +413,7 @@ pub fn update_dollar_crate_names(mut get_name: impl FnMut(SyntaxContext) -> Symb
|
|||||||
let names: Vec<_> =
|
let names: Vec<_> =
|
||||||
range_to_update.clone().map(|idx| get_name(SyntaxContext::from_u32(idx as u32))).collect();
|
range_to_update.clone().map(|idx| get_name(SyntaxContext::from_u32(idx as u32))).collect();
|
||||||
HygieneData::with(|data| {
|
HygieneData::with(|data| {
|
||||||
range_to_update.zip(names.into_iter()).for_each(|(idx, name)| {
|
range_to_update.zip(names).for_each(|(idx, name)| {
|
||||||
data.syntax_context_data[idx].dollar_crate_name = name;
|
data.syntax_context_data[idx].dollar_crate_name = name;
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#![feature(box_patterns)]
|
#![feature(box_patterns)]
|
||||||
#![feature(drain_filter)]
|
#![feature(drain_filter)]
|
||||||
#![feature(in_band_lifetimes)]
|
#![feature(in_band_lifetimes)]
|
||||||
|
#![feature(iter_zip)]
|
||||||
#![feature(never_type)]
|
#![feature(never_type)]
|
||||||
#![feature(crate_visibility_modifier)]
|
#![feature(crate_visibility_modifier)]
|
||||||
#![cfg_attr(bootstrap, feature(or_patterns))]
|
#![cfg_attr(bootstrap, feature(or_patterns))]
|
||||||
|
@ -12,6 +12,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
|||||||
|
|
||||||
use std::collections::hash_map::Entry;
|
use std::collections::hash_map::Entry;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
// FIXME(twk): this is obviously not nice to duplicate like that
|
// FIXME(twk): this is obviously not nice to duplicate like that
|
||||||
#[derive(Eq, PartialEq, Hash, Copy, Clone, Debug)]
|
#[derive(Eq, PartialEq, Hash, Copy, Clone, Debug)]
|
||||||
@ -428,7 +429,9 @@ impl AutoTraitFinder<'tcx> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (new_region, old_region) in new_substs.regions().zip(old_substs.regions()) {
|
for (new_region, old_region) in
|
||||||
|
iter::zip(new_substs.regions(), old_substs.regions())
|
||||||
|
{
|
||||||
match (new_region, old_region) {
|
match (new_region, old_region) {
|
||||||
// If both predicates have an `ReLateBound` (a HRTB) in the
|
// If both predicates have an `ReLateBound` (a HRTB) in the
|
||||||
// same spot, we do nothing.
|
// same spot, we do nothing.
|
||||||
|
@ -74,23 +74,22 @@ where
|
|||||||
let impl2_ref = tcx.impl_trait_ref(impl2_def_id);
|
let impl2_ref = tcx.impl_trait_ref(impl2_def_id);
|
||||||
|
|
||||||
// Check if any of the input types definitely do not unify.
|
// Check if any of the input types definitely do not unify.
|
||||||
if impl1_ref
|
if iter::zip(
|
||||||
.iter()
|
impl1_ref.iter().flat_map(|tref| tref.substs.types()),
|
||||||
.flat_map(|tref| tref.substs.types())
|
impl2_ref.iter().flat_map(|tref| tref.substs.types()),
|
||||||
.zip(impl2_ref.iter().flat_map(|tref| tref.substs.types()))
|
)
|
||||||
.any(|(ty1, ty2)| {
|
.any(|(ty1, ty2)| {
|
||||||
let t1 = fast_reject::simplify_type(tcx, ty1, false);
|
let t1 = fast_reject::simplify_type(tcx, ty1, false);
|
||||||
let t2 = fast_reject::simplify_type(tcx, ty2, false);
|
let t2 = fast_reject::simplify_type(tcx, ty2, false);
|
||||||
if let (Some(t1), Some(t2)) = (t1, t2) {
|
if let (Some(t1), Some(t2)) = (t1, t2) {
|
||||||
// Simplified successfully
|
// Simplified successfully
|
||||||
// Types cannot unify if they differ in their reference mutability or simplify to different types
|
// Types cannot unify if they differ in their reference mutability or simplify to different types
|
||||||
t1 != t2 || ty1.ref_mutability() != ty2.ref_mutability()
|
t1 != t2 || ty1.ref_mutability() != ty2.ref_mutability()
|
||||||
} else {
|
} else {
|
||||||
// Types might unify
|
// Types might unify
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
})
|
}) {
|
||||||
{
|
|
||||||
// Some types involved are definitely different, so the impls couldn't possibly overlap.
|
// Some types involved are definitely different, so the impls couldn't possibly overlap.
|
||||||
debug!("overlapping_impls: fast_reject early-exit");
|
debug!("overlapping_impls: fast_reject early-exit");
|
||||||
return no_overlap();
|
return no_overlap();
|
||||||
|
@ -23,6 +23,7 @@ use rustc_span::def_id::{DefId, LocalDefId};
|
|||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
|
use std::iter;
|
||||||
use std::ops::ControlFlow;
|
use std::ops::ControlFlow;
|
||||||
|
|
||||||
/// Check if a given constant can be evaluated.
|
/// Check if a given constant can be evaluated.
|
||||||
@ -672,9 +673,7 @@ pub(super) fn try_unify<'tcx>(
|
|||||||
if a_args.len() == b_args.len() =>
|
if a_args.len() == b_args.len() =>
|
||||||
{
|
{
|
||||||
try_unify(tcx, a.subtree(a_f), b.subtree(b_f))
|
try_unify(tcx, a.subtree(a_f), b.subtree(b_f))
|
||||||
&& a_args
|
&& iter::zip(a_args, b_args)
|
||||||
.iter()
|
|
||||||
.zip(b_args)
|
|
||||||
.all(|(&an, &bn)| try_unify(tcx, a.subtree(an), b.subtree(bn)))
|
.all(|(&an, &bn)| try_unify(tcx, a.subtree(an), b.subtree(bn)))
|
||||||
}
|
}
|
||||||
_ => false,
|
_ => false,
|
||||||
|
@ -28,6 +28,7 @@ use rustc_session::DiagnosticMessageId;
|
|||||||
use rustc_span::symbol::{kw, sym};
|
use rustc_span::symbol::{kw, sym};
|
||||||
use rustc_span::{ExpnKind, MultiSpan, Span, DUMMY_SP};
|
use rustc_span::{ExpnKind, MultiSpan, Span, DUMMY_SP};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
|
use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
|
||||||
use crate::traits::query::normalize::AtExt as _;
|
use crate::traits::query::normalize::AtExt as _;
|
||||||
@ -161,7 +162,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (error, suppressed) in errors.iter().zip(is_suppressed) {
|
for (error, suppressed) in iter::zip(errors, is_suppressed) {
|
||||||
if !suppressed {
|
if !suppressed {
|
||||||
self.report_fulfillment_error(error, body_id, fallback_has_occurred);
|
self.report_fulfillment_error(error, body_id, fallback_has_occurred);
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ use rustc_hir::def_id::DefId;
|
|||||||
use rustc_middle::ty::subst::Subst;
|
use rustc_middle::ty::subst::Subst;
|
||||||
use rustc_middle::ty::{self, GenericParamDefKind};
|
use rustc_middle::ty::{self, GenericParamDefKind};
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
use super::InferCtxtPrivExt;
|
use super::InferCtxtPrivExt;
|
||||||
|
|
||||||
@ -51,12 +52,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
if let Ok(..) = self.can_eq(param_env, trait_self_ty, impl_self_ty) {
|
if let Ok(..) = self.can_eq(param_env, trait_self_ty, impl_self_ty) {
|
||||||
self_match_impls.push(def_id);
|
self_match_impls.push(def_id);
|
||||||
|
|
||||||
if trait_ref
|
if iter::zip(
|
||||||
.substs
|
trait_ref.substs.types().skip(1),
|
||||||
.types()
|
impl_trait_ref.substs.types().skip(1),
|
||||||
.skip(1)
|
)
|
||||||
.zip(impl_trait_ref.substs.types().skip(1))
|
.all(|(u, v)| self.fuzzy_match_tys(u, v))
|
||||||
.all(|(u, v)| self.fuzzy_match_tys(u, v))
|
|
||||||
{
|
{
|
||||||
fuzzy_match_impls.push(def_id);
|
fuzzy_match_impls.push(def_id);
|
||||||
}
|
}
|
||||||
|
@ -1887,7 +1887,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
// substitution if we find that any of the input types, when
|
// substitution if we find that any of the input types, when
|
||||||
// simplified, do not match.
|
// simplified, do not match.
|
||||||
|
|
||||||
obligation.predicate.skip_binder().trait_ref.substs.iter().zip(impl_trait_ref.substs).any(
|
iter::zip(obligation.predicate.skip_binder().trait_ref.substs, impl_trait_ref.substs).any(
|
||||||
|(obligation_arg, impl_arg)| {
|
|(obligation_arg, impl_arg)| {
|
||||||
match (obligation_arg.unpack(), impl_arg.unpack()) {
|
match (obligation_arg.unpack(), impl_arg.unpack()) {
|
||||||
(GenericArgKind::Type(obligation_ty), GenericArgKind::Type(impl_ty)) => {
|
(GenericArgKind::Type(obligation_ty), GenericArgKind::Type(impl_ty)) => {
|
||||||
|
@ -692,11 +692,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
|||||||
let predicates = predicates.instantiate(self.infcx.tcx, substs);
|
let predicates = predicates.instantiate(self.infcx.tcx, substs);
|
||||||
debug_assert_eq!(predicates.predicates.len(), origins.len());
|
debug_assert_eq!(predicates.predicates.len(), origins.len());
|
||||||
|
|
||||||
predicates
|
iter::zip(iter::zip(predicates.predicates, predicates.spans), origins.into_iter().rev())
|
||||||
.predicates
|
|
||||||
.into_iter()
|
|
||||||
.zip(predicates.spans.into_iter())
|
|
||||||
.zip(origins.into_iter().rev())
|
|
||||||
.map(|((pred, span), origin_def_id)| {
|
.map(|((pred, span), origin_def_id)| {
|
||||||
let cause = self.cause(traits::BindingObligation(origin_def_id, span));
|
let cause = self.cause(traits::BindingObligation(origin_def_id, span));
|
||||||
traits::Obligation::with_depth(cause, self.recursion_depth, self.param_env, pred)
|
traits::Obligation::with_depth(cause, self.recursion_depth, self.param_env, pred)
|
||||||
|
@ -10,6 +10,7 @@ use rustc_span::symbol::{sym, Ident};
|
|||||||
use rustc_span::{Span, DUMMY_SP};
|
use rustc_span::{Span, DUMMY_SP};
|
||||||
|
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
/// On missing type parameters, emit an E0393 error and provide a structured suggestion using
|
/// On missing type parameters, emit an E0393 error and provide a structured suggestion using
|
||||||
@ -309,7 +310,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
// that the user forgot to give the associtated type's name. The canonical
|
// that the user forgot to give the associtated type's name. The canonical
|
||||||
// example would be trying to use `Iterator<isize>` instead of
|
// example would be trying to use `Iterator<isize>` instead of
|
||||||
// `Iterator<Item = isize>`.
|
// `Iterator<Item = isize>`.
|
||||||
for (potential, item) in potential_assoc_types.iter().zip(assoc_items.iter()) {
|
for (potential, item) in iter::zip(&potential_assoc_types, assoc_items) {
|
||||||
if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(*potential) {
|
if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(*potential) {
|
||||||
suggestions.push((*potential, format!("{} = {}", item.ident, snippet)));
|
suggestions.push((*potential, format!("{} = {}", item.ident, snippet)));
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ use rustc_span::symbol::{sym, Ident};
|
|||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
use rustc_target::spec::abi;
|
use rustc_target::spec::abi;
|
||||||
use rustc_trait_selection::autoderef::Autoderef;
|
use rustc_trait_selection::autoderef::Autoderef;
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
/// Checks that it is legal to call methods of the trait corresponding
|
/// Checks that it is legal to call methods of the trait corresponding
|
||||||
/// to `trait_id` (this only cares about the trait, not the specific
|
/// to `trait_id` (this only cares about the trait, not the specific
|
||||||
@ -539,7 +540,7 @@ impl<'a, 'tcx> DeferredCallResolution<'tcx> {
|
|||||||
debug!("attempt_resolution: method_callee={:?}", method_callee);
|
debug!("attempt_resolution: method_callee={:?}", method_callee);
|
||||||
|
|
||||||
for (method_arg_ty, self_arg_ty) in
|
for (method_arg_ty, self_arg_ty) in
|
||||||
method_sig.inputs().iter().skip(1).zip(self.fn_sig.inputs())
|
iter::zip(method_sig.inputs().iter().skip(1), self.fn_sig.inputs())
|
||||||
{
|
{
|
||||||
fcx.demand_eqtype(self.call_expr.span, &self_arg_ty, &method_arg_ty);
|
fcx.demand_eqtype(self.call_expr.span, &self_arg_ty, &method_arg_ty);
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ use rustc_trait_selection::opaque_types::InferCtxtExt as _;
|
|||||||
use rustc_trait_selection::traits::error_reporting::InferCtxtExt as _;
|
use rustc_trait_selection::traits::error_reporting::InferCtxtExt as _;
|
||||||
use rustc_trait_selection::traits::{self, ObligationCauseCode};
|
use rustc_trait_selection::traits::{self, ObligationCauseCode};
|
||||||
|
|
||||||
|
use std::iter;
|
||||||
use std::ops::ControlFlow;
|
use std::ops::ControlFlow;
|
||||||
|
|
||||||
pub fn check_wf_new(tcx: TyCtxt<'_>) {
|
pub fn check_wf_new(tcx: TyCtxt<'_>) {
|
||||||
@ -1472,7 +1473,7 @@ fn check_enum<'tcx>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut disr_vals: Vec<Discr<'tcx>> = Vec::with_capacity(vs.len());
|
let mut disr_vals: Vec<Discr<'tcx>> = Vec::with_capacity(vs.len());
|
||||||
for ((_, discr), v) in def.discriminants(tcx).zip(vs) {
|
for ((_, discr), v) in iter::zip(def.discriminants(tcx), vs) {
|
||||||
// Check for duplicate discriminant values
|
// Check for duplicate discriminant values
|
||||||
if let Some(i) = disr_vals.iter().position(|&x| x.val == discr.val) {
|
if let Some(i) = disr_vals.iter().position(|&x| x.val == discr.val) {
|
||||||
let variant_did = def.variants[VariantIdx::new(i)].def_id;
|
let variant_did = def.variants[VariantIdx::new(i)].def_id;
|
||||||
|
@ -492,13 +492,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
|
|
||||||
// The liberated version of this signature should be a subtype
|
// The liberated version of this signature should be a subtype
|
||||||
// of the liberated form of the expectation.
|
// of the liberated form of the expectation.
|
||||||
for ((hir_ty, &supplied_ty), expected_ty) in decl
|
for ((hir_ty, &supplied_ty), expected_ty) in iter::zip(
|
||||||
.inputs
|
iter::zip(
|
||||||
.iter()
|
decl.inputs,
|
||||||
.zip(supplied_sig.inputs().skip_binder()) // binder moved to (*) below
|
supplied_sig.inputs().skip_binder(), // binder moved to (*) below
|
||||||
.zip(expected_sigs.liberated_sig.inputs())
|
),
|
||||||
// `liberated_sig` is E'.
|
expected_sigs.liberated_sig.inputs(), // `liberated_sig` is E'.
|
||||||
{
|
) {
|
||||||
// Instantiate (this part of..) S to S', i.e., with fresh variables.
|
// Instantiate (this part of..) S to S', i.e., with fresh variables.
|
||||||
let (supplied_ty, _) = self.infcx.replace_bound_vars_with_fresh_vars(
|
let (supplied_ty, _) = self.infcx.replace_bound_vars_with_fresh_vars(
|
||||||
hir_ty.span,
|
hir_ty.span,
|
||||||
|
@ -14,6 +14,7 @@ use rustc_middle::ty::{GenericParamDefKind, ToPredicate, TyCtxt};
|
|||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
use rustc_trait_selection::traits::error_reporting::InferCtxtExt;
|
use rustc_trait_selection::traits::error_reporting::InferCtxtExt;
|
||||||
use rustc_trait_selection::traits::{self, ObligationCause, ObligationCauseCode, Reveal};
|
use rustc_trait_selection::traits::{self, ObligationCause, ObligationCauseCode, Reveal};
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
use super::{potentially_plural_count, FnCtxt, Inherited};
|
use super::{potentially_plural_count, FnCtxt, Inherited};
|
||||||
|
|
||||||
@ -410,8 +411,7 @@ fn extract_spans_for_error_reporting<'a, 'tcx>(
|
|||||||
_ => bug!("{:?} is not a TraitItemKind::Fn", trait_m),
|
_ => bug!("{:?} is not a TraitItemKind::Fn", trait_m),
|
||||||
};
|
};
|
||||||
|
|
||||||
impl_m_iter
|
iter::zip(impl_m_iter, trait_m_iter)
|
||||||
.zip(trait_m_iter)
|
|
||||||
.find(|&(ref impl_arg, ref trait_arg)| {
|
.find(|&(ref impl_arg, ref trait_arg)| {
|
||||||
match (&impl_arg.kind, &trait_arg.kind) {
|
match (&impl_arg.kind, &trait_arg.kind) {
|
||||||
(
|
(
|
||||||
@ -443,11 +443,8 @@ fn extract_spans_for_error_reporting<'a, 'tcx>(
|
|||||||
|
|
||||||
let impl_iter = impl_sig.inputs().iter();
|
let impl_iter = impl_sig.inputs().iter();
|
||||||
let trait_iter = trait_sig.inputs().iter();
|
let trait_iter = trait_sig.inputs().iter();
|
||||||
impl_iter
|
iter::zip(iter::zip(impl_iter, trait_iter), iter::zip(impl_m_iter, trait_m_iter))
|
||||||
.zip(trait_iter)
|
.find_map(|((&impl_arg_ty, &trait_arg_ty), (impl_arg, trait_arg))| match infcx
|
||||||
.zip(impl_m_iter)
|
|
||||||
.zip(trait_m_iter)
|
|
||||||
.find_map(|(((&impl_arg_ty, &trait_arg_ty), impl_arg), trait_arg)| match infcx
|
|
||||||
.at(&cause, param_env)
|
.at(&cause, param_env)
|
||||||
.sub(trait_arg_ty, impl_arg_ty)
|
.sub(trait_arg_ty, impl_arg_ty)
|
||||||
{
|
{
|
||||||
@ -799,7 +796,7 @@ fn compare_synthetic_generics<'tcx>(
|
|||||||
GenericParamDefKind::Lifetime | GenericParamDefKind::Const { .. } => None,
|
GenericParamDefKind::Lifetime | GenericParamDefKind::Const { .. } => None,
|
||||||
});
|
});
|
||||||
for ((impl_def_id, impl_synthetic), (trait_def_id, trait_synthetic)) in
|
for ((impl_def_id, impl_synthetic), (trait_def_id, trait_synthetic)) in
|
||||||
impl_m_type_params.zip(trait_m_type_params)
|
iter::zip(impl_m_type_params, trait_m_type_params)
|
||||||
{
|
{
|
||||||
if impl_synthetic != trait_synthetic {
|
if impl_synthetic != trait_synthetic {
|
||||||
let impl_hir_id = tcx.hir().local_def_id_to_hir_id(impl_def_id.expect_local());
|
let impl_hir_id = tcx.hir().local_def_id_to_hir_id(impl_def_id.expect_local());
|
||||||
|
@ -42,6 +42,7 @@ use rustc_trait_selection::traits::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use std::collections::hash_map::Entry;
|
use std::collections::hash_map::Entry;
|
||||||
|
use std::iter;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
|
|
||||||
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
@ -1146,7 +1147,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
(
|
(
|
||||||
hir::ItemKind::OpaqueTy(hir::OpaqueTy { bounds: last_bounds, .. }),
|
hir::ItemKind::OpaqueTy(hir::OpaqueTy { bounds: last_bounds, .. }),
|
||||||
hir::ItemKind::OpaqueTy(hir::OpaqueTy { bounds: exp_bounds, .. }),
|
hir::ItemKind::OpaqueTy(hir::OpaqueTy { bounds: exp_bounds, .. }),
|
||||||
) if last_bounds.iter().zip(exp_bounds.iter()).all(|(left, right)| {
|
) if iter::zip(*last_bounds, *exp_bounds).all(|(left, right)| {
|
||||||
match (left, right) {
|
match (left, right) {
|
||||||
(
|
(
|
||||||
hir::GenericBound::Trait(tl, ml),
|
hir::GenericBound::Trait(tl, ml),
|
||||||
|
@ -23,6 +23,7 @@ use rustc_span::{self, MultiSpan, Span};
|
|||||||
use rustc_trait_selection::traits::{self, ObligationCauseCode, StatementAsExpression};
|
use rustc_trait_selection::traits::{self, ObligationCauseCode, StatementAsExpression};
|
||||||
|
|
||||||
use crate::structured_errors::StructuredDiagnostic;
|
use crate::structured_errors::StructuredDiagnostic;
|
||||||
|
use std::iter;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
|
|
||||||
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
@ -108,7 +109,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
|
|
||||||
// All the input types from the fn signature must outlive the call
|
// All the input types from the fn signature must outlive the call
|
||||||
// so as to validate implied bounds.
|
// so as to validate implied bounds.
|
||||||
for (&fn_input_ty, arg_expr) in fn_inputs.iter().zip(args.iter()) {
|
for (&fn_input_ty, arg_expr) in iter::zip(fn_inputs, args) {
|
||||||
self.register_wf_obligation(fn_input_ty.into(), arg_expr.span, traits::MiscObligation);
|
self.register_wf_obligation(fn_input_ty.into(), arg_expr.span, traits::MiscObligation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,8 +218,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
self.is_hir_id_from_struct_pattern_shorthand_field(expr.hir_id, expr.span);
|
self.is_hir_id_from_struct_pattern_shorthand_field(expr.hir_id, expr.span);
|
||||||
let methods = self.get_conversion_methods(expr.span, expected, found, expr.hir_id);
|
let methods = self.get_conversion_methods(expr.span, expected, found, expr.hir_id);
|
||||||
if let Ok(expr_text) = self.sess().source_map().span_to_snippet(expr.span) {
|
if let Ok(expr_text) = self.sess().source_map().span_to_snippet(expr.span) {
|
||||||
let mut suggestions = iter::repeat(&expr_text)
|
let mut suggestions = iter::zip(iter::repeat(&expr_text), &methods)
|
||||||
.zip(methods.iter())
|
|
||||||
.filter_map(|(receiver, method)| {
|
.filter_map(|(receiver, method)| {
|
||||||
let method_call = format!(".{}()", method.ident);
|
let method_call = format!(".{}()", method.ident);
|
||||||
if receiver.ends_with(&method_call) {
|
if receiver.ends_with(&method_call) {
|
||||||
|
@ -15,6 +15,7 @@ use rustc_middle::ty::{self, GenericParamDefKind, Ty};
|
|||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
use rustc_trait_selection::traits;
|
use rustc_trait_selection::traits;
|
||||||
|
|
||||||
|
use std::iter;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
struct ConfirmContext<'a, 'tcx> {
|
struct ConfirmContext<'a, 'tcx> {
|
||||||
@ -496,10 +497,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
|
|||||||
// We don't care about regions here.
|
// We don't care about regions here.
|
||||||
.filter_map(|obligation| match obligation.predicate.kind().skip_binder() {
|
.filter_map(|obligation| match obligation.predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(trait_pred, _) if trait_pred.def_id() == sized_def_id => {
|
ty::PredicateKind::Trait(trait_pred, _) if trait_pred.def_id() == sized_def_id => {
|
||||||
let span = predicates
|
let span = iter::zip(&predicates.predicates, &predicates.spans)
|
||||||
.predicates
|
|
||||||
.iter()
|
|
||||||
.zip(predicates.spans.iter())
|
|
||||||
.find_map(
|
.find_map(
|
||||||
|(p, span)| {
|
|(p, span)| {
|
||||||
if *p == obligation.predicate { Some(*span) } else { None }
|
if *p == obligation.predicate { Some(*span) } else { None }
|
||||||
|
@ -49,6 +49,8 @@ use rustc_span::{MultiSpan, Span, Symbol};
|
|||||||
use rustc_index::vec::Idx;
|
use rustc_index::vec::Idx;
|
||||||
use rustc_target::abi::VariantIdx;
|
use rustc_target::abi::VariantIdx;
|
||||||
|
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
/// Describe the relationship between the paths of two places
|
/// Describe the relationship between the paths of two places
|
||||||
/// eg:
|
/// eg:
|
||||||
/// - `foo` is ancestor of `foo.bar.baz`
|
/// - `foo` is ancestor of `foo.bar.baz`
|
||||||
@ -1631,7 +1633,7 @@ fn determine_place_ancestry_relation(
|
|||||||
let projections_b = &place_b.projections;
|
let projections_b = &place_b.projections;
|
||||||
|
|
||||||
let same_initial_projections =
|
let same_initial_projections =
|
||||||
projections_a.iter().zip(projections_b.iter()).all(|(proj_a, proj_b)| proj_a == proj_b);
|
iter::zip(projections_a, projections_b).all(|(proj_a, proj_b)| proj_a == proj_b);
|
||||||
|
|
||||||
if same_initial_projections {
|
if same_initial_projections {
|
||||||
// First min(n, m) projections are the same
|
// First min(n, m) projections are the same
|
||||||
|
@ -24,6 +24,7 @@ use rustc_trait_selection::opaque_types::may_define_opaque_type;
|
|||||||
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
|
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
|
||||||
use rustc_trait_selection::traits::{self, ObligationCause, ObligationCauseCode};
|
use rustc_trait_selection::traits::{self, ObligationCause, ObligationCauseCode};
|
||||||
|
|
||||||
|
use std::iter;
|
||||||
use std::ops::ControlFlow;
|
use std::ops::ControlFlow;
|
||||||
|
|
||||||
/// Helper type of a temporary returned by `.for_item(...)`.
|
/// Helper type of a temporary returned by `.for_item(...)`.
|
||||||
@ -863,7 +864,7 @@ fn check_where_clauses<'tcx, 'fcx>(
|
|||||||
debug!("check_where_clauses: predicates={:?}", predicates.predicates);
|
debug!("check_where_clauses: predicates={:?}", predicates.predicates);
|
||||||
assert_eq!(predicates.predicates.len(), predicates.spans.len());
|
assert_eq!(predicates.predicates.len(), predicates.spans.len());
|
||||||
let wf_obligations =
|
let wf_obligations =
|
||||||
predicates.predicates.iter().zip(predicates.spans.iter()).flat_map(|(&p, &sp)| {
|
iter::zip(&predicates.predicates, &predicates.spans).flat_map(|(&p, &sp)| {
|
||||||
traits::wf::predicate_obligations(fcx, fcx.param_env, fcx.body_id, p, sp)
|
traits::wf::predicate_obligations(fcx, fcx.param_env, fcx.body_id, p, sp)
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -885,8 +886,8 @@ fn check_fn_or_method<'fcx, 'tcx>(
|
|||||||
let sig = fcx.normalize_associated_types_in(span, sig);
|
let sig = fcx.normalize_associated_types_in(span, sig);
|
||||||
let sig = fcx.tcx.liberate_late_bound_regions(def_id, sig);
|
let sig = fcx.tcx.liberate_late_bound_regions(def_id, sig);
|
||||||
|
|
||||||
for (&input_ty, span) in sig.inputs().iter().zip(hir_decl.inputs.iter().map(|t| t.span)) {
|
for (&input_ty, ty) in iter::zip(sig.inputs(), hir_decl.inputs) {
|
||||||
fcx.register_wf_obligation(input_ty.into(), span, ObligationCauseCode::MiscObligation);
|
fcx.register_wf_obligation(input_ty.into(), ty.span, ObligationCauseCode::MiscObligation);
|
||||||
}
|
}
|
||||||
implied_bounds.extend(sig.inputs());
|
implied_bounds.extend(sig.inputs());
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
|||||||
use rustc_span::{Span, DUMMY_SP};
|
use rustc_span::{Span, DUMMY_SP};
|
||||||
use rustc_target::spec::abi;
|
use rustc_target::spec::abi;
|
||||||
use rustc_trait_selection::traits::error_reporting::suggestions::NextTypeParamName;
|
use rustc_trait_selection::traits::error_reporting::suggestions::NextTypeParamName;
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
mod item_bounds;
|
mod item_bounds;
|
||||||
mod type_of;
|
mod type_of;
|
||||||
@ -2439,7 +2440,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>(
|
|||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
for (input, ty) in decl.inputs.iter().zip(fty.inputs().skip_binder()) {
|
for (input, ty) in iter::zip(decl.inputs, fty.inputs().skip_binder()) {
|
||||||
check(&input, ty)
|
check(&input, ty)
|
||||||
}
|
}
|
||||||
if let hir::FnRetTy::Return(ref ty) = decl.output {
|
if let hir::FnRetTy::Return(ref ty) = decl.output {
|
||||||
|
@ -18,6 +18,7 @@ use rustc_middle::hir::place::ProjectionKind;
|
|||||||
use rustc_middle::mir::FakeReadCause;
|
use rustc_middle::mir::FakeReadCause;
|
||||||
use rustc_middle::ty::{self, adjustment, TyCtxt};
|
use rustc_middle::ty::{self, adjustment, TyCtxt};
|
||||||
use rustc_target::abi::VariantIdx;
|
use rustc_target::abi::VariantIdx;
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
use crate::mem_categorization as mc;
|
use crate::mem_categorization as mc;
|
||||||
|
|
||||||
@ -333,7 +334,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hir::ExprKind::LlvmInlineAsm(ref ia) => {
|
hir::ExprKind::LlvmInlineAsm(ref ia) => {
|
||||||
for (o, output) in ia.inner.outputs.iter().zip(ia.outputs_exprs) {
|
for (o, output) in iter::zip(&ia.inner.outputs, ia.outputs_exprs) {
|
||||||
if o.is_indirect {
|
if o.is_indirect {
|
||||||
self.consume_expr(output);
|
self.consume_expr(output);
|
||||||
} else {
|
} else {
|
||||||
|
@ -63,6 +63,7 @@ This API is completely unstable and subject to change.
|
|||||||
#![feature(format_args_capture)]
|
#![feature(format_args_capture)]
|
||||||
#![feature(in_band_lifetimes)]
|
#![feature(in_band_lifetimes)]
|
||||||
#![feature(is_sorted)]
|
#![feature(is_sorted)]
|
||||||
|
#![feature(iter_zip)]
|
||||||
#![feature(nll)]
|
#![feature(nll)]
|
||||||
#![cfg_attr(bootstrap, feature(or_patterns))]
|
#![cfg_attr(bootstrap, feature(or_patterns))]
|
||||||
#![feature(try_blocks)]
|
#![feature(try_blocks)]
|
||||||
|
Loading…
Reference in New Issue
Block a user