Remove dead-code: 'Layer'

This commit is contained in:
KtorZ 2024-03-09 23:13:00 +01:00
parent ec18127191
commit 191e4d47b3
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
4 changed files with 3 additions and 35 deletions

View File

@ -857,17 +857,12 @@ pub struct UnqualifiedImport {
pub location: Span,
pub name: String,
pub as_name: Option<String>,
pub layer: Layer,
}
impl UnqualifiedImport {
pub fn variable_name(&self) -> &str {
self.as_name.as_deref().unwrap_or(&self.name)
}
pub fn is_value(&self) -> bool {
self.layer.is_value()
}
}
// TypeAst
@ -1015,20 +1010,6 @@ impl Annotation {
}
}
#[derive(Debug, Clone, PartialEq, Eq, Default, serde::Serialize, serde::Deserialize)]
pub enum Layer {
#[default]
Value,
Type,
}
impl Layer {
/// Returns `true` if the layer is [`Value`].
pub fn is_value(&self) -> bool {
matches!(self, Self::Value)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum BinOp {
// Boolean logic

View File

@ -1,9 +1,8 @@
use chumsky::prelude::*;
use crate::{
ast,
parser::{error::ParseError, token::Token},
};
use chumsky::prelude::*;
pub fn parser() -> impl Parser<Token, ast::UntypedDefinition, Error = ParseError> {
let unqualified_import = choice((
@ -22,7 +21,6 @@ pub fn parser() -> impl Parser<Token, ast::UntypedDefinition, Error = ParseError
name,
location: span,
as_name,
layer: Default::default(),
});
let unqualified_imports = just(Token::Dot)

View File

@ -18,7 +18,6 @@ Use(
as_name: Some(
"A",
),
layer: Value,
},
UnqualifiedImport {
location: 31..41,
@ -26,7 +25,6 @@ Use(
as_name: Some(
"w",
),
layer: Value,
},
],
},

View File

@ -7,7 +7,7 @@ use super::{
};
use crate::{
ast::{
Annotation, Arg, ArgName, ArgVia, DataType, Definition, Function, Layer, ModuleConstant,
Annotation, Arg, ArgName, ArgVia, DataType, Definition, Function, ModuleConstant,
ModuleKind, RecordConstructor, RecordConstructorArg, Tracing, TypeAlias, TypedArg,
TypedDefinition, TypedFunction, TypedModule, UntypedArg, UntypedDefinition, UntypedModule,
Use, Validator,
@ -584,7 +584,7 @@ fn infer_definition(
location,
module,
as_name,
mut unqualified,
unqualified,
..
}) => {
let name = module.join("/");
@ -600,15 +600,6 @@ fn infer_definition(
imported_modules: environment.imported_modules.keys().cloned().collect(),
})?;
// TODO: remove this most likely
// Record any imports that are types only as this information is
// needed to prevent types being imported in generated JavaScript
for import in unqualified.iter_mut() {
if environment.imported_types.contains(import.variable_name()) {
import.layer = Layer::Type;
}
}
Ok(Definition::Use(Use {
location,
module,