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: expected NodeId to be lowered already for res Local #84324

Closed
ahmtcn123 opened this issue Apr 18, 2021 · 5 comments
Closed

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

ahmtcn123 opened this issue Apr 18, 2021 · 5 comments
Labels
C-bug Category: This is a bug. F-let_chains `#![feature(let_chains)]` 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

@ahmtcn123
Copy link

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.
@ahmtcn123 ahmtcn123 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 Apr 18, 2021
@ahmtcn123
Copy link
Author

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

@jyn514 jyn514 changed the title Internal Compiler Error ICE: expected NodeId to be lowered already for res Local Apr 19, 2021
@hellow554
Copy link
Contributor

hellow554 commented Apr 19, 2021

@rustbot modify labels: F-let_chains

@rustbot rustbot added the F-let_chains `#![feature(let_chains)]` label Apr 19, 2021
@hellow554
Copy link
Contributor

hellow554 commented Apr 19, 2021

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
Copy link
Contributor

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

@hellow554
Copy link
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
Labels
C-bug Category: This is a bug. F-let_chains `#![feature(let_chains)]` 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

4 participants