Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information