Skip to content

ICE: this path really should be doomed #134162

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
matthiaskrgr opened this issue Dec 11, 2024 · 6 comments · Fixed by #134279
Closed

ICE: this path really should be doomed #134162

matthiaskrgr opened this issue Dec 11, 2024 · 6 comments · Fixed by #134279
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. S-has-bisection Status: a bisection has been found for this issue S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

fn main() {
    struct X;

    let xs = [X, X, X];
    let eq = xs == [panic!("panic evaluated"); 2];
}

original:

fn main() {
    struct X;
    //~^ HELP consider annotating `X` with `#[derive(PartialEq)]`
    let xs = [X, X, X];
    let eq = xs == [panic!("panic evaluated"); 2];
    //~^ ERROR binary operation `==` cannot be applied to type `[X; 3]`
}

Version information

rustc 1.85.0-nightly (33c245b9e 2024-12-10)
binary: rustc
commit-hash: 33c245b9e98bc91e18ea1c5033824f4c6f92766f
commit-date: 2024-12-10
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.5

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

warning: unreachable expression
 --> /tmp/icemaker_global_tempdir.NcZ6cDcOgb7d/rustc_testrunner_tmpdir_reporting.dN0NI0VTaCoG/mvce.rs:5:20
  |
5 |     let eq = xs == [panic!("panic evaluated"); 2];
  |                    ^-------------------------^^^^
  |                    ||
  |                    |any code following this expression is unreachable
  |                    unreachable expression
  |
  = note: `#[warn(unreachable_code)]` on by default

warning: 1 warning emitted

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: this path really should be doomed...
 --> /tmp/icemaker_global_tempdir.NcZ6cDcOgb7d/rustc_testrunner_tmpdir_reporting.dN0NI0VTaCoG/mvce.rs:5:17
  |
5 |     let eq = xs == [panic!("panic evaluated"); 2];
  |                 ^^
  |
note: delayed at compiler/rustc_hir_typeck/src/op.rs:925:28 - disabled backtrace
 --> /tmp/icemaker_global_tempdir.NcZ6cDcOgb7d/rustc_testrunner_tmpdir_reporting.dN0NI0VTaCoG/mvce.rs:5:17
  |
5 |     let eq = xs == [panic!("panic evaluated"); 2];
  |                 ^^

error: internal compiler error: expression with never type wound up being adjusted
 --> /tmp/icemaker_global_tempdir.NcZ6cDcOgb7d/rustc_testrunner_tmpdir_reporting.dN0NI0VTaCoG/mvce.rs:5:21
  |
5 |     let eq = xs == [panic!("panic evaluated"); 2];
  |                     ^^^^^^^^^^^^^^^^^^^^^^^^^
  |
note: delayed at compiler/rustc_hir_typeck/src/expr.rs:76:43 - disabled backtrace
 --> /tmp/icemaker_global_tempdir.NcZ6cDcOgb7d/rustc_testrunner_tmpdir_reporting.dN0NI0VTaCoG/mvce.rs:5:21
  |
5 |     let eq = xs == [panic!("panic evaluated"); 2];
  |                     ^^^^^^^^^^^^^^^^^^^^^^^^^
  = note: this error: internal compiler error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_hir_typeck/src/op.rs:303:17 - disabled backtrace

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: please make sure that you have updated to the latest nightly

note: rustc 1.85.0-nightly (33c245b9e 2024-12-10) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack

@matthiaskrgr matthiaskrgr 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 Dec 11, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 11, 2024
@jieyouxu
Copy link
Member

ICEs on stable too.

@jieyouxu
Copy link
Member

********************************************************************************
Regression in nightly-2024-02-22
********************************************************************************

looking for regression commit between 2024-02-21 and 2024-02-22
fetching (via remote github) commits from max(bb594538fc6e84213a6b8d5e165442570aa48923, 2024-02-19) to 3406ada96f8e16e49e947a91db3eba0db45245fa
ending github query because we found starting sha: bb594538fc6e84213a6b8d5e165442570aa48923
get_commits_between returning commits, len: 11
  commit[0] 2024-02-20: Auto merge of #121345 - Nilstrieb:rollup-reb0xge, r=Nilstrieb
  commit[1] 2024-02-20: Auto merge of #121356 - matthiaskrgr:rollup-d80af2s, r=matthiaskrgr
  commit[2] 2024-02-21: Auto merge of #120904 - Nadrieril:match-lowering-intermediate-repr, r=matthewjasper
  commit[3] 2024-02-21: Auto merge of #121172 - Nadrieril:simplify-empty-selection, r=matthewjasper
  commit[4] 2024-02-21: Auto merge of #121380 - weihanglo:update-cargo, r=weihanglo
  commit[5] 2024-02-21: Auto merge of #120588 - alexcrichton:wasm-rmeta-object, r=wesleywiser,bjorn3
  commit[6] 2024-02-21: Auto merge of #120718 - saethlin:reasonable-fast-math, r=nnethercote
  commit[7] 2024-02-21: Auto merge of #121383 - Dylan-DPC:rollup-735p4u4, r=Dylan-DPC
  commit[8] 2024-02-21: Auto merge of #121400 - fmease:rollup-8m29g7a, r=fmease
  commit[9] 2024-02-21: Auto merge of #121321 - compiler-errors:yeet-querytyperelating, r=lcnr
  commit[10] 2024-02-21: Auto merge of #117658 - RalfJung:ptr-dangling, r=m-ou-se
ERROR: no CI builds available between bb594538fc6e84213a6b8d5e165442570aa48923 and 3406ada96f8e16e49e947a91db3eba0db45245fa within last 167 days

@jieyouxu
Copy link
Member

I have a feeling this might be a #121208

@jieyouxu
Copy link
Member

@jieyouxu jieyouxu self-assigned this Dec 11, 2024
@jieyouxu
Copy link
Member

fn main() {
    struct X;
    let _ = [X] == [panic!(); 2];
}

@jieyouxu jieyouxu added S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue S-has-bisection Status: a bisection has been found for this issue and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Dec 11, 2024
@jieyouxu
Copy link
Member

Ah: this is also edition sensitive. It ICEs on 2021 and 2024, but not on earlier editions.

jieyouxu added a commit to jieyouxu/rust that referenced this issue Dec 13, 2024
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Dec 14, 2024
jieyouxu added a commit to jieyouxu/rust that referenced this issue Dec 14, 2024
@bors bors closed this as completed in 752f79a Dec 14, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Dec 14, 2024
Rollup merge of rust-lang#134279 - jieyouxu:return-adjustment-target, r=compiler-errors

(Re-)return adjustment target if adjust kind is never-to-any

This PR fixes rust-lang#134162 where we ICE'd on

```rs
fn main() {
    struct X;
    let _ = [X] == [panic!(); 2];
}
```

In rust-lang#121208 (comment), there was a change

```diff
- if let Some(adjustments) = self.typeck_results.borrow().adjustments().get(expr.hir_id) {
-     let reported = self.dcx().span_delayed_bug(
-         expr.span,
-         "expression with never type wound up being adjusted",
-     );
-     return if let [Adjustment { kind: Adjust::NeverToAny, target }] = &adjustments[..] {
-         target.to_owned()
-     } else {
-         Ty::new_error(self.tcx(), reported)
-     };
- }
+ if let Some(_) = self.typeck_results.borrow().adjustments().get(expr.hir_id) {
+     self.dcx()
+         .span_bug(expr.span, "expression with never type wound up being adjusted");
+ }
```

It turned out returning the adjustment target if the adjustment kind is `NeverToAny` is necessary, as otherwise we will go through a series of `delay_bug`s and eventually find that we constructed a `TyKind::Error` without having actually emitted an error.

This PR addresses that by re-returning the adjustment target if the adjustment kind is `NeverToAny`, partially reverting this change from rust-lang#121208.

This PR has two commits:

1. The first commit adds a regression test for rust-lang#134162, which will ICE (on stable 1.83.0, beta and nightly 2024-12-13).
2. The second commit is the partial revert, which will fix the ICE.

cc `@nnethercote` FYI as this is related to rust-lang#121208 changes. The changes from rust-lang#121208 exposed that we lacked test coverage for the code pattern reported in rust-lang#134162.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. S-has-bisection Status: a bisection has been found for this issue S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue 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.

3 participants