Skip to content

Commit

Permalink
Remove unused error variant
Browse files Browse the repository at this point in the history
  • Loading branch information
lpil committed Apr 22, 2024
1 parent 65f6a1d commit b59c573
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 53 deletions.
8 changes: 2 additions & 6 deletions compiler-core/src/analyse/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ impl<'a> Importer<'a> {
name: import.name.clone(),
module_name: module.name.clone(),
type_constructors: module.public_type_names(),
imported_type_as_value: module
.get_public_value(&import.name)
.map_or_else(|| false, |_| true),
value_with_same_name: module.get_public_value(&import.name).is_some(),
})?
.clone()
.with_location(import.location);
Expand Down Expand Up @@ -124,9 +122,7 @@ impl<'a> Importer<'a> {
name: import_name.clone(),
module_name: module.name.clone(),
value_constructors: module.public_value_names(),
imported_value_as_type: module
.get_public_type(import_name)
.map_or_else(|| false, |_| true),
type_with_same_name: module.get_public_type(import_name).is_some(),
});
}
};
Expand Down
34 changes: 2 additions & 32 deletions compiler-core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1912,7 +1912,7 @@ Private types can only be used within the module that defines them.",
name,
module_name,
type_constructors,
imported_type_as_value
value_with_same_name: imported_type_as_value
} => {
let text = if *imported_type_as_value {
format!("`{name}` is only a value, it cannot be imported as a type.")
Expand Down Expand Up @@ -1945,7 +1945,7 @@ Private types can only be used within the module that defines them.",
name,
module_name,
value_constructors,
imported_value_as_type,
type_with_same_name: imported_value_as_type,
} => {
let text = if *imported_value_as_type {
format!("`{name}` is only a type, it cannot be imported as a value.")
Expand Down Expand Up @@ -1973,36 +1973,6 @@ Private types can only be used within the module that defines them.",
}
}

TypeError::UnknownModuleField {
location,
name,
module_name,
type_constructors,
value_constructors,
} => {
let options: Vec<_> = type_constructors
.iter()
.chain(value_constructors)
.cloned()
.collect();
let text = format!("The module `{module_name}` does not have a `{name}` field.",);
Diagnostic {
title: "Unknown module field".into(),
text,
hint: None,
level: Level::Error,
location: Some(Location {
label: Label {
text: did_you_mean(name, &options),
span: *location,
},
path: path.clone(),
src: src.clone(),
extra_labels: vec![],
}),
}
}

TypeError::IncorrectNumClausePatterns {
location,
expected,
Expand Down
17 changes: 4 additions & 13 deletions compiler-core/src/type_/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,15 @@ pub enum Error {
name: EcoString,
module_name: EcoString,
type_constructors: Vec<EcoString>,
imported_type_as_value: bool,
value_with_same_name: bool,
},

UnknownModuleValue {
location: SrcSpan,
name: EcoString,
module_name: EcoString,
value_constructors: Vec<EcoString>,
imported_value_as_type: bool,
},

UnknownModuleField {
location: SrcSpan,
name: EcoString,
module_name: EcoString,
value_constructors: Vec<EcoString>,
type_constructors: Vec<EcoString>,
type_with_same_name: bool,
},

NotFn {
Expand Down Expand Up @@ -555,7 +547,6 @@ impl Error {
| Error::UnknownModule { location, .. }
| Error::UnknownModuleType { location, .. }
| Error::UnknownModuleValue { location, .. }
| Error::UnknownModuleField { location, .. }
| Error::NotFn { location, .. }
| Error::UnknownRecordField { location, .. }
| Error::IncorrectArity { location, .. }
Expand Down Expand Up @@ -700,7 +691,7 @@ pub fn convert_get_value_constructor_error(
name,
module_name,
value_constructors,
imported_value_as_type,
type_with_same_name: imported_value_as_type,
},
}
}
Expand Down Expand Up @@ -761,7 +752,7 @@ pub fn convert_get_type_constructor_error(
name,
module_name,
type_constructors,
imported_type_as_value,
value_with_same_name: imported_type_as_value,
},
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler-core/src/type_/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
},
module_name: module.name.clone(),
value_constructors: module.public_value_names(),
imported_value_as_type: false,
type_with_same_name: false,
})?;

// Emit a warning if the value being used is deprecated.
Expand Down Expand Up @@ -1959,7 +1959,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
module_name: module_name.clone(),
name: name.clone(),
value_constructors: module.public_value_names(),
imported_value_as_type: false,
type_with_same_name: false,
})?
}
};
Expand Down

0 comments on commit b59c573

Please sign in to comment.