Fix build errors on latest nightly

This commit is contained in:
Jonathan Turner 2019-11-18 16:12:37 +13:00
parent c04da4c232
commit 372f6c16b3
5 changed files with 48 additions and 20 deletions

View File

@ -1,7 +1,6 @@
use crate::commands::{Command, UnevaluatedCallInfo}; use crate::commands::{Command, UnevaluatedCallInfo};
use crate::parser::{hir, hir::syntax_shape::ExpandContext}; use crate::parser::{hir, hir::syntax_shape::ExpandContext};
use crate::prelude::*; use crate::prelude::*;
use derive_new::new;
use indexmap::IndexMap; use indexmap::IndexMap;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::error::Error; use std::error::Error;
@ -15,12 +14,19 @@ pub enum AnchorLocation {
Source(Text), Source(Text),
} }
#[derive(Clone, new)] #[derive(Clone)]
pub struct CommandRegistry { pub struct CommandRegistry {
#[new(value = "Arc::new(Mutex::new(IndexMap::default()))")]
registry: Arc<Mutex<IndexMap<String, Arc<Command>>>>, registry: Arc<Mutex<IndexMap<String, Arc<Command>>>>,
} }
impl CommandRegistry {
pub fn new() -> CommandRegistry {
CommandRegistry {
registry: Arc::new(Mutex::new(IndexMap::default())),
}
}
}
impl CommandRegistry { impl CommandRegistry {
pub(crate) fn empty() -> CommandRegistry { pub(crate) fn empty() -> CommandRegistry {
CommandRegistry { CommandRegistry {

View File

@ -6,18 +6,24 @@ use crate::parser::{
}; };
use crate::prelude::*; use crate::prelude::*;
use crate::TaggedDictBuilder; use crate::TaggedDictBuilder;
use derive_new::new;
use indexmap::IndexMap; use indexmap::IndexMap;
use log::trace; use log::trace;
use std::fmt; use std::fmt;
#[derive(new)]
pub struct Scope { pub struct Scope {
it: Tagged<Value>, it: Tagged<Value>,
#[new(default)]
vars: IndexMap<String, Tagged<Value>>, vars: IndexMap<String, Tagged<Value>>,
} }
impl Scope {
pub fn new(it: Tagged<Value>) -> Scope {
Scope {
it,
vars: IndexMap::new(),
}
}
}
impl fmt::Display for Scope { impl fmt::Display for Scope {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_map() f.debug_map()

View File

@ -1,7 +1,6 @@
use crate::parser::hir::Expression; use crate::parser::hir::Expression;
use crate::parser::Flag; use crate::parser::Flag;
use crate::prelude::*; use crate::prelude::*;
use derive_new::new;
use indexmap::IndexMap; use indexmap::IndexMap;
use log::trace; use log::trace;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -15,12 +14,19 @@ pub enum NamedValue {
Value(Expression), Value(Expression),
} }
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize, new)] #[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct NamedArguments { pub struct NamedArguments {
#[new(default)]
pub(crate) named: IndexMap<String, NamedValue>, pub(crate) named: IndexMap<String, NamedValue>,
} }
impl NamedArguments {
pub fn new() -> NamedArguments {
NamedArguments {
named: IndexMap::new(),
}
}
}
impl FormatDebug for NamedArguments { impl FormatDebug for NamedArguments {
fn fmt_debug(&self, f: &mut DebugFormatter, source: &str) -> fmt::Result { fn fmt_debug(&self, f: &mut DebugFormatter, source: &str) -> fmt::Result {
for (name, value) in &self.named { for (name, value) in &self.named {

View File

@ -6,17 +6,21 @@ use crate::parser::parse::pipeline::{Pipeline, PipelineElement};
use crate::parser::parse::token_tree::{DelimitedNode, Delimiter, TokenNode}; use crate::parser::parse::token_tree::{DelimitedNode, Delimiter, TokenNode};
use crate::parser::parse::tokens::{RawNumber, RawToken}; use crate::parser::parse::tokens::{RawNumber, RawToken};
use crate::parser::CallNode; use crate::parser::CallNode;
use derive_new::new;
#[derive(new)]
pub struct TokenTreeBuilder { pub struct TokenTreeBuilder {
#[new(default)]
pos: usize, pos: usize,
#[new(default)]
output: String, output: String,
} }
impl TokenTreeBuilder {
pub fn new() -> TokenTreeBuilder {
TokenTreeBuilder {
pos: 0,
output: String::new(),
}
}
}
pub type CurriedToken = Box<dyn FnOnce(&mut TokenTreeBuilder) -> TokenNode + 'static>; pub type CurriedToken = Box<dyn FnOnce(&mut TokenTreeBuilder) -> TokenNode + 'static>;
pub type CurriedCall = Box<dyn FnOnce(&mut TokenTreeBuilder) -> Spanned<CallNode> + 'static>; pub type CurriedCall = Box<dyn FnOnce(&mut TokenTreeBuilder) -> Spanned<CallNode> + 'static>;

View File

@ -60,22 +60,28 @@ impl PositionalType {
type Description = String; type Description = String;
#[derive(Debug, Serialize, Deserialize, Clone, new)] #[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Signature { pub struct Signature {
pub name: String, pub name: String,
#[new(default)]
pub usage: String, pub usage: String,
#[new(default)]
pub positional: Vec<(PositionalType, Description)>, pub positional: Vec<(PositionalType, Description)>,
#[new(value = "None")]
pub rest_positional: Option<(SyntaxShape, Description)>, pub rest_positional: Option<(SyntaxShape, Description)>,
#[new(default)]
pub named: IndexMap<String, (NamedType, Description)>, pub named: IndexMap<String, (NamedType, Description)>,
#[new(value = "false")]
pub is_filter: bool, pub is_filter: bool,
} }
impl Signature { impl Signature {
pub fn new(name: String) -> Signature {
Signature {
name,
usage: String::new(),
positional: vec![],
rest_positional: None,
named: IndexMap::new(),
is_filter: false,
}
}
pub fn build(name: impl Into<String>) -> Signature { pub fn build(name: impl Into<String>) -> Signature {
Signature::new(name.into()) Signature::new(name.into())
} }