about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-02-18 18:40:49 +0100
committerGitHub <noreply@github.com>2025-02-18 18:40:49 +0100
commit7edd17cfbbca044c165dc01f73ebea04f7eec588 (patch)
tree63ec4ce3608afc8673c4c68039528927ee31b00e /compiler
parent3b022d8ceea570db9730be34d964f0cc663a567f (diff)
parent08ee5f5e63afe3e6a3d852932484c506d0eaee87 (diff)
downloadrust-7edd17cfbbca044c165dc01f73ebea04f7eec588.tar.gz
rust-7edd17cfbbca044c165dc01f73ebea04f7eec588.zip
Rollup merge of #135711 - estebank:issue-135649, r=davidtwco
Do not ICE on default_field_value const with lifetimes

`#![feature(default_field_values)]` uses a `const` body that should be treated as inline `const`s, but is actually being detected otherwise. This is similar to the situation in #78174, so we take the same solution: we check if the const actually comes from a field, and if it does, we use that logic to get the appropriate lifetimes and not ICE during borrowck.

Fix #135649.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_borrowck/src/universal_regions.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs
index 4e6f82ac849..9a68eeb3326 100644
--- a/compiler/rustc_borrowck/src/universal_regions.rs
+++ b/compiler/rustc_borrowck/src/universal_regions.rs
@@ -21,6 +21,7 @@ use std::iter;
 use rustc_data_structures::fx::FxIndexMap;
 use rustc_errors::Diag;
 use rustc_hir::BodyOwnerKind;
+use rustc_hir::def::DefKind;
 use rustc_hir::def_id::{DefId, LocalDefId};
 use rustc_hir::lang_items::LangItem;
 use rustc_index::IndexVec;
@@ -603,7 +604,10 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
 
             BodyOwnerKind::Const { .. } | BodyOwnerKind::Static(..) => {
                 let identity_args = GenericArgs::identity_for_item(tcx, typeck_root_def_id);
-                if self.mir_def.to_def_id() == typeck_root_def_id {
+                if self.mir_def.to_def_id() == typeck_root_def_id
+                    // Do not ICE when checking default_field_values consts with lifetimes (#135649)
+                    && DefKind::Field != tcx.def_kind(tcx.parent(typeck_root_def_id))
+                {
                     let args =
                         self.infcx.replace_free_regions_with_nll_infer_vars(FR, identity_args);
                     DefiningTy::Const(self.mir_def.to_def_id(), args)