Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove extraneous Input::Error trait bounds #353

Merged
merged 2 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
build:
strategy:
matrix:
rust: [1.40.0, stable, beta, nightly]
rust: [1.51.0, stable, beta, nightly]
env:
CARGO_INCREMENTAL: 0 # Incremental compilation is slower and bloats the cache
RUST_BACKTRACE: 1
Expand All @@ -32,14 +32,14 @@ jobs:
- name: Build
run: cargo build

- name: Check 1.40
if: ${{ matrix.rust == '1.40.0' }}
- name: Check 1.51
if: ${{ matrix.rust == '1.51.0' }}
run: |
cargo "$@" check
cargo "$@" check --no-default-features

- name: Run tests
if: ${{ matrix.rust != '1.40.0' }}
if: ${{ matrix.rust != '1.51.0' }}
run: ./ci.sh

- name: Check docs
Expand Down
5 changes: 1 addition & 4 deletions benches/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,13 @@ fn is_http_version(c: u8) -> bool {
fn end_of_line<'a, Input>() -> impl Parser<Input, Output = u8>
where
Input: RangeStream<Token = u8, Range = &'a [u8]>,
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
{
(token(b'\r'), token(b'\n')).map(|_| b'\r').or(token(b'\n'))
}

fn message_header<'a, Input>() -> impl Parser<Input, Output = Header<'a>>
where
Input: RangeStream<Token = u8, Range = &'a [u8]>,
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
{
let message_header_line = (
take_while1(is_horizontal_space),
Expand All @@ -103,7 +101,6 @@ type HttpRequest<'a> = (Request<'a>, Vec<Header<'a>>);
fn parse_http_request<'a, Input>(input: Input) -> Result<(HttpRequest<'a>, Input), Input::Error>
where
Input: RangeStream<Token = u8, Range = &'a [u8]>,
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
{
let http_version = range(&b"HTTP/"[..]).with(take_while1(is_http_version));

Expand Down Expand Up @@ -155,7 +152,7 @@ fn http_requests_large_cheap_error(b: &mut Bencher<'_>) {
fn http_requests_bench<'a, Input>(b: &mut Bencher<'_>, buffer: Input)
where
Input: RangeStream<Token = u8, Range = &'a [u8]> + Clone,
Input::Error: ParseError<Input::Token, Input::Range, Input::Position> + fmt::Debug,
Input::Error: fmt::Debug,
{
b.iter(|| {
let mut buf = black_box(buffer.clone());
Expand Down
6 changes: 0 additions & 6 deletions benches/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ where
fn integer<Input>() -> impl Parser<Input, Output = i64>
where
Input: Stream<Token = char>,
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
{
lex(many1(digit()))
.map(|s: String| {
Expand All @@ -71,7 +70,6 @@ where
fn number<Input>() -> impl Parser<Input, Output = f64>
where
Input: Stream<Token = char>,
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
{
let i = char('0').map(|_| 0.0).or(integer().map(|x| x as f64));
let fractional = many(digit()).map(|digits: String| {
Expand Down Expand Up @@ -105,7 +103,6 @@ where
fn json_char<Input>() -> impl Parser<Input, Output = char>
where
Input: Stream<Token = char>,
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
{
parser(|input: &mut Input| {
let (c, committed) = any().parse_lazy(input).into_result()?;
Expand Down Expand Up @@ -133,15 +130,13 @@ where
fn json_string<Input>() -> impl Parser<Input, Output = String>
where
Input: Stream<Token = char>,
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
{
between(char('"'), lex(char('"')), many(json_char())).expected("string")
}

fn object<Input>() -> impl Parser<Input, Output = Value>
where
Input: Stream<Token = char>,
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
{
let field = (json_string(), lex(char(':')), json_value()).map(|t| (t.0, t.2));
let fields = sep_by(field, lex(char(',')));
Expand All @@ -154,7 +149,6 @@ where
fn json_value<Input>() -> impl Parser<Input, Output = Value>
where
Input: Stream<Token = char>,
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
{
json_value_()
}
Expand Down
2 changes: 0 additions & 2 deletions examples/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ fn decode_parser<'a, Input>(
) -> impl Parser<Input, Output = Vec<u8>, PartialState = AnyPartialState> + 'a
where
Input: RangeStream<Token = u8, Range = &'a [u8]> + 'a,
// Necessary due to rust-lang/rust#24159
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
{
let content_length = range(&b"Content-Length: "[..])
.with(recognize(skip_many1(digit())).and_then(|digits: &[u8]| {
Expand Down
7 changes: 0 additions & 7 deletions examples/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use std::{

use combine::{
choice,
error::ParseError,
many, optional,
parser::char::{char, digit},
stream::position,
Expand Down Expand Up @@ -63,8 +62,6 @@ pub struct DateTime {
fn two_digits<Input>() -> impl Parser<Input, Output = i32>
where
Input: Stream<Token = char>,
// Necessary due to rust-lang/rust#24159
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
{
(digit(), digit()).map(|(x, y): (char, char)| {
let x = x.to_digit(10).expect("digit");
Expand All @@ -81,7 +78,6 @@ where
fn time_zone<Input>() -> impl Parser<Input, Output = i32>
where
Input: Stream<Token = char>,
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
{
let utc = char('Z').map(|_| 0);
let offset = (
Expand All @@ -106,7 +102,6 @@ where
fn date<Input>() -> impl Parser<Input, Output = Date>
where
Input: Stream<Token = char>,
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
{
(
many::<String, _, _>(digit()),
Expand All @@ -130,7 +125,6 @@ where
fn time<Input>() -> impl Parser<Input, Output = Time>
where
Input: Stream<Token = char>,
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
{
(
two_digits(),
Expand All @@ -156,7 +150,6 @@ where
fn date_time<Input>() -> impl Parser<Input, Output = DateTime>
where
Input: Stream<Token = char>,
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
{
(date(), char('T'), time()).map(|(date, _, time)| DateTime { date, time })
}
Expand Down
6 changes: 0 additions & 6 deletions examples/ini.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ pub struct Ini {
fn property<Input>() -> impl Parser<Input, Output = (String, String)>
where
Input: Stream<Token = char>,
// Necessary due to rust-lang/rust#24159
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
{
(
many1(satisfy(|c| c != '=' && c != '[' && c != ';')),
Expand All @@ -56,7 +54,6 @@ where
fn whitespace<Input>() -> impl Parser<Input>
where
Input: Stream<Token = char>,
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
{
let comment = (token(';'), skip_many(satisfy(|c| c != '\n'))).map(|_| ());
// Wrap the `spaces().or(comment)` in `skip_many` so that it skips alternating whitespace and
Expand All @@ -67,7 +64,6 @@ where
fn properties<Input>() -> impl Parser<Input, Output = HashMap<String, String>>
where
Input: Stream<Token = char>,
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
{
// After each property we skip any whitespace that followed it
many(property().skip(whitespace()))
Expand All @@ -76,7 +72,6 @@ where
fn section<Input>() -> impl Parser<Input, Output = (String, HashMap<String, String>)>
where
Input: Stream<Token = char>,
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
{
(
between(token('['), token(']'), many(satisfy(|c| c != ']'))),
Expand All @@ -90,7 +85,6 @@ where
fn ini<Input>() -> impl Parser<Input, Output = Ini>
where
Input: Stream<Token = char>,
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
{
(whitespace(), properties(), many(section()))
.map(|(_, global, sections)| Ini { global, sections })
Expand Down
1 change: 0 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ impl<T> Commit<T> {
/// //and " respectively
/// fn char<Input>(input: &mut Input) -> StdParseResult<char, Input>
/// where Input: Stream<Token = char>,
/// Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
/// {
/// let (c, committed) = satisfy(|c| c != '"').parse_stream(input).into_result()?;
/// match c {
Expand Down
6 changes: 0 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@
//! // `impl Parser` can be used to create reusable parsers with zero overhead
//! fn expr_<Input>() -> impl Parser< Input, Output = Expr>
//! where Input: Stream<Token = char>,
//! // Necessary due to rust-lang/rust#24159
//! Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
//! {
//! let word = many1(letter());
//!
Expand Down Expand Up @@ -259,7 +257,6 @@ pub use crate::parser::token::tokens_cmp;
/// fn integer[Input]()(Input) -> i32
/// where [
/// Input: Stream<Token = char>,
/// Input::Error: ParseError<char, Input::Range, Input::Position>,
/// <Input::Error as ParseError<Input::Token, Input::Range, Input::Position>>::StreamError:
/// From<::std::num::ParseIntError>,
/// ]
Expand All @@ -283,7 +280,6 @@ pub use crate::parser::token::tokens_cmp;
/// pub fn integer_or_string[Input]()(Input) -> IntOrString
/// where [
/// Input: Stream<Token = char>,
/// Input::Error: ParseError<char, Input::Range, Input::Position>,
/// <Input::Error as ParseError<Input::Token, Input::Range, Input::Position>>::StreamError:
/// From<::std::num::ParseIntError>,
/// ]
Expand Down Expand Up @@ -709,7 +705,6 @@ mod std_tests {
fn integer<Input>(input: &mut Input) -> StdParseResult<i64, Input>
where
Input: Stream<Token = char>,
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
{
let (s, input) = many1::<String, _, _>(digit())
.expected("integer")
Expand Down Expand Up @@ -834,7 +829,6 @@ mod std_tests {
fn term<Input>(input: &mut Input) -> StdParseResult<Expr, Input>
where
Input: Stream<Token = char>,
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
{
fn times(l: Expr, r: Expr) -> Expr {
Expr::Times(Box::new(l), Box::new(r))
Expand Down
Loading