From 077d91c47e13ea94ebef95b3e98127118db120b9 Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Mon, 21 Aug 2023 16:31:44 +0200 Subject: [PATCH] cargo fix --- nested/src/editors/char/mod.rs | 3 ++- nested/src/editors/integer/ctx.rs | 15 ++++------- nested/src/editors/integer/editor.rs | 7 +++-- nested/src/editors/list/cmd.rs | 3 +-- nested/src/editors/list/ctx.rs | 9 +++---- nested/src/editors/list/editor.rs | 6 ++--- nested/src/editors/list/pty_editor.rs | 10 +++---- nested/src/editors/product/editor.rs | 2 +- nested/src/editors/typeterm/ctx.rs | 28 ++++++++----------- nested/src/editors/typeterm/mod.rs | 39 ++++++++++++--------------- nested/src/type_system/context.rs | 6 ++--- nested/src/type_system/repr_tree.rs | 2 +- nested/src/type_system/term.rs | 4 +-- 13 files changed, 56 insertions(+), 78 deletions(-) diff --git a/nested/src/editors/char/mod.rs b/nested/src/editors/char/mod.rs index 4ea87ff..9e207e2 100644 --- a/nested/src/editors/char/mod.rs +++ b/nested/src/editors/char/mod.rs @@ -8,7 +8,7 @@ use { }, crate::{ type_system::{Context, ReprTree, TypeTerm}, - terminal::{TerminalAtom, TerminalStyle}, + terminal::{TerminalAtom}, tree::{NestedNode, TreeNavResult}, commander::{ObjCommander} }, @@ -39,6 +39,7 @@ impl ObjCommander for CharEditor { let value = cmd_view.get(); if self.ctx.read().unwrap().meta_chars.contains(&value) { + eprintln!("char: meta char EXID"); TreeNavResult::Exit } else { self.data.set(value); diff --git a/nested/src/editors/integer/ctx.rs b/nested/src/editors/integer/ctx.rs index e197613..b683f3e 100644 --- a/nested/src/editors/integer/ctx.rs +++ b/nested/src/editors/integer/ctx.rs @@ -1,18 +1,13 @@ use { crate::{ - type_system::{Context, TypeTerm, ReprTree}, + type_system::{Context, TypeTerm}, editors::{ - char::*, list::*, - integer::*, - product::* + integer::* }, - tree::{NestedNode}, - diagnostics::{Diagnostics}, type_system::{MorphismTypePattern}, }, - std::sync::{Arc, RwLock}, - cgmath::Point2 + std::sync::{Arc, RwLock} }; pub fn init_ctx(ctx: &mut Context) { @@ -55,8 +50,8 @@ pub fn init_ctx(ctx: &mut Context) { ctx.add_morphism(pattern, Arc::new( |mut node, dst_type| { - let depth = node.depth.get(); - let editor = node.editor.get().unwrap().downcast::>().unwrap(); + let _depth = node.depth.get(); + let _editor = node.editor.get().unwrap().downcast::>().unwrap(); // todo: check src_type parameter to be ( Digit radix ) diff --git a/nested/src/editors/integer/editor.rs b/nested/src/editors/integer/editor.rs index 71684a6..b2fe84a 100644 --- a/nested/src/editors/integer/editor.rs +++ b/nested/src/editors/integer/editor.rs @@ -12,9 +12,9 @@ use { }, crate::{ type_system::{Context, TypeTerm, ReprTree}, - editors::list::{ListEditor, ListCmd, PTYListController, PTYListStyle}, + editors::list::{ListCmd, PTYListController, PTYListStyle}, terminal::{ - TerminalAtom, TerminalEvent, TerminalStyle, make_label + TerminalAtom, TerminalStyle, make_label }, diagnostics::{Message}, tree::{NestedNode, TreeNav, TreeNavResult, TreeCursor}, @@ -23,7 +23,6 @@ use { std::sync::Arc, std::sync::RwLock, std::iter::FromIterator, - termion::event::{Event, Key}, cgmath::{Point2} }; @@ -56,7 +55,7 @@ impl ObjCommander for DigitEditor { add a message to the diagnostics view */ - let mut message = IndexBuffer::from_iter(vec![ + let message = IndexBuffer::from_iter(vec![ (Point2::new(1, 0), make_label("invalid digit '")), (Point2::new(2, 0), make_label(&format!("{}", c)) .map_item(|_p,a| a.add_style_back(TerminalStyle::fg_color((140,140,250))))), diff --git a/nested/src/editors/list/cmd.rs b/nested/src/editors/list/cmd.rs index 83d10fd..e5fcb39 100644 --- a/nested/src/editors/list/cmd.rs +++ b/nested/src/editors/list/cmd.rs @@ -1,7 +1,6 @@ use { r3vi::{ - view::{singleton::*}, - buffer::{singleton::*} + view::{singleton::*} }, crate::{ editors::list::{ListEditor, ListCursor, ListCursorMode}, diff --git a/nested/src/editors/list/ctx.rs b/nested/src/editors/list/ctx.rs index 69fe434..875838a 100644 --- a/nested/src/editors/list/ctx.rs +++ b/nested/src/editors/list/ctx.rs @@ -1,13 +1,10 @@ use { r3vi::{ - view::{port::UpdateTask, OuterViewPort, singleton::*, sequence::*}, - buffer::{singleton::*, vec::*} + view::{sequence::*} }, crate::{ - type_system::{Context, TypeTerm, ReprTree}, - editors::list::{ListEditor, ListCursor, ListCursorMode, ListCmd, PTYListController, PTYListStyle}, - tree::{NestedNode, TreeNav, TreeCursor}, - diagnostics::Diagnostics + type_system::{Context, TypeTerm}, + editors::list::{ListEditor, PTYListController, PTYListStyle} }, std::sync::{Arc, RwLock} }; diff --git a/nested/src/editors/list/editor.rs b/nested/src/editors/list/editor.rs index 180f17b..007955e 100644 --- a/nested/src/editors/list/editor.rs +++ b/nested/src/editors/list/editor.rs @@ -5,7 +5,7 @@ use { }, crate::{ type_system::{Context, TypeTerm, ReprTree}, - editors::list::{ListCursor, ListCursorMode, ListCmd, PTYListController, PTYListStyle}, + editors::list::{ListCursor, ListCursorMode}, tree::{NestedNode, TreeNav, TreeCursor}, diagnostics::Diagnostics }, @@ -319,7 +319,7 @@ impl ListEditor { if let Some(item) = self.get_item() { // let item = item.read().unwrap(); - let depth = item.depth; + let _depth = item.depth; if let Some(head_editor) = item.editor.get() { eprintln!("listlistsplit:editor = {:?}", Arc::into_raw(head_editor.clone())); @@ -400,7 +400,7 @@ impl ListEditor { let next_editor = next_editor.read().unwrap(); if let Some(next_editor) = next_editor.editor.get() { if let Ok(next_editor) = next_editor.downcast::>() { - let mut next_editor = next_editor.write().unwrap(); + let next_editor = next_editor.write().unwrap(); let cur_editor = item.editor.get().unwrap(); let cur_editor = cur_editor.downcast::>().unwrap(); let mut cur_editor = cur_editor.write().unwrap(); diff --git a/nested/src/editors/list/pty_editor.rs b/nested/src/editors/list/pty_editor.rs index df5a4f5..1cf4ea6 100644 --- a/nested/src/editors/list/pty_editor.rs +++ b/nested/src/editors/list/pty_editor.rs @@ -4,16 +4,14 @@ use { projection::decorate_sequence::*, }, crate::{ - type_system::{Context, TypeTerm, ReprTree}, + type_system::{Context, ReprTree}, editors::list::*, terminal::{TerminalEvent, TerminalView, make_label}, tree::{TreeCursor, TreeNav, TreeNavResult}, - diagnostics::{Diagnostics}, tree::NestedNode, PtySegment }, std::sync::{Arc, RwLock}, - std::any::{Any}, termion::event::{Event, Key} }; @@ -103,7 +101,7 @@ impl PTYListController { close_char: Option ) { { - let mut ctx = node.ctx.as_ref(); + let ctx = node.ctx.as_ref(); let mut ctx = ctx.write().unwrap(); if let Some(c) = split_char.as_ref() { @@ -137,7 +135,7 @@ impl PTYListController { self.depth = depth; } - pub fn handle_term_event(&mut self, event: &TerminalEvent, cmd_obj: Arc>) -> TreeNavResult { + pub fn handle_term_event(&mut self, event: &TerminalEvent, _cmd_obj: Arc>) -> TreeNavResult { let mut e = self.editor.write().unwrap(); match event { TerminalEvent::Input(Event::Key(Key::Insert)) => { @@ -193,7 +191,7 @@ impl PTYListController { } }, ListCursorMode::Select => { - if let Some(mut item) = e.get_item_mut() { + if let Some(item) = e.get_item_mut() { eprintln!("PTYList(select): forward any cmd to current child item"); let res = item.write().unwrap().send_cmd_obj(cmd_obj.clone()); let child_close_char = item.read().unwrap().close_char.get(); diff --git a/nested/src/editors/product/editor.rs b/nested/src/editors/product/editor.rs index 6e44f2e..790a38d 100644 --- a/nested/src/editors/product/editor.rs +++ b/nested/src/editors/product/editor.rs @@ -211,7 +211,7 @@ impl ObjCommander for ProductEditor { let mut update_segment = false; - let result = if let Some(mut segment) = self.get_cur_segment_mut().as_deref_mut() { + let _result = if let Some(mut segment) = self.get_cur_segment_mut().as_deref_mut() { if let Some(ProductEditorSegment::N{ t, editor, ed_depth, cur_depth, cur_dist: _ }) = segment.deref_mut() { *cur_depth = self.get_cursor().tree_addr.len(); diff --git a/nested/src/editors/typeterm/ctx.rs b/nested/src/editors/typeterm/ctx.rs index 9ce71eb..a88f588 100644 --- a/nested/src/editors/typeterm/ctx.rs +++ b/nested/src/editors/typeterm/ctx.rs @@ -1,21 +1,14 @@ use { r3vi::{ - buffer::singleton::*, - view::{singleton::*, sequence::*, OuterViewPort}, - projection::flatten_grid::*, - projection::flatten_singleton::* + view::{singleton::*, sequence::*} }, crate::{ - type_system::{Context, TypeID, TypeTerm, ReprTree, MorphismTypePattern}, - terminal::{TerminalEvent, TerminalStyle}, - editors::{sum::*, list::{ListCursorMode, ListEditor, PTYListStyle, PTYListController}, typeterm::{State, TypeTermEditor}}, - tree::{NestedNode, TreeNav, TreeNavResult, TreeCursor}, - commander::ObjCommander, - PtySegment + type_system::{Context, TypeTerm, MorphismTypePattern}, + terminal::{TerminalStyle}, + editors::{list::{PTYListStyle, PTYListController}, typeterm::{State, TypeTermEditor}} }, - termion::event::{Key}, - std::{sync::{Arc, RwLock}, any::Any}, - cgmath::{Vector2, Point2} + std::{sync::{Arc, RwLock}}, + cgmath::{Point2} }; pub fn init_ctx(ctx: &mut Context) { @@ -31,8 +24,8 @@ pub fn init_ctx(ctx: &mut Context) { ctx.add_morphism( MorphismTypePattern { src_tyid: ctx.get_typeid("List"), dst_tyid: ctx.get_typeid("Type").unwrap() }, - Arc::new(move |mut node, _dst_type:_| { - let mut new_node = TypeTermEditor::with_node( node.ctx.clone(), node.depth.get(), node.clone(), State::Any ); + Arc::new(move |node, _dst_type:_| { + let new_node = TypeTermEditor::with_node( node.ctx.clone(), node.depth.get(), node.clone(), State::Any ); Some(new_node) })); @@ -77,14 +70,14 @@ pub fn init_ctx(ctx: &mut Context) { // display variables blue color if let Some(v) = node.view { node.view = Some( - v.map_item(|i,p| p.add_style_front(TerminalStyle::fg_color((5, 120, 240))))); + v.map_item(|_i,p| p.add_style_front(TerminalStyle::fg_color((5, 120, 240))))); } Some(node) })); ctx.add_morphism( MorphismTypePattern { src_tyid: ctx.get_typeid("PosInt"), dst_tyid: ctx.get_typeid("Type::Lit::Num").unwrap() }, - Arc::new(|mut node, _dst_type:_| { + Arc::new(|node, _dst_type:_| { Some(node) })); @@ -115,3 +108,4 @@ pub fn init_ctx(ctx: &mut Context) { Some(TypeTermEditor::new_node(ctx, depth)) })); } + diff --git a/nested/src/editors/typeterm/mod.rs b/nested/src/editors/typeterm/mod.rs index 7c320af..1f2c4f6 100644 --- a/nested/src/editors/typeterm/mod.rs +++ b/nested/src/editors/typeterm/mod.rs @@ -5,21 +5,16 @@ pub use ctx::init_ctx; use { r3vi::{ buffer::singleton::*, - view::{singleton::*, sequence::*, OuterViewPort}, - projection::flatten_grid::*, - projection::flatten_singleton::* + view::{singleton::*, sequence::*, OuterViewPort} }, crate::{ - type_system::{Context, TypeID, TypeTerm, ReprTree, MorphismTypePattern}, - terminal::{TerminalEvent, TerminalStyle}, - editors::{sum::*, list::{ListCursorMode, ListEditor, PTYListStyle, PTYListController}}, + type_system::{Context, TypeID, TypeTerm, ReprTree}, + editors::{list::{ListCursorMode}}, tree::{NestedNode, TreeNav, TreeNavResult, TreeCursor}, - commander::ObjCommander, - PtySegment + commander::ObjCommander }, - termion::event::{Key}, std::{sync::{Arc, RwLock}, any::Any}, - cgmath::{Vector2, Point2} + cgmath::{Vector2} }; #[derive(PartialEq, Eq, Clone, Copy)] @@ -55,7 +50,7 @@ impl TypeTermEditor { match term { TypeTerm::TypeID( tyid ) => { - let mut editor = node.get_edit::().expect("typ term edit"); + let editor = node.get_edit::().expect("typ term edit"); editor.write().unwrap().set_state(match tyid { TypeID::Fun(_) => State::FunSymbol, TypeID::Var(_) => State::VarSymbol @@ -71,11 +66,11 @@ impl TypeTermEditor { }, TypeTerm::App( args ) => { - let mut editor = node.get_edit::().expect("typ term edit"); + let editor = node.get_edit::().expect("typ term edit"); editor.write().unwrap().set_state( State::App ); for x in args.iter() { - let mut arg_node = TypeTermEditor::from_type_term( ctx.clone(), depth+1, x ); + let arg_node = TypeTermEditor::from_type_term( ctx.clone(), depth+1, x ); eprintln!("add node arg!"); node.send_cmd_obj( @@ -88,11 +83,11 @@ impl TypeTermEditor { } TypeTerm::Ladder( args ) => { - let mut editor = node.get_edit::().expect("typ term edit"); + let editor = node.get_edit::().expect("typ term edit"); editor.write().unwrap().set_state( State::Ladder ); for x in args.iter() { - let mut arg_node = TypeTermEditor::from_type_term( ctx.clone(), depth+1, x ); + let arg_node = TypeTermEditor::from_type_term( ctx.clone(), depth+1, x ); eprintln!("add node arg!"); node.send_cmd_obj( @@ -105,10 +100,10 @@ impl TypeTermEditor { } TypeTerm::Num( n ) => { - let mut editor = node.get_edit::().expect("typ term edit"); + let editor = node.get_edit::().expect("typ term edit"); - let mut int_edit = crate::editors::integer::PosIntEditor::from_u64(node.ctx.clone(), 10, *n as u64); - let mut node = int_edit.into_node(); + let int_edit = crate::editors::integer::PosIntEditor::from_u64(node.ctx.clone(), 10, *n as u64); + let node = int_edit.into_node(); editor.write().unwrap().editor.set(node.editor.get()); editor.write().unwrap().cur_node.set(node); @@ -116,7 +111,7 @@ impl TypeTermEditor { } TypeTerm::Char( c ) => { - let mut editor = node.get_edit::().expect("typ term edit"); + let editor = node.get_edit::().expect("typ term edit"); editor.write().unwrap().set_state( State::Char ); editor.write().unwrap().send_cmd_obj(ReprTree::from_char(&ctx, *c)); @@ -158,7 +153,7 @@ impl TypeTermEditor { node } State::Num => { - let mut int_edit = crate::editors::integer::PosIntEditor::new(self.ctx.clone(), 10); + let int_edit = crate::editors::integer::PosIntEditor::new(self.ctx.clone(), 10); let mut node = int_edit.into_node(); node = node.morph( (&self.ctx, "( Type::Lit::Num )").into() ); @@ -198,13 +193,13 @@ impl TypeTermEditor { } fn with_node(ctx: Arc>, depth: usize, node: NestedNode, state: State) -> NestedNode { - let buffer = SingletonBuffer::>::new( None ); + let _buffer = SingletonBuffer::>::new( None ); let data = Arc::new(RwLock::new(ReprTree::new( (&ctx, "( Type )") ))); - let mut editor = TypeTermEditor { + let editor = TypeTermEditor { ctx: ctx.clone(), state, data: data.clone(), diff --git a/nested/src/type_system/context.rs b/nested/src/type_system/context.rs index 3bda270..f302637 100644 --- a/nested/src/type_system/context.rs +++ b/nested/src/type_system/context.rs @@ -69,7 +69,7 @@ impl MorphismTypePattern { } impl From for MorphismTypePattern { - fn from(mut value: MorphismType) -> MorphismTypePattern { + fn from(value: MorphismType) -> MorphismTypePattern { fn strip( x: &TypeTerm ) -> TypeID { match x { TypeTerm::TypeID(id) => id.clone(), @@ -280,7 +280,7 @@ impl Context { /* create new context per node ?? too heavy.. whats the reason? TODO */ let new_ctx = Arc::new(RwLock::new(Context::with_parent(Some(ctx.clone())))); - let new_depth = depth; + let _new_depth = depth; mk_node( NestedNode::new(new_ctx, ReprTree::new_arc(type_term.clone()), 0), @@ -289,7 +289,7 @@ impl Context { } pub fn morph_node(mut node: NestedNode, dst_type: TypeTerm) -> NestedNode { - let mut src_type = node.data.read().unwrap().get_type().clone(); + let src_type = node.data.read().unwrap().get_type().clone(); let pattern = MorphismType { src_type: Some(src_type), dst_type: dst_type.clone() }; /* it is not univesally true to always use ascend. diff --git a/nested/src/type_system/repr_tree.rs b/nested/src/type_system/repr_tree.rs index 62f9246..eeeb8cf 100644 --- a/nested/src/type_system/repr_tree.rs +++ b/nested/src/type_system/repr_tree.rs @@ -22,7 +22,7 @@ impl std::fmt::Debug for ReprTree { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "type: {:?}", self.type_tag)?; - for (k,x) in self.branches.iter() { + for (_k,x) in self.branches.iter() { write!(f, "child: {:?}", x)?; } diff --git a/nested/src/type_system/term.rs b/nested/src/type_system/term.rs index c55aa90..cb0cce4 100644 --- a/nested/src/type_system/term.rs +++ b/nested/src/type_system/term.rs @@ -202,8 +202,8 @@ impl TypeTerm { // returns provided syntax-type, pub fn is_semantic_subtype_of(&self, expected_type: &TypeTerm) -> Option< TypeTerm > { - let mut provided_lnf = self.clone(); - let mut expected_lnf = expected_type.clone(); + let provided_lnf = self.clone(); + let expected_lnf = expected_type.clone(); match (provided_lnf.normalize(),