Improve some names.

Lots of vectors of messages called `message` or `msg`. This commit
pluralizes them.

Note that `emit_message_default` and `emit_messages_default` both
already existed, and both process a vector, so I renamed the former
`emit_messages_default_inner` because it's called by the latter.
This commit is contained in:
Nicholas Nethercote
2023-12-20 17:12:17 +11:00
parent d7a3b6291c
commit 824667f753
12 changed files with 45 additions and 45 deletions

View File

@@ -103,7 +103,7 @@ pub struct Diagnostic {
// outside of what methods in this crate themselves allow.
pub(crate) level: Level,
pub message: Vec<(DiagnosticMessage, Style)>,
pub messages: Vec<(DiagnosticMessage, Style)>,
pub code: Option<DiagnosticId>,
pub span: MultiSpan,
pub children: Vec<SubDiagnostic>,
@@ -161,7 +161,7 @@ pub enum DiagnosticId {
#[derive(Clone, Debug, PartialEq, Hash, Encodable, Decodable)]
pub struct SubDiagnostic {
pub level: Level,
pub message: Vec<(DiagnosticMessage, Style)>,
pub messages: Vec<(DiagnosticMessage, Style)>,
pub span: MultiSpan,
pub render_span: Option<MultiSpan>,
}
@@ -223,7 +223,7 @@ impl Diagnostic {
pub fn new_with_messages(level: Level, messages: Vec<(DiagnosticMessage, Style)>) -> Self {
Diagnostic {
level,
message: messages,
messages,
code: None,
span: MultiSpan::new(),
children: vec![],
@@ -905,7 +905,7 @@ impl Diagnostic {
}
pub fn set_primary_message(&mut self, msg: impl Into<DiagnosticMessage>) -> &mut Self {
self.message[0] = (msg.into(), Style::NoStyle);
self.messages[0] = (msg.into(), Style::NoStyle);
self
}
@@ -932,8 +932,8 @@ impl Diagnostic {
self.args = args;
}
pub fn styled_message(&self) -> &[(DiagnosticMessage, Style)] {
&self.message
pub fn messages(&self) -> &[(DiagnosticMessage, Style)] {
&self.messages
}
/// Helper function that takes a `SubdiagnosticMessage` and returns a `DiagnosticMessage` by
@@ -944,7 +944,7 @@ impl Diagnostic {
attr: impl Into<SubdiagnosticMessage>,
) -> DiagnosticMessage {
let msg =
self.message.iter().map(|(msg, _)| msg).next().expect("diagnostic with no messages");
self.messages.iter().map(|(msg, _)| msg).next().expect("diagnostic with no messages");
msg.with_subdiagnostic_message(attr.into())
}
@@ -961,7 +961,7 @@ impl Diagnostic {
) {
let sub = SubDiagnostic {
level,
message: vec![(
messages: vec![(
self.subdiagnostic_message_to_diagnostic_message(message),
Style::NoStyle,
)],
@@ -976,15 +976,15 @@ impl Diagnostic {
fn sub_with_highlights<M: Into<SubdiagnosticMessage>>(
&mut self,
level: Level,
message: Vec<(M, Style)>,
messages: Vec<(M, Style)>,
span: MultiSpan,
render_span: Option<MultiSpan>,
) {
let message = message
let messages = messages
.into_iter()
.map(|m| (self.subdiagnostic_message_to_diagnostic_message(m.0), m.1))
.collect();
let sub = SubDiagnostic { level, message, span, render_span };
let sub = SubDiagnostic { level, messages, span, render_span };
self.children.push(sub);
}
@@ -1002,7 +1002,7 @@ impl Diagnostic {
) {
(
&self.level,
&self.message,
&self.messages,
self.args().collect(),
&self.code,
&self.span,