mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-16 17:58:16 +00:00
Merge #9741
9741: minor: Replace useless types r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
commit
bcc3241c9e
3 changed files with 7 additions and 7 deletions
|
@ -86,7 +86,7 @@ pub(crate) fn replace_if_let_with_match(acc: &mut Assists, ctx: &AssistContext)
|
||||||
target,
|
target,
|
||||||
move |edit| {
|
move |edit| {
|
||||||
let match_expr = {
|
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 make_match_arm = |(pat, body): (_, ast::BlockExpr)| {
|
||||||
let body = body.reset_indent().indent(IndentLevel(1));
|
let body = body.reset_indent().indent(IndentLevel(1));
|
||||||
match pat {
|
match pat {
|
||||||
|
@ -119,12 +119,12 @@ pub(crate) fn replace_if_let_with_match(acc: &mut Assists, ctx: &AssistContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_else_arm(
|
fn make_else_arm(
|
||||||
else_block: Option<ast::BlockExpr>,
|
|
||||||
cond_bodies: &Vec<(Either<ast::Pat, ast::Expr>, ast::BlockExpr)>,
|
|
||||||
ctx: &AssistContext,
|
ctx: &AssistContext,
|
||||||
|
else_block: Option<ast::BlockExpr>,
|
||||||
|
conditionals: &[(Either<ast::Pat, ast::Expr>, ast::BlockExpr)],
|
||||||
) -> ast::MatchArm {
|
) -> ast::MatchArm {
|
||||||
if let Some(else_block) = else_block {
|
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
|
ctx.sema
|
||||||
.type_of_pat(&pat)
|
.type_of_pat(&pat)
|
||||||
.and_then(|ty| TryEnum::from_ty(&ctx.sema, &ty))
|
.and_then(|ty| TryEnum::from_ty(&ctx.sema, &ty))
|
||||||
|
|
|
@ -34,8 +34,8 @@ impl UsageSearchResult {
|
||||||
self.references.len()
|
self.references.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter(&self) -> impl Iterator<Item = (&FileId, &Vec<FileReference>)> + '_ {
|
pub fn iter(&self) -> impl Iterator<Item = (&FileId, &[FileReference])> + '_ {
|
||||||
self.references.iter()
|
self.references.iter().map(|(file_id, refs)| (file_id, &**refs))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn file_ranges(&self) -> impl Iterator<Item = FileRange> + '_ {
|
pub fn file_ranges(&self) -> impl Iterator<Item = FileRange> + '_ {
|
||||||
|
|
|
@ -218,7 +218,7 @@ mod vec_token_tree {
|
||||||
use super::{TokenTree, TokenTreeDef};
|
use super::{TokenTree, TokenTreeDef};
|
||||||
use serde::{ser::SerializeSeq, Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{ser::SerializeSeq, Deserialize, Deserializer, Serialize, Serializer};
|
||||||
|
|
||||||
pub(super) fn serialize<S>(value: &Vec<TokenTree>, serializer: S) -> Result<S::Ok, S::Error>
|
pub(super) fn serialize<S>(value: &[TokenTree], serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: Serializer,
|
S: Serializer,
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue