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.

Activity

added
C-bugCategory: This is a bug.
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.
on Apr 18, 2021
ahmtcn123

ahmtcn123 commented on Apr 18, 2021

@ahmtcn123
Author

Info: If I remove i != 0 at line 9 It compiles correctly

changed the title [-]Internal Compiler Error[/-] [+]ICE: expected `NodeId` to be lowered already for res Local[/+] on Apr 19, 2021
hellow554

hellow554 commented on Apr 19, 2021

@hellow554
Contributor

@rustbot modify labels: F-let_chains

hellow554

hellow554 commented on Apr 19, 2021

@hellow554
Contributor

MCVE:

fn main() {
    let i = 0;
    let last = Some(' ');

    if let Some(q) = last && i == 0 {
        if q == ' ' {}
    }
}

this issue is fixed on nightly, so this is probably a E-needs-test only

SNCPlay42

SNCPlay42 commented on Apr 20, 2021

@SNCPlay42
Contributor

Duplicate of #82290. I think the test in the fixing PR, #82308, covers this.

hellow554

hellow554 commented on Apr 21, 2021

@hellow554
Contributor

Yep, looks like a dup of this mcve #82290 (comment)

@ahmtcn123 thanks for the report! Can you close it though?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @hellow554@SNCPlay42@ahmtcn123@rustbot

        Issue actions

          ICE: expected `NodeId` to be lowered already for res Local · Issue #84324 · rust-lang/rust