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

ICE: when specifiying explicit chumsky State #109145

Closed
CreatorSiSo opened this issue Mar 14, 2023 · 3 comments
Closed

ICE: when specifiying explicit chumsky State #109145

CreatorSiSo opened this issue Mar 14, 2023 · 3 comments
Labels
C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@CreatorSiSo
Copy link

CreatorSiSo commented Mar 14, 2023

The error only comes up if

 .map_with_state(|_, span, state| state.0[span]);

is changed to

 .map_with_state(|_, span, state: State| state.0[span]);

and

just::<_, SpannedInput<Token, Span, &[(Token, Span)]>, extra::State<&mut str>>(Token::Ident)

is changed to

just::<_, SpannedInput<Token, Span, &[(Token, Span)]>, extra::State<State>>(Token::Ident)

All other cases are still erronous but only these two combined result in this internal compiler error.

Code

GitHub: https://github.com/CreatorSiSo/rustc_internal_bug_1

[package]
name = "rustc_internal_bug_1"
version = "0.1.0"
edition = "2021"

[dependencies]
chumsky = { git = "https://github.com/zesterer/chumsky", rev = "ac31aea841c395138aee43ff5139fb49d4a9a60c" }
use chumsky::input::SpannedInput;
use chumsky::prelude::*;

fn main() {
    type Span = std::ops::Range<usize>;

    #[derive(Clone, PartialEq, Eq)]
    enum Token {
        Ident,
    }
    struct State<'a>(&'a str);

    let ident_parser =
        just::<_, SpannedInput<Token, Span, &[(Token, Span)]>, extra::State<State>>(Token::Ident)
            .map_with_state(|_, span, state: State| state.0[span]);

    ident_parser.parse_with_state(&[(Token::Ident, 0..7)].spanned(7..7), State("testing"));
}

Meta

rustc --version --verbose:

rustc 1.68.0 (2c8cc3432 2023-03-06)
binary: rustc
commit-hash: 2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74
commit-date: 2023-03-06
host: x86_64-unknown-linux-gnu
release: 1.68.0
LLVM version: 15.0.6

Error output

error: internal compiler error: compiler/rustc_infer/src/infer/region_constraints/mod.rs:568:17: cannot relate bound region: ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:23 ~ rustc_internal_bug_1[4a0a]::main::'_), '_) }) <= '_#20r

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/compiler/rustc_errors/src/lib.rs:987:33
stack backtrace:
   0:     0x7f877756659a - std::backtrace_rs::backtrace::libunwind::trace::h595f06c70adcc478
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f877756659a - std::backtrace_rs::backtrace::trace_unsynchronized::h177a0149c76cdde9
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f877756659a - std::sys_common::backtrace::_print_fmt::hc0701fd2c3530c58
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f877756659a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd4cd115d8750fd6c
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f87775c839e - core::fmt::write::h93e2f5923c7eca08
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/fmt/mod.rs:1213:17
   5:     0x7f8777556be5 - std::io::Write::write_fmt::h8162dbb45f0b9e62
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/io/mod.rs:1682:15
   6:     0x7f8777566365 - std::sys_common::backtrace::_print::h1835ef8a8f9066da
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f8777566365 - std::sys_common::backtrace::print::hcb5e6388b9235f41
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f877756912f - std::panicking::default_hook::{{closure}}::h9c084969ccf9a722
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:267:22
   9:     0x7f8777568e6b - std::panicking::default_hook::h68fa2ba3c3c6c12f
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:286:9
  10:     0x7f877a8b56e4 - <rustc_driver[f4ad927b3c57833d]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[d16e85342ea223d9]::ops::function::FnOnce<(&core[d16e85342ea223d9]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f877756996a - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h4e6ced11e07d8b24
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/alloc/src/boxed.rs:2002:9
  12:     0x7f877756996a - std::panicking::rust_panic_with_hook::h8d5c434518ef298c
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:692:13
  13:     0x7f877ab71501 - std[3da461b304582a2c]::panicking::begin_panic::<rustc_errors[41d09747e2f98dea]::ExplicitBug>::{closure#0}
  14:     0x7f877ab69e56 - std[3da461b304582a2c]::sys_common::backtrace::__rust_end_short_backtrace::<std[3da461b304582a2c]::panicking::begin_panic<rustc_errors[41d09747e2f98dea]::ExplicitBug>::{closure#0}, !>
  15:     0x7f877abf9df6 - std[3da461b304582a2c]::panicking::begin_panic::<rustc_errors[41d09747e2f98dea]::ExplicitBug>
  16:     0x7f877abf9de6 - std[3da461b304582a2c]::panic::panic_any::<rustc_errors[41d09747e2f98dea]::ExplicitBug>
  17:     0x7f877abf8b92 - <rustc_errors[41d09747e2f98dea]::HandlerInner>::span_bug::<rustc_span[4bb3e3ecb57f95d5]::span_encoding::Span, &alloc[5b05b59796bdfb5c]::string::String>
  18:     0x7f877abf8a37 - <rustc_errors[41d09747e2f98dea]::Handler>::span_bug::<rustc_span[4bb3e3ecb57f95d5]::span_encoding::Span, &alloc[5b05b59796bdfb5c]::string::String>
  19:     0x7f877abadf9b - rustc_middle[eb7209f5870e9fb7]::util::bug::opt_span_bug_fmt::<rustc_span[4bb3e3ecb57f95d5]::span_encoding::Span>::{closure#0}
  20:     0x7f877abadfea - rustc_middle[eb7209f5870e9fb7]::ty::context::tls::with_opt::<rustc_middle[eb7209f5870e9fb7]::util::bug::opt_span_bug_fmt<rustc_span[4bb3e3ecb57f95d5]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f877abad0aa - rustc_middle[eb7209f5870e9fb7]::ty::context::tls::with_context_opt::<rustc_middle[eb7209f5870e9fb7]::ty::context::tls::with_opt<rustc_middle[eb7209f5870e9fb7]::util::bug::opt_span_bug_fmt<rustc_span[4bb3e3ecb57f95d5]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f877abacfd6 - rustc_middle[eb7209f5870e9fb7]::util::bug::opt_span_bug_fmt::<rustc_span[4bb3e3ecb57f95d5]::span_encoding::Span>
  23:     0x7f877abacf94 - rustc_middle[eb7209f5870e9fb7]::util::bug::span_bug_fmt::<rustc_span[4bb3e3ecb57f95d5]::span_encoding::Span>
  24:     0x7f8778843fa4 - <rustc_middle[eb7209f5870e9fb7]::ty::sty::Region as rustc_middle[eb7209f5870e9fb7]::ty::relate::Relate>::relate::<rustc_infer[41785f830319e09c]::infer::equate::Equate>
  25:     0x7f877883f25f - rustc_middle[eb7209f5870e9fb7]::ty::relate::super_relate_tys::<rustc_infer[41785f830319e09c]::infer::equate::Equate>
  26:     0x7f877883c25e - <rustc_infer[41785f830319e09c]::infer::equate::Equate as rustc_middle[eb7209f5870e9fb7]::ty::relate::TypeRelation>::tys
  27:     0x7f8779175d23 - <rustc_infer[41785f830319e09c]::infer::InferCtxt>::commit_if_ok::<rustc_infer[41785f830319e09c]::infer::InferOk<()>, rustc_middle[eb7209f5870e9fb7]::ty::error::TypeError, <rustc_infer[41785f830319e09c]::infer::at::Trace>::eq<rustc_middle[eb7209f5870e9fb7]::ty::Ty>::{closure#0}>
  28:     0x7f8779175c16 - <rustc_infer[41785f830319e09c]::infer::at::At>::eq::<rustc_middle[eb7209f5870e9fb7]::ty::Ty>
  29:     0x7f877b493bfe - <rustc_infer[41785f830319e09c]::infer::InferCtxt>::can_eq::<rustc_middle[eb7209f5870e9fb7]::ty::Ty>
  30:     0x7f877b476b42 - rustc_trait_selection[94d7ef6b5a6b8462]::traits::error_reporting::suggestions::hint_missing_borrow
  31:     0x7f877b519fe4 - <rustc_infer[41785f830319e09c]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[94d7ef6b5a6b8462]::traits::error_reporting::suggestions::TypeErrCtxtExt>::report_closure_arg_mismatch
  32:     0x7f877b529e38 - <rustc_infer[41785f830319e09c]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[94d7ef6b5a6b8462]::traits::error_reporting::TypeErrCtxtExt>::report_selection_error
  33:     0x7f877b533817 - <rustc_infer[41785f830319e09c]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[94d7ef6b5a6b8462]::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error
  34:     0x7f877b526e7f - <rustc_infer[41785f830319e09c]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[94d7ef6b5a6b8462]::traits::error_reporting::TypeErrCtxtExt>::report_fulfillment_errors
  35:     0x7f8778ab13c3 - <rustc_hir_typeck[7533f7cabd9af3c4]::fn_ctxt::FnCtxt>::demand_coerce
  36:     0x7f8778a79e79 - <rustc_hir_typeck[7533f7cabd9af3c4]::fn_ctxt::FnCtxt>::check_decl
  37:     0x7f8778a76f63 - <rustc_hir_typeck[7533f7cabd9af3c4]::fn_ctxt::FnCtxt>::check_block_with_expected
  38:     0x7f8778a4154c - <rustc_hir_typeck[7533f7cabd9af3c4]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  39:     0x7f87789dc071 - <rustc_hir_typeck[7533f7cabd9af3c4]::fn_ctxt::FnCtxt>::check_return_expr
  40:     0x7f87789d2fa2 - rustc_hir_typeck[7533f7cabd9af3c4]::check::check_fn
  41:     0x7f87789bb85e - rustc_hir_typeck[7533f7cabd9af3c4]::typeck
  42:     0x7f8778929bf7 - <rustc_query_system[e5b40bf290de15d8]::dep_graph::graph::DepGraph<rustc_middle[eb7209f5870e9fb7]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[eb7209f5870e9fb7]::ty::context::TyCtxt, rustc_span[4bb3e3ecb57f95d5]::def_id::LocalDefId, &rustc_middle[eb7209f5870e9fb7]::ty::typeck_results::TypeckResults>
  43:     0x7f877892174b - rustc_query_system[e5b40bf290de15d8]::query::plumbing::try_execute_query::<rustc_query_impl[3a6baddf07124ab7]::queries::typeck, rustc_query_impl[3a6baddf07124ab7]::plumbing::QueryCtxt>
  44:     0x7f877a008aad - rustc_data_structures[f387d52c0b9780fc]::sync::par_for_each_in::<&[rustc_span[4bb3e3ecb57f95d5]::def_id::LocalDefId], <rustc_middle[eb7209f5870e9fb7]::hir::map::Map>::par_body_owners<rustc_hir_typeck[7533f7cabd9af3c4]::typeck_item_bodies::{closure#0}>::{closure#0}>
  45:     0x7f877a008853 - rustc_hir_typeck[7533f7cabd9af3c4]::typeck_item_bodies
  46:     0x7f877a01fa07 - <rustc_query_system[e5b40bf290de15d8]::dep_graph::graph::DepGraph<rustc_middle[eb7209f5870e9fb7]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[eb7209f5870e9fb7]::ty::context::TyCtxt, (), ()>
  47:     0x7f8779e328e6 - rustc_query_system[e5b40bf290de15d8]::query::plumbing::try_execute_query::<rustc_query_impl[3a6baddf07124ab7]::queries::typeck_item_bodies, rustc_query_impl[3a6baddf07124ab7]::plumbing::QueryCtxt>
  48:     0x7f877a26eefb - <rustc_query_impl[3a6baddf07124ab7]::Queries as rustc_middle[eb7209f5870e9fb7]::ty::query::QueryEngine>::typeck_item_bodies
  49:     0x7f8778d60892 - <rustc_session[b580c712976fc965]::session::Session>::time::<(), rustc_hir_analysis[9174c993ab369dfd]::check_crate::{closure#7}>
  50:     0x7f8778d5fd12 - rustc_hir_analysis[9174c993ab369dfd]::check_crate
  51:     0x7f8778d5f96b - rustc_interface[3781616314f5d936]::passes::analysis
  52:     0x7f8779fd7b16 - <rustc_query_system[e5b40bf290de15d8]::dep_graph::graph::DepGraph<rustc_middle[eb7209f5870e9fb7]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[eb7209f5870e9fb7]::ty::context::TyCtxt, (), core[d16e85342ea223d9]::result::Result<(), rustc_errors[41d09747e2f98dea]::ErrorGuaranteed>>
  53:     0x7f8779fd6cd1 - rustc_query_system[e5b40bf290de15d8]::query::plumbing::try_execute_query::<rustc_query_impl[3a6baddf07124ab7]::queries::analysis, rustc_query_impl[3a6baddf07124ab7]::plumbing::QueryCtxt>
  54:     0x7f877a26b7aa - <rustc_query_impl[3a6baddf07124ab7]::Queries as rustc_middle[eb7209f5870e9fb7]::ty::query::QueryEngine>::analysis
  55:     0x7f8779a95850 - <rustc_interface[3781616314f5d936]::passes::QueryContext>::enter::<rustc_driver[f4ad927b3c57833d]::run_compiler::{closure#1}::{closure#2}::{closure#2}, core[d16e85342ea223d9]::result::Result<(), rustc_errors[41d09747e2f98dea]::ErrorGuaranteed>>
  56:     0x7f8779a932c4 - rustc_span[4bb3e3ecb57f95d5]::with_source_map::<core[d16e85342ea223d9]::result::Result<(), rustc_errors[41d09747e2f98dea]::ErrorGuaranteed>, rustc_interface[3781616314f5d936]::interface::run_compiler<core[d16e85342ea223d9]::result::Result<(), rustc_errors[41d09747e2f98dea]::ErrorGuaranteed>, rustc_driver[f4ad927b3c57833d]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  57:     0x7f8779a8bce4 - <scoped_tls[1a6b834cb64348ef]::ScopedKey<rustc_span[4bb3e3ecb57f95d5]::SessionGlobals>>::set::<rustc_interface[3781616314f5d936]::interface::run_compiler<core[d16e85342ea223d9]::result::Result<(), rustc_errors[41d09747e2f98dea]::ErrorGuaranteed>, rustc_driver[f4ad927b3c57833d]::run_compiler::{closure#1}>::{closure#0}, core[d16e85342ea223d9]::result::Result<(), rustc_errors[41d09747e2f98dea]::ErrorGuaranteed>>
  58:     0x7f8779a8b3e2 - std[3da461b304582a2c]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3781616314f5d936]::util::run_in_thread_pool_with_globals<rustc_interface[3781616314f5d936]::interface::run_compiler<core[d16e85342ea223d9]::result::Result<(), rustc_errors[41d09747e2f98dea]::ErrorGuaranteed>, rustc_driver[f4ad927b3c57833d]::run_compiler::{closure#1}>::{closure#0}, core[d16e85342ea223d9]::result::Result<(), rustc_errors[41d09747e2f98dea]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d16e85342ea223d9]::result::Result<(), rustc_errors[41d09747e2f98dea]::ErrorGuaranteed>>
  59:     0x7f8779a8b18a - <<std[3da461b304582a2c]::thread::Builder>::spawn_unchecked_<rustc_interface[3781616314f5d936]::util::run_in_thread_pool_with_globals<rustc_interface[3781616314f5d936]::interface::run_compiler<core[d16e85342ea223d9]::result::Result<(), rustc_errors[41d09747e2f98dea]::ErrorGuaranteed>, rustc_driver[f4ad927b3c57833d]::run_compiler::{closure#1}>::{closure#0}, core[d16e85342ea223d9]::result::Result<(), rustc_errors[41d09747e2f98dea]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d16e85342ea223d9]::result::Result<(), rustc_errors[41d09747e2f98dea]::ErrorGuaranteed>>::{closure#1} as core[d16e85342ea223d9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  60:     0x7f8777573823 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1c0f3664d7ced314
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/alloc/src/boxed.rs:1988:9
  61:     0x7f8777573823 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h67647c21c6c4968a
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/alloc/src/boxed.rs:1988:9
  62:     0x7f8777573823 - std::sys::unix::thread::Thread::new::thread_start::h355d348ba593a22c
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys/unix/thread.rs:108:17
  63:     0x7f877731312d - start_thread
  64:     0x7f8777394bc0 - clone3
  65:                0x0 - <unknown>
Backtrace

error: internal compiler error: compiler/rustc_infer/src/infer/region_constraints/mod.rs:568:17: cannot relate bound region: ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:23 ~ rustc_internal_bug_1[4a0a]::main::'_), '_) }) <= '_#20r

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/compiler/rustc_errors/src/lib.rs:987:33
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: std::panic::panic_any::<rustc_errors::ExplicitBug>
   2: <rustc_errors::HandlerInner>::span_bug::<rustc_span::span_encoding::Span, &alloc::string::String>
   3: <rustc_errors::Handler>::span_bug::<rustc_span::span_encoding::Span, &alloc::string::String>
   4: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   5: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   6: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   7: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>
   8: rustc_middle::util::bug::span_bug_fmt::<rustc_span::span_encoding::Span>
   9: <rustc_middle::ty::sty::Region as rustc_middle::ty::relate::Relate>::relate::<rustc_infer::infer::equate::Equate>
  10: rustc_middle::ty::relate::super_relate_tys::<rustc_infer::infer::equate::Equate>
  11: <rustc_infer::infer::equate::Equate as rustc_middle::ty::relate::TypeRelation>::tys
  12: <rustc_infer::infer::InferCtxt>::commit_if_ok::<rustc_infer::infer::InferOk<()>, rustc_middle::ty::error::TypeError, <rustc_infer::infer::at::Trace>::eq<rustc_middle::ty::Ty>::{closure#0}>
  13: <rustc_infer::infer::at::At>::eq::<rustc_middle::ty::Ty>
  14: <rustc_infer::infer::InferCtxt>::can_eq::<rustc_middle::ty::Ty>
  15: rustc_trait_selection::traits::error_reporting::suggestions::hint_missing_borrow
  16: <rustc_infer::infer::error_reporting::TypeErrCtxt as rustc_trait_selection::traits::error_reporting::suggestions::TypeErrCtxtExt>::report_closure_arg_mismatch
  17: <rustc_infer::infer::error_reporting::TypeErrCtxt as rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt>::report_selection_error
  18: <rustc_infer::infer::error_reporting::TypeErrCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error
  19: <rustc_infer::infer::error_reporting::TypeErrCtxt as rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt>::report_fulfillment_errors
  20: <rustc_hir_typeck::fn_ctxt::FnCtxt>::demand_coerce
  21: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_decl
  22: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_block_with_expected
  23: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  24: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_return_expr
  25: rustc_hir_typeck::check::check_fn
  26: rustc_hir_typeck::typeck
  27: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId, &rustc_middle::ty::typeck_results::TypeckResults>
  28: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::typeck, rustc_query_impl::plumbing::QueryCtxt>
  29: rustc_data_structures::sync::par_for_each_in::<&[rustc_span::def_id::LocalDefId], <rustc_middle::hir::map::Map>::par_body_owners<rustc_hir_typeck::typeck_item_bodies::{closure#0}>::{closure#0}>
  30: rustc_hir_typeck::typeck_item_bodies
  31: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), ()>
  32: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::typeck_item_bodies, rustc_query_impl::plumbing::QueryCtxt>
  33: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck_item_bodies
  34: <rustc_session::session::Session>::time::<(), rustc_hir_analysis::check_crate::{closure#7}>
  35: rustc_hir_analysis::check_crate
  36: rustc_interface::passes::analysis
  37: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  38: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  39: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  40: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#2}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  41: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  42: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>

@CreatorSiSo CreatorSiSo added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 14, 2023
@CreatorSiSo CreatorSiSo changed the title Internal compiler error when specifiying explicit chumsky State ICE: when specifiying explicit chumsky State Mar 14, 2023
@langston-barrett
Copy link
Contributor

@rustbot label +E-needs-mcve

@rustbot rustbot added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Mar 18, 2023
@bwmf2
Copy link
Contributor

bwmf2 commented Mar 19, 2023

Minimized:

// #![no_std]
use crate::chumsky::{just, Parser, State};

mod chumsky {
    pub struct MapWithState;

    pub trait ParserExtra {
        type State;
    }

    pub struct State<S>(core::marker::PhantomData<(S,)>);

    impl<S> ParserExtra for State<S> {
        type State = S;
    }

    pub struct Just<E>(core::marker::PhantomData<(E,)>);

    pub const fn just<E>() -> Just<E> {
        loop {}
    }

    impl<E> ParserSealed<E> for Just<E> where E: ParserExtra {}

    pub trait ParserSealed<E> {}

    pub trait Parser<E: ParserExtra> {
        fn map_with_state<U, F: Fn(&mut E::State) -> U>(self, f: F)
        where
            Self: Sized,
        {
        }
    }

    impl<E, P> Parser<E> for P
    where
        E: ParserExtra,
        P: ParserSealed<E>,
    {
    }
}

fn main() {
    struct Q<'a>(&'a ());

    just::<State<Q>>(()).map_with_state(|state: Q| loop {});
}

@aliemjay
Copy link
Member

Closing in favor of #109361. Thank you for the report and minimization!

@aliemjay aliemjay closed this as not planned Won't fix, can't repro, duplicate, stale Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants