Skip to content

Commit 03209b9

Browse files
authored
relaxed bounds on ParserExtra (only context needs it now) (#874)
Co-authored-by: zer0guz <zer0guz>
1 parent 04cfced commit 03209b9

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

src/extra.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ type DefaultCtx = ();
1717
///
1818
/// This trait is sealed and so cannot be implemented by other crates because all uses should instead
1919
/// go through the types defined in this module.
20-
pub trait ParserExtra<'a, I>: 'a + Sealed
20+
pub trait ParserExtra<'a, I>: Sealed
2121
where
2222
I: Input<'a>,
2323
{
2424
/// Error type to use for the parser. This type must implement [`Error`], and when it fails,
2525
/// the parser will return a set of this type to describe why the failure occurred.
26-
type Error: Error<'a, I> + 'a;
26+
type Error: Error<'a, I>;
2727
/// State type to use for the parser. This is used to provide stateful *output* of the parser,
2828
/// such as interned identifiers or position-dependent name resolution, however *cannot* influence
2929
/// the actual progress of the parser - for that, use [`Self::Context`].
3030
///
3131
/// For examples of using this type, see [`Parser::map_with`] or [`Parser::foldl_with`].
32-
type State: Inspector<'a, I> + 'a;
32+
type State: Inspector<'a, I>;
3333
/// Context used for parser configuration. This is used to provide context-sensitive parsing of *input*.
3434
/// Context-sensitive parsing in chumsky is always left-hand sensitive - context for the parse must originate
3535
/// from an earlier point in the stream than the parser relying on it. This can affect the output of a parser,
@@ -63,8 +63,8 @@ impl<E, S, C> Sealed for Full<E, S, C> {}
6363
impl<'a, I, E, S, C> ParserExtra<'a, I> for Full<E, S, C>
6464
where
6565
I: Input<'a>,
66-
E: Error<'a, I> + 'a,
67-
S: Inspector<'a, I> + 'a,
66+
E: Error<'a, I>,
67+
S: Inspector<'a, I>,
6868
C: 'a,
6969
{
7070
type Error = E;

src/input.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1355,7 +1355,7 @@ impl<'src, 'parse, I: Input<'src>, E: ParserExtra<'src, I>> InputRef<'src, 'pars
13551355
) -> O
13561356
where
13571357
'parse: 'sub_parse,
1358-
S: 'src + Inspector<'src, I>,
1358+
S: Inspector<'src, I>,
13591359
{
13601360
let mut new_inp = InputRef {
13611361
cursor: self.cursor.clone(),

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,7 +2200,7 @@ pub trait Parser<'src, I: Input<'src>, O, E: ParserExtra<'src, I> = extra::Defau
22002200
///
22012201
fn boxed<'b>(self) -> Boxed<'src, 'b, I, O, E>
22022202
where
2203-
Self: Sized + 'src + 'b,
2203+
Self: Sized + 'b,
22042204
{
22052205
Boxed {
22062206
inner: Rc::new(self),
@@ -2822,7 +2822,7 @@ where
28222822

28232823
fn boxed<'c>(self) -> Boxed<'src, 'c, I, O, E>
28242824
where
2825-
Self: Sized + 'src + 'c,
2825+
Self: Sized + 'c,
28262826
{
28272827
// Never double-box parsers
28282828
self

src/recovery.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,17 +231,18 @@ pub fn skip_until<S, U, F>(skip: S, until: U, fallback: F) -> SkipUntil<S, U, F>
231231
///
232232
/// A function that generates a fallback output on recovery is also required.
233233
// TODO: Make this a strategy, add an unclosed_delimiter error
234-
pub fn nested_delimiters<'src, I, O, E, F, const N: usize>(
234+
pub fn nested_delimiters<'src, 'parse, I, O, E, F, const N: usize>(
235235
start: I::Token,
236236
end: I::Token,
237237
others: [(I::Token, I::Token); N],
238238
fallback: F,
239-
) -> impl Parser<'src, I, O, E> + Clone
239+
) -> impl Parser<'src, I, O, E> + Clone + 'parse
240240
where
241241
I: ValueInput<'src>,
242242
I::Token: PartialEq + Clone,
243-
E: extra::ParserExtra<'src, I>,
244-
F: Fn(I::Span) -> O + Clone,
243+
E: extra::ParserExtra<'src, I> + 'parse,
244+
'src: 'parse,
245+
F: Fn(I::Span) -> O + Clone + 'parse,
245246
{
246247
// TODO: Does this actually work? TESTS!
247248
#[allow(clippy::tuple_array_conversions)]

0 commit comments

Comments
 (0)