mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Merge #10691
10691: minor: Use array `into_iter` in more places r=lnicola a=lnicola bors r+ Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
This commit is contained in:
commit
c96481e25f
5 changed files with 8 additions and 11 deletions
|
@ -21,8 +21,7 @@ pub(super) fn parse_intra_doc_link(s: &str) -> (&str, Option<hir::Namespace>) {
|
||||||
(hir::Namespace::Values, (VALUES.0.iter(), VALUES.1.iter())),
|
(hir::Namespace::Values, (VALUES.0.iter(), VALUES.1.iter())),
|
||||||
(hir::Namespace::Macros, (MACROS.0.iter(), MACROS.1.iter())),
|
(hir::Namespace::Macros, (MACROS.0.iter(), MACROS.1.iter())),
|
||||||
]
|
]
|
||||||
.iter()
|
.into_iter()
|
||||||
.cloned()
|
|
||||||
.find_map(|(ns, (mut prefixes, mut suffixes))| {
|
.find_map(|(ns, (mut prefixes, mut suffixes))| {
|
||||||
if let Some(prefix) = prefixes.find(|&&prefix| {
|
if let Some(prefix) = prefixes.find(|&&prefix| {
|
||||||
s.starts_with(prefix)
|
s.starts_with(prefix)
|
||||||
|
@ -42,8 +41,7 @@ pub(super) fn strip_prefixes_suffixes(s: &str) -> &str {
|
||||||
(VALUES.0.iter(), VALUES.1.iter()),
|
(VALUES.0.iter(), VALUES.1.iter()),
|
||||||
(MACROS.0.iter(), MACROS.1.iter()),
|
(MACROS.0.iter(), MACROS.1.iter()),
|
||||||
]
|
]
|
||||||
.iter()
|
.into_iter()
|
||||||
.cloned()
|
|
||||||
.find_map(|(mut prefixes, mut suffixes)| {
|
.find_map(|(mut prefixes, mut suffixes)| {
|
||||||
if let Some(prefix) = prefixes.find(|&&prefix| {
|
if let Some(prefix) = prefixes.find(|&&prefix| {
|
||||||
s.starts_with(prefix)
|
s.starts_with(prefix)
|
||||||
|
|
|
@ -226,7 +226,7 @@ fn find_imported_defs(ctx: &AssistContext, star: SyntaxToken) -> Option<Vec<Def>
|
||||||
|
|
||||||
Some(
|
Some(
|
||||||
[Direction::Prev, Direction::Next]
|
[Direction::Prev, Direction::Next]
|
||||||
.iter()
|
.into_iter()
|
||||||
.flat_map(|dir| {
|
.flat_map(|dir| {
|
||||||
parent_use_item_syntax
|
parent_use_item_syntax
|
||||||
.siblings(dir.to_owned())
|
.siblings(dir.to_owned())
|
||||||
|
|
|
@ -105,7 +105,7 @@ fn generate_lint_descriptor(buf: &mut String) {
|
||||||
|
|
||||||
fn generate_feature_descriptor(buf: &mut String, src_dir: &Path) {
|
fn generate_feature_descriptor(buf: &mut String, src_dir: &Path) {
|
||||||
let mut features = ["language-features", "library-features"]
|
let mut features = ["language-features", "library-features"]
|
||||||
.iter()
|
.into_iter()
|
||||||
.flat_map(|it| sourcegen::list_files(&src_dir.join(it)))
|
.flat_map(|it| sourcegen::list_files(&src_dir.join(it)))
|
||||||
.filter(|path| {
|
.filter(|path| {
|
||||||
// Get all `.md ` files
|
// Get all `.md ` files
|
||||||
|
|
|
@ -43,8 +43,7 @@ impl Sysroot {
|
||||||
// core is added as a dependency before std in order to
|
// core is added as a dependency before std in order to
|
||||||
// mimic rustcs dependency order
|
// mimic rustcs dependency order
|
||||||
["core", "alloc", "std"]
|
["core", "alloc", "std"]
|
||||||
.iter()
|
.into_iter()
|
||||||
.copied()
|
|
||||||
.zip(iter::repeat(true))
|
.zip(iter::repeat(true))
|
||||||
.chain(iter::once(("test", false)))
|
.chain(iter::once(("test", false)))
|
||||||
.filter_map(move |(name, prelude)| Some((name, self.by_name(name)?, prelude)))
|
.filter_map(move |(name, prelude)| Some((name, self.by_name(name)?, prelude)))
|
||||||
|
@ -78,7 +77,7 @@ impl Sysroot {
|
||||||
for path in SYSROOT_CRATES.trim().lines() {
|
for path in SYSROOT_CRATES.trim().lines() {
|
||||||
let name = path.split('/').last().unwrap();
|
let name = path.split('/').last().unwrap();
|
||||||
let root = [format!("{}/src/lib.rs", path), format!("lib{}/lib.rs", path)]
|
let root = [format!("{}/src/lib.rs", path), format!("lib{}/lib.rs", path)]
|
||||||
.iter()
|
.into_iter()
|
||||||
.map(|it| sysroot.root.join(it))
|
.map(|it| sysroot.root.join(it))
|
||||||
.filter_map(|it| ManifestPath::try_from(it).ok())
|
.filter_map(|it| ManifestPath::try_from(it).ok())
|
||||||
.find(|it| fs::metadata(it).is_ok());
|
.find(|it| fs::metadata(it).is_ok());
|
||||||
|
|
|
@ -212,8 +212,8 @@ impl Server {
|
||||||
if req.method == "client/registerCapability" {
|
if req.method == "client/registerCapability" {
|
||||||
let params = req.params.to_string();
|
let params = req.params.to_string();
|
||||||
if ["workspace/didChangeWatchedFiles", "textDocument/didSave"]
|
if ["workspace/didChangeWatchedFiles", "textDocument/didSave"]
|
||||||
.iter()
|
.into_iter()
|
||||||
.any(|&it| params.contains(it))
|
.any(|it| params.contains(it))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue