From 7c7c4543da5678deb91ade4e688fe242522a2562 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sat, 31 Jul 2021 14:29:15 +0200 Subject: [PATCH] Replace useless types --- .../ide_assists/src/handlers/replace_if_let_with_match.rs | 8 ++++---- crates/ide_db/src/search.rs | 4 ++-- crates/proc_macro_api/src/rpc.rs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/ide_assists/src/handlers/replace_if_let_with_match.rs b/crates/ide_assists/src/handlers/replace_if_let_with_match.rs index 4c201aee6a..25a9e71502 100644 --- a/crates/ide_assists/src/handlers/replace_if_let_with_match.rs +++ b/crates/ide_assists/src/handlers/replace_if_let_with_match.rs @@ -86,7 +86,7 @@ pub(crate) fn replace_if_let_with_match(acc: &mut Assists, ctx: &AssistContext) target, move |edit| { let match_expr = { - let else_arm = make_else_arm(else_block, &cond_bodies, ctx); + let else_arm = make_else_arm(ctx, else_block, &cond_bodies); let make_match_arm = |(pat, body): (_, ast::BlockExpr)| { let body = body.reset_indent().indent(IndentLevel(1)); match pat { @@ -119,12 +119,12 @@ pub(crate) fn replace_if_let_with_match(acc: &mut Assists, ctx: &AssistContext) } fn make_else_arm( - else_block: Option, - cond_bodies: &Vec<(Either, ast::BlockExpr)>, ctx: &AssistContext, + else_block: Option, + conditionals: &[(Either, ast::BlockExpr)], ) -> ast::MatchArm { if let Some(else_block) = else_block { - let pattern = if let [(Either::Left(pat), _)] = &**cond_bodies { + let pattern = if let [(Either::Left(pat), _)] = conditionals { ctx.sema .type_of_pat(&pat) .and_then(|ty| TryEnum::from_ty(&ctx.sema, &ty)) diff --git a/crates/ide_db/src/search.rs b/crates/ide_db/src/search.rs index 41254b7847..980abae93c 100644 --- a/crates/ide_db/src/search.rs +++ b/crates/ide_db/src/search.rs @@ -34,8 +34,8 @@ impl UsageSearchResult { self.references.len() } - pub fn iter(&self) -> impl Iterator)> + '_ { - self.references.iter() + pub fn iter(&self) -> impl Iterator + '_ { + self.references.iter().map(|(file_id, refs)| (file_id, &**refs)) } pub fn file_ranges(&self) -> impl Iterator + '_ { diff --git a/crates/proc_macro_api/src/rpc.rs b/crates/proc_macro_api/src/rpc.rs index d56136196e..9fc220cf3f 100644 --- a/crates/proc_macro_api/src/rpc.rs +++ b/crates/proc_macro_api/src/rpc.rs @@ -218,7 +218,7 @@ mod vec_token_tree { use super::{TokenTree, TokenTreeDef}; use serde::{ser::SerializeSeq, Deserialize, Deserializer, Serialize, Serializer}; - pub(super) fn serialize(value: &Vec, serializer: S) -> Result + pub(super) fn serialize(value: &[TokenTree], serializer: S) -> Result where S: Serializer, {