1
Fork 0

fix clippy::clone_on_ref_ptr for compiler

This commit is contained in:
klensy 2024-10-07 22:22:51 +03:00
parent 0bff99403c
commit 746b675c5a
33 changed files with 98 additions and 91 deletions

View file

@ -173,7 +173,7 @@ impl AnnotateSnippetEmitter {
source_map.ensure_source_file_source_present(&file);
(
format!("{}", source_map.filename_for_diagnostics(&file.name)),
source_string(file.clone(), &line),
source_string(Lrc::clone(&file), &line),
line.line_index,
line.annotations,
)

View file

@ -1555,7 +1555,7 @@ impl HumanEmitter {
// Get the left-side margin to remove it
let mut whitespace_margin = usize::MAX;
for line_idx in 0..annotated_file.lines.len() {
let file = annotated_file.file.clone();
let file = Lrc::clone(&annotated_file.file);
let line = &annotated_file.lines[line_idx];
if let Some(source_string) =
line.line_index.checked_sub(1).and_then(|l| file.get_line(l))
@ -1646,7 +1646,7 @@ impl HumanEmitter {
let depths = self.render_source_line(
&mut buffer,
annotated_file.file.clone(),
Lrc::clone(&annotated_file.file),
&annotated_file.lines[line_idx],
width_offset,
code_offset,
@ -2529,7 +2529,12 @@ impl FileWithAnnotatedLines {
// | | |
// | |______foo
// | baz
add_annotation_to_file(&mut output, file.clone(), ann.line_start, ann.as_start());
add_annotation_to_file(
&mut output,
Lrc::clone(&file),
ann.line_start,
ann.as_start(),
);
// 4 is the minimum vertical length of a multiline span when presented: two lines
// of code and two lines of underline. This is not true for the special case where
// the beginning doesn't have an underline, but the current logic seems to be
@ -2545,11 +2550,11 @@ impl FileWithAnnotatedLines {
.unwrap_or(ann.line_start);
for line in ann.line_start + 1..until {
// Every `|` that joins the beginning of the span (`___^`) to the end (`|__^`).
add_annotation_to_file(&mut output, file.clone(), line, ann.as_line());
add_annotation_to_file(&mut output, Lrc::clone(&file), line, ann.as_line());
}
let line_end = ann.line_end - 1;
if middle < line_end {
add_annotation_to_file(&mut output, file.clone(), line_end, ann.as_line());
add_annotation_to_file(&mut output, Lrc::clone(&file), line_end, ann.as_line());
}
} else {
end_ann.annotation_type = AnnotationType::Singleline;

View file

@ -367,9 +367,9 @@ impl Diagnostic {
ColorConfig::Always | ColorConfig::Auto => dst = Box::new(termcolor::Ansi::new(dst)),
ColorConfig::Never => {}
}
HumanEmitter::new(dst, je.fallback_bundle.clone())
HumanEmitter::new(dst, Lrc::clone(&je.fallback_bundle))
.short_message(short)
.sm(Some(je.sm.clone()))
.sm(Some(Lrc::clone(&je.sm)))
.fluent_bundle(je.fluent_bundle.clone())
.diagnostic_width(je.diagnostic_width)
.macro_backtrace(je.macro_backtrace)