From 25fb759730503a8eb0ef176dec0296cd70199b3d Mon Sep 17 00:00:00 2001 From: GearsDatapacks Date: Mon, 16 Dec 2024 17:57:31 +0000 Subject: [PATCH] Use option --- compiler-core/src/type_/error.rs | 14 +++++++------- compiler-core/src/warning.rs | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/compiler-core/src/type_/error.rs b/compiler-core/src/type_/error.rs index cb77fc7cc21..81d3c94d88e 100644 --- a/compiler-core/src/type_/error.rs +++ b/compiler-core/src/type_/error.rs @@ -660,16 +660,16 @@ pub enum VariableOrigin { } impl VariableOrigin { - pub fn how_to_ignore(&self) -> String { + pub fn how_to_ignore(&self) -> Option { match self { VariableOrigin::Variable(name) => { - format!("You can ignore it with an underscore: `_{name}`.") + Some(format!("You can ignore it with an underscore: `_{name}`.")) } - VariableOrigin::LabelShorthand(label) => { - format!("You can ignore it with an underscore: `{label}: _`.") - } - VariableOrigin::AssignmentPattern => "You can safely remove it.".to_string(), - VariableOrigin::Generated => String::new(), + VariableOrigin::LabelShorthand(label) => Some(format!( + "You can ignore it with an underscore: `{label}: _`." + )), + VariableOrigin::AssignmentPattern => Some("You can safely remove it.".to_string()), + VariableOrigin::Generated => None, } } } diff --git a/compiler-core/src/warning.rs b/compiler-core/src/warning.rs index cdf50024dd5..83f7aa3db82 100644 --- a/compiler-core/src/warning.rs +++ b/compiler-core/src/warning.rs @@ -633,7 +633,7 @@ Hint: You can safely remove it. type_::Warning::UnusedVariable { location, origin } => Diagnostic { title: "Unused variable".into(), text: "".into(), - hint: Some(origin.how_to_ignore()), + hint: origin.how_to_ignore(), level: diagnostic::Level::Warning, location: Some(Location { src: src.clone(),