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

View File

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

View File

@ -1,7 +1,6 @@
use crate::parser::hir::Expression;
use crate::parser::Flag;
use crate::prelude::*;
use derive_new::new;
use indexmap::IndexMap;
use log::trace;
use serde::{Deserialize, Serialize};
@ -15,12 +14,19 @@ pub enum NamedValue {
Value(Expression),
}
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize, new)]
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct NamedArguments {
#[new(default)]
pub(crate) named: IndexMap<String, NamedValue>,
}
impl NamedArguments {
pub fn new() -> NamedArguments {
NamedArguments {
named: IndexMap::new(),
}
}
}
impl FormatDebug for NamedArguments {
fn fmt_debug(&self, f: &mut DebugFormatter, source: &str) -> fmt::Result {
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::tokens::{RawNumber, RawToken};
use crate::parser::CallNode;
use derive_new::new;
#[derive(new)]
pub struct TokenTreeBuilder {
#[new(default)]
pos: usize,
#[new(default)]
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 CurriedCall = Box<dyn FnOnce(&mut TokenTreeBuilder) -> Spanned<CallNode> + 'static>;

View File

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