Skip to content

Commit 87e7397

Browse files
authored
Merge pull request #829 from epage/clippy
style: Make clippy happy
2 parents 79b3941 + e221679 commit 87e7397

File tree

26 files changed

+228
-301
lines changed

26 files changed

+228
-301
lines changed

examples/arithmetic/parser_lexer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,21 +89,21 @@ impl winnow::stream::ContainsToken<&'_ Token<'_>> for TokenKind {
8989
impl winnow::stream::ContainsToken<&'_ Token<'_>> for &'_ [TokenKind] {
9090
#[inline]
9191
fn contains_token(&self, token: &'_ Token<'_>) -> bool {
92-
self.iter().any(|t| *t == token.kind)
92+
self.contains(&token.kind)
9393
}
9494
}
9595

9696
impl<const LEN: usize> winnow::stream::ContainsToken<&'_ Token<'_>> for &'_ [TokenKind; LEN] {
9797
#[inline]
9898
fn contains_token(&self, token: &'_ Token<'_>) -> bool {
99-
self.iter().any(|t| *t == token.kind)
99+
self.contains(&token.kind)
100100
}
101101
}
102102

103103
impl<const LEN: usize> winnow::stream::ContainsToken<&'_ Token<'_>> for [TokenKind; LEN] {
104104
#[inline]
105105
fn contains_token(&self, token: &'_ Token<'_>) -> bool {
106-
self.iter().any(|t| *t == token.kind)
106+
self.contains(&token.kind)
107107
}
108108
}
109109

src/_topic/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
//! - [`toml_edit`](https://crates.io/crates/toml_edit)
2626
//! - [`hcl-edit`](https://crates.io/crates/hcl-edit)
2727
#![allow(clippy::std_instead_of_core)]
28+
#![allow(clippy::test_attr_in_doctest)]
2829

2930
pub mod arithmetic;
3031
pub mod error;

src/ascii/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#[cfg(test)]
66
mod tests;
77

8-
use crate::lib::std::ops::{Add, Shl};
8+
use core::ops::{Add, Shl};
99

1010
use crate::combinator::alt;
1111
use crate::combinator::dispatch;
@@ -1118,7 +1118,7 @@ where
11181118
.verify_map(|s: <Input as Stream>::Slice| {
11191119
let s = s.as_bstr();
11201120
// SAFETY: Only 7-bit ASCII characters are parsed
1121-
let s = unsafe { crate::lib::std::str::from_utf8_unchecked(s) };
1121+
let s = unsafe { core::str::from_utf8_unchecked(s) };
11221122
Output::try_from_dec_uint(s)
11231123
})
11241124
.parse_next(input)
@@ -1208,7 +1208,7 @@ where
12081208
.verify_map(|s: <Input as Stream>::Slice| {
12091209
let s = s.as_bstr();
12101210
// SAFETY: Only 7-bit ASCII characters are parsed
1211-
let s = unsafe { crate::lib::std::str::from_utf8_unchecked(s) };
1211+
let s = unsafe { core::str::from_utf8_unchecked(s) };
12121212
Output::try_from_dec_int(s)
12131213
})
12141214
.parse_next(input)

src/ascii/tests.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ mod complete {
1515
use crate::token::none_of;
1616
use crate::token::one_of;
1717
#[cfg(feature = "alloc")]
18-
use crate::{lib::std::string::String, lib::std::vec::Vec};
18+
use alloc::string::String;
19+
#[cfg(feature = "alloc")]
20+
use alloc::vec::Vec;
1921

2022
#[test]
2123
fn character() {

src/binary/bits/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ mod tests;
66

77
use crate::combinator::trace;
88
use crate::error::{ErrorConvert, Needed, ParserError};
9-
use crate::lib::std::ops::{AddAssign, Div, Shl, Shr};
109
use crate::stream::{Stream, StreamIsPartial, ToUsize};
1110
use crate::{Parser, Result};
11+
use core::ops::{AddAssign, Div, Shl, Shr};
1212

1313
/// Number of bits in a byte
1414
const BYTE: usize = u8::BITS as usize;

src/binary/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ use crate::combinator::repeat;
1111
use crate::combinator::trace;
1212
use crate::error::Needed;
1313
use crate::error::ParserError;
14-
use crate::lib::std::ops::{Add, Shl};
1514
use crate::stream::Accumulate;
1615
use crate::stream::{Stream, StreamIsPartial};
1716
use crate::stream::{ToUsize, UpdateSlice};
1817
use crate::Parser;
1918
use crate::Result;
19+
use core::ops::{Add, Shl};
2020

2121
/// Configurable endianness
2222
#[derive(Debug, PartialEq, Eq, Clone, Copy)]

src/binary/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,14 +1163,14 @@ Ok(
11631163
mod partial {
11641164
use super::*;
11651165

1166-
#[cfg(feature = "alloc")]
1167-
use crate::lib::std::vec::Vec;
11681166
use crate::Partial;
11691167
use crate::{
11701168
ascii::digit1 as digit,
11711169
binary::{be_u16, be_u8},
1172-
lib::std::str::{self, FromStr},
11731170
};
1171+
#[cfg(feature = "alloc")]
1172+
use alloc::vec::Vec;
1173+
use core::str::{self, FromStr};
11741174

11751175
#[test]
11761176
fn i8_tests() {

src/combinator/debug/internals.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl AsRef<usize> for Depth {
9999
}
100100
}
101101

102-
impl crate::lib::std::ops::Deref for Depth {
102+
impl core::ops::Deref for Depth {
103103
type Target = usize;
104104

105105
#[inline(always)]
@@ -130,7 +130,7 @@ impl Severity {
130130

131131
pub(crate) fn start<I: Stream>(
132132
depth: usize,
133-
name: &dyn crate::lib::std::fmt::Display,
133+
name: &dyn core::fmt::Display,
134134
count: usize,
135135
input: &I,
136136
) {
@@ -183,7 +183,7 @@ pub(crate) fn start<I: Stream>(
183183

184184
pub(crate) fn end(
185185
depth: usize,
186-
name: &dyn crate::lib::std::fmt::Display,
186+
name: &dyn core::fmt::Display,
187187
count: usize,
188188
consumed: usize,
189189
severity: Severity,
@@ -231,7 +231,7 @@ pub(crate) fn end(
231231
);
232232
}
233233

234-
pub(crate) fn result(depth: usize, name: &dyn crate::lib::std::fmt::Display, severity: Severity) {
234+
pub(crate) fn result(depth: usize, name: &dyn core::fmt::Display, severity: Severity) {
235235
let gutter_style = anstyle::Style::new().bold();
236236

237237
let (call_width, _) = column_widths();

src/combinator/debug/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use crate::Parser;
3838
#[cfg_attr(not(feature = "debug"), allow(unused_mut))]
3939
#[cfg_attr(not(feature = "debug"), inline(always))]
4040
pub fn trace<I: Stream, O, E: ParserError<I>>(
41-
name: impl crate::lib::std::fmt::Display,
41+
name: impl core::fmt::Display,
4242
parser: impl Parser<I, O, E>,
4343
) -> impl Parser<I, O, E> {
4444
#[cfg(feature = "debug")]
@@ -53,7 +53,7 @@ pub fn trace<I: Stream, O, E: ParserError<I>>(
5353

5454
#[cfg_attr(not(feature = "debug"), allow(unused_variables))]
5555
pub(crate) fn trace_result<T, I: Stream, E: ParserError<I>>(
56-
name: impl crate::lib::std::fmt::Display,
56+
name: impl core::fmt::Display,
5757
res: &Result<T, E>,
5858
) {
5959
#[cfg(feature = "debug")]
@@ -66,8 +66,8 @@ pub(crate) fn trace_result<T, I: Stream, E: ParserError<I>>(
6666

6767
pub(crate) struct DisplayDebug<D>(pub(crate) D);
6868

69-
impl<D: crate::lib::std::fmt::Debug> crate::lib::std::fmt::Display for DisplayDebug<D> {
70-
fn fmt(&self, f: &mut crate::lib::std::fmt::Formatter<'_>) -> crate::lib::std::fmt::Result {
69+
impl<D: core::fmt::Debug> core::fmt::Display for DisplayDebug<D> {
70+
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
7171
write!(f, "{:?}", self.0)
7272
}
7373
}

src/combinator/impls.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ use crate::combinator::DisplayDebug;
77
#[cfg(feature = "std")]
88
use crate::error::FromRecoverableError;
99
use crate::error::{AddContext, FromExternalError, ParserError};
10-
use crate::lib::std::borrow::Borrow;
11-
use crate::lib::std::ops::Range;
1210
#[cfg(feature = "unstable-recover")]
1311
#[cfg(feature = "std")]
1412
use crate::stream::Recover;
1513
use crate::stream::StreamIsPartial;
1614
use crate::stream::{Location, Stream};
1715
use crate::*;
16+
use core::borrow::Borrow;
17+
use core::ops::Range;
1818

1919
/// [`Parser`] implementation for [`Parser::by_ref`]
2020
pub struct ByRef<'p, P, I, O, E> {
@@ -548,7 +548,7 @@ where
548548
I: Stream,
549549
E: AddContext<I, C>,
550550
E: ParserError<I>,
551-
C: Clone + crate::lib::std::fmt::Debug,
551+
C: Clone + core::fmt::Debug,
552552
{
553553
pub(crate) parser: F,
554554
pub(crate) context: C,
@@ -563,7 +563,7 @@ where
563563
I: Stream,
564564
E: AddContext<I, C>,
565565
E: ParserError<I>,
566-
C: Clone + crate::lib::std::fmt::Debug,
566+
C: Clone + core::fmt::Debug,
567567
{
568568
#[inline]
569569
fn parse_next(&mut self, i: &mut I) -> Result<O, E> {
@@ -586,7 +586,7 @@ where
586586
E: AddContext<I, C>,
587587
E: ParserError<I>,
588588
F: Fn() -> FI + Clone,
589-
C: crate::lib::std::fmt::Debug,
589+
C: core::fmt::Debug,
590590
FI: Iterator<Item = C>,
591591
{
592592
pub(crate) parser: P,
@@ -605,7 +605,7 @@ where
605605
E: AddContext<I, C>,
606606
E: ParserError<I>,
607607
F: Fn() -> FI + Clone,
608-
C: crate::lib::std::fmt::Debug,
608+
C: core::fmt::Debug,
609609
FI: Iterator<Item = C>,
610610
{
611611
#[inline]

0 commit comments

Comments
 (0)