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

Rustc internal panic with feature(let_chains) #82250

Closed
JakkuSakura opened this issue Feb 18, 2021 · 7 comments · Fixed by #82308
Closed

Rustc internal panic with feature(let_chains) #82250

JakkuSakura opened this issue Feb 18, 2021 · 7 comments · Fixed by #82308
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@JakkuSakura
Copy link

JakkuSakura commented Feb 18, 2021

I tried this code:

#![feature(let_chains)]
<with a lot of code>

Meta

rustc --version --verbose:

rustc 1.52.0-nightly (e9920ef77 2021-02-11)
binary: rustc
commit-hash: e9920ef7749d11fc71cc32ca4ba055bcfeaab945
commit-date: 2021-02-11
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 11.0.1
thread 'rustc' panicked at 'expected `NodeId` to be lowered already for res Local(
    NodeId(48000),
)', compiler/rustc_ast_lowering/src/lib.rs:714:17
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e9920ef7749d11fc71cc32ca4ba055bcfeaab945/library/std/src/panicking.rs:493:5
   1: std::panicking::begin_panic_fmt
             at /rustc/e9920ef7749d11fc71cc32ca4ba055bcfeaab945/library/std/src/panicking.rs:435:5
   2: rustc_ast_lowering::LoweringContext::lower_node_id_generic
   3: rustc_ast_lowering::path::<impl rustc_ast_lowering::LoweringContext>::lower_qpath
   4: rustc_data_structures::stack::ensure_sufficient_stack
   5: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
   6: rustc_ast_lowering::expr::<impl rustc_ast_lowering::LoweringContext>::lower_exprs
   7: rustc_data_structures::stack::ensure_sufficient_stack
   8: rustc_ast_lowering::LoweringContext::lower_stmt
   9: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  10: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  11: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  12: rustc_arena::cold_path
  13: rustc_ast_lowering::expr::<impl rustc_ast_lowering::LoweringContext>::lower_expr_if
  14: rustc_data_structures::stack::ensure_sufficient_stack
  15: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  16: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  17: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  18: rustc_arena::cold_path
  19: rustc_ast_lowering::LoweringContext::lower_block
  20: rustc_data_structures::stack::ensure_sufficient_stack
  21: rustc_ast_lowering::expr::<impl rustc_ast_lowering::LoweringContext>::lower_arm
  22: rustc_ast_lowering::Arena::alloc_from_iter
  23: rustc_data_structures::stack::ensure_sufficient_stack
  24: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  25: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  26: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  27: rustc_arena::cold_path
  28: rustc_ast_lowering::expr::<impl rustc_ast_lowering::LoweringContext>::lower_expr_if
  29: rustc_data_structures::stack::ensure_sufficient_stack
  30: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  31: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  32: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  33: rustc_arena::cold_path
  34: rustc_ast_lowering::expr::<impl rustc_ast_lowering::LoweringContext>::lower_expr_if_let
  35: rustc_data_structures::stack::ensure_sufficient_stack
  36: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  37: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  38: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  39: rustc_arena::cold_path
  40: rustc_ast_lowering::item::<impl rustc_ast_lowering::LoweringContext>::lower_fn_body_block
  41: rustc_ast_lowering::item::<impl rustc_ast_lowering::LoweringContext>::lower_maybe_async_body
  42: rustc_ast_lowering::LoweringContext::with_hir_id_owner
  43: rustc_ast::visit::walk_item
  44: rustc_ast_lowering::item::<impl rustc_ast_lowering::LoweringContext>::with_parent_item_lifetime_defs
  45: <rustc_ast_lowering::item::ItemLowerer as rustc_ast::visit::Visitor>::visit_mod
  46: rustc_ast::visit::walk_item
  47: rustc_ast_lowering::item::<impl rustc_ast_lowering::LoweringContext>::with_parent_item_lifetime_defs
  48: <rustc_ast_lowering::item::ItemLowerer as rustc_ast::visit::Visitor>::visit_mod
  49: rustc_ast::visit::walk_item
  50: rustc_ast_lowering::item::<impl rustc_ast_lowering::LoweringContext>::with_parent_item_lifetime_defs
  51: <rustc_ast_lowering::item::ItemLowerer as rustc_ast::visit::Visitor>::visit_mod
  52: rustc_ast_lowering::lower_crate
  53: rustc_interface::passes::BoxedResolver::access::{{closure}}
  54: rustc_interface::passes::configure_and_expand::{{closure}}
  55: rustc_interface::passes::BoxedResolver::access
  56: rustc_interface::queries::Queries::lower_to_hir
  57: rustc_interface::queries::Queries::global_ctxt
  58: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  59: rustc_span::with_source_map
  60: rustc_interface::interface::create_compiler_and_run
  61: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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.52.0-nightly (e9920ef77 2021-02-11) 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: could not compile `project`
To learn more, run the command again with --verbose.
Process finished with exit code 101

Note:
A simpler program does not crash, but does not compile.
rust-lang/rfcs#2411 (comment)

#![feature(let_chains)]
use std::error::Error;
fn main(){
    let obj = Some(1);
    if let Some(i) = obj && i > 5 {

    }
}
error: `let` expressions are not supported here
 --> src/main.rs:5:8
  |
5 |     if let Some(i) = obj && i > 5 {
  |        ^^^^^^^^^^^^^^^^^
  |
  = note: only supported directly in conditions of `if`- and `while`-expressions
  = note: as well as when nested within `&&` and parenthesis in those conditions

#53667

@JakkuSakura JakkuSakura added the C-bug Category: This is a bug. label Feb 18, 2021
@osa1
Copy link
Contributor

osa1 commented Feb 18, 2021

Is it possible for you to share the code?

@jyn514 jyn514 added 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) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 18, 2021
@HTGAzureX1212
Copy link
Contributor

HTGAzureX1212 commented Feb 19, 2021

@qiujiangkun It might be better for you to share the code which reproduces the issue on your nightly, 2021-02-11, so that I can try to reproduce it on the latest nightly build and possibly find the commit that might have introduced this issue.

@JakkuSakura
Copy link
Author

Okay, I'll trim down my base and share it later today.

@JakkuSakura
Copy link
Author

JakkuSakura commented Feb 19, 2021

I deleted my whole project and got this
lib.rs

#![feature(let_chains)]

pub struct Describer {}

impl Describer {
    fn process_input(&mut self) {
        let index = "1";
        if let Ok(index) = index.parse::<usize>() && index < self.l2_items.len() {
            self.select(index);
        }
    }
}

@osa1
Copy link
Contributor

osa1 commented Feb 19, 2021

Thanks @qiujiangkun.

@rustbot label: -E-needs-mcve

@rustbot rustbot removed the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Feb 19, 2021
@HTGAzureX1212
Copy link
Contributor

Not sure if this helps: I ran bisect-rustc on my host target x86_64-pc-windows-msvc, and it is shown that it ICEd back in 2018 (even before the initial implementation of the let_chains feature.

@jyn514
Copy link
Member

jyn514 commented Feb 20, 2021

Duplicate of #82290.

@jyn514 jyn514 closed this as completed Feb 20, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Feb 23, 2021
Lower condition of `if` expression before it's "then" block

Fix rust-lang#82290, fix rust-lang#82250.
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. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants