From 58a32490c57e57bf03a753bfcebb1a6746193e91 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Thu, 29 Aug 2019 21:16:11 +0900 Subject: [PATCH] Remove usage of in_band_lifetimes feature --- src/cli.rs | 2 +- src/format/generic.rs | 2 +- src/lib.rs | 1 - src/object/base.rs | 42 ++++++++++++------------- src/object/dict.rs | 2 +- src/object/meta.rs | 2 +- src/object/types.rs | 4 +-- src/parser/deserializer.rs | 2 +- src/parser/hir/baseline_parse_tokens.rs | 4 +-- src/parser/parse/parser.rs | 2 +- src/parser/parse/text.rs | 2 +- src/parser/parse/token_tree.rs | 6 ++-- src/parser/parse/tokens.rs | 4 +-- src/parser/parse_command.rs | 6 ++-- src/parser/registry.rs | 12 +++---- src/traits.rs | 4 +-- src/utils.rs | 2 +- 17 files changed, 49 insertions(+), 50 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 6cbb0c189..4aa9c34d0 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -30,7 +30,7 @@ pub enum MaybeOwned<'a, T> { Borrowed(&'a T), } -impl MaybeOwned<'a, T> { +impl MaybeOwned<'_, T> { pub fn borrow(&self) -> &T { match self { MaybeOwned::Owned(v) => v, diff --git a/src/format/generic.rs b/src/format/generic.rs index 42971febc..6142b1122 100644 --- a/src/format/generic.rs +++ b/src/format/generic.rs @@ -9,7 +9,7 @@ pub struct GenericView<'value> { value: &'value Value, } -impl RenderView for GenericView<'value> { +impl RenderView for GenericView<'_> { fn render_view(&self, host: &mut dyn Host) -> Result<(), ShellError> { match self.value { Value::Primitive(p) => Ok(host.stdout(&p.format(None))), diff --git a/src/lib.rs b/src/lib.rs index 7c0f5c495..b258e75ae 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,4 @@ #![feature(crate_visibility_modifier)] -#![feature(in_band_lifetimes)] #![feature(generators)] #![feature(specialization)] #![feature(proc_macro_hygiene)] diff --git a/src/object/base.rs b/src/object/base.rs index a9a485f9f..08379240b 100644 --- a/src/object/base.rs +++ b/src/object/base.rs @@ -176,7 +176,7 @@ pub enum Value { Block(Block), } -pub fn debug_list(values: &'a Vec>) -> ValuesDebug<'a> { +pub fn debug_list(values: &Vec>) -> ValuesDebug<'_> { ValuesDebug { values } } @@ -184,7 +184,7 @@ pub struct ValuesDebug<'a> { values: &'a Vec>, } -impl fmt::Debug for ValuesDebug<'a> { +impl fmt::Debug for ValuesDebug<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_list() .entries(self.values.iter().map(|i| i.debug())) @@ -196,7 +196,7 @@ pub struct ValueDebug<'a> { value: &'a Tagged, } -impl fmt::Debug for ValueDebug<'a> { +impl fmt::Debug for ValueDebug<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.value.item() { Value::Primitive(p) => p.debug(f), @@ -215,10 +215,10 @@ impl Tagged { } } -impl std::convert::TryFrom<&'a Tagged> for Block { +impl std::convert::TryFrom<&Tagged> for Block { type Error = ShellError; - fn try_from(value: &'a Tagged) -> Result { + fn try_from(value: &Tagged) -> Result { match value.item() { Value::Block(block) => Ok(block.clone()), v => Err(ShellError::type_error( @@ -229,10 +229,10 @@ impl std::convert::TryFrom<&'a Tagged> for Block { } } -impl std::convert::TryFrom<&'a Tagged> for i64 { +impl std::convert::TryFrom<&Tagged> for i64 { type Error = ShellError; - fn try_from(value: &'a Tagged) -> Result { + fn try_from(value: &Tagged) -> Result { match value.item() { Value::Primitive(Primitive::Int(int)) => Ok(*int), v => Err(ShellError::type_error( @@ -243,10 +243,10 @@ impl std::convert::TryFrom<&'a Tagged> for i64 { } } -impl std::convert::TryFrom<&'a Tagged> for String { +impl std::convert::TryFrom<&Tagged> for String { type Error = ShellError; - fn try_from(value: &'a Tagged) -> Result { + fn try_from(value: &Tagged) -> Result { match value.item() { Value::Primitive(Primitive::String(s)) => Ok(s.clone()), v => Err(ShellError::type_error( @@ -257,10 +257,10 @@ impl std::convert::TryFrom<&'a Tagged> for String { } } -impl std::convert::TryFrom<&'a Tagged> for Vec { +impl std::convert::TryFrom<&Tagged> for Vec { type Error = ShellError; - fn try_from(value: &'a Tagged) -> Result, ShellError> { + fn try_from(value: &Tagged) -> Result, ShellError> { match value.item() { Value::Binary(b) => Ok(b.clone()), v => Err(ShellError::type_error( @@ -271,7 +271,7 @@ impl std::convert::TryFrom<&'a Tagged> for Vec { } } -impl std::convert::TryFrom<&'a Tagged> for &'a crate::object::Dictionary { +impl<'a> std::convert::TryFrom<&'a Tagged> for &'a crate::object::Dictionary { type Error = ShellError; fn try_from(value: &'a Tagged) -> Result<&'a crate::object::Dictionary, ShellError> { @@ -301,10 +301,10 @@ impl Switch { } } -impl std::convert::TryFrom>> for Switch { +impl std::convert::TryFrom>> for Switch { type Error = ShellError; - fn try_from(value: Option<&'a Tagged>) -> Result { + fn try_from(value: Option<&Tagged>) -> Result { match value { None => Ok(Switch::Absent), Some(value) => match value.item() { @@ -319,7 +319,7 @@ impl std::convert::TryFrom>> for Switch { } impl Tagged { - pub(crate) fn debug(&'a self) -> ValueDebug<'a> { + pub(crate) fn debug(&self) -> ValueDebug<'_> { ValueDebug { value: self } } } @@ -351,7 +351,7 @@ impl Value { } } - pub(crate) fn get_data_by_key(&'a self, name: &str) -> Option<&Tagged> { + pub(crate) fn get_data_by_key(&self, name: &str) -> Option<&Tagged> { match self { Value::Object(o) => o.get_data_by_key(name), Value::List(l) => { @@ -374,14 +374,14 @@ impl Value { } #[allow(unused)] - pub(crate) fn get_data_by_index(&'a self, idx: usize) -> Option<&Tagged> { + pub(crate) fn get_data_by_index(&self, idx: usize) -> Option<&Tagged> { match self { Value::List(l) => l.iter().nth(idx), _ => None, } } - pub fn get_data_by_path(&'a self, tag: Tag, path: &str) -> Option> { + pub fn get_data_by_path(&self, tag: Tag, path: &str) -> Option> { let mut current = self; for p in path.split(".") { match current.get_data_by_key(p) { @@ -394,7 +394,7 @@ impl Value { } pub fn insert_data_at_path( - &'a self, + &self, tag: Tag, path: &str, new_value: Value, @@ -447,7 +447,7 @@ impl Value { } pub fn replace_data_at_path( - &'a self, + &self, tag: Tag, path: &str, replaced_value: Value, @@ -481,7 +481,7 @@ impl Value { None } - pub fn get_data(&'a self, desc: &String) -> MaybeOwned<'a, Value> { + pub fn get_data(&self, desc: &String) -> MaybeOwned<'_, Value> { match self { p @ Value::Primitive(_) => MaybeOwned::Borrowed(p), Value::Object(o) => o.get_data(desc), diff --git a/src/object/dict.rs b/src/object/dict.rs index 80e391e26..86d6cf9ea 100644 --- a/src/object/dict.rs +++ b/src/object/dict.rs @@ -72,7 +72,7 @@ impl PartialEq for Dictionary { } impl Dictionary { - pub fn get_data(&'a self, desc: &String) -> MaybeOwned<'a, Value> { + pub fn get_data(&self, desc: &String) -> MaybeOwned<'_, Value> { match self.entries.get(desc) { Some(v) => MaybeOwned::Borrowed(v), None => MaybeOwned::Owned(Value::Primitive(Primitive::Nothing)), diff --git a/src/object/meta.rs b/src/object/meta.rs index 3c2c2f3b8..f1d2b6713 100644 --- a/src/object/meta.rs +++ b/src/object/meta.rs @@ -256,7 +256,7 @@ impl Span { self.start == 0 && self.end == 0 } - pub fn slice(&self, source: &'a str) -> &'a str { + pub fn slice<'a>(&self, source: &'a str) -> &'a str { &source[self.start..self.end] } } diff --git a/src/object/types.rs b/src/object/types.rs index 2f3dc795f..b98e4b549 100644 --- a/src/object/types.rs +++ b/src/object/types.rs @@ -100,7 +100,7 @@ impl ExtractType for Value { } impl ExtractType for bool { - fn extract(value: &'a Tagged) -> Result { + fn extract(value: &Tagged) -> Result { trace!("Extracting {:?} for bool", value); match &value { @@ -118,7 +118,7 @@ impl ExtractType for bool { } impl ExtractType for std::path::PathBuf { - fn extract(value: &'a Tagged) -> Result { + fn extract(value: &Tagged) -> Result { trace!("Extracting {:?} for PathBuf", value); match &value { diff --git a/src/parser/deserializer.rs b/src/parser/deserializer.rs index ff00a6142..633a5b49d 100644 --- a/src/parser/deserializer.rs +++ b/src/parser/deserializer.rs @@ -16,7 +16,7 @@ pub struct ConfigDeserializer<'de> { position: usize, } -impl ConfigDeserializer<'de> { +impl<'de> ConfigDeserializer<'de> { pub fn from_call_info(call: CallInfo) -> ConfigDeserializer<'de> { ConfigDeserializer { call, diff --git a/src/parser/hir/baseline_parse_tokens.rs b/src/parser/hir/baseline_parse_tokens.rs index f0716d343..be056b5b5 100644 --- a/src/parser/hir/baseline_parse_tokens.rs +++ b/src/parser/hir/baseline_parse_tokens.rs @@ -331,7 +331,7 @@ pub struct TokensIterator<'a> { seen: indexmap::IndexSet, } -impl TokensIterator<'a> { +impl TokensIterator<'_> { pub fn remove(&mut self, position: usize) { self.seen.insert(position); } @@ -404,7 +404,7 @@ impl TokensIterator<'a> { } } -impl Iterator for TokensIterator<'a> { +impl<'a> Iterator for TokensIterator<'a> { type Item = &'a TokenNode; fn next(&mut self) -> Option<&'a TokenNode> { diff --git a/src/parser/parse/parser.rs b/src/parser/parse/parser.rs index a5afac756..94ff2976e 100644 --- a/src/parser/parse/parser.rs +++ b/src/parser/parse/parser.rs @@ -23,7 +23,7 @@ use std::str::FromStr; pub type NomSpan<'a> = LocatedSpan<&'a str>; -pub fn nom_input(s: &'a str) -> NomSpan<'a> { +pub fn nom_input(s: &str) -> NomSpan<'_> { LocatedSpan::new(s) } diff --git a/src/parser/parse/text.rs b/src/parser/parse/text.rs index b17092dc1..a3a9924b7 100644 --- a/src/parser/parse/text.rs +++ b/src/parser/parse/text.rs @@ -213,7 +213,7 @@ impl Serialize for Text { } } -impl Deserialize<'de> for Text { +impl<'de> Deserialize<'de> for Text { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, diff --git a/src/parser/parse/token_tree.rs b/src/parser/parse/token_tree.rs index 211d7afa2..8831c5263 100644 --- a/src/parser/parse/token_tree.rs +++ b/src/parser/parse/token_tree.rs @@ -27,7 +27,7 @@ pub struct DebugTokenNode<'a> { source: &'a Text, } -impl fmt::Debug for DebugTokenNode<'a> { +impl fmt::Debug for DebugTokenNode<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.node { TokenNode::Token(t) => write!(f, "{:?}", t.debug(self.source)), @@ -115,7 +115,7 @@ impl TokenNode { .to_string() } - pub fn debug(&'a self, source: &'a Text) -> DebugTokenNode<'a> { + pub fn debug<'a>(&'a self, source: &'a Text) -> DebugTokenNode<'a> { DebugTokenNode { node: self, source } } @@ -123,7 +123,7 @@ impl TokenNode { self.span().slice(source).to_string() } - pub fn source(&self, source: &'a Text) -> &'a str { + pub fn source<'a>(&self, source: &'a Text) -> &'a str { self.span().slice(source) } diff --git a/src/parser/parse/tokens.rs b/src/parser/parse/tokens.rs index 2970948a7..717f5845e 100644 --- a/src/parser/parse/tokens.rs +++ b/src/parser/parse/tokens.rs @@ -28,7 +28,7 @@ impl RawToken { pub type Token = Tagged; impl Token { - pub fn debug(&self, source: &'a Text) -> DebugToken<'a> { + pub fn debug<'a>(&self, source: &'a Text) -> DebugToken<'a> { DebugToken { node: *self, source, @@ -41,7 +41,7 @@ pub struct DebugToken<'a> { source: &'a Text, } -impl fmt::Debug for DebugToken<'a> { +impl fmt::Debug for DebugToken<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.node.span().slice(self.source)) } diff --git a/src/parser/parse_command.rs b/src/parser/parse_command.rs index 6677f6617..33ad25e6f 100644 --- a/src/parser/parse_command.rs +++ b/src/parser/parse_command.rs @@ -205,7 +205,7 @@ fn extract_switch(name: &str, tokens: &mut hir::TokensIterator<'_>, source: &Tex fn extract_mandatory( config: &Signature, name: &str, - tokens: &mut hir::TokensIterator<'a>, + tokens: &mut hir::TokensIterator<'_>, source: &Text, span: Span, ) -> Result<(usize, Tagged), ShellError> { @@ -227,7 +227,7 @@ fn extract_mandatory( fn extract_optional( name: &str, - tokens: &mut hir::TokensIterator<'a>, + tokens: &mut hir::TokensIterator<'_>, source: &Text, ) -> Result<(Option<(usize, Tagged)>), ShellError> { let flag = tokens.extract(|t| t.as_flag(name, source)); @@ -241,7 +241,7 @@ fn extract_optional( } } -pub fn trace_remaining(desc: &'static str, tail: hir::TokensIterator<'a>, source: &Text) { +pub fn trace_remaining(desc: &'static str, tail: hir::TokensIterator<'_>, source: &Text) { trace!( "{} = {:?}", desc, diff --git a/src/parser/registry.rs b/src/parser/registry.rs index 2f8b57d92..52d49ea5c 100644 --- a/src/parser/registry.rs +++ b/src/parser/registry.rs @@ -158,7 +158,7 @@ pub struct DebugEvaluatedPositional<'a> { positional: &'a Option>>, } -impl fmt::Debug for DebugEvaluatedPositional<'a> { +impl fmt::Debug for DebugEvaluatedPositional<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match &self.positional { None => write!(f, "None"), @@ -175,7 +175,7 @@ pub struct DebugEvaluatedNamed<'a> { named: &'a Option>>, } -impl fmt::Debug for DebugEvaluatedNamed<'a> { +impl fmt::Debug for DebugEvaluatedNamed<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match &self.named { None => write!(f, "None"), @@ -191,7 +191,7 @@ pub struct DebugEvaluatedArgs<'a> { args: &'a EvaluatedArgs, } -impl fmt::Debug for DebugEvaluatedArgs<'a> { +impl fmt::Debug for DebugEvaluatedArgs<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let mut s = f.debug_struct("Args"); @@ -206,7 +206,7 @@ impl fmt::Debug for DebugEvaluatedArgs<'a> { } impl EvaluatedArgs { - pub fn debug(&'a self) -> DebugEvaluatedArgs<'a> { + pub fn debug(&self) -> DebugEvaluatedArgs<'_> { DebugEvaluatedArgs { args: self } } @@ -248,7 +248,7 @@ impl EvaluatedArgs { } } - pub fn positional_iter(&'a self) -> PositionalIter<'a> { + pub fn positional_iter(&self) -> PositionalIter<'_> { match &self.positional { None => PositionalIter::Empty, Some(v) => { @@ -264,7 +264,7 @@ pub enum PositionalIter<'a> { Array(std::slice::Iter<'a, Tagged>), } -impl Iterator for PositionalIter<'a> { +impl<'a> Iterator for PositionalIter<'a> { type Item = &'a Tagged; fn next(&mut self) -> Option { diff --git a/src/traits.rs b/src/traits.rs index ba67bddff..5b022c444 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -6,7 +6,7 @@ pub struct Debuggable<'a, T: ToDebug> { source: &'a str, } -impl fmt::Display for Debuggable<'a, T> { +impl fmt::Display for Debuggable<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.inner.fmt_debug(f, self.source) } @@ -17,7 +17,7 @@ pub trait HasSpan { } pub trait ToDebug: Sized { - fn debug(&'a self, source: &'a str) -> Debuggable<'a, Self> { + fn debug<'a>(&'a self, source: &'a str) -> Debuggable<'a, Self> { Debuggable { inner: self, source, diff --git a/src/utils.rs b/src/utils.rs index 271c799b3..159907ea5 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -185,7 +185,7 @@ impl FileStructure { Ok(()) } - fn build(&mut self, src: &'a Path, lvl: usize) -> Result<(), ShellError> { + fn build(&mut self, src: &Path, lvl: usize) -> Result<(), ShellError> { let source = dunce::canonicalize(src)?; if source.is_dir() {