From 372f6c16b31dab03af0f6adc5e050884f2d854c2 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Mon, 18 Nov 2019 16:12:37 +1300 Subject: [PATCH] Fix build errors on latest nightly --- src/context.rs | 12 +++++++++--- src/evaluate/evaluator.rs | 12 +++++++++--- src/parser/hir/named.rs | 12 +++++++++--- src/parser/parse/token_tree_builder.rs | 14 +++++++++----- src/parser/registry.rs | 18 ++++++++++++------ 5 files changed, 48 insertions(+), 20 deletions(-) diff --git a/src/context.rs b/src/context.rs index fe7d99319b..70c0485d32 100644 --- a/src/context.rs +++ b/src/context.rs @@ -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>>>, } +impl CommandRegistry { + pub fn new() -> CommandRegistry { + CommandRegistry { + registry: Arc::new(Mutex::new(IndexMap::default())), + } + } +} + impl CommandRegistry { pub(crate) fn empty() -> CommandRegistry { CommandRegistry { diff --git a/src/evaluate/evaluator.rs b/src/evaluate/evaluator.rs index ceb555c339..aee48f2e8d 100644 --- a/src/evaluate/evaluator.rs +++ b/src/evaluate/evaluator.rs @@ -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, - #[new(default)] vars: IndexMap>, } +impl Scope { + pub fn new(it: Tagged) -> Scope { + Scope { + it, + vars: IndexMap::new(), + } + } +} + impl fmt::Display for Scope { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_map() diff --git a/src/parser/hir/named.rs b/src/parser/hir/named.rs index 152525f0aa..fcea6caa2f 100644 --- a/src/parser/hir/named.rs +++ b/src/parser/hir/named.rs @@ -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, } +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 { diff --git a/src/parser/parse/token_tree_builder.rs b/src/parser/parse/token_tree_builder.rs index 7146a3c201..00b7581f80 100644 --- a/src/parser/parse/token_tree_builder.rs +++ b/src/parser/parse/token_tree_builder.rs @@ -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 TokenNode + 'static>; pub type CurriedCall = Box Spanned + 'static>; diff --git a/src/parser/registry.rs b/src/parser/registry.rs index ff0a98ae85..11f9d6baa4 100644 --- a/src/parser/registry.rs +++ b/src/parser/registry.rs @@ -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, - #[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) -> Signature { Signature::new(name.into()) }