Skip to content

ICE: expected NodeId to be lowered already for res Local #84324

Closed
@ahmtcn123

Description

@ahmtcn123

Code

Luckily I found this error in rust playground.

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=0bec2b9d9de92d2870dba0ceb2076982

pub fn trimGood(line: String) -> String {
    let mut fixed = String::new();
    for i in 0..line.len() {
        let last = line.chars().nth(if i == 0 { 0 } else {i - 1}); //I think this made the error
        let current = line.chars().nth(i).unwrap();
        let next = line.chars().nth(i);
        
        if let Some(q) = last && i != 0 {
            if q == ' ' && current == ' ' {
                println!("Ignore; current: {:#?}, next: {:#?}", current, q);
                fixed += "@";
            } else {
                fixed += &current.to_string();
            }
        } else {
            fixed += &current.to_string();
        }

    }
    return fixed;
}

fn main() {
    let q = "  trim  this  ";
    println!("ptr: {:#?}", q.to_string());
    println!("ptr: {:#?}", trimGood(q.to_string()));
}

Meta

Stable: 1.51.0

Error output

   Compiling playground v0.0.1 (/playground)
error[E0658]: `let` expressions in this position are experimental
 --> src/main.rs:9:12
  |
9 |         if let Some(q) = last && i != 0 {
  |            ^^^^^^^^^^^^^^^^^^
  |
  = 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(77),
)', compiler/rustc_ast_lowering/src/lib.rs:714:17
note: run with `RUST_BACKTRACE=1` environment variable to display a 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.51.0 (2fd73fabe 2021-03-23) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type bin

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 `playground`

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-let_chains`#![feature(let_chains)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions