From c5f15bd607a143e984b7d2dca666be3f4c4b31f8 Mon Sep 17 00:00:00 2001 From: Waffle Lapkin Date: Tue, 2 Dec 2025 13:06:15 +0100 Subject: [PATCH] fix the check for which expressions read never type ...wrt `type_ascribe`/unsafe binders -- the check was infinitely recursive before. --- compiler/rustc_middle/src/hir/mod.rs | 2 +- .../{crashes => ui/unreachable-code}/nested_type_ascription.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename tests/{crashes => ui/unreachable-code}/nested_type_ascription.rs (95%) diff --git a/compiler/rustc_middle/src/hir/mod.rs b/compiler/rustc_middle/src/hir/mod.rs index 6622d007b564..08b262df2f6e 100644 --- a/compiler/rustc_middle/src/hir/mod.rs +++ b/compiler/rustc_middle/src/hir/mod.rs @@ -251,7 +251,7 @@ impl<'tcx> TyCtxt<'tcx> { // Place-preserving expressions only constitute reads if their // parent expression constitutes a read. ExprKind::Type(..) | ExprKind::UnsafeBinderCast(..) => { - self.expr_guaranteed_to_constitute_read_for_never(expr) + self.expr_guaranteed_to_constitute_read_for_never(parent_expr) } ExprKind::Assign(lhs, _, _) => { diff --git a/tests/crashes/nested_type_ascription.rs b/tests/ui/unreachable-code/nested_type_ascription.rs similarity index 95% rename from tests/crashes/nested_type_ascription.rs rename to tests/ui/unreachable-code/nested_type_ascription.rs index 734dabd554bb..9423082bc63f 100644 --- a/tests/crashes/nested_type_ascription.rs +++ b/tests/ui/unreachable-code/nested_type_ascription.rs @@ -3,7 +3,7 @@ // This checks that a nested type ascription doesn't cause a crash when the // compiler checks if it constitutes a read of the never type. // -//@ known-bug: #149542 +//@ check-pass #![feature(never_type)] #![feature(type_ascription)]