Skip to content

Panic related to compound if ... && let Ok(...) = ... { statement #84952

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

Closed
nickbp opened this issue May 5, 2021 · 2 comments
Closed

Panic related to compound if ... && let Ok(...) = ... { statement #84952

nickbp opened this issue May 5, 2021 · 2 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

@nickbp
Copy link

nickbp commented May 5, 2021

Code

The code in question (copied below) is also found here: https://git.sr.ht/~nickbp/kapiti/tree/8b9a7869/item/src/runner.rs#L308

If filter_uri.scheme() != None && is removed from line 308, the crash goes away. I tried getting a minimal repro via a separate project but wasn't able to get the panic, only the error around experimental support. For example, I tried reproducing it with regular functions, and then again with async functions with smol imported as the async runtime to match the original code, and none of these were able to get a repro.

The crash that I had experienced locally was also reproduced in the CI build of the 8b9a7869 commit, so it looks like it's at least not just my machine: https://builds.sr.ht/~nickbp/job/501433

async fn refresh_filter(
    fetch_client: &Client<hyper_smol::SmolConnector>,
    filters_dir: &PathBuf,
    filter_path_or_url: &String,
    filter_type: reader::FilterType,
) -> Option<reader::FilterEntries> {
    if let Ok(filter_uri) = Uri::try_from(filter_path_or_url) {
        // Parsed as a URL, try to download
        // Filesystem paths can get parsed as URLs with no scheme
        // COMPILER CRASH!:
        if filter_uri.scheme() != None && let Ok((local_path, _downloaded)) = filter::update_url(
            fetch_client,
            filters_dir,
            filter_path_or_url,
            10000,
        ).await {
            if let Ok(filter) = reader::read(
                filter_type,
                reader::FileInfo {
                    source_path: filter_path_or_url.clone(),
                    local_path
                }
            ) {
                return Some(filter);
            }
        }
        return None
    } else if let Ok(filter) = reader::read(
        filter_type,
        reader::FileInfo {
            source_path: filter_path_or_url.clone(),
            local_path: filter_path_or_url.clone(),
        }
    ) {
        return Some(filter);
    }
    None
}

Meta

rustc --version --verbose:

rustc 1.51.0 (2fd73fabe 2021-03-23)
binary: rustc
commit-hash: 2fd73fabe469357a12c2c974c140f67e7cdd76d0
commit-date: 2021-03-23
host: x86_64-unknown-linux-gnu
release: 1.51.0
LLVM version: 11.0.1

Error output

$ RUST_BACKTRACE=full cargo build
   Compiling kapiti v0.0.1 (/home/nick/proj/kapiti)
error[E0658]: `let` expressions in this position are experimental
   --> src/runner.rs:308:43
    |
308 |           if filter_uri.scheme() != None && let Ok((local_path, _downloaded)) = filter::update_url(
    |  ___________________________________________^
309 | |             fetch_client,
310 | |             filters_dir,
311 | |             filter_path_or_url,
312 | |             10000,
313 | |         ).await {
    | |_______________^
    |
    = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information

thread 'rustc' panicked at 'expected `NodeId` to be lowered already for res Local(
    NodeId(20547),
)', compiler/rustc_ast_lowering/src/lib.rs:714:17
stack backtrace:
  [see below]

error: internal compiler error: unexpected panic

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.51.0 (2fd73fabe 2021-03-23) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

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

query stack during panic:
end of query stack
error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.
error: could not compile `kapiti`

To learn more, run the command again with --verbose.
Backtrace

   0:     0x7fe7e70b1ee0 - std::backtrace_rs::backtrace::libunwind::trace::h5e9d00f0cdf4f57e
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7fe7e70b1ee0 - std::backtrace_rs::backtrace::trace_unsynchronized::hd5302bd66215dab9
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fe7e70b1ee0 - std::sys_common::backtrace::_print_fmt::ha0237cd11a34e2bf
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7fe7e70b1ee0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h171d4c10df1a98ee
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7fe7e7122d0c - core::fmt::write::h89e4288724daa3fa
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/fmt/mod.rs:1096:17
   5:     0x7fe7e70a4ff2 - std::io::Write::write_fmt::h6d40f996e84584d9
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/io/mod.rs:1568:15
   6:     0x7fe7e70b5d95 - std::sys_common::backtrace::_print::h0c0b93221682afc8
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7fe7e70b5d95 - std::sys_common::backtrace::print::h57a9f95204c2fdd6
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7fe7e70b5d95 - std::panicking::default_hook::{{closure}}::h4245258b50e37e69
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:208:50
   9:     0x7fe7e70b58f3 - std::panicking::default_hook::h7b00dcc1d0944747
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:225:9
  10:     0x7fe7e7917f3b - rustc_driver::report_ice::hd11b2540f4ebea82
  11:     0x7fe7d1efb506 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hb235817cd188ea25
                               at /home/nick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1535:9
  12:     0x7fe7d1f21b19 - proc_macro::bridge::client::<impl proc_macro::bridge::Bridge>::enter::{{closure}}::{{closure}}::h7f8d2074dfba5d83
                               at /home/nick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/client.rs:320:21
  13:     0x7fe7e70b6696 - std::panicking::rust_panic_with_hook::h71e6a073d87de1f5
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:595:17
  14:     0x7fe7e70b61b7 - std::panicking::begin_panic_handler::{{closure}}::hd549436f6bb6dbb8
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:497:13
  15:     0x7fe7e70b237c - std::sys_common::backtrace::__rust_end_short_backtrace::h4e5f4b72b04174c3
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys_common/backtrace.rs:141:18
  16:     0x7fe7e70b6119 - rust_begin_unwind
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:493:5
  17:     0x7fe7e70b60cb - std::panicking::begin_panic_fmt::h818c3c917eaeb432
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:435:5
  18:     0x7fe7e94c5e8e - rustc_ast_lowering::LoweringContext::lower_node_id_generic::h002cd4f9b856a42a
  19:     0x7fe7e94c0823 - rustc_ast_lowering::path::<impl rustc_ast_lowering::LoweringContext>::lower_qpath::h948d180b7a292ea4
  20:     0x7fe7e94d4ad4 - rustc_data_structures::stack::ensure_sufficient_stack::haf3691f03b57c500
  21:     0x7fe7e94cf18f - rustc_ast_lowering::Arena::alloc_from_iter::hb07baa383b21d949
  22:     0x7fe7e94d5558 - rustc_data_structures::stack::ensure_sufficient_stack::haf3691f03b57c500
  23:     0x7fe7e94d978a - <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend::h804dbd4869de84ce
  24:     0x7fe7e94b8a9f - rustc_ast_lowering::expr::<impl rustc_ast_lowering::LoweringContext>::lower_exprs::h31ae1104318e374f
  25:     0x7fe7e94d4d37 - rustc_data_structures::stack::ensure_sufficient_stack::haf3691f03b57c500
  26:     0x7fe7ea0c3f32 - rustc_ast_lowering::expr::<impl rustc_ast_lowering::LoweringContext>::lower_expr_if_let::hc3e641198888b81e
  27:     0x7fe7e94d58f6 - rustc_data_structures::stack::ensure_sufficient_stack::haf3691f03b57c500
  28:     0x7fe7e94b7d40 - core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::hb22a697bd9a38dee
  29:     0x7fe7e94d7409 - <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next::h9267902070b24882
  30:     0x7fe7e94d9393 - <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend::h523719ca991d7de5
  31:     0x7fe7e94d0f96 - rustc_arena::cold_path::h2d0592dc184bf65c
  32:     0x7fe7ea0c3648 - rustc_ast_lowering::expr::<impl rustc_ast_lowering::LoweringContext>::lower_expr_if::h4e01bb73047fe9d5
  33:     0x7fe7e94d548f - rustc_data_structures::stack::ensure_sufficient_stack::haf3691f03b57c500
  34:     0x7fe7e94cd9dd - rustc_ast_lowering::LoweringContext::lower_stmt::h89627d805bec8b65
  35:     0x7fe7e94b7daa - core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::hb22a697bd9a38dee
  36:     0x7fe7e94d7409 - <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next::h9267902070b24882
  37:     0x7fe7e94d9393 - <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend::h523719ca991d7de5
  38:     0x7fe7e94d0f96 - rustc_arena::cold_path::h2d0592dc184bf65c
  39:     0x7fe7ea0c4088 - rustc_ast_lowering::expr::<impl rustc_ast_lowering::LoweringContext>::lower_expr_if_let::hc3e641198888b81e
  40:     0x7fe7e94d58f6 - rustc_data_structures::stack::ensure_sufficient_stack::haf3691f03b57c500
  41:     0x7fe7e94cd9dd - rustc_ast_lowering::LoweringContext::lower_stmt::h89627d805bec8b65
  42:     0x7fe7e94b7daa - core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::hb22a697bd9a38dee
  43:     0x7fe7e94d7409 - <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next::h9267902070b24882
  44:     0x7fe7e94d9393 - <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend::h523719ca991d7de5
  45:     0x7fe7e94d0f96 - rustc_arena::cold_path::h2d0592dc184bf65c
  46:     0x7fe7e94bd998 - rustc_ast_lowering::item::<impl rustc_ast_lowering::LoweringContext>::lower_maybe_async_body::he02a6308a00b8208
  47:     0x7fe7e94ba665 - rustc_ast_lowering::item::<impl rustc_ast_lowering::LoweringContext>::lower_item::h3ba67499588754eb
  48:     0x7fe7e94c76d5 - rustc_ast_lowering::LoweringContext::with_hir_id_owner::h7b2fa9b481f88b61
  49:     0x7fe7e94d0ad3 - <rustc_ast_lowering::item::ItemLowerer as rustc_ast::visit::Visitor>::visit_mod::h73d8ca6d3aa148c9
  50:     0x7fe7e94e381e - rustc_ast::visit::walk_item::hebaa139b96b09853
  51:     0x7fe7e94b9239 - rustc_ast_lowering::item::<impl rustc_ast_lowering::LoweringContext>::with_parent_item_lifetime_defs::h852a078c86fec3d5
  52:     0x7fe7e94d0aec - <rustc_ast_lowering::item::ItemLowerer as rustc_ast::visit::Visitor>::visit_mod::h73d8ca6d3aa148c9
  53:     0x7fe7e94c3406 - rustc_ast_lowering::lower_crate::hb73d62985cd7bb14
  54:     0x7fe7e9cb790f - rustc_interface::passes::BoxedResolver::access::{{closure}}::hb9c484859450932f
  55:     0x7fe7e9ca8f54 - rustc_interface::passes::configure_and_expand::{{closure}}::h3a41a297ff107384
  56:     0x7fe7e9cb7756 - rustc_interface::passes::BoxedResolver::access::hfd0e687e2c8082e4
  57:     0x7fe7e9cc71b5 - rustc_interface::queries::Queries::lower_to_hir::h526946090fe9ea3a
  58:     0x7fe7e9cc7c1e - rustc_interface::queries::Queries::global_ctxt::hd6c3bc1c7f006419
  59:     0x7fe7e9c5bc23 - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::hc8c0f3e9bba77540
  60:     0x7fe7e9c55643 - rustc_span::with_source_map::hedfeccc0422f91c4
  61:     0x7fe7e9c5ceca - rustc_interface::interface::create_compiler_and_run::h7abf0b53119fd7ea
  62:     0x7fe7e9c55d05 - rustc_span::with_session_globals::hb5dbfdbd3bd12723
  63:     0x7fe7e9c5d36a - std::sys_common::backtrace::__rust_begin_short_backtrace::hfe0fde7e082e2baf
  64:     0x7fe7e9c79c4a - core::ops::function::FnOnce::call_once{{vtable.shim}}::h83306388c44d16bf
  65:     0x7fe7e70c6c8a - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h61144a2be4ee36d8
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/alloc/src/boxed.rs:1521:9
  66:     0x7fe7e70c6c8a - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hcf5d395fdd120c17
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/alloc/src/boxed.rs:1521:9
  67:     0x7fe7e70c6c8a - std::sys::unix::thread::Thread::new::thread_start::hb5e40d3d934ebb7a
                               at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys/unix/thread.rs:71:17
  68:     0x7fe7e6fd8299 - start_thread
  69:     0x7fe7e6eed053 - clone
  70:                0x0 - <unknown>

@nickbp nickbp 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 May 5, 2021
@jyn514
Copy link
Member

jyn514 commented May 5, 2021

Looks like #84795 - can you check if this is fixed on nightly?

@jyn514 jyn514 added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label May 5, 2021
@nickbp
Copy link
Author

nickbp commented May 5, 2021

Looks like it's fixed on nightly. I switched to the following nightly rustc and the panic no longer occurred, only seeing the compile errors as expected:

rustc 1.53.0-nightly (42816d61e 2021-04-24)
binary: rustc
commit-hash: 42816d61ead7e46d462df997958ccfd514f8c21c
commit-date: 2021-04-24
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0

I'm going to close this as it indeed looks like it's already been resolved. Thanks!

@nickbp nickbp closed this as completed May 5, 2021
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

2 participants