Skip to content

Commit c5c8f49

Browse files
authored
clean up warnings (#1791)
* clean up warnings * clippy * fix
1 parent 9745930 commit c5c8f49

File tree

5 files changed

+24
-22
lines changed

5 files changed

+24
-22
lines changed

src/bytes/complete.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,13 +415,13 @@ where
415415
/// assert_eq!(esc(r#"12\"34;"#), Ok((";", r#"12\"34"#)));
416416
/// ```
417417
///
418-
pub fn escaped<'a, I: 'a, Error, F, G>(
418+
pub fn escaped<'a, I, Error, F, G>(
419419
normal: F,
420420
control_char: char,
421421
escapable: G,
422422
) -> impl FnMut(I) -> IResult<I, I, Error>
423423
where
424-
I: Clone + crate::traits::Offset + Input,
424+
I: Clone + crate::traits::Offset + Input + 'a,
425425
<I as Input>::Item: crate::traits::AsChar,
426426
F: Parser<I, Error = Error>,
427427
G: Parser<I, Error = Error>,

src/error.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
//! Parsers are generic over their error type, requiring that it implements
44
//! the `error::ParseError<Input>` trait.
55
6-
use crate::internal::{Mode, OutputMode, PResult, Parser};
6+
use crate::internal::{Err, Mode, OutputMode, PResult, Parser};
77
use crate::lib::std::fmt;
88

99
#[cfg(feature = "alloc")]
1010
use crate::alloc::borrow::ToOwned;
1111

12+
#[cfg(feature = "std")]
13+
use crate::internal::IResult;
14+
1215
/// This trait must be implemented by the error type of a nom parser.
1316
///
1417
/// There are already implementations of it for `(Input, ErrorKind)`
@@ -320,8 +323,6 @@ impl From<VerboseError<&str>> for VerboseError<crate::lib::std::string::String>
320323
}
321324
}
322325

323-
use crate::internal::{Err, IResult};
324-
325326
/// Create a new error from an input position, a static string and an existing error.
326327
/// This is used mainly in the [context] combinator, to add user friendly information
327328
/// to errors when backtracking through a parse tree
@@ -733,7 +734,6 @@ where
733734
#[cfg(test)]
734735
mod tests {
735736
use super::*;
736-
use crate::character::complete::char;
737737

738738
#[test]
739739
fn context_test() {
@@ -794,6 +794,9 @@ mod tests {
794794
#[cfg(feature = "alloc")]
795795
#[test]
796796
fn convert_error_panic() {
797+
use crate::character::complete::char;
798+
use crate::internal::IResult;
799+
797800
let input = "";
798801

799802
let _result: IResult<_, _, VerboseError<&str>> = char('x')(input);

src/internal.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ pub trait Finish<I, O, E> {
2727
/// *warning*: if the result is `Err(Err::Incomplete(_))`, this method will panic.
2828
/// - "complete" parsers: It will not be an issue, `Incomplete` is never used
2929
/// - "streaming" parsers: `Incomplete` will be returned if there's not enough data
30-
/// for the parser to decide, and you should gather more data before parsing again.
31-
/// Once the parser returns either `Ok(_)`, `Err(Err::Error(_))` or `Err(Err::Failure(_))`,
32-
/// you can get out of the parsing loop and call `finish()` on the parser's result
30+
/// for the parser to decide, and you should gather more data before parsing again.
31+
/// Once the parser returns either `Ok(_)`, `Err(Err::Error(_))` or `Err(Err::Failure(_))`,
32+
/// you can get out of the parsing loop and call `finish()` on the parser's result
3333
fn finish(self) -> Result<(I, O), E>;
3434
}
3535

@@ -83,14 +83,14 @@ impl Needed {
8383
/// It has three cases:
8484
///
8585
/// * `Incomplete` indicates that more data is needed to decide. The `Needed` enum
86-
/// can contain how many additional bytes are necessary. If you are sure your parser
87-
/// is working on full data, you can wrap your parser with the `complete` combinator
88-
/// to transform that case in `Error`
86+
/// can contain how many additional bytes are necessary. If you are sure your parser
87+
/// is working on full data, you can wrap your parser with the `complete` combinator
88+
/// to transform that case in `Error`
8989
/// * `Error` means some parser did not succeed, but another one might (as an example,
90-
/// when testing different branches of an `alt` combinator)
90+
/// when testing different branches of an `alt` combinator)
9191
/// * `Failure` indicates an unrecoverable error. For example, when a prefix has been
92-
/// recognised and the next parser has been confirmed, if that parser fails, then the
93-
/// entire process fails; there are no more parsers to try.
92+
/// recognised and the next parser has been confirmed, if that parser fails, then the
93+
/// entire process fails; there are no more parsers to try.
9494
///
9595
/// Distinguishing `Failure` this from `Error` is only relevant inside the parser's code. For
9696
/// external consumers, both mean that parsing failed.
@@ -316,10 +316,10 @@ impl Mode for Check {
316316
/// Parser result type
317317
///
318318
/// * `Ok` branch: a tuple of the remaining input data, and the output value.
319-
/// The output value is of the `O` type if the output mode was [Emit], and `()`
320-
/// if the mode was [Check]
319+
/// The output value is of the `O` type if the output mode was [Emit], and `()`
320+
/// if the mode was [Check]
321321
/// * `Err` branch: an error of the `E` type if the erroor mode was [Emit], and `()`
322-
/// if the mode was [Check]
322+
/// if the mode was [Check]
323323
pub type PResult<OM, I, O, E> = Result<
324324
(I, <<OM as OutputMode>::Output as Mode>::Output<O>),
325325
Err<E, <<OM as OutputMode>::Error as Mode>::Output<E>>,

src/traits.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,7 @@ impl NomRange<usize> for RangeFrom<usize> {
15331533
}
15341534

15351535
fn bounded_iter(&self) -> Self::Bounded {
1536-
0..core::usize::MAX
1536+
0..usize::MAX
15371537
}
15381538
}
15391539

@@ -1616,7 +1616,7 @@ impl NomRange<usize> for RangeFull {
16161616
}
16171617

16181618
fn bounded_iter(&self) -> Self::Bounded {
1619-
0..core::usize::MAX
1619+
0..usize::MAX
16201620
}
16211621
}
16221622

tests/float.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ use nom::number::complete::f32;
77
use nom::number::complete::f64;
88
use nom::number::Endianness;
99
use nom::sequence::{delimited, pair};
10-
use nom::{Err, Needed};
10+
use nom::Err;
1111
use nom::{IResult, Parser};
12-
use std::num::NonZeroUsize;
1312
use std::str;
1413
use std::str::FromStr;
1514

0 commit comments

Comments
 (0)