Fix clippy::println_empty_string
, clippy::while_let_on_iterator
, clippy::while_let_on_iterator
lint style violations (#36613)
Related: #36577 Release Notes: - N/A
This commit is contained in:
parent
41e28a7185
commit
ec8106d1db
20 changed files with 35 additions and 32 deletions
|
@ -904,6 +904,7 @@ ok_expect = "warn"
|
||||||
owned_cow = "warn"
|
owned_cow = "warn"
|
||||||
print_literal = "warn"
|
print_literal = "warn"
|
||||||
print_with_newline = "warn"
|
print_with_newline = "warn"
|
||||||
|
println_empty_string = "warn"
|
||||||
ptr_eq = "warn"
|
ptr_eq = "warn"
|
||||||
question_mark = "warn"
|
question_mark = "warn"
|
||||||
redundant_closure = "warn"
|
redundant_closure = "warn"
|
||||||
|
@ -924,7 +925,9 @@ unneeded_struct_pattern = "warn"
|
||||||
unsafe_removed_from_name = "warn"
|
unsafe_removed_from_name = "warn"
|
||||||
unused_unit = "warn"
|
unused_unit = "warn"
|
||||||
unusual_byte_groupings = "warn"
|
unusual_byte_groupings = "warn"
|
||||||
|
while_let_on_iterator = "warn"
|
||||||
write_literal = "warn"
|
write_literal = "warn"
|
||||||
|
write_with_newline = "warn"
|
||||||
writeln_empty_string = "warn"
|
writeln_empty_string = "warn"
|
||||||
wrong_self_convention = "warn"
|
wrong_self_convention = "warn"
|
||||||
zero_ptr = "warn"
|
zero_ptr = "warn"
|
||||||
|
|
|
@ -362,7 +362,7 @@ impl Display for DirectoryContext {
|
||||||
let mut is_first = true;
|
let mut is_first = true;
|
||||||
for descendant in &self.descendants {
|
for descendant in &self.descendants {
|
||||||
if !is_first {
|
if !is_first {
|
||||||
write!(f, "\n")?;
|
writeln!(f)?;
|
||||||
} else {
|
} else {
|
||||||
is_first = false;
|
is_first = false;
|
||||||
}
|
}
|
||||||
|
@ -650,7 +650,7 @@ impl TextThreadContextHandle {
|
||||||
impl Display for TextThreadContext {
|
impl Display for TextThreadContext {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||||
// TODO: escape title?
|
// TODO: escape title?
|
||||||
write!(f, "<text_thread title=\"{}\">\n", self.title)?;
|
writeln!(f, "<text_thread title=\"{}\">", self.title)?;
|
||||||
write!(f, "{}", self.text.trim())?;
|
write!(f, "{}", self.text.trim())?;
|
||||||
write!(f, "\n</text_thread>")
|
write!(f, "\n</text_thread>")
|
||||||
}
|
}
|
||||||
|
@ -716,7 +716,7 @@ impl RulesContextHandle {
|
||||||
impl Display for RulesContext {
|
impl Display for RulesContext {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
if let Some(title) = &self.title {
|
if let Some(title) = &self.title {
|
||||||
write!(f, "Rules title: {}\n", title)?;
|
writeln!(f, "Rules title: {}", title)?;
|
||||||
}
|
}
|
||||||
let code_block = MarkdownCodeBlock {
|
let code_block = MarkdownCodeBlock {
|
||||||
tag: "",
|
tag: "",
|
||||||
|
|
|
@ -163,7 +163,7 @@ impl UserMessage {
|
||||||
if !content.is_empty() {
|
if !content.is_empty() {
|
||||||
let _ = write!(&mut markdown, "{}\n\n{}\n", uri.as_link(), content);
|
let _ = write!(&mut markdown, "{}\n\n{}\n", uri.as_link(), content);
|
||||||
} else {
|
} else {
|
||||||
let _ = write!(&mut markdown, "{}\n", uri.as_link());
|
let _ = writeln!(&mut markdown, "{}", uri.as_link());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2024,8 +2024,8 @@ mod tests {
|
||||||
fn gen_working_copy(rng: &mut StdRng, head: &str) -> String {
|
fn gen_working_copy(rng: &mut StdRng, head: &str) -> String {
|
||||||
let mut old_lines = {
|
let mut old_lines = {
|
||||||
let mut old_lines = Vec::new();
|
let mut old_lines = Vec::new();
|
||||||
let mut old_lines_iter = head.lines();
|
let old_lines_iter = head.lines();
|
||||||
while let Some(line) = old_lines_iter.next() {
|
for line in old_lines_iter {
|
||||||
assert!(!line.ends_with("\n"));
|
assert!(!line.ends_with("\n"));
|
||||||
old_lines.push(line.to_owned());
|
old_lines.push(line.to_owned());
|
||||||
}
|
}
|
||||||
|
|
|
@ -3183,9 +3183,9 @@ mod tests {
|
||||||
// so we special case row 0 to assume a leading '\n'.
|
// so we special case row 0 to assume a leading '\n'.
|
||||||
//
|
//
|
||||||
// Linehood is the birthright of strings.
|
// Linehood is the birthright of strings.
|
||||||
let mut input_text_lines = input_text.split('\n').enumerate().peekable();
|
let input_text_lines = input_text.split('\n').enumerate().peekable();
|
||||||
let mut block_row = 0;
|
let mut block_row = 0;
|
||||||
while let Some((wrap_row, input_line)) = input_text_lines.next() {
|
for (wrap_row, input_line) in input_text_lines {
|
||||||
let wrap_row = wrap_row as u32;
|
let wrap_row = wrap_row as u32;
|
||||||
let multibuffer_row = wraps_snapshot
|
let multibuffer_row = wraps_snapshot
|
||||||
.to_point(WrapPoint::new(wrap_row, 0), Bias::Left)
|
.to_point(WrapPoint::new(wrap_row, 0), Bias::Left)
|
||||||
|
|
|
@ -11021,7 +11021,7 @@ impl Editor {
|
||||||
let mut col = 0;
|
let mut col = 0;
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
|
|
||||||
while let Some(ch) = chars.next() {
|
for ch in chars.by_ref() {
|
||||||
match ch {
|
match ch {
|
||||||
' ' => {
|
' ' => {
|
||||||
reindented_line.push(' ');
|
reindented_line.push(' ');
|
||||||
|
@ -11077,7 +11077,7 @@ impl Editor {
|
||||||
let mut first_non_indent_char = None;
|
let mut first_non_indent_char = None;
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
|
|
||||||
while let Some(ch) = chars.next() {
|
for ch in chars.by_ref() {
|
||||||
match ch {
|
match ch {
|
||||||
' ' => {
|
' ' => {
|
||||||
// Keep track of spaces. Append \t when we reach tab_size
|
// Keep track of spaces. Append \t when we reach tab_size
|
||||||
|
|
|
@ -164,8 +164,8 @@ pub fn indent_guides_in_range(
|
||||||
let end_anchor = snapshot.buffer_snapshot.anchor_after(end_offset);
|
let end_anchor = snapshot.buffer_snapshot.anchor_after(end_offset);
|
||||||
|
|
||||||
let mut fold_ranges = Vec::<Range<Point>>::new();
|
let mut fold_ranges = Vec::<Range<Point>>::new();
|
||||||
let mut folds = snapshot.folds_in_range(start_offset..end_offset).peekable();
|
let folds = snapshot.folds_in_range(start_offset..end_offset).peekable();
|
||||||
while let Some(fold) = folds.next() {
|
for fold in folds {
|
||||||
let start = fold.range.start.to_point(&snapshot.buffer_snapshot);
|
let start = fold.range.start.to_point(&snapshot.buffer_snapshot);
|
||||||
let end = fold.range.end.to_point(&snapshot.buffer_snapshot);
|
let end = fold.range.end.to_point(&snapshot.buffer_snapshot);
|
||||||
if let Some(last_range) = fold_ranges.last_mut()
|
if let Some(last_range) = fold_ranges.last_mut()
|
||||||
|
|
|
@ -103,9 +103,9 @@ impl FollowableItem for Editor {
|
||||||
multibuffer = MultiBuffer::new(project.read(cx).capability());
|
multibuffer = MultiBuffer::new(project.read(cx).capability());
|
||||||
let mut sorted_excerpts = state.excerpts.clone();
|
let mut sorted_excerpts = state.excerpts.clone();
|
||||||
sorted_excerpts.sort_by_key(|e| e.id);
|
sorted_excerpts.sort_by_key(|e| e.id);
|
||||||
let mut sorted_excerpts = sorted_excerpts.into_iter().peekable();
|
let sorted_excerpts = sorted_excerpts.into_iter().peekable();
|
||||||
|
|
||||||
while let Some(excerpt) = sorted_excerpts.next() {
|
for excerpt in sorted_excerpts {
|
||||||
let Ok(buffer_id) = BufferId::new(excerpt.buffer_id) else {
|
let Ok(buffer_id) = BufferId::new(excerpt.buffer_id) else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
|
@ -706,7 +706,7 @@ fn print_report(
|
||||||
println!("Average thread score: {average_thread_score}%");
|
println!("Average thread score: {average_thread_score}%");
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("");
|
println!();
|
||||||
|
|
||||||
print_h2("CUMULATIVE TOOL METRICS");
|
print_h2("CUMULATIVE TOOL METRICS");
|
||||||
println!("{}", cumulative_tool_metrics);
|
println!("{}", cumulative_tool_metrics);
|
||||||
|
|
|
@ -913,9 +913,9 @@ impl RequestMarkdown {
|
||||||
for tool in &request.tools {
|
for tool in &request.tools {
|
||||||
write!(&mut tools, "# {}\n\n", tool.name).unwrap();
|
write!(&mut tools, "# {}\n\n", tool.name).unwrap();
|
||||||
write!(&mut tools, "{}\n\n", tool.description).unwrap();
|
write!(&mut tools, "{}\n\n", tool.description).unwrap();
|
||||||
write!(
|
writeln!(
|
||||||
&mut tools,
|
&mut tools,
|
||||||
"{}\n",
|
"{}",
|
||||||
MarkdownCodeBlock {
|
MarkdownCodeBlock {
|
||||||
tag: "json",
|
tag: "json",
|
||||||
text: &format!("{:#}", tool.input_schema)
|
text: &format!("{:#}", tool.input_schema)
|
||||||
|
|
|
@ -916,7 +916,7 @@ impl GitRepository for RealGitRepository {
|
||||||
.context("no stdin for git cat-file subprocess")?;
|
.context("no stdin for git cat-file subprocess")?;
|
||||||
let mut stdin = BufWriter::new(stdin);
|
let mut stdin = BufWriter::new(stdin);
|
||||||
for rev in &revs {
|
for rev in &revs {
|
||||||
write!(&mut stdin, "{rev}\n")?;
|
writeln!(&mut stdin, "{rev}")?;
|
||||||
}
|
}
|
||||||
stdin.flush()?;
|
stdin.flush()?;
|
||||||
drop(stdin);
|
drop(stdin);
|
||||||
|
|
|
@ -186,7 +186,7 @@ fn tokenize(text: &str, language_scope: Option<LanguageScope>) -> impl Iterator<
|
||||||
let mut prev = None;
|
let mut prev = None;
|
||||||
let mut start_ix = 0;
|
let mut start_ix = 0;
|
||||||
iter::from_fn(move || {
|
iter::from_fn(move || {
|
||||||
while let Some((ix, c)) = chars.next() {
|
for (ix, c) in chars.by_ref() {
|
||||||
let mut token = None;
|
let mut token = None;
|
||||||
let kind = classifier.kind(c);
|
let kind = classifier.kind(c);
|
||||||
if let Some((prev_char, prev_kind)) = prev
|
if let Some((prev_char, prev_kind)) = prev
|
||||||
|
|
|
@ -2250,11 +2250,11 @@ impl ReferenceMultibuffer {
|
||||||
let base_buffer = diff.base_text();
|
let base_buffer = diff.base_text();
|
||||||
|
|
||||||
let mut offset = buffer_range.start;
|
let mut offset = buffer_range.start;
|
||||||
let mut hunks = diff
|
let hunks = diff
|
||||||
.hunks_intersecting_range(excerpt.range.clone(), buffer, cx)
|
.hunks_intersecting_range(excerpt.range.clone(), buffer, cx)
|
||||||
.peekable();
|
.peekable();
|
||||||
|
|
||||||
while let Some(hunk) = hunks.next() {
|
for hunk in hunks {
|
||||||
// Ignore hunks that are outside the excerpt range.
|
// Ignore hunks that are outside the excerpt range.
|
||||||
let mut hunk_range = hunk.buffer_range.to_offset(buffer);
|
let mut hunk_range = hunk.buffer_range.to_offset(buffer);
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,8 @@ impl<'a> GitTraversal<'a> {
|
||||||
// other_repo/
|
// other_repo/
|
||||||
// .git/
|
// .git/
|
||||||
// our_query.txt
|
// our_query.txt
|
||||||
let mut query = path.ancestors();
|
let query = path.ancestors();
|
||||||
while let Some(query) = query.next() {
|
for query in query {
|
||||||
let (_, snapshot) = self
|
let (_, snapshot) = self
|
||||||
.repo_root_to_snapshot
|
.repo_root_to_snapshot
|
||||||
.range(Path::new("")..=query)
|
.range(Path::new("")..=query)
|
||||||
|
|
|
@ -13149,10 +13149,10 @@ fn ensure_uniform_list_compatible_label(label: &mut CodeLabel) {
|
||||||
let mut offset_map = vec![0; label.text.len() + 1];
|
let mut offset_map = vec![0; label.text.len() + 1];
|
||||||
let mut last_char_was_space = false;
|
let mut last_char_was_space = false;
|
||||||
let mut new_idx = 0;
|
let mut new_idx = 0;
|
||||||
let mut chars = label.text.char_indices().fuse();
|
let chars = label.text.char_indices().fuse();
|
||||||
let mut newlines_removed = false;
|
let mut newlines_removed = false;
|
||||||
|
|
||||||
while let Some((idx, c)) = chars.next() {
|
for (idx, c) in chars {
|
||||||
offset_map[idx] = new_idx;
|
offset_map[idx] = new_idx;
|
||||||
|
|
||||||
match c {
|
match c {
|
||||||
|
|
|
@ -209,7 +209,7 @@ fn replace_value_in_json_text(
|
||||||
if ch == ',' {
|
if ch == ',' {
|
||||||
removal_end = existing_value_range.end + offset + 1;
|
removal_end = existing_value_range.end + offset + 1;
|
||||||
// Also consume whitespace after the comma
|
// Also consume whitespace after the comma
|
||||||
while let Some((_, next_ch)) = chars.next() {
|
for (_, next_ch) in chars.by_ref() {
|
||||||
if next_ch.is_whitespace() {
|
if next_ch.is_whitespace() {
|
||||||
removal_end += next_ch.len_utf8();
|
removal_end += next_ch.len_utf8();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -307,7 +307,7 @@ impl TabSwitcherDelegate {
|
||||||
(Reverse(history.get(&item.item.item_id())), item.item_index)
|
(Reverse(history.get(&item.item.item_id())), item.item_index)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
eprintln!("");
|
eprintln!();
|
||||||
all_items
|
all_items
|
||||||
.sort_by_key(|tab| (Reverse(history.get(&tab.item.item_id())), tab.item_index));
|
.sort_by_key(|tab| (Reverse(history.get(&tab.item.item_id())), tab.item_index));
|
||||||
all_items
|
all_items
|
||||||
|
|
|
@ -1397,8 +1397,8 @@ fn possible_open_target(
|
||||||
let found_entry = worktree
|
let found_entry = worktree
|
||||||
.update(cx, |worktree, _| {
|
.update(cx, |worktree, _| {
|
||||||
let worktree_root = worktree.abs_path();
|
let worktree_root = worktree.abs_path();
|
||||||
let mut traversal = worktree.traverse_from_path(true, true, false, "".as_ref());
|
let traversal = worktree.traverse_from_path(true, true, false, "".as_ref());
|
||||||
while let Some(entry) = traversal.next() {
|
for entry in traversal {
|
||||||
if let Some(path_in_worktree) = worktree_paths_to_check
|
if let Some(path_in_worktree) = worktree_paths_to_check
|
||||||
.iter()
|
.iter()
|
||||||
.find(|path_to_check| entry.path.ends_with(&path_to_check.path))
|
.find(|path_to_check| entry.path.ends_with(&path_to_check.path))
|
||||||
|
|
|
@ -1492,7 +1492,7 @@ impl OnMatchingLines {
|
||||||
let mut search = String::new();
|
let mut search = String::new();
|
||||||
let mut escaped = false;
|
let mut escaped = false;
|
||||||
|
|
||||||
while let Some(c) = chars.next() {
|
for c in chars.by_ref() {
|
||||||
if escaped {
|
if escaped {
|
||||||
escaped = false;
|
escaped = false;
|
||||||
// unescape escaped parens
|
// unescape escaped parens
|
||||||
|
|
|
@ -274,9 +274,9 @@ fn find_boolean(snapshot: &MultiBufferSnapshot, start: Point) -> Option<(Range<P
|
||||||
let mut end = None;
|
let mut end = None;
|
||||||
let mut word = String::new();
|
let mut word = String::new();
|
||||||
|
|
||||||
let mut chars = snapshot.chars_at(offset);
|
let chars = snapshot.chars_at(offset);
|
||||||
|
|
||||||
while let Some(ch) = chars.next() {
|
for ch in chars {
|
||||||
if ch.is_ascii_alphabetic() {
|
if ch.is_ascii_alphabetic() {
|
||||||
if begin.is_none() {
|
if begin.is_none() {
|
||||||
begin = Some(offset);
|
begin = Some(offset);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue