Remove useless borrows and derefs
This commit is contained in:
parent
9c0bc3028a
commit
f2b97a8bfe
41 changed files with 145 additions and 146 deletions
|
@ -39,7 +39,7 @@ impl Translate for AnnotateSnippetEmitterWriter {
|
|||
}
|
||||
|
||||
fn fallback_fluent_bundle(&self) -> &FluentBundle {
|
||||
&**self.fallback_bundle
|
||||
&self.fallback_bundle
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ impl Emitter for AnnotateSnippetEmitterWriter {
|
|||
let fluent_args = to_fluent_args(diag.args());
|
||||
|
||||
let mut children = diag.children.clone();
|
||||
let (mut primary_span, suggestions) = self.primary_span_formatted(&diag, &fluent_args);
|
||||
let (mut primary_span, suggestions) = self.primary_span_formatted(diag, &fluent_args);
|
||||
|
||||
self.fix_multispans_in_extern_macros_and_render_macro_backtrace(
|
||||
&mut primary_span,
|
||||
|
@ -65,7 +65,7 @@ impl Emitter for AnnotateSnippetEmitterWriter {
|
|||
&diag.code,
|
||||
&primary_span,
|
||||
&children,
|
||||
&suggestions,
|
||||
suggestions,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -292,7 +292,7 @@ impl Diagnostic {
|
|||
let lint_index = expectation_id.get_lint_index();
|
||||
expectation_id.set_lint_index(None);
|
||||
let mut stable_id = unstable_to_stable
|
||||
.get(&expectation_id)
|
||||
.get(expectation_id)
|
||||
.expect("each unstable `LintExpectationId` must have a matching stable id")
|
||||
.normalize();
|
||||
|
||||
|
|
|
@ -283,7 +283,7 @@ pub trait Emitter: Translate {
|
|||
if self
|
||||
.source_map()
|
||||
.map(|sm| is_case_difference(
|
||||
&**sm,
|
||||
sm,
|
||||
substitution,
|
||||
sugg.substitutions[0].parts[0].span,
|
||||
))
|
||||
|
@ -525,7 +525,7 @@ impl Translate for EmitterWriter {
|
|||
}
|
||||
|
||||
fn fallback_fluent_bundle(&self) -> &FluentBundle {
|
||||
&**self.fallback_bundle
|
||||
&self.fallback_bundle
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -538,7 +538,7 @@ impl Emitter for EmitterWriter {
|
|||
let fluent_args = to_fluent_args(diag.args());
|
||||
|
||||
let mut children = diag.children.clone();
|
||||
let (mut primary_span, suggestions) = self.primary_span_formatted(&diag, &fluent_args);
|
||||
let (mut primary_span, suggestions) = self.primary_span_formatted(diag, &fluent_args);
|
||||
debug!("emit_diagnostic: suggestions={:?}", suggestions);
|
||||
|
||||
self.fix_multispans_in_extern_macros_and_render_macro_backtrace(
|
||||
|
@ -555,7 +555,7 @@ impl Emitter for EmitterWriter {
|
|||
&diag.code,
|
||||
&primary_span,
|
||||
&children,
|
||||
&suggestions,
|
||||
suggestions,
|
||||
self.track_diagnostics.then_some(&diag.emitted_at),
|
||||
);
|
||||
}
|
||||
|
@ -801,7 +801,7 @@ impl EmitterWriter {
|
|||
}
|
||||
|
||||
let source_string = match file.get_line(line.line_index - 1) {
|
||||
Some(s) => normalize_whitespace(&*s),
|
||||
Some(s) => normalize_whitespace(&s),
|
||||
None => return Vec::new(),
|
||||
};
|
||||
|
||||
|
@ -1148,7 +1148,7 @@ impl EmitterWriter {
|
|||
(pos + 2, annotation.start_col.saturating_sub(left))
|
||||
};
|
||||
if let Some(ref label) = annotation.label {
|
||||
buffer.puts(line_offset + pos, code_offset + col, &label, style);
|
||||
buffer.puts(line_offset + pos, code_offset + col, label, style);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1358,7 +1358,7 @@ impl EmitterWriter {
|
|||
// only render error codes, not lint codes
|
||||
if let Some(DiagnosticId::Error(ref code)) = *code {
|
||||
buffer.append(0, "[", Style::Level(*level));
|
||||
buffer.append(0, &code, Style::Level(*level));
|
||||
buffer.append(0, code, Style::Level(*level));
|
||||
buffer.append(0, "]", Style::Level(*level));
|
||||
label_width += 2 + code.len();
|
||||
}
|
||||
|
@ -1683,7 +1683,7 @@ impl EmitterWriter {
|
|||
};
|
||||
|
||||
// Render the replacements for each suggestion
|
||||
let suggestions = suggestion.splice_lines(&**sm);
|
||||
let suggestions = suggestion.splice_lines(sm);
|
||||
debug!("emit_suggestion_default: suggestions={:?}", suggestions);
|
||||
|
||||
if suggestions.is_empty() {
|
||||
|
@ -1784,7 +1784,7 @@ impl EmitterWriter {
|
|||
buffer.puts(
|
||||
row_num - 1 + line - line_start,
|
||||
max_line_num_len + 3,
|
||||
&normalize_whitespace(&*file_lines.file.get_line(line - 1).unwrap()),
|
||||
&normalize_whitespace(&file_lines.file.get_line(line - 1).unwrap()),
|
||||
Style::Removal,
|
||||
);
|
||||
}
|
||||
|
@ -1926,7 +1926,7 @@ impl EmitterWriter {
|
|||
buffer.putc(
|
||||
row_num,
|
||||
(padding as isize + p) as usize,
|
||||
if part.is_addition(&sm) { '+' } else { '~' },
|
||||
if part.is_addition(sm) { '+' } else { '~' },
|
||||
Style::Addition,
|
||||
);
|
||||
}
|
||||
|
@ -1973,7 +1973,7 @@ impl EmitterWriter {
|
|||
buffer.puts(row_num, max_line_num_len + 3, &msg, Style::NoStyle);
|
||||
} else if notice_capitalization {
|
||||
let msg = "notice the capitalization difference";
|
||||
buffer.puts(row_num, max_line_num_len + 3, &msg, Style::NoStyle);
|
||||
buffer.puts(row_num, max_line_num_len + 3, msg, Style::NoStyle);
|
||||
}
|
||||
emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?;
|
||||
Ok(())
|
||||
|
@ -2028,7 +2028,7 @@ impl EmitterWriter {
|
|||
for child in children {
|
||||
let span = child.render_span.as_ref().unwrap_or(&child.span);
|
||||
if let Err(err) = self.emit_message_default(
|
||||
&span,
|
||||
span,
|
||||
&child.message,
|
||||
args,
|
||||
&None,
|
||||
|
@ -2113,7 +2113,7 @@ impl EmitterWriter {
|
|||
*row_num - 1,
|
||||
max_line_num_len + 3,
|
||||
&normalize_whitespace(
|
||||
&*file_lines.file.get_line(file_lines.lines[line_pos].line_index).unwrap(),
|
||||
&file_lines.file.get_line(file_lines.lines[line_pos].line_index).unwrap(),
|
||||
),
|
||||
Style::NoStyle,
|
||||
);
|
||||
|
|
|
@ -136,7 +136,7 @@ impl Translate for JsonEmitter {
|
|||
}
|
||||
|
||||
fn fallback_fluent_bundle(&self) -> &FluentBundle {
|
||||
&**self.fallback_bundle
|
||||
&self.fallback_bundle
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1328,7 +1328,7 @@ impl HandlerInner {
|
|||
|
||||
diagnostic.children.drain_filter(already_emitted_sub).for_each(|_| {});
|
||||
|
||||
self.emitter.emit_diagnostic(&diagnostic);
|
||||
self.emitter.emit_diagnostic(diagnostic);
|
||||
if diagnostic.is_error() {
|
||||
self.deduplicated_err_count += 1;
|
||||
} else if let Warning(_) = diagnostic.level {
|
||||
|
|
|
@ -59,13 +59,13 @@ pub trait Translate {
|
|||
trace!(?message, ?args);
|
||||
let (identifier, attr) = match message {
|
||||
DiagnosticMessage::Str(msg) | DiagnosticMessage::Eager(msg) => {
|
||||
return Cow::Borrowed(&msg);
|
||||
return Cow::Borrowed(msg);
|
||||
}
|
||||
DiagnosticMessage::FluentIdentifier(identifier, attr) => (identifier, attr),
|
||||
};
|
||||
|
||||
let translate_with_bundle = |bundle: &'a FluentBundle| -> Option<(Cow<'_, str>, Vec<_>)> {
|
||||
let message = bundle.get_message(&identifier)?;
|
||||
let message = bundle.get_message(identifier)?;
|
||||
let value = match attr {
|
||||
Some(attr) => message.get_attribute(attr)?.value(),
|
||||
None => message.value()?,
|
||||
|
@ -73,7 +73,7 @@ pub trait Translate {
|
|||
debug!(?message, ?value);
|
||||
|
||||
let mut errs = vec![];
|
||||
let translated = bundle.format_pattern(value, Some(&args), &mut errs);
|
||||
let translated = bundle.format_pattern(value, Some(args), &mut errs);
|
||||
debug!(?translated, ?errs);
|
||||
Some((translated, errs))
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue