diff --git a/src/parser.rs b/src/parser.rs index 0086f813..b25073f7 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -46,7 +46,7 @@ pub struct ParseState<'e> { /// Input stream buffer containing the next character to read. pub tokenizer_control: TokenizerControl, /// Interned strings. - interned_strings: StringsInterner, + interned_strings: StringsInterner<'e>, /// External [scope][Scope] with constants. pub scope: &'e Scope<'e>, /// Global runtime state. diff --git a/src/types/interner.rs b/src/types/interner.rs index e82152be..a5277207 100644 --- a/src/types/interner.rs +++ b/src/types/interner.rs @@ -1,14 +1,14 @@ use crate::{Identifier, ImmutableString}; #[cfg(feature = "no_std")] use std::prelude::v1::*; -use std::{collections::BTreeMap, ops::AddAssign}; +use std::{collections::BTreeMap, marker::PhantomData, ops::AddAssign}; /// _(internals)_ A factory of identifiers from text strings. /// Exported under the `internals` feature only. /// /// Normal identifiers, property getters and setters are interned separately. #[derive(Debug, Clone, Default, Hash)] -pub struct StringsInterner { +pub struct StringsInterner<'a> { /// Normal strings. strings: BTreeMap, /// Property getters. @@ -17,9 +17,11 @@ pub struct StringsInterner { /// Property setters. #[cfg(not(feature = "no_object"))] setters: BTreeMap, + /// Take care of the lifetime parameter. + dummy: PhantomData<&'a ()>, } -impl StringsInterner { +impl StringsInterner<'_> { /// Create a new [`StringsInterner`]. #[inline] #[must_use] @@ -30,6 +32,7 @@ impl StringsInterner { getters: BTreeMap::new(), #[cfg(not(feature = "no_object"))] setters: BTreeMap::new(), + dummy: PhantomData, } } /// Get an identifier from a text string and prefix, adding it to the interner if necessary. @@ -69,7 +72,7 @@ impl StringsInterner { } } -impl AddAssign for StringsInterner { +impl AddAssign for StringsInterner<'_> { #[inline(always)] fn add_assign(&mut self, rhs: Self) { self.strings.extend(rhs.strings.into_iter()); @@ -80,7 +83,7 @@ impl AddAssign for StringsInterner { } } -impl AddAssign<&Self> for StringsInterner { +impl AddAssign<&Self> for StringsInterner<'_> { #[inline(always)] fn add_assign(&mut self, rhs: &Self) { self.strings