Display warning help + minor error improvements.

This commit is contained in:
KtorZ 2023-01-21 17:42:45 +01:00
parent 83fd910604
commit 91bd0d1d77
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
2 changed files with 7 additions and 4 deletions

View File

@ -638,7 +638,10 @@ The best thing to do from here is to remove it."#))]
#[diagnostic(code("type_mismatch"))]
#[diagnostic(help("{}", suggest_unify(expected, given, situation, rigid_type_names)))]
CouldNotUnify {
#[label]
#[label(
"expected type '{}'",
expected.to_pretty_with_names(rigid_type_names.clone(), 0),
)]
location: Span,
expected: Arc<Type>,
given: Arc<Type>,
@ -1152,13 +1155,13 @@ pub enum Warning {
name: String,
},
#[error("I came across an unused variable: '{}'.\n", name.purple())]
#[error("I came across an unused variable.\n")]
#[diagnostic(help(
"No big deal, but you might want to remove it to get rid of that warning."
))]
#[diagnostic(code("unused::variable"))]
UnusedVariable {
#[label]
#[label("unused")]
location: Span,
name: String,
},

View File

@ -480,7 +480,7 @@ impl Diagnostic for Warning {
fn help<'a>(&'a self) -> Option<Box<dyn Display + 'a>> {
match self {
Warning::Type { .. } => None,
Warning::Type { warning, .. } => warning.help(),
Warning::NoValidators => None,
Warning::DependencyAlreadyExists { .. } => Some(Box::new(
"If you need to change the version, try 'aiken packages upgrade' instead.",