Enable clippy::unnecessary_filter_map
(#8738)
This PR enables the [`clippy::unnecessary_filter_map`](https://rust-lang.github.io/rust-clippy/master/index.html#/unnecessary_filter_map) rule and fixes the outstanding violations. Release Notes: - N/A
This commit is contained in:
parent
a17c207217
commit
f79f56f8b4
7 changed files with 34 additions and 46 deletions
|
@ -1634,22 +1634,20 @@ impl Conversation {
|
||||||
let messages = self
|
let messages = self
|
||||||
.messages(cx)
|
.messages(cx)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|message| {
|
.map(|message| tiktoken_rs::ChatCompletionRequestMessage {
|
||||||
Some(tiktoken_rs::ChatCompletionRequestMessage {
|
role: match message.role {
|
||||||
role: match message.role {
|
Role::User => "user".into(),
|
||||||
Role::User => "user".into(),
|
Role::Assistant => "assistant".into(),
|
||||||
Role::Assistant => "assistant".into(),
|
Role::System => "system".into(),
|
||||||
Role::System => "system".into(),
|
},
|
||||||
},
|
content: Some(
|
||||||
content: Some(
|
self.buffer
|
||||||
self.buffer
|
.read(cx)
|
||||||
.read(cx)
|
.text_for_range(message.offset_range)
|
||||||
.text_for_range(message.offset_range)
|
.collect(),
|
||||||
.collect(),
|
),
|
||||||
),
|
name: None,
|
||||||
name: None,
|
function_call: None,
|
||||||
function_call: None,
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let model = self.model;
|
let model = self.model;
|
||||||
|
|
|
@ -839,12 +839,10 @@ impl ChannelStore {
|
||||||
Ok(users
|
Ok(users
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.zip(response.members)
|
.zip(response.members)
|
||||||
.filter_map(|(user, member)| {
|
.map(|(user, member)| ChannelMembership {
|
||||||
Some(ChannelMembership {
|
user,
|
||||||
user,
|
role: member.role(),
|
||||||
role: member.role(),
|
kind: member.kind(),
|
||||||
kind: member.kind(),
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.collect())
|
.collect())
|
||||||
})
|
})
|
||||||
|
|
|
@ -529,10 +529,7 @@ impl Database {
|
||||||
.all(&*tx)
|
.all(&*tx)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let channels = channels
|
let channels = channels.into_iter().map(Channel::from_model).collect();
|
||||||
.into_iter()
|
|
||||||
.filter_map(|channel| Some(Channel::from_model(channel)))
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
Ok(channels)
|
Ok(channels)
|
||||||
})
|
})
|
||||||
|
|
|
@ -441,17 +441,13 @@ impl CollabPanel {
|
||||||
// Populate remote participants.
|
// Populate remote participants.
|
||||||
self.match_candidates.clear();
|
self.match_candidates.clear();
|
||||||
self.match_candidates
|
self.match_candidates
|
||||||
.extend(
|
.extend(room.remote_participants().values().map(|participant| {
|
||||||
room.remote_participants()
|
StringMatchCandidate {
|
||||||
.iter()
|
id: participant.user.id as usize,
|
||||||
.filter_map(|(_, participant)| {
|
string: participant.user.github_login.clone(),
|
||||||
Some(StringMatchCandidate {
|
char_bag: participant.user.github_login.chars().collect(),
|
||||||
id: participant.user.id as usize,
|
}
|
||||||
string: participant.user.github_login.clone(),
|
}));
|
||||||
char_bag: participant.user.github_login.chars().collect(),
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
let mut matches = executor.block(match_strings(
|
let mut matches = executor.block(match_strings(
|
||||||
&self.match_candidates,
|
&self.match_candidates,
|
||||||
&query,
|
&query,
|
||||||
|
|
|
@ -3172,7 +3172,7 @@ impl MultiBufferSnapshot {
|
||||||
let buffer_hunks = excerpt
|
let buffer_hunks = excerpt
|
||||||
.buffer
|
.buffer
|
||||||
.git_diff_hunks_intersecting_range_rev(buffer_start..buffer_end)
|
.git_diff_hunks_intersecting_range_rev(buffer_start..buffer_end)
|
||||||
.filter_map(move |hunk| {
|
.map(move |hunk| {
|
||||||
let start = multibuffer_start.row
|
let start = multibuffer_start.row
|
||||||
+ hunk
|
+ hunk
|
||||||
.buffer_range
|
.buffer_range
|
||||||
|
@ -3185,10 +3185,10 @@ impl MultiBufferSnapshot {
|
||||||
.min(excerpt_end_point.row + 1)
|
.min(excerpt_end_point.row + 1)
|
||||||
.saturating_sub(excerpt_start_point.row);
|
.saturating_sub(excerpt_start_point.row);
|
||||||
|
|
||||||
Some(DiffHunk {
|
DiffHunk {
|
||||||
buffer_range: start..end,
|
buffer_range: start..end,
|
||||||
diff_base_byte_range: hunk.diff_base_byte_range.clone(),
|
diff_base_byte_range: hunk.diff_base_byte_range.clone(),
|
||||||
})
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cursor.prev(&());
|
cursor.prev(&());
|
||||||
|
@ -3234,7 +3234,7 @@ impl MultiBufferSnapshot {
|
||||||
let buffer_hunks = excerpt
|
let buffer_hunks = excerpt
|
||||||
.buffer
|
.buffer
|
||||||
.git_diff_hunks_intersecting_range(buffer_start..buffer_end)
|
.git_diff_hunks_intersecting_range(buffer_start..buffer_end)
|
||||||
.filter_map(move |hunk| {
|
.map(move |hunk| {
|
||||||
let start = multibuffer_start.row
|
let start = multibuffer_start.row
|
||||||
+ hunk
|
+ hunk
|
||||||
.buffer_range
|
.buffer_range
|
||||||
|
@ -3247,10 +3247,10 @@ impl MultiBufferSnapshot {
|
||||||
.min(excerpt_end_point.row + 1)
|
.min(excerpt_end_point.row + 1)
|
||||||
.saturating_sub(excerpt_start_point.row);
|
.saturating_sub(excerpt_start_point.row);
|
||||||
|
|
||||||
Some(DiffHunk {
|
DiffHunk {
|
||||||
buffer_range: start..end,
|
buffer_range: start..end,
|
||||||
diff_base_byte_range: hunk.diff_base_byte_range.clone(),
|
diff_base_byte_range: hunk.diff_base_byte_range.clone(),
|
||||||
})
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cursor.next(&());
|
cursor.next(&());
|
||||||
|
|
|
@ -184,7 +184,7 @@ pub async fn handle_cli_connection(
|
||||||
} else {
|
} else {
|
||||||
paths
|
paths
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|path_with_position_string| {
|
.map(|path_with_position_string| {
|
||||||
let path_with_position = PathLikeWithPosition::parse_str(
|
let path_with_position = PathLikeWithPosition::parse_str(
|
||||||
&path_with_position_string,
|
&path_with_position_string,
|
||||||
|path_str| {
|
|path_str| {
|
||||||
|
@ -203,7 +203,7 @@ pub async fn handle_cli_connection(
|
||||||
caret_positions.insert(path.clone(), Point::new(row, col));
|
caret_positions.insert(path.clone(), Point::new(row, col));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(path)
|
path
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
};
|
};
|
||||||
|
|
|
@ -124,7 +124,6 @@ fn run_clippy(args: ClippyArgs) -> Result<()> {
|
||||||
"clippy::suspicious_to_owned",
|
"clippy::suspicious_to_owned",
|
||||||
"clippy::type_complexity",
|
"clippy::type_complexity",
|
||||||
"clippy::unit_arg",
|
"clippy::unit_arg",
|
||||||
"clippy::unnecessary_filter_map",
|
|
||||||
"clippy::unnecessary_find_map",
|
"clippy::unnecessary_find_map",
|
||||||
"clippy::unnecessary_operation",
|
"clippy::unnecessary_operation",
|
||||||
"clippy::unnecessary_to_owned",
|
"clippy::unnecessary_to_owned",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue