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