Align warnings message's style with errors.

This commit is contained in:
KtorZ 2022-12-28 18:45:04 +01:00
parent 7c1b8e8f3b
commit c4c0ace3a6
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
1 changed files with 40 additions and 12 deletions

View File

@ -1361,7 +1361,8 @@ impl Diagnostic for Error {
#[derive(Debug, PartialEq, Clone, thiserror::Error, Diagnostic)] #[derive(Debug, PartialEq, Clone, thiserror::Error, Diagnostic)]
pub enum Warning { pub enum Warning {
#[error("Todo\n")] #[error("I found a todo left in the code.\n")]
#[diagnostic(help("You probably want to replace that one with real code... eventually."))]
Todo { Todo {
kind: TodoKind, kind: TodoKind,
#[label] #[label]
@ -1369,31 +1370,38 @@ pub enum Warning {
tipo: Arc<Type>, tipo: Arc<Type>,
}, },
#[error("Implicitly discarded result\n")] #[error(
"I realized the following expression returned a result that is implicitly discarded.\n"
)]
#[diagnostic(help(
"You can use the '_' symbol should you want to explicitly discard a result."
))]
ImplicitlyDiscardedResult { ImplicitlyDiscardedResult {
#[label] #[label]
location: Span, location: Span,
}, },
#[error("Unused literal\n")] #[error("I found a literal that is unused.\n")]
UnusedLiteral { UnusedLiteral {
#[label] #[label]
location: Span, location: Span,
}, },
#[error("Record update with no fields\n")] #[error("I found a record update with no fields; effectively updating nothing.\n")]
#[diagnostic(url("https://aiken-lang.org/language-tour/custom-types#record-updates"))]
NoFieldsRecordUpdate { NoFieldsRecordUpdate {
#[label] #[label]
location: Span, location: Span,
}, },
#[error("Record update using all fields\n")] #[error("I found a record update using all fields; thus redundant.\n")]
#[diagnostic(url("https://aiken-lang.org/language-tour/custom-types#record-updates"))]
AllFieldsRecordUpdate { AllFieldsRecordUpdate {
#[label] #[label]
location: Span, location: Span,
}, },
#[error("Unused type {name}\n")] #[error("I discovered an unused type: '{}'.\n", name.purple())]
UnusedType { UnusedType {
#[label] #[label]
location: Span, location: Span,
@ -1401,7 +1409,10 @@ pub enum Warning {
name: String, name: String,
}, },
#[error("Unused constructor {name}\n")] #[error("I discovered an unused constructor: '{}'.\n", name.purple())]
#[diagnostic(help(
"No big deal, but you might want to remove it to get rid of that warning."
))]
UnusedConstructor { UnusedConstructor {
#[label] #[label]
location: Span, location: Span,
@ -1409,35 +1420,52 @@ pub enum Warning {
name: String, name: String,
}, },
#[error("Unused imported value {name}\n")] #[error("I discovered an unused imported value: '{}'.\n", name.purple())]
#[diagnostic(help(
"No big deal, but you might want to remove it to get rid of that warning."
))]
UnusedImportedValue { UnusedImportedValue {
#[label] #[label]
location: Span, location: Span,
name: String, name: String,
}, },
#[error("Unused imported module {name}\n")] #[error("I discovered an unused imported module: '{}'.\n", name.purple())]
#[diagnostic(help(
"No big deal, but you might want to remove it to get rid of that warning."
))]
UnusedImportedModule { UnusedImportedModule {
#[label] #[label]
location: Span, location: Span,
name: String, name: String,
}, },
#[error("Unused private module constant {name}\n")] #[error("I found an unused (private) module constant: '{}'.\n", name.purple())]
#[diagnostic(help(
"Perhaps your forgot to make it public using the 'pub' keyword?\n\
Otherwise, you might want to get rid of it altogether."
))]
UnusedPrivateModuleConstant { UnusedPrivateModuleConstant {
#[label] #[label]
location: Span, location: Span,
name: String, name: String,
}, },
#[error("Unused private function {name}\n")] #[error("I found an unused private function: '{}'.\n", name.purple())]
#[diagnostic(help(
"Perhaps your forgot to make it public using the 'pub' keyword?\n\
Otherwise, you might want to get rid of it altogether."
))]
UnusedPrivateFunction { UnusedPrivateFunction {
#[label] #[label]
location: Span, location: Span,
name: String, name: String,
}, },
#[error("Unused variable {name}\n")] #[error("I came across an unused variable: '{}'.\n", name.purple())]
#[diagnostic(help(
"No big deal, but you might want to remove it to get rid of that warning."
))]
UnusedVariable { UnusedVariable {
#[label] #[label]
location: Span, location: Span,