diff --git a/fluent-bundle/src/resolver/expression.rs b/fluent-bundle/src/resolver/expression.rs index 5d22b54e..63dc50a8 100644 --- a/fluent-bundle/src/resolver/expression.rs +++ b/fluent-bundle/src/resolver/expression.rs @@ -12,9 +12,9 @@ use crate::resource::FluentResource; use crate::types::FluentValue; impl<'bundle> WriteOrResolve<'bundle> for ast::Expression<&'bundle str> { - fn write_or_resolve<'ast, 'args, 'errors, R, M, T>( - &'ast self, - scope: &mut Scope<'bundle, 'ast, 'args, 'errors, R, M>, + fn write_or_resolve<'other, R, M, T>( + &'bundle self, + scope: &mut Scope<'bundle, 'other, R, M>, context: &mut T, ) -> T::Result where diff --git a/fluent-bundle/src/resolver/inline_expression.rs b/fluent-bundle/src/resolver/inline_expression.rs index 8d30cb06..7bdf825c 100644 --- a/fluent-bundle/src/resolver/inline_expression.rs +++ b/fluent-bundle/src/resolver/inline_expression.rs @@ -10,9 +10,9 @@ use std::borrow::{Borrow, Cow}; use std::fmt; impl<'bundle> WriteOrResolve<'bundle> for ast::InlineExpression<&'bundle str> { - fn write_or_resolve<'ast, 'args, 'errors, R, M, T>( - &'ast self, - scope: &mut Scope<'bundle, 'ast, 'args, 'errors, R, M>, + fn write_or_resolve<'other, R, M, T>( + &'bundle self, + scope: &mut Scope<'bundle, 'other, R, M>, context: &mut T, ) -> T::Result where diff --git a/fluent-bundle/src/resolver/mod.rs b/fluent-bundle/src/resolver/mod.rs index 2457e3f2..d53f2537 100644 --- a/fluent-bundle/src/resolver/mod.rs +++ b/fluent-bundle/src/resolver/mod.rs @@ -27,9 +27,9 @@ pub trait WriteOrResolveContext<'bundle> { type Result; fn unescape(&mut self, s: &'bundle str) -> Self::Result; - fn value<'ast, 'args, 'errors, R, M>( + fn value<'other, R, M>( &mut self, - scope: &Scope<'bundle, 'ast, 'args, 'errors, R, M>, + scope: &Scope<'bundle, 'other, R, M>, value: Cow>, ) -> Self::Result where @@ -37,10 +37,10 @@ pub trait WriteOrResolveContext<'bundle> { M: MemoizerKind; fn error>(&mut self, exp: &E, is_ref: bool) -> Self::Result; - fn resolve_pattern<'ast, 'args, 'errors, R, M>( + fn resolve_pattern<'other, R, M>( &mut self, - scope: &mut Scope<'bundle, 'ast, 'args, 'errors, R, M>, - pattern: &'ast ast::Pattern<&'bundle str>, + scope: &mut Scope<'bundle, 'other, R, M>, + pattern: &'bundle ast::Pattern<&'bundle str>, ) -> Self::Result where R: Borrow, @@ -58,9 +58,9 @@ where unescape_unicode(self, s) } - fn value<'ast, 'args, 'errors, R, M>( + fn value<'other, R, M>( &mut self, - scope: &Scope<'bundle, 'ast, 'args, 'errors, R, M>, + scope: &Scope<'bundle, 'other, R, M>, value: Cow>, ) -> Self::Result where @@ -86,10 +86,10 @@ where Ok(()) } - fn resolve_pattern<'ast, 'args, 'errors, R, M>( + fn resolve_pattern<'other, R, M>( &mut self, - scope: &mut Scope<'bundle, 'ast, 'args, 'errors, R, M>, - pattern: &'ast ast::Pattern<&'bundle str>, + scope: &mut Scope<'bundle, 'other, R, M>, + pattern: &'bundle ast::Pattern<&'bundle str>, ) -> Self::Result where R: Borrow, @@ -109,9 +109,9 @@ impl<'bundle> WriteOrResolveContext<'bundle> for ResolveContext { unescape_unicode_to_string(s).into() } - fn value<'ast, 'args, 'errors, R, M>( + fn value<'other, R, M>( &mut self, - _scope: &Scope<'bundle, 'ast, 'args, 'errors, R, M>, + _scope: &Scope<'bundle, 'other, R, M>, value: Cow>, ) -> Self::Result where @@ -125,10 +125,10 @@ impl<'bundle> WriteOrResolveContext<'bundle> for ResolveContext { FluentValue::Error } - fn resolve_pattern<'ast, 'args, 'errors, R, M>( + fn resolve_pattern<'other, R, M>( &mut self, - scope: &mut Scope<'bundle, 'ast, 'args, 'errors, R, M>, - pattern: &'ast ast::Pattern<&'bundle str>, + scope: &mut Scope<'bundle, 'other, R, M>, + pattern: &'bundle ast::Pattern<&'bundle str>, ) -> Self::Result where R: Borrow, @@ -139,9 +139,9 @@ impl<'bundle> WriteOrResolveContext<'bundle> for ResolveContext { } pub trait WriteOrResolve<'bundle> { - fn write_or_resolve<'ast, 'args, 'errors, R, M, T>( - &'ast self, - scope: &mut Scope<'bundle, 'ast, 'args, 'errors, R, M>, + fn write_or_resolve<'other, R, M, T>( + &'bundle self, + scope: &mut Scope<'bundle, 'other, R, M>, context: &mut T, ) -> T::Result where diff --git a/fluent-bundle/src/resolver/pattern.rs b/fluent-bundle/src/resolver/pattern.rs index 96cfc813..3c1ab4fa 100644 --- a/fluent-bundle/src/resolver/pattern.rs +++ b/fluent-bundle/src/resolver/pattern.rs @@ -12,10 +12,10 @@ use crate::types::FluentValue; const MAX_PLACEABLES: u8 = 100; -pub fn write_pattern<'bundle, 'ast, 'args, 'errors, W, R, M>( - pattern: &'ast ast::Pattern<&'bundle str>, +pub fn write_pattern<'bundle, 'other, W, R, M>( + pattern: &'bundle ast::Pattern<&'bundle str>, w: &mut W, - scope: &mut Scope<'bundle, 'ast, 'args, 'errors, R, M>, + scope: &mut Scope<'bundle, 'other, R, M>, ) -> fmt::Result where W: fmt::Write, @@ -66,9 +66,9 @@ where Ok(()) } -pub fn resolve_pattern<'bundle, 'ast, 'args, 'errors, R, M>( - pattern: &'ast ast::Pattern<&'bundle str>, - scope: &mut Scope<'bundle, 'ast, 'args, 'errors, R, M>, +pub fn resolve_pattern<'bundle, 'other, R, M>( + pattern: &'bundle ast::Pattern<&'bundle str>, + scope: &mut Scope<'bundle, 'other, R, M>, ) -> FluentValue<'bundle> where R: Borrow, diff --git a/fluent-bundle/src/resolver/scope.rs b/fluent-bundle/src/resolver/scope.rs index 7061a4b0..f12fddae 100644 --- a/fluent-bundle/src/resolver/scope.rs +++ b/fluent-bundle/src/resolver/scope.rs @@ -8,29 +8,29 @@ use std::borrow::Borrow; use super::{ResolveContext, ResolverError, WriteOrResolve, WriteOrResolveContext}; /// State for a single `WriteOrResolve::write_or_resolve` call. -pub struct Scope<'bundle, 'ast, 'args, 'errors, R, M> { +pub struct Scope<'bundle, 'other, R, M> { /// The current `FluentBundle` instance. pub bundle: &'bundle FluentBundle, /// The current arguments passed by the developer. - pub(super) args: Option<&'args FluentArgs<'args>>, + pub(super) args: Option<&'other FluentArgs<'other>>, /// Local args pub(super) local_args: Option>, /// The running count of resolved placeables. Used to detect the Billion /// Laughs and Quadratic Blowup attacks. pub(super) placeables: u8, /// Tracks hashes to prevent infinite recursion. - travelled: smallvec::SmallVec<[&'ast ast::Pattern<&'bundle str>; 2]>, + travelled: smallvec::SmallVec<[&'bundle ast::Pattern<&'bundle str>; 2]>, /// Track errors accumulated during resolving. - pub errors: Option<&'errors mut Vec>, + pub errors: Option<&'other mut Vec>, /// Makes the resolver bail. pub dirty: bool, } -impl<'bundle, 'ast, 'args, 'errors, R, M> Scope<'bundle, 'ast, 'args, 'errors, R, M> { +impl<'bundle, 'other, R, M> Scope<'bundle, 'other, R, M> { pub fn new( bundle: &'bundle FluentBundle, - args: Option<&'args FluentArgs>, - errors: Option<&'errors mut Vec>, + args: Option<&'other FluentArgs>, + errors: Option<&'other mut Vec>, ) -> Self { Scope { bundle, @@ -57,8 +57,8 @@ impl<'bundle, 'ast, 'args, 'errors, R, M> Scope<'bundle, 'ast, 'args, 'errors, R pub fn maybe_track( &mut self, context: &mut T, - pattern: &'ast ast::Pattern<&'bundle str>, - exp: &'ast ast::Expression<&'bundle str>, + pattern: &'bundle ast::Pattern<&'bundle str>, + exp: &'bundle ast::Expression<&'bundle str>, ) -> T::Result where R: Borrow, @@ -79,8 +79,8 @@ impl<'bundle, 'ast, 'args, 'errors, R, M> Scope<'bundle, 'ast, 'args, 'errors, R pub fn track( &mut self, context: &mut T, - pattern: &'ast ast::Pattern<&'bundle str>, - exp: &'ast ast::InlineExpression<&'bundle str>, + pattern: &'bundle ast::Pattern<&'bundle str>, + exp: &'bundle ast::InlineExpression<&'bundle str>, ) -> T::Result where R: Borrow, @@ -100,7 +100,7 @@ impl<'bundle, 'ast, 'args, 'errors, R, M> Scope<'bundle, 'ast, 'args, 'errors, R pub fn get_arguments( &mut self, - arguments: Option<&'ast ast::CallArguments<&'bundle str>>, + arguments: Option<&'bundle ast::CallArguments<&'bundle str>>, ) -> (Vec>, FluentArgs<'bundle>) where R: Borrow,