Skip to content

Commit

Permalink
Merge branch 'main' into inline-split
Browse files Browse the repository at this point in the history
  • Loading branch information
Geal committed May 5, 2024
2 parents 30c7595 + 5773e90 commit 543237c
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 119 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,10 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: tarpaulin
args: --output-dir coverage --out Lcov
args: --output-dir coverage --out xml --workspace --exclude benchmarks

- name: Publish to Coveralls
uses: coverallsapp/github-action@master
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.CODECOV_TOKEN }}
slug: rust-bakery/nom
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

name = "nom"
version = "7.1.2"
version = "8.0.0-alpha1"
authors = ["contact@geoffroycouprie.com"]
description = "A byte-oriented, zero-copy, parser combinators library"
license = "MIT"
Expand Down
10 changes: 5 additions & 5 deletions src/bytes/complete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use core::marker::PhantomData;

use crate::error::ParseError;
use crate::internal::{IResult, Parser};
use crate::traits::{Compare, FindSubstring, FindToken, InputLength, ToUsize};
use crate::traits::{Compare, FindSubstring, FindToken, ToUsize};
use crate::Complete;
use crate::Emit;
use crate::Input;
Expand Down Expand Up @@ -32,7 +32,7 @@ use crate::OutputM;
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
where
I: Input + Compare<T>,
T: InputLength + Clone,
T: Input + Clone,
{
move |i: I| {
let mut parser = super::Tag {
Expand Down Expand Up @@ -68,7 +68,7 @@ where
pub fn tag_no_case<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
where
I: Input + Compare<T>,
T: InputLength + Clone,
T: Input + Clone,
{
move |i: I| {
let mut parser = super::TagNoCase {
Expand Down Expand Up @@ -359,7 +359,7 @@ where
pub fn take_until<T, I, Error: ParseError<I>>(tag: T) -> impl FnMut(I) -> IResult<I, I, Error>
where
I: Input + FindSubstring<T>,
T: InputLength + Clone,
T: Input + Clone,
{
let mut parser = super::take_until(tag);

Expand Down Expand Up @@ -388,7 +388,7 @@ where
pub fn take_until1<T, I, Error: ParseError<I>>(tag: T) -> impl FnMut(I) -> IResult<I, I, Error>
where
I: Input + FindSubstring<T>,
T: InputLength + Clone,
T: Input + Clone,
{
let mut parser = super::take_until1(tag);

Expand Down
10 changes: 5 additions & 5 deletions src/bytes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::error::ErrorKind;
use crate::error::ParseError;
use crate::internal::{Err, Needed, Parser};
use crate::lib::std::result::Result::*;
use crate::traits::{Compare, CompareResult, InputLength};
use crate::traits::{Compare, CompareResult};
use crate::AsChar;
use crate::Check;
use crate::ExtendInto;
Expand Down Expand Up @@ -45,7 +45,7 @@ use crate::ToUsize;
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Parser<I, Output = I, Error = Error>
where
I: Input + Compare<T>,
T: InputLength + Clone,
T: Input + Clone,
{
Tag {
tag,
Expand All @@ -62,7 +62,7 @@ pub struct Tag<T, E> {
impl<I, Error: ParseError<I>, T> Parser<I> for Tag<T, Error>
where
I: Input + Compare<T>,
T: InputLength + Clone,
T: Input + Clone,
{
type Output = I;

Expand Down Expand Up @@ -114,7 +114,7 @@ where
pub fn tag_no_case<T, I, Error: ParseError<I>>(tag: T) -> impl Parser<I, Output = I, Error = Error>
where
I: Input + Compare<T>,
T: InputLength + Clone,
T: Input + Clone,
{
TagNoCase {
tag,
Expand All @@ -131,7 +131,7 @@ pub struct TagNoCase<T, E> {
impl<I, Error: ParseError<I>, T> Parser<I> for TagNoCase<T, Error>
where
I: Input + Compare<T>,
T: InputLength + Clone,
T: Input + Clone,
{
type Output = I;

Expand Down
8 changes: 4 additions & 4 deletions src/bytes/streaming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use core::marker::PhantomData;

use crate::error::ParseError;
use crate::internal::{IResult, Parser};
use crate::traits::{Compare, FindSubstring, FindToken, InputLength, ToUsize};
use crate::traits::{Compare, FindSubstring, FindToken, ToUsize};
use crate::Emit;
use crate::Input;
use crate::OutputM;
Expand All @@ -31,7 +31,7 @@ use crate::Streaming;
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
where
I: Input + Compare<T>,
T: InputLength + Clone,
T: Input + Clone,
{
move |i: I| {
let mut parser = super::Tag {
Expand Down Expand Up @@ -65,7 +65,7 @@ where
pub fn tag_no_case<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
where
I: Input + Compare<T>,
T: InputLength + Clone,
T: Input + Clone,
{
move |i: I| {
let mut parser = super::TagNoCase {
Expand Down Expand Up @@ -338,7 +338,7 @@ where
/// ```
pub fn take<C, I, Error: ParseError<I>>(count: C) -> impl FnMut(I) -> IResult<I, I, Error>
where
I: Input + InputLength,
I: Input,
C: ToUsize,
{
let mut parser = super::take(count);
Expand Down
4 changes: 2 additions & 2 deletions src/bytes/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,10 +636,10 @@ fn tag_fixed_size_array() {
use crate::bytes::streaming::tag;

fn test(i: &[u8]) -> IResult<&[u8], &[u8]> {
tag([0x42])(i)
tag(&[0x42][..])(i)
}
fn test2(i: &[u8]) -> IResult<&[u8], &[u8]> {
tag(&[0x42])(i)
tag(&[0x42][..])(i)
}
let input = [0x42, 0x00];
assert_eq!(test(&input), Ok((&b"\x00"[..], &b"\x42"[..])));
Expand Down
4 changes: 2 additions & 2 deletions src/character/complete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::combinator::opt;
use crate::error::ErrorKind;
use crate::error::ParseError;
use crate::internal::{Err, IResult};
use crate::traits::{AsChar, FindToken, Input, InputLength};
use crate::traits::{AsChar, FindToken, Input};
use crate::traits::{Compare, CompareResult};
use crate::Complete;
use crate::Emit;
Expand Down Expand Up @@ -208,7 +208,7 @@ where
/// ```
pub fn line_ending<T, E: ParseError<T>>(input: T) -> IResult<T, T, E>
where
T: Input + InputLength,
T: Input,
T: Compare<&'static str>,
{
match input.compare("\n") {
Expand Down
10 changes: 5 additions & 5 deletions src/combinator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::lib::std::convert::Into;
use crate::lib::std::fmt::Debug;
use crate::lib::std::mem::transmute;
use crate::lib::std::ops::{Range, RangeFrom, RangeTo};
use crate::traits::{AsChar, Input, InputLength, ParseTo};
use crate::traits::{AsChar, Input, ParseTo};
use crate::traits::{Compare, CompareResult, Offset};

#[cfg(test)]
Expand Down Expand Up @@ -48,7 +48,7 @@ where
#[inline]
pub fn rest_len<T, E: ParseError<T>>(input: T) -> IResult<T, usize, E>
where
T: InputLength,
T: Input,
{
let len = input.input_len();
Ok((input, len))
Expand Down Expand Up @@ -363,7 +363,7 @@ where
/// assert_eq!(parser(""), Ok(("", "")));
/// # }
/// ```
pub fn eof<I: InputLength + Clone, E: ParseError<I>>(input: I) -> IResult<I, I, E> {
pub fn eof<I: Input + Clone, E: ParseError<I>>(input: I) -> IResult<I, I, E> {
if input.input_len() == 0 {
let clone = input.clone();
Ok((input, clone))
Expand Down Expand Up @@ -443,7 +443,7 @@ pub fn all_consuming<I, E: ParseError<I>, F>(
parser: F,
) -> impl Parser<I, Output = <F as Parser<I>>::Output, Error = E>
where
I: InputLength,
I: Input,
F: Parser<I, Error = E>,
{
AllConsuming { parser }
Expand All @@ -456,7 +456,7 @@ pub struct AllConsuming<F> {

impl<I, F> Parser<I> for AllConsuming<F>
where
I: InputLength,
I: Input,
F: Parser<I>,
{
type Output = <F as Parser<I>>::Output;
Expand Down
8 changes: 0 additions & 8 deletions src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ impl<I, O, E> Finish<I, O, E> for IResult<I, O, E> {

/// Contains information on needed data if a parser returned `Incomplete`
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
#[cfg_attr(nightly, warn(rustdoc::missing_doc_code_examples))]
pub enum Needed {
/// Needs more data, but we do not know how much
Unknown,
Expand Down Expand Up @@ -99,7 +98,6 @@ impl Needed {
/// See also: [`Finish`].
///
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(nightly, warn(rustdoc::missing_doc_code_examples))]
pub enum Err<Failure, Error = Failure> {
/// There was not enough data
Incomplete(Needed),
Expand Down Expand Up @@ -579,7 +577,6 @@ impl<I, O, E: ParseError<I>> Parser<I> for Box<dyn Parser<I, Output = O, Error =
}
*/
/// Implementation of `Parser::map`
#[cfg_attr(nightly, warn(rustdoc::missing_doc_code_examples))]
pub struct Map<F, G> {
f: F,
g: G,
Expand Down Expand Up @@ -660,7 +657,6 @@ where
}

/// Implementation of `Parser::flat_map`
#[cfg_attr(nightly, warn(rustdoc::missing_doc_code_examples))]
pub struct FlatMap<F, G> {
f: F,
g: G,
Expand All @@ -687,7 +683,6 @@ impl<
}

/// Implementation of `Parser::and_then`
#[cfg_attr(nightly, warn(rustdoc::missing_doc_code_examples))]
pub struct AndThen<F, G> {
f: F,
g: G,
Expand All @@ -710,7 +705,6 @@ impl<I, F: Parser<I>, G: Parser<<F as Parser<I>>::Output, Error = <F as Parser<I
}

/// Implementation of `Parser::and`
#[cfg_attr(nightly, warn(rustdoc::missing_doc_code_examples))]
pub struct And<F, G> {
f: F,
g: G,
Expand All @@ -732,7 +726,6 @@ impl<I, E: ParseError<I>, F: Parser<I, Error = E>, G: Parser<I, Error = E>> Pars
}

/// Implementation of `Parser::or`
#[cfg_attr(nightly, warn(rustdoc::missing_doc_code_examples))]
pub struct Or<F, G> {
f: F,
g: G,
Expand Down Expand Up @@ -761,7 +754,6 @@ impl<
}

/// Implementation of `Parser::into`
#[cfg_attr(nightly, warn(rustdoc::missing_doc_code_examples))]
pub struct Into<F, O2, E2> {
f: F,
phantom_out2: core::marker::PhantomData<O2>,
Expand Down
4 changes: 0 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@
#![cfg_attr(feature = "docsrs", feature(doc_cfg))]
#![allow(clippy::doc_markdown)]
#![deny(missing_docs)]
#[cfg_attr(nightly, warn(rustdoc::missing_doc_code_examples))]
#[cfg(feature = "alloc")]
#[macro_use]
extern crate alloc;
Expand All @@ -391,12 +390,10 @@ doc_comment::doctest!("../README.md");

/// Lib module to re-export everything needed from `std` or `core`/`alloc`. This is how `serde` does
/// it, albeit there it is not public.
#[cfg_attr(nightly, allow(rustdoc::missing_doc_code_examples))]
pub mod lib {
/// `std` facade allowing `std`/`core` to be interchangeable. Reexports `alloc` crate optionally,
/// as well as `core` or `std`
#[cfg(not(feature = "std"))]
#[cfg_attr(nightly, allow(rustdoc::missing_doc_code_examples))]
/// internal std exports for no_std compatibility
pub mod std {
#[doc(hidden)]
Expand All @@ -418,7 +415,6 @@ pub mod lib {
}

#[cfg(feature = "std")]
#[cfg_attr(nightly, allow(rustdoc::missing_doc_code_examples))]
/// internal std exports for no_std compatibility
pub mod std {
#[doc(hidden)]
Expand Down

0 comments on commit 543237c

Please sign in to comment.