From d4670375742c69512ec0a143b196bf31dd019b5f Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Fri, 8 May 2026 15:06:00 +0900 Subject: [PATCH] avoid ICE in as_ref suggestion for untyped receiver --- compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index 7e2f3e62589f..01479180dd3e 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -2787,7 +2787,7 @@ fn can_use_as_ref(&self, expr: &hir::Expr<'_>) -> Option<(Vec<(Span, String)>, & return None; }; - let self_ty = self.typeck_results.borrow().expr_ty(receiver); + let self_ty = self.typeck_results.borrow().expr_ty_opt(receiver)?; let name = method_path.ident.name; let is_as_ref_able = match self_ty.peel_refs().kind() { ty::Adt(def, _) => {