mirror of
https://forge.katzen.cafe/katzen-cafe/iowo.git
synced 2024-12-22 10:05:52 +01:00
fix clippy warnings
This commit is contained in:
parent
ab7ff35d6c
commit
49995bbc62
5 changed files with 14 additions and 28 deletions
|
@ -12,6 +12,8 @@ pub mod lexer;
|
|||
|
||||
pub mod namespace;
|
||||
pub mod syntax;
|
||||
|
||||
#[allow(dead_code, reason = "the future!!!")]
|
||||
pub mod typed;
|
||||
|
||||
// basically logos::Span but in this repo
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
use std::collections::HashMap;
|
||||
use std::fmt::Debug;
|
||||
use std::fmt::Display;
|
||||
|
||||
use super::typedef::{InternalTypeDef, TypeDef};
|
||||
use super::CommandId;
|
||||
use super::TraitId;
|
||||
|
||||
use super::GlobalNamespace;
|
||||
|
||||
|
@ -26,12 +24,11 @@ impl<'a> Command<'a> {
|
|||
self.namespace.commands.borrow()[self.id]
|
||||
.input
|
||||
.as_ref()
|
||||
.map(|inputs| match inputs {
|
||||
.map_or(0, |inputs| match inputs {
|
||||
InternalTypeDef::Single(_) | InternalTypeDef::Generic(_) => 1,
|
||||
InternalTypeDef::List(list) => list.len(),
|
||||
InternalTypeDef::Record(rec) => rec.len(),
|
||||
})
|
||||
.unwrap_or(0)
|
||||
}
|
||||
pub fn get_output_types(&self) -> Option<TypeDef> {
|
||||
self.namespace.commands.borrow()[self.id]
|
||||
|
|
|
@ -120,7 +120,7 @@ impl GlobalNamespace {
|
|||
return Err(NsRegistrationError::GenericNameAlreadyExists);
|
||||
}
|
||||
internal_generics_namespace
|
||||
.insert(name.to_string(), conditions.iter().map(|t| t.id).collect());
|
||||
.insert(name.to_owned(), conditions.iter().map(|t| t.id).collect());
|
||||
}
|
||||
|
||||
if let Some(def) = input {
|
||||
|
|
|
@ -4,11 +4,9 @@ use std::fmt::Display;
|
|||
|
||||
use super::TraitId;
|
||||
use super::TypeId;
|
||||
use super::TypeNamespaceId;
|
||||
|
||||
use super::GlobalNamespace;
|
||||
|
||||
use super::r#trait::Trait;
|
||||
use super::r#type::Type;
|
||||
|
||||
pub enum TypeDef<'a> {
|
||||
|
@ -34,7 +32,7 @@ impl<'a> TypeDef<'a> {
|
|||
}
|
||||
TypeDef::List(defs) => {
|
||||
let r = defs
|
||||
.into_iter()
|
||||
.iter()
|
||||
.map(|def| def.check_generics_exist(map))
|
||||
.filter_map(|check_res| {
|
||||
if let Err(invalid_names) = check_res {
|
||||
|
@ -55,8 +53,8 @@ impl<'a> TypeDef<'a> {
|
|||
}
|
||||
TypeDef::Record(rec) => {
|
||||
let r = rec
|
||||
.into_iter()
|
||||
.map(|(n, def)| def.check_generics_exist(map))
|
||||
.iter()
|
||||
.map(|(_n, def)| def.check_generics_exist(map))
|
||||
.filter_map(|check_res| {
|
||||
if let Err(invalid_names) = check_res {
|
||||
Some(invalid_names)
|
||||
|
@ -107,7 +105,7 @@ impl Display for TypeDef<'_> {
|
|||
if let Some(first) = l.first() {
|
||||
Display::fmt(&first, f)?;
|
||||
}
|
||||
for (i, item) in l.iter().skip(1).enumerate() {
|
||||
for item in l.iter().skip(1) {
|
||||
f.write_str(", ")?;
|
||||
Display::fmt(&item, f)?;
|
||||
}
|
||||
|
@ -175,11 +173,9 @@ impl From<&TypeDef<'_>> for InternalTypeDef {
|
|||
TypeDef::Type(val) => Self::Single(val.id),
|
||||
// TODO: rewrite this to be better
|
||||
TypeDef::Generic(name) => Self::Generic(name.to_owned()),
|
||||
TypeDef::List(list) => {
|
||||
Self::List(list.into_iter().map(std::convert::Into::into).collect())
|
||||
}
|
||||
TypeDef::List(list) => Self::List(list.iter().map(std::convert::Into::into).collect()),
|
||||
TypeDef::Record(rec) => Self::Record(
|
||||
rec.into_iter()
|
||||
rec.iter()
|
||||
.map(|(name, typ)| (name.to_owned(), typ.into()))
|
||||
.collect(),
|
||||
),
|
||||
|
|
17
src/typed.rs
17
src/typed.rs
|
@ -51,8 +51,8 @@ pub struct CommandExpr<'a> {
|
|||
}
|
||||
|
||||
impl<'a> CommandExpr<'a> {
|
||||
fn try_find_concrete(&'a self, ns: &'a GlobalNamespace) -> IoTypes<'a> {
|
||||
let Self { command, args } = self;
|
||||
fn try_find_concrete(&'a self, _ns: &'a GlobalNamespace) -> IoTypes<'a> {
|
||||
let Self { command, .. } = self;
|
||||
|
||||
match command.get_output_types() {
|
||||
None => IoTypes::Empty,
|
||||
|
@ -89,7 +89,7 @@ impl LiteralKind {
|
|||
clippy::unwrap_used,
|
||||
reason = "these are fetched by type name constants used for keeping names consistent in codebase, which cannot be None"
|
||||
)]
|
||||
pub fn get_type<'a>(&self, ns: &'a GlobalNamespace) -> ConcreteTypeDef<'a> {
|
||||
fn get_type<'a>(&self, ns: &'a GlobalNamespace) -> ConcreteTypeDef<'a> {
|
||||
ConcreteTypeDef::Single(match self {
|
||||
LiteralKind::Int(_) => ns.get_type_by_name(TYPE_INTEGER).unwrap(),
|
||||
LiteralKind::Float(_) => ns.get_type_by_name(TYPE_FLOAT).unwrap(),
|
||||
|
@ -230,14 +230,5 @@ impl<'a> TypeChecker<'a> {
|
|||
}
|
||||
|
||||
// not sure if this is the optimal alg, or even a working one, but lets see
|
||||
fn check_forward(&self) {
|
||||
let i = 0;
|
||||
|
||||
// loop {
|
||||
// let maybe_concrete = match self.typed_syntax[i].kind {
|
||||
// ExprKind::Literal(l) => todo!(),
|
||||
// ExprKind::Command(c) => todo!(),
|
||||
// }
|
||||
// }
|
||||
}
|
||||
fn check_forward() {}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue