rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.03k stars 12.68k forks source link

ice: combine tests: Ty::fn_sig() called on non-fn type: _ #102289

Closed matthiaskrgr closed 2 years ago

matthiaskrgr commented 2 years ago

Code

This happens inside https://github.com/Marwes/combine The ice seems to come from this test function https://github.com/Marwes/combine/blob/master/src/lib.rs#L637

    fn chainl1_error_consume() {
        fn first<T, U>(t: T, _: U) -> T {
            t
        }
        let mut p = chainl1(string("abc"), char(',').map(|_| first));
        assert!(p.parse("abc,ab").is_err());
    }

Meta

rustc --version --verbose:

rustc 1.66.0-nightly (3f83906b3 2022-09-24)
binary: rustc
commit-hash: 3f83906b30798bf61513fa340524cebf6676f9db
commit-date: 2022-09-24
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.0

Error output

error: internal compiler error: compiler/rustc_middle/src/ty/sty.rs:1912:18: Ty::fn_sig() called on non-fn type: _

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/3f83906b30798bf61513fa340524cebf6676f9db/compiler/rustc_errors/src/lib.rs:1496:9
stack backtrace:
   0:     0x7f1d2c032fc0 - std::backtrace_rs::backtrace::libunwind::trace::h83db09f97ba446e0
                               at /rustc/3f83906b30798bf61513fa340524cebf6676f9db/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7f1d2c032fc0 - std::backtrace_rs::backtrace::trace_unsynchronized::hbc692a375382599a
                               at /rustc/3f83906b30798bf61513fa340524cebf6676f9db/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f1d2c032fc0 - std::sys_common::backtrace::_print_fmt::h5d9374f1dc540502
                               at /rustc/3f83906b30798bf61513fa340524cebf6676f9db/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f1d2c032fc0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h678bc20029fef91d
                               at /rustc/3f83906b30798bf61513fa340524cebf6676f9db/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f1d2c08ddfe - core::fmt::write::h3ff59c1e0cfd7af2
                               at /rustc/3f83906b30798bf61513fa340524cebf6676f9db/library/core/src/fmt/mod.rs:1202:17
   5:     0x7f1d2c023c05 - std::io::Write::write_fmt::h57bc84b9ab3e4292
                               at /rustc/3f83906b30798bf61513fa340524cebf6676f9db/library/std/src/io/mod.rs:1679:15
   6:     0x7f1d2c035d43 - std::sys_common::backtrace::_print::h58613138e3b60a1b
                               at /rustc/3f83906b30798bf61513fa340524cebf6676f9db/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f1d2c035d43 - std::sys_common::backtrace::print::h182e9bde2e8d07ea
                               at /rustc/3f83906b30798bf61513fa340524cebf6676f9db/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f1d2c035d43 - std::panicking::default_hook::{{closure}}::h829771b46ce932f3
                               at /rustc/3f83906b30798bf61513fa340524cebf6676f9db/library/std/src/panicking.rs:267:22
   9:     0x7f1d2c035a2f - std::panicking::default_hook::h167447d609e3453b
                               at /rustc/3f83906b30798bf61513fa340524cebf6676f9db/library/std/src/panicking.rs:286:9
  10:     0x7f1d2e86d431 - <rustc_driver[615eae184240f2d1]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[d525c930f060fa4e]::ops::function::FnOnce<(&core[d525c930f060fa4e]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f1d2c03657b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h8a7c5a65eb87446d
                               at /rustc/3f83906b30798bf61513fa340524cebf6676f9db/library/alloc/src/boxed.rs:1954:9
  12:     0x7f1d2c03657b - std::panicking::rust_panic_with_hook::haa7a7aef616e6ae8
                               at /rustc/3f83906b30798bf61513fa340524cebf6676f9db/library/std/src/panicking.rs:673:13
  13:     0x7f1d2f84de31 - std[590eaa09bda9df92]::panicking::begin_panic::<rustc_errors[a92f92f3abe4e548]::ExplicitBug>::{closure#0}
  14:     0x7f1d2f84bb76 - std[590eaa09bda9df92]::sys_common::backtrace::__rust_end_short_backtrace::<std[590eaa09bda9df92]::panicking::begin_panic<rustc_errors[a92f92f3abe4e548]::ExplicitBug>::{closure#0}, !>
  15:     0x7f1d2f84ac36 - std[590eaa09bda9df92]::panicking::begin_panic::<rustc_errors[a92f92f3abe4e548]::ExplicitBug>
  16:     0x7f1d2f7ef916 - std[590eaa09bda9df92]::panic::panic_any::<rustc_errors[a92f92f3abe4e548]::ExplicitBug>
  17:     0x7f1d2f7eaaad - <rustc_errors[a92f92f3abe4e548]::HandlerInner>::bug::<&alloc[10be8beb537b5cb7]::string::String>
  18:     0x7f1d2f7ea4e0 - <rustc_errors[a92f92f3abe4e548]::Handler>::bug::<&alloc[10be8beb537b5cb7]::string::String>
  19:     0x7f1d2f89434d - rustc_middle[8d8f61e964fd0615]::ty::context::tls::with_context_opt::<rustc_middle[8d8f61e964fd0615]::ty::context::tls::with_opt<rustc_middle[8d8f61e964fd0615]::util::bug::opt_span_bug_fmt<rustc_span[199ab19abca3e97b]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
  20:     0x7f1d2f895066 - rustc_middle[8d8f61e964fd0615]::util::bug::opt_span_bug_fmt::<rustc_span[199ab19abca3e97b]::span_encoding::Span>
  21:     0x7f1d2d2e0003 - rustc_middle[8d8f61e964fd0615]::util::bug::bug_fmt
  22:     0x7f1d2d779533 - <rustc_middle[8d8f61e964fd0615]::ty::Ty>::fn_sig
  23:     0x7f1d2d2d2c1a - <rustc_trait_selection[397ec81caba7286e]::traits::select::SelectionContext>::confirm_candidate
  24:     0x7f1d2de6f9df - <rustc_trait_selection[397ec81caba7286e]::traits::select::SelectionContext>::evaluate_stack
  25:     0x7f1d2d3a6fa6 - <rustc_trait_selection[397ec81caba7286e]::traits::select::SelectionContext>::evaluate_predicates_recursively::<alloc[10be8beb537b5cb7]::vec::into_iter::IntoIter<rustc_infer[5da9e549f60f19ef]::traits::Obligation<rustc_middle[8d8f61e964fd0615]::ty::Predicate>>>
  26:     0x7f1d2de6fa6e - <rustc_trait_selection[397ec81caba7286e]::traits::select::SelectionContext>::evaluate_stack
  27:     0x7f1d2da8ba53 - <rustc_trait_selection[397ec81caba7286e]::traits::select::SelectionContext>::evaluate_predicate_recursively
  28:     0x7f1d2da8a8d1 - <rustc_trait_selection[397ec81caba7286e]::traits::select::SelectionContext>::evaluate_root_obligation
  29:     0x7f1d2da892de - <rustc_infer[5da9e549f60f19ef]::infer::InferCtxtBuilder>::enter_with_canonical::<rustc_middle[8d8f61e964fd0615]::ty::ParamEnvAnd<rustc_middle[8d8f61e964fd0615]::ty::Predicate>, core[d525c930f060fa4e]::result::Result<rustc_middle[8d8f61e964fd0615]::traits::select::EvaluationResult, rustc_middle[8d8f61e964fd0615]::traits::select::OverflowError>, rustc_traits[c5c1b050b581cd5b]::evaluate_obligation::evaluate_obligation::{closure#0}>
  30:     0x7f1d2da88b73 - rustc_traits[c5c1b050b581cd5b]::evaluate_obligation::evaluate_obligation
  31:     0x7f1d2dd76ae8 - <rustc_query_system[9d2042684edff429]::dep_graph::graph::DepGraph<rustc_middle[8d8f61e964fd0615]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[8d8f61e964fd0615]::ty::context::TyCtxt, rustc_middle[8d8f61e964fd0615]::infer::canonical::Canonical<rustc_middle[8d8f61e964fd0615]::ty::ParamEnvAnd<rustc_middle[8d8f61e964fd0615]::ty::Predicate>>, core[d525c930f060fa4e]::result::Result<rustc_middle[8d8f61e964fd0615]::traits::select::EvaluationResult, rustc_middle[8d8f61e964fd0615]::traits::select::OverflowError>>
  32:     0x7f1d2dd74b6b - rustc_query_system[9d2042684edff429]::query::plumbing::get_query::<rustc_query_impl[38a29e0b83f56d80]::queries::evaluate_obligation, rustc_query_impl[38a29e0b83f56d80]::plumbing::QueryCtxt>
  33:     0x7f1d2dd74005 - <rustc_query_impl[38a29e0b83f56d80]::Queries as rustc_middle[8d8f61e964fd0615]::ty::query::QueryEngine>::evaluate_obligation
  34:     0x7f1d2dda1175 - <rustc_infer[5da9e549f60f19ef]::infer::InferCtxt as rustc_trait_selection[397ec81caba7286e]::traits::query::evaluate_obligation::InferCtxtExt>::predicate_may_hold
  35:     0x7f1d2dd9e9b0 - <rustc_infer[5da9e549f60f19ef]::infer::InferCtxt>::probe::<rustc_typeck[9e2d563d2719f460]::check::method::probe::ProbeResult, <rustc_typeck[9e2d563d2719f460]::check::method::probe::ProbeContext>::consider_probe::{closure#0}>
  36:     0x7f1d2dd9baef - <rustc_typeck[9e2d563d2719f460]::check::method::probe::ProbeContext>::pick_method
  37:     0x7f1d2dd9b318 - <rustc_typeck[9e2d563d2719f460]::check::method::probe::ProbeContext>::pick_all_method
  38:     0x7f1d2d3154eb - <rustc_infer[5da9e549f60f19ef]::infer::InferCtxt>::probe::<core[d525c930f060fa4e]::result::Result<rustc_typeck[9e2d563d2719f460]::check::method::probe::Pick, rustc_typeck[9e2d563d2719f460]::check::method::MethodError>, <rustc_typeck[9e2d563d2719f460]::check::fn_ctxt::FnCtxt>::probe_op<<rustc_typeck[9e2d563d2719f460]::check::fn_ctxt::FnCtxt>::probe_for_name::{closure#0}, rustc_typeck[9e2d563d2719f460]::check::method::probe::Pick>::{closure#4}>
  39:     0x7f1d2d312481 - <rustc_typeck[9e2d563d2719f460]::check::fn_ctxt::FnCtxt>::lookup_method
  40:     0x7f1d2d2ad78a - <rustc_typeck[9e2d563d2719f460]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  41:     0x7f1d2d2ad724 - <rustc_typeck[9e2d563d2719f460]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  42:     0x7f1d2d2aed5b - <rustc_typeck[9e2d563d2719f460]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  43:     0x7f1d2d2aede7 - <rustc_typeck[9e2d563d2719f460]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  44:     0x7f1d2d2aec35 - <rustc_typeck[9e2d563d2719f460]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  45:     0x7f1d2d323569 - <rustc_typeck[9e2d563d2719f460]::check::fn_ctxt::FnCtxt>::check_block_with_expected
  46:     0x7f1d2d2ad6b5 - <rustc_typeck[9e2d563d2719f460]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  47:     0x7f1d2dea0156 - <rustc_typeck[9e2d563d2719f460]::check::fn_ctxt::FnCtxt>::check_return_expr
  48:     0x7f1d2de989a0 - rustc_typeck[9e2d563d2719f460]::check::check::check_fn
  49:     0x7f1d2de8b0ac - <rustc_infer[5da9e549f60f19ef]::infer::InferCtxtBuilder>::enter::<&rustc_middle[8d8f61e964fd0615]::ty::context::TypeckResults, <rustc_typeck[9e2d563d2719f460]::check::inherited::InheritedBuilder>::enter<rustc_typeck[9e2d563d2719f460]::check::typeck_with_fallback<rustc_typeck[9e2d563d2719f460]::check::typeck::{closure#0}>::{closure#1}, &rustc_middle[8d8f61e964fd0615]::ty::context::TypeckResults>::{closure#0}>
  50:     0x7f1d2de89269 - rustc_typeck[9e2d563d2719f460]::check::typeck
  51:     0x7f1d2db9bf2d - <rustc_query_system[9d2042684edff429]::dep_graph::graph::DepGraph<rustc_middle[8d8f61e964fd0615]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[8d8f61e964fd0615]::ty::context::TyCtxt, rustc_span[199ab19abca3e97b]::def_id::LocalDefId, &rustc_middle[8d8f61e964fd0615]::ty::context::TypeckResults>
  52:     0x7f1d2db882e2 - rustc_query_system[9d2042684edff429]::query::plumbing::try_execute_query::<rustc_query_impl[38a29e0b83f56d80]::plumbing::QueryCtxt, rustc_query_system[9d2042684edff429]::query::caches::DefaultCache<rustc_span[199ab19abca3e97b]::def_id::LocalDefId, &rustc_middle[8d8f61e964fd0615]::ty::context::TypeckResults>>
  53:     0x7f1d2e7a2eae - <rustc_query_impl[38a29e0b83f56d80]::Queries as rustc_middle[8d8f61e964fd0615]::ty::query::QueryEngine>::typeck
  54:     0x7f1d2e5f0327 - rustc_data_structures[28a3ae1a5b9f2391]::sync::par_for_each_in::<&[rustc_span[199ab19abca3e97b]::def_id::LocalDefId], <rustc_middle[8d8f61e964fd0615]::hir::map::Map>::par_body_owners<rustc_typeck[9e2d563d2719f460]::check::typeck_item_bodies::{closure#0}>::{closure#0}>
  55:     0x7f1d2e5f00e3 - rustc_typeck[9e2d563d2719f460]::check::typeck_item_bodies
  56:     0x7f1d2e4fdcb5 - <rustc_query_system[9d2042684edff429]::dep_graph::graph::DepGraph<rustc_middle[8d8f61e964fd0615]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[8d8f61e964fd0615]::ty::context::TyCtxt, (), ()>
  57:     0x7f1d2e4fcca8 - rustc_query_system[9d2042684edff429]::query::plumbing::try_execute_query::<rustc_query_impl[38a29e0b83f56d80]::plumbing::QueryCtxt, rustc_query_system[9d2042684edff429]::query::caches::DefaultCache<(), ()>>
  58:     0x7f1d2e4fc6b7 - rustc_query_system[9d2042684edff429]::query::plumbing::get_query::<rustc_query_impl[38a29e0b83f56d80]::queries::typeck_item_bodies, rustc_query_impl[38a29e0b83f56d80]::plumbing::QueryCtxt>
  59:     0x7f1d2dc2e00f - <rustc_session[c2bba8d08c637bfa]::session::Session>::time::<(), rustc_typeck[9e2d563d2719f460]::check_crate::{closure#7}>
  60:     0x7f1d2dc2dbcf - rustc_typeck[9e2d563d2719f460]::check_crate
  61:     0x7f1d2dc2d197 - rustc_interface[c48cc815669d5993]::passes::analysis
  62:     0x7f1d2e630d32 - <rustc_query_system[9d2042684edff429]::dep_graph::graph::DepGraph<rustc_middle[8d8f61e964fd0615]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[8d8f61e964fd0615]::ty::context::TyCtxt, (), core[d525c930f060fa4e]::result::Result<(), rustc_errors[a92f92f3abe4e548]::ErrorGuaranteed>>
  63:     0x7f1d2e630426 - rustc_query_system[9d2042684edff429]::query::plumbing::try_execute_query::<rustc_query_impl[38a29e0b83f56d80]::plumbing::QueryCtxt, rustc_query_system[9d2042684edff429]::query::caches::DefaultCache<(), core[d525c930f060fa4e]::result::Result<(), rustc_errors[a92f92f3abe4e548]::ErrorGuaranteed>>>
  64:     0x7f1d2e62ff07 - rustc_query_system[9d2042684edff429]::query::plumbing::get_query::<rustc_query_impl[38a29e0b83f56d80]::queries::analysis, rustc_query_impl[38a29e0b83f56d80]::plumbing::QueryCtxt>
  65:     0x7f1d2d5f8c8e - <rustc_interface[c48cc815669d5993]::passes::QueryContext>::enter::<rustc_driver[615eae184240f2d1]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[d525c930f060fa4e]::result::Result<(), rustc_errors[a92f92f3abe4e548]::ErrorGuaranteed>>
  66:     0x7f1d2d5f35fc - rustc_interface[c48cc815669d5993]::interface::create_compiler_and_run::<core[d525c930f060fa4e]::result::Result<(), rustc_errors[a92f92f3abe4e548]::ErrorGuaranteed>, rustc_driver[615eae184240f2d1]::run_compiler::{closure#1}>
  67:     0x7f1d2d5f1f41 - <scoped_tls[cad2a7494d31e12]::ScopedKey<rustc_span[199ab19abca3e97b]::SessionGlobals>>::set::<rustc_interface[c48cc815669d5993]::interface::run_compiler<core[d525c930f060fa4e]::result::Result<(), rustc_errors[a92f92f3abe4e548]::ErrorGuaranteed>, rustc_driver[615eae184240f2d1]::run_compiler::{closure#1}>::{closure#0}, core[d525c930f060fa4e]::result::Result<(), rustc_errors[a92f92f3abe4e548]::ErrorGuaranteed>>
  68:     0x7f1d2d5f1c2f - std[590eaa09bda9df92]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[c48cc815669d5993]::util::run_in_thread_pool_with_globals<rustc_interface[c48cc815669d5993]::interface::run_compiler<core[d525c930f060fa4e]::result::Result<(), rustc_errors[a92f92f3abe4e548]::ErrorGuaranteed>, rustc_driver[615eae184240f2d1]::run_compiler::{closure#1}>::{closure#0}, core[d525c930f060fa4e]::result::Result<(), rustc_errors[a92f92f3abe4e548]::ErrorGuaranteed>>::{closure#0}, core[d525c930f060fa4e]::result::Result<(), rustc_errors[a92f92f3abe4e548]::ErrorGuaranteed>>
  69:     0x7f1d2e6c3ff0 - <<std[590eaa09bda9df92]::thread::Builder>::spawn_unchecked_<rustc_interface[c48cc815669d5993]::util::run_in_thread_pool_with_globals<rustc_interface[c48cc815669d5993]::interface::run_compiler<core[d525c930f060fa4e]::result::Result<(), rustc_errors[a92f92f3abe4e548]::ErrorGuaranteed>, rustc_driver[615eae184240f2d1]::run_compiler::{closure#1}>::{closure#0}, core[d525c930f060fa4e]::result::Result<(), rustc_errors[a92f92f3abe4e548]::ErrorGuaranteed>>::{closure#0}, core[d525c930f060fa4e]::result::Result<(), rustc_errors[a92f92f3abe4e548]::ErrorGuaranteed>>::{closure#1} as core[d525c930f060fa4e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  70:     0x7f1d2c040363 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc33c8b6114373b1d
                               at /rustc/3f83906b30798bf61513fa340524cebf6676f9db/library/alloc/src/boxed.rs:1940:9
  71:     0x7f1d2c040363 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h477ba7c62d8daaed
                               at /rustc/3f83906b30798bf61513fa340524cebf6676f9db/library/alloc/src/boxed.rs:1940:9
  72:     0x7f1d2c040363 - std::sys::unix::thread::Thread::new::thread_start::h7a4a94e6bf66c5d5
                               at /rustc/3f83906b30798bf61513fa340524cebf6676f9db/library/std/src/sys/unix/thread.rs:108:17
  73:     0x7f1d2bd9878d - <unknown>
  74:     0x7f1d2be198e4 - clone
  75:                0x0 - <unknown>

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.66.0-nightly (3f83906b3 2022-09-24) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED] -C target-cpu=native

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `for<'r> parser::repeat::Chainl1<impl for<'r> parser::Parser<^2_0, Output = &'r str>, parser::combinator::Map<parser::token::Token<^1_2>, [closure@src/lib.rs:641:58: 641:61]>>: parser::Parser<^1_5>`
#1 [typeck] type-checking `tests::chainl1_error_consume`
#2 [typeck_item_bodies] type-checking all item bodies
#3 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `combine`
Backtrace

``` ```

compiler-errors commented 2 years ago

Hmm... this will be fun to minimize, lol.

compiler-errors commented 2 years ago

Ok this is due to #100096. I'll probably revert that due to its existing perf regression and this ICE. I may also work on a test, but it might be hard to minimize. I'll see.

compiler-errors commented 2 years ago

searched nightlies: from nightly-2022-06-01 to nightly-2022-09-25 regressed nightly: nightly-2022-09-22 searched commit range: https://github.com/rust-lang/rust/compare/432abd86f231c908f6df3cdd779e83f35084be90...9062b780b32d2eab060b4432863e085d9504ca5c regressed commit: https://github.com/rust-lang/rust/commit/1de00d1ac5247a02184ef7ad044f6521ade7e0cc

bisected with cargo-bisect-rustc v0.6.3 Host triple: x86_64-unknown-linux-gnu Reproduce with: ```bash cargo bisect-rustc --start=2022-06-01 -- test ```
aDotInTheVoid commented 2 years ago

95 line minimisation. It's probably possible to go smaller, but I can't figure out how

matthiaskrgr commented 2 years ago

down to ~50 lines

pub(crate) trait Parser: Sized {
    type Output;
    fn parse(&mut self, _input: &str) -> Result<(), ()> {
        loop {}
    }
    fn map<F, B>(self, _f: F) -> Map<Self, F>
    where
        F: FnMut(Self::Output) -> B,
    {
        todo!()
    }
}

pub(crate) struct Chainl1<P, Op>(P, Op);
impl<P, Op> Parser for Chainl1<P, Op>
where
    P: Parser,
    Op: Parser,
    Op::Output: FnOnce(P::Output, P::Output) -> P::Output,
{
    type Output = P::Output;
}
pub(crate) fn chainl1<P, Op>(_parser: P, _op: Op) -> Chainl1<P, Op>
where
    P: Parser,
    Op: Parser,
    Op::Output: FnOnce(P::Output, P::Output) -> P::Output,
{
    loop {}
}

pub(crate) struct Map<P, F>(P, F);
impl<A, B, P, F> Parser for Map<P, F>
where
    P: Parser<Output = A>,
    F: FnMut(A) -> B,
{
    type Output = B;
}

impl Parser for u32 {
    type Output = ();
}

pub fn chainl1_error_consume() {
    fn first<T, U>(t: T, _: U) -> T {
        t
    }
    let _ = chainl1(1, 1.map(|_| first)).parse("");
}