Skip to content

Commit

Permalink
Use option
Browse files Browse the repository at this point in the history
  • Loading branch information
GearsDatapacks committed Dec 16, 2024
1 parent 934cfaa commit 25fb759
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions compiler-core/src/type_/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,16 +660,16 @@ pub enum VariableOrigin {
}

impl VariableOrigin {
pub fn how_to_ignore(&self) -> String {
pub fn how_to_ignore(&self) -> Option<String> {
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,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler-core/src/warning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 25fb759

Please sign in to comment.