Use IntoIterator for array impl everywhere.
This commit is contained in:
parent
b34cf1a9e1
commit
1acb44f03c
21 changed files with 41 additions and 50 deletions
|
@ -70,10 +70,9 @@ use smallvec::SmallVec;
|
||||||
use tracing::{debug, trace};
|
use tracing::{debug, trace};
|
||||||
|
|
||||||
macro_rules! arena_vec {
|
macro_rules! arena_vec {
|
||||||
($this:expr; $($x:expr),*) => ({
|
($this:expr; $($x:expr),*) => (
|
||||||
let a = [$($x),*];
|
$this.arena.alloc_from_iter([$($x),*])
|
||||||
$this.arena.alloc_from_iter(std::array::IntoIter::new(a))
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mod asm;
|
mod asm;
|
||||||
|
|
|
@ -42,7 +42,7 @@ fn main() {
|
||||||
"RUSTFLAGS",
|
"RUSTFLAGS",
|
||||||
env::var("RUSTFLAGS").unwrap_or(String::new()) + " -Cprefer-dynamic",
|
env::var("RUSTFLAGS").unwrap_or(String::new()) + " -Cprefer-dynamic",
|
||||||
);
|
);
|
||||||
std::array::IntoIter::new(["rustc".to_string()])
|
IntoIterator::into_iter(["rustc".to_string()])
|
||||||
.chain(env::args().skip(2))
|
.chain(env::args().skip(2))
|
||||||
.chain([
|
.chain([
|
||||||
"--".to_string(),
|
"--".to_string(),
|
||||||
|
@ -56,7 +56,7 @@ fn main() {
|
||||||
"RUSTFLAGS",
|
"RUSTFLAGS",
|
||||||
env::var("RUSTFLAGS").unwrap_or(String::new()) + " -Cprefer-dynamic",
|
env::var("RUSTFLAGS").unwrap_or(String::new()) + " -Cprefer-dynamic",
|
||||||
);
|
);
|
||||||
std::array::IntoIter::new(["rustc".to_string()])
|
IntoIterator::into_iter(["rustc".to_string()])
|
||||||
.chain(env::args().skip(2))
|
.chain(env::args().skip(2))
|
||||||
.chain([
|
.chain([
|
||||||
"--".to_string(),
|
"--".to_string(),
|
||||||
|
|
|
@ -466,13 +466,12 @@ impl server::TokenStream for Rustc<'_, '_> {
|
||||||
ast::ExprKind::Unary(ast::UnOp::Neg, e) => match &e.kind {
|
ast::ExprKind::Unary(ast::UnOp::Neg, e) => match &e.kind {
|
||||||
ast::ExprKind::Lit(l) => match l.token {
|
ast::ExprKind::Lit(l) => match l.token {
|
||||||
token::Lit { kind: token::Integer | token::Float, .. } => {
|
token::Lit { kind: token::Integer | token::Float, .. } => {
|
||||||
Ok(std::array::IntoIter::new([
|
Ok(Self::TokenStream::from_iter([
|
||||||
// FIXME: The span of the `-` token is lost when
|
// FIXME: The span of the `-` token is lost when
|
||||||
// parsing, so we cannot faithfully recover it here.
|
// parsing, so we cannot faithfully recover it here.
|
||||||
tokenstream::TokenTree::token(token::BinOp(token::Minus), e.span),
|
tokenstream::TokenTree::token(token::BinOp(token::Minus), e.span),
|
||||||
tokenstream::TokenTree::token(token::Literal(l.token), l.span),
|
tokenstream::TokenTree::token(token::Literal(l.token), l.span),
|
||||||
])
|
]))
|
||||||
.collect())
|
|
||||||
}
|
}
|
||||||
_ => Err(()),
|
_ => Err(()),
|
||||||
},
|
},
|
||||||
|
|
|
@ -443,11 +443,11 @@ impl<T> PerNS<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn into_iter(self) -> IntoIter<T, 3> {
|
pub fn into_iter(self) -> IntoIter<T, 3> {
|
||||||
IntoIter::new([self.value_ns, self.type_ns, self.macro_ns])
|
[self.value_ns, self.type_ns, self.macro_ns].into_iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter(&self) -> IntoIter<&T, 3> {
|
pub fn iter(&self) -> IntoIter<&T, 3> {
|
||||||
IntoIter::new([&self.value_ns, &self.type_ns, &self.macro_ns])
|
[&self.value_ns, &self.type_ns, &self.macro_ns].into_iter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,7 +481,7 @@ impl<T> PerNS<Option<T>> {
|
||||||
|
|
||||||
/// Returns an iterator over the items which are `Some`.
|
/// Returns an iterator over the items which are `Some`.
|
||||||
pub fn present_items(self) -> impl Iterator<Item = T> {
|
pub fn present_items(self) -> impl Iterator<Item = T> {
|
||||||
IntoIter::new([self.type_ns, self.value_ns, self.macro_ns]).flatten()
|
[self.type_ns, self.value_ns, self.macro_ns].into_iter().flatten()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ pub use self::FileMatch::*;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
use std::iter::FromIterator;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use crate::search_paths::{PathKind, SearchPath, SearchPathFile};
|
use crate::search_paths::{PathKind, SearchPath, SearchPathFile};
|
||||||
|
@ -91,8 +92,7 @@ impl<'a> FileSearch<'a> {
|
||||||
|
|
||||||
pub fn make_target_lib_path(sysroot: &Path, target_triple: &str) -> PathBuf {
|
pub fn make_target_lib_path(sysroot: &Path, target_triple: &str) -> PathBuf {
|
||||||
let rustlib_path = rustc_target::target_rustlib_path(sysroot, target_triple);
|
let rustlib_path = rustc_target::target_rustlib_path(sysroot, target_triple);
|
||||||
std::array::IntoIter::new([sysroot, Path::new(&rustlib_path), Path::new("lib")])
|
PathBuf::from_iter([sysroot, Path::new(&rustlib_path), Path::new("lib")])
|
||||||
.collect::<PathBuf>()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This function checks if sysroot is found using env::args().next(), and if it
|
/// This function checks if sysroot is found using env::args().next(), and if it
|
||||||
|
|
|
@ -795,12 +795,11 @@ impl Session {
|
||||||
/// Returns a list of directories where target-specific tool binaries are located.
|
/// Returns a list of directories where target-specific tool binaries are located.
|
||||||
pub fn get_tools_search_paths(&self, self_contained: bool) -> Vec<PathBuf> {
|
pub fn get_tools_search_paths(&self, self_contained: bool) -> Vec<PathBuf> {
|
||||||
let rustlib_path = rustc_target::target_rustlib_path(&self.sysroot, &config::host_triple());
|
let rustlib_path = rustc_target::target_rustlib_path(&self.sysroot, &config::host_triple());
|
||||||
let p = std::array::IntoIter::new([
|
let p = PathBuf::from_iter([
|
||||||
Path::new(&self.sysroot),
|
Path::new(&self.sysroot),
|
||||||
Path::new(&rustlib_path),
|
Path::new(&rustlib_path),
|
||||||
Path::new("bin"),
|
Path::new("bin"),
|
||||||
])
|
]);
|
||||||
.collect::<PathBuf>();
|
|
||||||
if self_contained { vec![p.clone(), p.join("self-contained")] } else { vec![p] }
|
if self_contained { vec![p.clone(), p.join("self-contained")] } else { vec![p] }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#![feature(min_specialization)]
|
#![feature(min_specialization)]
|
||||||
#![feature(step_trait)]
|
#![feature(step_trait)]
|
||||||
|
|
||||||
|
use std::iter::FromIterator;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -47,12 +48,11 @@ const RUST_LIB_DIR: &str = "rustlib";
|
||||||
/// `"lib*/rustlib/x86_64-unknown-linux-gnu"`.
|
/// `"lib*/rustlib/x86_64-unknown-linux-gnu"`.
|
||||||
pub fn target_rustlib_path(sysroot: &Path, target_triple: &str) -> PathBuf {
|
pub fn target_rustlib_path(sysroot: &Path, target_triple: &str) -> PathBuf {
|
||||||
let libdir = find_libdir(sysroot);
|
let libdir = find_libdir(sysroot);
|
||||||
std::array::IntoIter::new([
|
PathBuf::from_iter([
|
||||||
Path::new(libdir.as_ref()),
|
Path::new(libdir.as_ref()),
|
||||||
Path::new(RUST_LIB_DIR),
|
Path::new(RUST_LIB_DIR),
|
||||||
Path::new(target_triple),
|
Path::new(target_triple),
|
||||||
])
|
])
|
||||||
.collect::<PathBuf>()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The name of the directory rustc expects libraries to be located.
|
/// The name of the directory rustc expects libraries to be located.
|
||||||
|
|
|
@ -42,6 +42,7 @@ use rustc_serialize::json::{Json, ToJson};
|
||||||
use rustc_span::symbol::{sym, Symbol};
|
use rustc_span::symbol::{sym, Symbol};
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
|
use std::iter::FromIterator;
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
@ -2173,12 +2174,11 @@ impl Target {
|
||||||
// Additionally look in the sysroot under `lib/rustlib/<triple>/target.json`
|
// Additionally look in the sysroot under `lib/rustlib/<triple>/target.json`
|
||||||
// as a fallback.
|
// as a fallback.
|
||||||
let rustlib_path = crate::target_rustlib_path(&sysroot, &target_triple);
|
let rustlib_path = crate::target_rustlib_path(&sysroot, &target_triple);
|
||||||
let p = std::array::IntoIter::new([
|
let p = PathBuf::from_iter([
|
||||||
Path::new(sysroot),
|
Path::new(sysroot),
|
||||||
Path::new(&rustlib_path),
|
Path::new(&rustlib_path),
|
||||||
Path::new("target.json"),
|
Path::new("target.json"),
|
||||||
])
|
]);
|
||||||
.collect::<PathBuf>();
|
|
||||||
if p.is_file() {
|
if p.is_file() {
|
||||||
return load_file(&p);
|
return load_file(&p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ use rustc_span::symbol::Symbol;
|
||||||
use rustc_span::{MultiSpan, Span};
|
use rustc_span::{MultiSpan, Span};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
use std::array;
|
|
||||||
use std::iter;
|
use std::iter;
|
||||||
use std::ops::ControlFlow;
|
use std::ops::ControlFlow;
|
||||||
|
|
||||||
|
@ -692,11 +691,8 @@ fn receiver_is_dispatchable<'tcx>(
|
||||||
.to_predicate(tcx)
|
.to_predicate(tcx)
|
||||||
};
|
};
|
||||||
|
|
||||||
let caller_bounds: Vec<Predicate<'tcx>> = param_env
|
let caller_bounds: Vec<Predicate<'tcx>> =
|
||||||
.caller_bounds()
|
param_env.caller_bounds().iter().chain([unsize_predicate, trait_predicate]).collect();
|
||||||
.iter()
|
|
||||||
.chain(array::IntoIter::new([unsize_predicate, trait_predicate]))
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
ty::ParamEnv::new(tcx.intern_predicates(&caller_bounds), param_env.reveal())
|
ty::ParamEnv::new(tcx.intern_predicates(&caller_bounds), param_env.reveal())
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,7 +35,6 @@ use rustc_trait_selection::traits::error_reporting::report_object_safety_error;
|
||||||
use rustc_trait_selection::traits::wf::object_region_bounds;
|
use rustc_trait_selection::traits::wf::object_region_bounds;
|
||||||
|
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::array;
|
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
|
|
||||||
|
@ -1635,7 +1634,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
debug!("one_bound_for_assoc_type: bound2 = {:?}", bound2);
|
debug!("one_bound_for_assoc_type: bound2 = {:?}", bound2);
|
||||||
|
|
||||||
let is_equality = is_equality();
|
let is_equality = is_equality();
|
||||||
let bounds = array::IntoIter::new([bound, bound2]).chain(matching_candidates);
|
let bounds = IntoIterator::into_iter([bound, bound2]).chain(matching_candidates);
|
||||||
let mut err = if is_equality.is_some() {
|
let mut err = if is_equality.is_some() {
|
||||||
// More specific Error Index entry.
|
// More specific Error Index entry.
|
||||||
struct_span_err!(
|
struct_span_err!(
|
||||||
|
|
|
@ -1822,7 +1822,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// Inherent impl: take implied bounds from the `self` type.
|
// Inherent impl: take implied bounds from the `self` type.
|
||||||
let self_ty = self.tcx.type_of(impl_def_id);
|
let self_ty = self.tcx.type_of(impl_def_id);
|
||||||
let self_ty = self.normalize_associated_types_in(span, self_ty);
|
let self_ty = self.normalize_associated_types_in(span, self_ty);
|
||||||
std::array::IntoIter::new([self_ty]).collect()
|
FxHashSet::from_iter([self_ty])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1500,7 +1500,7 @@ impl<T: Ord, const N: usize> From<[T; N]> for BinaryHeap<T> {
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
fn from(arr: [T; N]) -> Self {
|
fn from(arr: [T; N]) -> Self {
|
||||||
core::array::IntoIter::new(arr).collect()
|
Self::from_iter(arr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1305,11 +1305,11 @@ impl<K, V> BTreeMap<K, V> {
|
||||||
pub(crate) fn bulk_build_from_sorted_iter<I>(iter: I) -> Self
|
pub(crate) fn bulk_build_from_sorted_iter<I>(iter: I) -> Self
|
||||||
where
|
where
|
||||||
K: Ord,
|
K: Ord,
|
||||||
I: Iterator<Item = (K, V)>,
|
I: IntoIterator<Item = (K, V)>,
|
||||||
{
|
{
|
||||||
let mut root = Root::new();
|
let mut root = Root::new();
|
||||||
let mut length = 0;
|
let mut length = 0;
|
||||||
root.bulk_push(DedupSortedIter::new(iter), &mut length);
|
root.bulk_push(DedupSortedIter::new(iter.into_iter()), &mut length);
|
||||||
BTreeMap { root: Some(root), length }
|
BTreeMap { root: Some(root), length }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1944,7 +1944,7 @@ impl<K: Ord, V> FromIterator<(K, V)> for BTreeMap<K, V> {
|
||||||
|
|
||||||
// use stable sort to preserve the insertion order.
|
// use stable sort to preserve the insertion order.
|
||||||
inputs.sort_by(|a, b| a.0.cmp(&b.0));
|
inputs.sort_by(|a, b| a.0.cmp(&b.0));
|
||||||
BTreeMap::bulk_build_from_sorted_iter(inputs.into_iter())
|
BTreeMap::bulk_build_from_sorted_iter(inputs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2061,7 +2061,7 @@ impl<K: Ord, V, const N: usize> From<[(K, V); N]> for BTreeMap<K, V> {
|
||||||
|
|
||||||
// use stable sort to preserve the insertion order.
|
// use stable sort to preserve the insertion order.
|
||||||
arr.sort_by(|a, b| a.0.cmp(&b.0));
|
arr.sort_by(|a, b| a.0.cmp(&b.0));
|
||||||
BTreeMap::bulk_build_from_sorted_iter(core::array::IntoIter::new(arr))
|
BTreeMap::bulk_build_from_sorted_iter(arr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1106,7 +1106,7 @@ impl<T: Ord, const N: usize> From<[T; N]> for BTreeSet<T> {
|
||||||
|
|
||||||
// use stable sort to preserve the insertion order.
|
// use stable sort to preserve the insertion order.
|
||||||
arr.sort();
|
arr.sort();
|
||||||
let iter = core::array::IntoIter::new(arr).map(|k| (k, ()));
|
let iter = IntoIterator::into_iter(arr).map(|k| (k, ()));
|
||||||
let map = BTreeMap::bulk_build_from_sorted_iter(iter);
|
let map = BTreeMap::bulk_build_from_sorted_iter(iter);
|
||||||
BTreeSet { map }
|
BTreeSet { map }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1961,7 +1961,7 @@ impl<T, const N: usize> From<[T; N]> for LinkedList<T> {
|
||||||
/// assert_eq!(list1, list2);
|
/// assert_eq!(list1, list2);
|
||||||
/// ```
|
/// ```
|
||||||
fn from(arr: [T; N]) -> Self {
|
fn from(arr: [T; N]) -> Self {
|
||||||
core::array::IntoIter::new(arr).collect()
|
Self::from_iter(arr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use super::*;
|
use super::*;
|
||||||
use core::array;
|
|
||||||
use core::iter::*;
|
use core::iter::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -134,7 +133,7 @@ fn test_double_ended_flatten() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_trusted_len_flatten() {
|
fn test_trusted_len_flatten() {
|
||||||
fn assert_trusted_len<T: TrustedLen>(_: &T) {}
|
fn assert_trusted_len<T: TrustedLen>(_: &T) {}
|
||||||
let mut iter = array::IntoIter::new([[0; 3]; 4]).flatten();
|
let mut iter = IntoIterator::into_iter([[0; 3]; 4]).flatten();
|
||||||
assert_trusted_len(&iter);
|
assert_trusted_len(&iter);
|
||||||
|
|
||||||
assert_eq!(iter.size_hint(), (12, Some(12)));
|
assert_eq!(iter.size_hint(), (12, Some(12)));
|
||||||
|
@ -143,21 +142,21 @@ fn test_trusted_len_flatten() {
|
||||||
iter.next_back();
|
iter.next_back();
|
||||||
assert_eq!(iter.size_hint(), (10, Some(10)));
|
assert_eq!(iter.size_hint(), (10, Some(10)));
|
||||||
|
|
||||||
let iter = array::IntoIter::new([[(); usize::MAX]; 1]).flatten();
|
let iter = IntoIterator::into_iter([[(); usize::MAX]; 1]).flatten();
|
||||||
assert_eq!(iter.size_hint(), (usize::MAX, Some(usize::MAX)));
|
assert_eq!(iter.size_hint(), (usize::MAX, Some(usize::MAX)));
|
||||||
|
|
||||||
let iter = array::IntoIter::new([[(); usize::MAX]; 2]).flatten();
|
let iter = IntoIterator::into_iter([[(); usize::MAX]; 2]).flatten();
|
||||||
assert_eq!(iter.size_hint(), (usize::MAX, None));
|
assert_eq!(iter.size_hint(), (usize::MAX, None));
|
||||||
|
|
||||||
let mut a = [(); 10];
|
let mut a = [(); 10];
|
||||||
let mut b = [(); 10];
|
let mut b = [(); 10];
|
||||||
|
|
||||||
let iter = array::IntoIter::new([&mut a, &mut b]).flatten();
|
let iter = IntoIterator::into_iter([&mut a, &mut b]).flatten();
|
||||||
assert_trusted_len(&iter);
|
assert_trusted_len(&iter);
|
||||||
assert_eq!(iter.size_hint(), (20, Some(20)));
|
assert_eq!(iter.size_hint(), (20, Some(20)));
|
||||||
core::mem::drop(iter);
|
core::mem::drop(iter);
|
||||||
|
|
||||||
let iter = array::IntoIter::new([&a, &b]).flatten();
|
let iter = IntoIterator::into_iter([&a, &b]).flatten();
|
||||||
assert_trusted_len(&iter);
|
assert_trusted_len(&iter);
|
||||||
assert_eq!(iter.size_hint(), (20, Some(20)));
|
assert_eq!(iter.size_hint(), (20, Some(20)));
|
||||||
|
|
||||||
|
|
|
@ -1186,7 +1186,7 @@ where
|
||||||
/// assert_eq!(map1, map2);
|
/// assert_eq!(map1, map2);
|
||||||
/// ```
|
/// ```
|
||||||
fn from(arr: [(K, V); N]) -> Self {
|
fn from(arr: [(K, V); N]) -> Self {
|
||||||
crate::array::IntoIter::new(arr).collect()
|
Self::from_iter(arr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1022,7 +1022,7 @@ where
|
||||||
/// assert_eq!(set1, set2);
|
/// assert_eq!(set1, set2);
|
||||||
/// ```
|
/// ```
|
||||||
fn from(arr: [T; N]) -> Self {
|
fn from(arr: [T; N]) -> Self {
|
||||||
crate::array::IntoIter::new(arr).collect()
|
Self::from_iter(arr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1043,7 +1043,7 @@ impl Build {
|
||||||
options[1] = Some(format!("-Clink-arg=-Wl,{}", threads));
|
options[1] = Some(format!("-Clink-arg=-Wl,{}", threads));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array::IntoIter::new(options).flatten()
|
IntoIterator::into_iter(options).flatten()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns if this target should statically link the C runtime, if specified
|
/// Returns if this target should statically link the C runtime, if specified
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#![crate_type = "proc-macro"]
|
#![crate_type = "proc-macro"]
|
||||||
|
|
||||||
extern crate proc_macro;
|
extern crate proc_macro;
|
||||||
|
use std::iter::FromIterator;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use proc_macro::*;
|
use proc_macro::*;
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@ pub fn custom_quote(input: TokenStream) -> TokenStream {
|
||||||
let set_span_method = TokenStream::from_str("ident.set_span").unwrap();
|
let set_span_method = TokenStream::from_str("ident.set_span").unwrap();
|
||||||
let set_span_arg = TokenStream::from(TokenTree::Group(Group::new(Delimiter::Parenthesis, quoted_span)));
|
let set_span_arg = TokenStream::from(TokenTree::Group(Group::new(Delimiter::Parenthesis, quoted_span)));
|
||||||
let suffix = TokenStream::from_str(";proc_macro::TokenStream::from(proc_macro::TokenTree::Ident(ident))").unwrap();
|
let suffix = TokenStream::from_str(";proc_macro::TokenStream::from(proc_macro::TokenTree::Ident(ident))").unwrap();
|
||||||
let full_stream: TokenStream = std::array::IntoIter::new([prefix, set_span_method, set_span_arg, suffix]).collect();
|
let full_stream = TokenStream::from_iter([prefix, set_span_method, set_span_arg, suffix]);
|
||||||
full_stream
|
full_stream
|
||||||
}
|
}
|
||||||
_ => unreachable!()
|
_ => unreachable!()
|
||||||
|
|
|
@ -13,7 +13,6 @@ use clippy_utils::{
|
||||||
remove_blocks, strip_pat_refs,
|
remove_blocks, strip_pat_refs,
|
||||||
};
|
};
|
||||||
use clippy_utils::{paths, search_same, SpanlessEq, SpanlessHash};
|
use clippy_utils::{paths, search_same, SpanlessEq, SpanlessHash};
|
||||||
use core::array;
|
|
||||||
use core::iter::{once, ExactSizeIterator};
|
use core::iter::{once, ExactSizeIterator};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_ast::ast::{Attribute, LitKind};
|
use rustc_ast::ast::{Attribute, LitKind};
|
||||||
|
@ -1306,7 +1305,7 @@ fn check_match_like_matches<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>)
|
||||||
return find_matches_sugg(
|
return find_matches_sugg(
|
||||||
cx,
|
cx,
|
||||||
let_expr,
|
let_expr,
|
||||||
array::IntoIter::new([(&[][..], Some(let_pat), if_then, None), (&[][..], None, if_else, None)]),
|
IntoIterator::into_iter([(&[][..], Some(let_pat), if_then, None), (&[][..], None, if_else, None)]),
|
||||||
expr,
|
expr,
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue