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

Invalid assignment in a while loop causes an ICE #93727

Closed
Aiden2207 opened this issue Feb 7, 2022 · 2 comments
Closed

Invalid assignment in a while loop causes an ICE #93727

Aiden2207 opened this issue Feb 7, 2022 · 2 comments
Labels
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.

Comments

@Aiden2207
Copy link

Code

fn main() {
    while false{
        1 = 1;
    }   
}

Playground

When running on the most recent stable rust, I get

error: internal compiler error[[E0070]](https://doc.rust-lang.org/stable/error-index.html#E0070): invalid left-hand side of assignment
 --> src/main.rs:4:11
  |
4 |         1 = 1;
  |         - ^
  |         |
  |         cannot assign to this expression
  |
help: you might have meant to use pattern destructuring
  |
3 |     while let false{
  |           +++

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1188:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/db9d1b20bba1968c1ec1fc49616d4742c1725b4b/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/db9d1b20bba1968c1ec1fc49616d4742c1725b4b/library/core/src/panicking.rs:107:14
   2: core::panicking::panic_display::<&str>
   3: <rustc_errors::HandlerInner>::flush_delayed
   4: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   5: core::ptr::drop_in_place::<rustc_session::parse::ParseSess>
   6: <alloc::rc::Rc<rustc_session::session::Session> as core::ops::drop::Drop>::drop
   7: core::ptr::drop_in_place::<rustc_interface::interface::Compiler>
   8: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
   9: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>
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.58.1 (db9d1b20b 2022-01-20) 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: could not compile `playground

On beta, the compiler doesn't crash, but rustc does give a questionable recommendation to fix the issue:

error[[E0070]](https://doc.rust-lang.org/beta/error-index.html#E0070): invalid left-hand side of assignment
 --> src/main.rs:4:11
  |
4 |         1 = 1;
  |         - ^
  |         |
  |         cannot assign to this expression
  |
help: you might have meant to use pattern destructuring
  |
3 |     while let false{
  |           +++

For more information about this error, try `rustc --explain E0070`.
error: could not compile `playground` due to previous error

On nightly(2022-02-06 as the time of writing) it compiles fine, giving the expected error message:

error[[E0070]](https://doc.rust-lang.org/nightly/error-index.html#E0070): invalid left-hand side of assignment
 --> src/main.rs:4:11
  |
4 |         1 = 1;
  |         - ^
  |         |
  |         cannot assign to this expression

For more information about this error, try `rustc --explain E0070`.
error: could not compile `playground` due to previous error
@Aiden2207 Aiden2207 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 Feb 7, 2022
@compiler-errors
Copy link
Member

compiler-errors commented Feb 7, 2022

Yeah, I believe I fixed this in the latest nightly, cc #93574. Not sure if there's anything to fix then?

@matthiaskrgr
Copy link
Member

Closing as this does not crash on latest nightly rustc 1.60.0-nightly (0c292c966 2022-02-08)

error[E0070]: invalid left-hand side of assignment
 --> test.rs:3:11
  |
3 |         1 = 1;
  |         - ^
  |         |
  |         cannot assign to this expression

error: aborting due to previous error

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) ❄️ 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

3 participants