mirror of
https://github.com/nushell/nushell.git
synced 2024-12-28 09:59:36 +01:00
Merge pull request #527 from taiki-e/in_band_lifetimes
Remove usage of in_band_lifetimes feature
This commit is contained in:
commit
ebce7231a2
@ -30,7 +30,7 @@ pub enum MaybeOwned<'a, T> {
|
||||
Borrowed(&'a T),
|
||||
}
|
||||
|
||||
impl<T> MaybeOwned<'a, T> {
|
||||
impl<T> MaybeOwned<'_, T> {
|
||||
pub fn borrow(&self) -> &T {
|
||||
match self {
|
||||
MaybeOwned::Owned(v) => v,
|
||||
|
@ -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))),
|
||||
|
@ -1,5 +1,4 @@
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![feature(generators)]
|
||||
#![feature(specialization)]
|
||||
#![feature(proc_macro_hygiene)]
|
||||
|
@ -176,7 +176,7 @@ pub enum Value {
|
||||
Block(Block),
|
||||
}
|
||||
|
||||
pub fn debug_list(values: &'a Vec<Tagged<Value>>) -> ValuesDebug<'a> {
|
||||
pub fn debug_list(values: &Vec<Tagged<Value>>) -> ValuesDebug<'_> {
|
||||
ValuesDebug { values }
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ pub struct ValuesDebug<'a> {
|
||||
values: &'a Vec<Tagged<Value>>,
|
||||
}
|
||||
|
||||
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<Value>,
|
||||
}
|
||||
|
||||
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<Value> {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::TryFrom<&'a Tagged<Value>> for Block {
|
||||
impl std::convert::TryFrom<&Tagged<Value>> for Block {
|
||||
type Error = ShellError;
|
||||
|
||||
fn try_from(value: &'a Tagged<Value>) -> Result<Block, ShellError> {
|
||||
fn try_from(value: &Tagged<Value>) -> Result<Block, ShellError> {
|
||||
match value.item() {
|
||||
Value::Block(block) => Ok(block.clone()),
|
||||
v => Err(ShellError::type_error(
|
||||
@ -229,10 +229,10 @@ impl std::convert::TryFrom<&'a Tagged<Value>> for Block {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::TryFrom<&'a Tagged<Value>> for i64 {
|
||||
impl std::convert::TryFrom<&Tagged<Value>> for i64 {
|
||||
type Error = ShellError;
|
||||
|
||||
fn try_from(value: &'a Tagged<Value>) -> Result<i64, ShellError> {
|
||||
fn try_from(value: &Tagged<Value>) -> Result<i64, ShellError> {
|
||||
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<Value>> for i64 {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::TryFrom<&'a Tagged<Value>> for String {
|
||||
impl std::convert::TryFrom<&Tagged<Value>> for String {
|
||||
type Error = ShellError;
|
||||
|
||||
fn try_from(value: &'a Tagged<Value>) -> Result<String, ShellError> {
|
||||
fn try_from(value: &Tagged<Value>) -> Result<String, ShellError> {
|
||||
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<Value>> for String {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::TryFrom<&'a Tagged<Value>> for Vec<u8> {
|
||||
impl std::convert::TryFrom<&Tagged<Value>> for Vec<u8> {
|
||||
type Error = ShellError;
|
||||
|
||||
fn try_from(value: &'a Tagged<Value>) -> Result<Vec<u8>, ShellError> {
|
||||
fn try_from(value: &Tagged<Value>) -> Result<Vec<u8>, 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<Value>> for Vec<u8> {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::TryFrom<&'a Tagged<Value>> for &'a crate::object::Dictionary {
|
||||
impl<'a> std::convert::TryFrom<&'a Tagged<Value>> for &'a crate::object::Dictionary {
|
||||
type Error = ShellError;
|
||||
|
||||
fn try_from(value: &'a Tagged<Value>) -> Result<&'a crate::object::Dictionary, ShellError> {
|
||||
@ -301,10 +301,10 @@ impl Switch {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::TryFrom<Option<&'a Tagged<Value>>> for Switch {
|
||||
impl std::convert::TryFrom<Option<&Tagged<Value>>> for Switch {
|
||||
type Error = ShellError;
|
||||
|
||||
fn try_from(value: Option<&'a Tagged<Value>>) -> Result<Switch, ShellError> {
|
||||
fn try_from(value: Option<&Tagged<Value>>) -> Result<Switch, ShellError> {
|
||||
match value {
|
||||
None => Ok(Switch::Absent),
|
||||
Some(value) => match value.item() {
|
||||
@ -319,7 +319,7 @@ impl std::convert::TryFrom<Option<&'a Tagged<Value>>> for Switch {
|
||||
}
|
||||
|
||||
impl Tagged<Value> {
|
||||
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<Value>> {
|
||||
pub(crate) fn get_data_by_key(&self, name: &str) -> Option<&Tagged<Value>> {
|
||||
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<Value>> {
|
||||
pub(crate) fn get_data_by_index(&self, idx: usize) -> Option<&Tagged<Value>> {
|
||||
match self {
|
||||
Value::List(l) => l.iter().nth(idx),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_data_by_path(&'a self, tag: Tag, path: &str) -> Option<Tagged<&Value>> {
|
||||
pub fn get_data_by_path(&self, tag: Tag, path: &str) -> Option<Tagged<&Value>> {
|
||||
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),
|
||||
|
@ -72,7 +72,7 @@ impl PartialEq<Value> 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)),
|
||||
|
@ -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]
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ impl ExtractType for Value {
|
||||
}
|
||||
|
||||
impl ExtractType for bool {
|
||||
fn extract(value: &'a Tagged<Value>) -> Result<bool, ShellError> {
|
||||
fn extract(value: &Tagged<Value>) -> Result<bool, ShellError> {
|
||||
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<Value>) -> Result<std::path::PathBuf, ShellError> {
|
||||
fn extract(value: &Tagged<Value>) -> Result<std::path::PathBuf, ShellError> {
|
||||
trace!("Extracting {:?} for PathBuf", value);
|
||||
|
||||
match &value {
|
||||
|
@ -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,
|
||||
|
@ -331,7 +331,7 @@ pub struct TokensIterator<'a> {
|
||||
seen: indexmap::IndexSet<usize>,
|
||||
}
|
||||
|
||||
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> {
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ impl Serialize for Text {
|
||||
}
|
||||
}
|
||||
|
||||
impl Deserialize<'de> for Text {
|
||||
impl<'de> Deserialize<'de> for Text {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ impl RawToken {
|
||||
pub type Token = Tagged<RawToken>;
|
||||
|
||||
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))
|
||||
}
|
||||
|
@ -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<Flag>), 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<Flag>)>), 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,
|
||||
|
@ -158,7 +158,7 @@ pub struct DebugEvaluatedPositional<'a> {
|
||||
positional: &'a Option<Vec<Tagged<Value>>>,
|
||||
}
|
||||
|
||||
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<IndexMap<String, Tagged<Value>>>,
|
||||
}
|
||||
|
||||
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<Value>>),
|
||||
}
|
||||
|
||||
impl Iterator for PositionalIter<'a> {
|
||||
impl<'a> Iterator for PositionalIter<'a> {
|
||||
type Item = &'a Tagged<Value>;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
|
@ -6,7 +6,7 @@ pub struct Debuggable<'a, T: ToDebug> {
|
||||
source: &'a str,
|
||||
}
|
||||
|
||||
impl<T: ToDebug> fmt::Display for Debuggable<'a, T> {
|
||||
impl<T: ToDebug> 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,
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user