Skip to content

Commit

Permalink
remove warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Geal committed Jun 16, 2019
1 parent 6af9692 commit f8e32ba
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 41 deletions.
12 changes: 8 additions & 4 deletions src/branch/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,11 +720,15 @@ macro_rules! permutation_iterator (
#[cfg(test)]
mod tests {
use crate::error::ErrorKind;
use crate::error::ParseError;
use crate::internal::{Err, IResult, Needed};
use crate::lib::std::fmt::Debug;
#[cfg(feature = "alloc")]
use crate::lib::std::string::{String, ToString};
use crate::{
error::ParseError,
lib::std::{
fmt::Debug,
string::{String, ToString}
}
};
use crate::internal::{Err, IResult, Needed};

// reproduce the tag and take macros, because of module import order
macro_rules! tag (
Expand Down
1 change: 1 addition & 0 deletions src/bytes/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ mod tests {
use crate::error::ErrorKind;
use crate::character::is_alphabetic;

#[cfg(feature = "alloc")]
macro_rules! one_of (
($i:expr, $inp: expr) => (
{
Expand Down
15 changes: 4 additions & 11 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
//! It contains an error code and the input position that triggered it.
//!
use crate::internal::{Err, IResult};

#[cfg(feature="std")]
use std::iter::repeat;
#[cfg(feature="std")]
use crate::traits::Offset;

/// this trait must be implemented by the error type of a nom parser
///
/// There are already implementations of it for `(Input, ErrorKind)`
Expand Down Expand Up @@ -125,6 +118,9 @@ impl<I> ParseError<I> for VerboseError<I> {
}
}

#[cfg(feature = "alloc")]
use crate::internal::{Err, IResult};

/// create a new error from an input position, a static string and an existing error.
/// This is used mainly in the [context] combinator, to add user friendly information
/// to errors when backtracking through a parse tree
Expand All @@ -147,10 +143,7 @@ where
#[cfg(feature="alloc")]
pub fn convert_error(input: &str, e: VerboseError<&str>) -> crate::lib::std::string::String {
use crate::{
lib::std::{
string::String, vec::Vec,
iter::repeat
},
lib::std::iter::repeat,
traits::Offset
};

Expand Down
14 changes: 0 additions & 14 deletions src/multi/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,20 +578,6 @@ mod tests {
);
);

macro_rules! take(
($i:expr, $count:expr) => (
{
let cnt = $count as usize;
let res:IResult<&[u8],&[u8],_> = if $i.len() < cnt {
Err(Err::Incomplete(Needed::Size(cnt)))
} else {
Ok((&$i[cnt..],&$i[0..cnt]))
};
res
}
);
);

#[test]
#[cfg(feature = "alloc")]
fn separated_list() {
Expand Down
7 changes: 0 additions & 7 deletions src/number/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,6 @@ macro_rules! i128 ( ($i:expr, $e:expr) => ( {if $crate::number::Endianness::Big
mod tests {
use crate::number::Endianness;

macro_rules! assert_parse(
($left: expr, $right: expr) => {
let res: $crate::IResult<_, _, (_, ErrorKind)> = $left;
assert_eq!(res, $right);
};
);

#[test]
fn configurable_endianness() {
named!(be_tst16<u16>, u16!(Endianness::Big));
Expand Down
4 changes: 2 additions & 2 deletions src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,8 @@ impl<'a, 'b> Compare<&'b [u8]> for &'a [u8] {
let other = &t[..m];

if !reduced.iter().zip(other).all(|(a, b)| match (*a, *b) {
(0...64, 0...64) | (91...96, 91...96) | (123...255, 123...255) => a == b,
(65...90, 65...90) | (97...122, 97...122) | (65...90, 97...122) | (97...122, 65...90) => *a | 0b00_10_00_00 == *b | 0b00_10_00_00,
(0..=64, 0..=64) | (91..=96, 91..=96) | (123..=255, 123..=255) => a == b,
(65..=90, 65..=90) | (97..=122, 97..=122) | (65..=90, 97..=122) | (97..=122, 65..=90) => *a | 0b00_10_00_00 == *b | 0b00_10_00_00,
_ => false,
}) {
CompareResult::Error
Expand Down
10 changes: 7 additions & 3 deletions src/whitespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,10 +819,14 @@ macro_rules! ws (
#[allow(dead_code)]
mod tests {
#[cfg(feature = "alloc")]
use crate::lib::std::string::{String, ToString};
use crate::lib::std::fmt::Debug;
use crate::{
error::ParseError,
lib::std::{
string::{String, ToString},
fmt::Debug
}
};
use crate::internal::{Err, IResult, Needed};
use crate::error::ParseError;
use crate::character::complete::multispace0 as sp;
use crate::error::ErrorKind;

Expand Down
1 change: 1 addition & 0 deletions tests/overflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
extern crate nom;

use nom::{Err, Needed};
#[cfg(feature = "alloc")]
use nom::number::streaming::be_u64;

// Parser definition
Expand Down

0 comments on commit f8e32ba

Please sign in to comment.