Skip to content

Commit

Permalink
fix naming
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank-III authored and lpil committed Dec 4, 2024
1 parent bb47e3a commit 53eb5e0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion compiler-core/src/analyse/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl<'context, 'problems> Importer<'context, 'problems> {
module_name: module.name.clone(),
value_constructors: module.public_value_names(),
type_with_same_name: module.get_public_type(import_name).is_some(),
context: crate::type_::error::ModuleValueErrorContext::UnqualifiedImport,
context: crate::type_::error::ModuleValueUsageContext::UnqualifiedImport,
});
return;
}
Expand Down
8 changes: 4 additions & 4 deletions compiler-core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use crate::build::{Outcome, Runtime, Target};
use crate::diagnostic::{Diagnostic, ExtraLabel, Label, Location};
use crate::type_::error::{
MissingAnnotation, ModuleValueErrorContext, Named, UnknownField, UnknownTypeHint,
MissingAnnotation, ModuleValueUsageContext, Named, UnknownField, UnknownTypeHint,
UnsafeRecordUpdateReason,
};
use crate::type_::printer::{Names, Printer};
Expand Down Expand Up @@ -2232,9 +2232,9 @@ Private types can only be used within the module that defines them.",
} => {
let text = if *imported_value_as_type {
match context {
ModuleValueErrorContext::UnqualifiedImport =>
ModuleValueUsageContext::UnqualifiedImport =>
wrap_format!("`{name}` is only a type, it cannot be imported as a value."),
ModuleValueErrorContext::ModuleAccess =>
ModuleValueUsageContext::ModuleAccess =>
wrap_format!("{module_name}.{name} is a type constructor, it cannot be used as a value"),
}
} else {
Expand All @@ -2247,7 +2247,7 @@ Private types can only be used within the module that defines them.",
level: Level::Error,
location: Some(Location {
label: Label {
text: if *imported_value_as_type && matches!(context, ModuleValueErrorContext::UnqualifiedImport) {
text: if *imported_value_as_type && matches!(context, ModuleValueUsageContext::UnqualifiedImport) {
Some(format!("Did you mean `type {name}`?"))
} else {
did_you_mean(name, value_constructors)
Expand Down
6 changes: 3 additions & 3 deletions compiler-core/src/type_/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ pub enum Error {
module_name: EcoString,
value_constructors: Vec<EcoString>,
type_with_same_name: bool,
context: ModuleValueErrorContext,
context: ModuleValueUsageContext,
},

ModuleAliasUsedAsName {
Expand Down Expand Up @@ -585,7 +585,7 @@ pub enum Error {
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ModuleValueErrorContext {
pub enum ModuleValueUsageContext {
UnqualifiedImport,
ModuleAccess,
}
Expand Down Expand Up @@ -1142,7 +1142,7 @@ pub fn convert_get_value_constructor_error(
module_name,
value_constructors,
type_with_same_name: imported_value_as_type,
context: ModuleValueErrorContext::ModuleAccess,
context: ModuleValueUsageContext::ModuleAccess,
},
}
}
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 @@ -2225,7 +2225,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
module_name: module.name.clone(),
value_constructors: module.public_value_names(),
type_with_same_name: module.get_public_type(&label).is_some(),
context: ModuleValueErrorContext::ModuleAccess,
context: ModuleValueUsageContext::ModuleAccess,
})?;

// Emit a warning if the value being used is deprecated.
Expand Down Expand Up @@ -2787,7 +2787,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
name: name.clone(),
value_constructors: module.public_value_names(),
type_with_same_name: module.get_public_type(name).is_some(),
context: ModuleValueErrorContext::ModuleAccess,
context: ModuleValueUsageContext::ModuleAccess,
})?
}
};
Expand Down

0 comments on commit 53eb5e0

Please sign in to comment.