diff options
| author | Michael Goulet <michael@errs.io> | 2024-11-26 23:18:02 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-11-27 02:39:07 +0000 |
| commit | 72cd7ac4f13ff37cb21c2cbdf2dbac6000a11dd9 (patch) | |
| tree | cd0e907fc288b2084eda2ed3b20b9922183cface /compiler | |
| parent | f2abf827c128120ed7a874d02973947968c158b8 (diff) | |
| download | rust-72cd7ac4f13ff37cb21c2cbdf2dbac6000a11dd9.tar.gz rust-72cd7ac4f13ff37cb21c2cbdf2dbac6000a11dd9.zip | |
Structurally resolve before checking never
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_hir_typeck/src/expr.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 6599b49baa3..b4715839cf5 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -68,7 +68,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // While we don't allow *arbitrary* coercions here, we *do* allow // coercions from ! to `expected`. - if ty.is_never() && self.expr_guaranteed_to_constitute_read_for_never(expr) { + if self.try_structurally_resolve_type(expr.span, ty).is_never() + && self.expr_guaranteed_to_constitute_read_for_never(expr) + { if let Some(_) = self.typeck_results.borrow().adjustments().get(expr.hir_id) { let reported = self.dcx().span_delayed_bug( expr.span, @@ -274,7 +276,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // unless it's a place expression that isn't being read from, in which case // diverging would be unsound since we may never actually read the `!`. // e.g. `let _ = *never_ptr;` with `never_ptr: *const !`. - if ty.is_never() && self.expr_guaranteed_to_constitute_read_for_never(expr) { + if self.try_structurally_resolve_type(expr.span, ty).is_never() + && self.expr_guaranteed_to_constitute_read_for_never(expr) + { self.diverges.set(self.diverges.get() | Diverges::always(expr.span)); } |
