diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-12-14 14:07:59 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-14 14:07:59 +0100 |
| commit | 752f79a018e5852d3eb15f031610003bafb1b368 (patch) | |
| tree | ea21e5c735b5278df49c42f41686828107fc2ad2 /compiler/rustc_codegen_gcc | |
| parent | 352e3232b91ff87fb7f11866a4912593a7bbd0be (diff) | |
| parent | d15315cf9d2fbe3c2d348267567feacaddf89c50 (diff) | |
| download | rust-752f79a018e5852d3eb15f031610003bafb1b368.tar.gz rust-752f79a018e5852d3eb15f031610003bafb1b368.zip | |
Rollup merge of #134279 - jieyouxu:return-adjustment-target, r=compiler-errors
(Re-)return adjustment target if adjust kind is never-to-any
This PR fixes #134162 where we ICE'd on
```rs
fn main() {
struct X;
let _ = [X] == [panic!(); 2];
}
```
In https://github.com/rust-lang/rust/pull/121208#discussion_r1494187622, 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 #121208.
This PR has two commits:
1. The first commit adds a regression test for #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 #121208 changes. The changes from #121208 exposed that we lacked test coverage for the code pattern reported in #134162.
Diffstat (limited to 'compiler/rustc_codegen_gcc')
0 files changed, 0 insertions, 0 deletions
