Skip to content

Using default_field_values with a lifetime field triggers a region conversion error ('cannot convert 'a/#0 to a region vid') #137136

Closed as duplicate of#135649
@pk5ls20

Description

@pk5ls20

Code

#![feature(default_field_values)]

struct Example<'a> {
    name: &'a str = "example",
}

fn main() {
    println!("Hello, world!");
}

Meta

rustc --version --verbose:

rustc 1.86.0-nightly (9cd60bd2c 2025-02-15)
binary: rustc
commit-hash: 9cd60bd2ccc41bc898d2ad86728f14035d2df72d
commit-date: 2025-02-15
host: x86_64-pc-windows-msvc
release: 1.86.0-nightly
LLVM version: 19.1.7

Error output

error: internal compiler error: compiler\rustc_borrowck\src\universal_regions.rs:888:36: cannot convert `'a/#0` to a region vid


thread 'rustc' panicked at compiler\rustc_borrowck\src\universal_regions.rs:888:36:

#0 [mir_borrowck] borrow-checking `Example::name::{constant#0}`
#1 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `untitled8` (bin "untitled8")

Caused by:
  process didn't exit successfully: `C:\Users\pk5ls\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\bin\rustc.exe --crate-name untitled8 --edition=2024 src\main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=155 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --check-cfg cfg(docsrs,test) --check-cfg "cfg(feature, values())" -C metadata=c36b17d98ff1d493 --out-dir C:\Users\pk5ls\Desktop\Projects\untitled8\target\debug\deps -C incremental=C:\Users\pk5ls\Desktop\Projects\untitled8\target\debug\incremental -L dependency=C:\Users\pk5ls\Desktop\Projects\untitled8\target\debug\deps` (exit code: 101)

rustc-ice-2025-02-16T13_50_18-45760.txt

Backtrace

stack backtrace:
   0:     0x7ffd0dba60b1 - std::backtrace_rs::backtrace::win64::trace
                               at /rustc/9cd60bd2ccc41bc898d2ad86728f14035d2df72d/library\std\src\..\..\backtrace\src\backtrace\win64.rs:85
   1:     0x7ffd0dba60b1 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/9cd60bd2ccc41bc898d2ad86728f14035d2df72d/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ffd0dba60b1 - std::sys::backtrace::_print_fmt
                               at /rustc/9cd60bd2ccc41bc898d2ad86728f14035d2df72d/library\std\src\sys\backtrace.rs:66
   3:     0x7ffd0dba60b1 - std::sys::backtrace::impl$0::print::impl$0::fmt
                               at /rustc/9cd60bd2ccc41bc898d2ad86728f14035d2df72d/library\std\src\sys\backtrace.rs:39
   4:     0x7ffd0dbd9dba - core::fmt::rt::Argument::fmt
                               at /rustc/9cd60bd2ccc41bc898d2ad86728f14035d2df72d/library\core\src\fmt\rt.rs:177
   5:     0x7ffd0dbd9dba - core::fmt::write
                               at /rustc/9cd60bd2ccc41bc898d2ad86728f14035d2df72d/library\core\src\fmt\mod.rs:1449
   6:     0x7ffd0db9be37 - std::io::Write::write_fmt<std::sys::pal::windows::stdio::Stderr>
                               at /rustc/9cd60bd2ccc41bc898d2ad86728f14035d2df72d/library\std\src\io\mod.rs:1890
   7:     0x7ffd0dba5ef5 - std::sys::backtrace::BacktraceLock::print
                               at /rustc/9cd60bd2ccc41bc898d2ad86728f14035d2df72d/library\std\src\sys\backtrace.rs:42
   8:     0x7ffd0dba8e20 - std::panicking::default_hook::closure$0
                               at /rustc/9cd60bd2ccc41bc898d2ad86728f14035d2df72d/library\std\src\panicking.rs:298
   9:     0x7ffd0dba8c11 - std::panicking::default_hook
                               at /rustc/9cd60bd2ccc41bc898d2ad86728f14035d2df72d/library\std\src\panicking.rs:325
  10:     0x7ffd0f26892f - core[27cb0ac7d8c09e90]::slice::sort::unstable::heapsort::heapsort::<((rustc_lint_defs[25819311ec1e66fe]::Level, &str), usize), <((rustc_lint_defs[25819311ec1e66fe]::Level, &str), usize) as core[27cb0ac7d8c09e90]::cmp::PartialOrd>::lt>
  11:     0x7ffd0dba9aae - alloc::boxed::impl$30::call
                               at /rustc/9cd60bd2ccc41bc898d2ad86728f14035d2df72d/library\alloc\src\boxed.rs:1990
  12:     0x7ffd0dba9aae - std::panicking::rust_panic_with_hook
                               at /rustc/9cd60bd2ccc41bc898d2ad86728f14035d2df72d/library\std\src\panicking.rs:839
  13:     0x7ffd10956303 - RINvNtNtNtNtCs3pOI3W5Bmr4_4core5slice4sort6stable9quicksort9quicksortTjRNtNtCsd1GWAzBbQtC_12rustc_errors7snippet10AnnotationENCINvMNtCs7EaMS2g59As_5alloc5sliceSB15_11sort_by_keyTINtNtBa_3cmp7ReversejEbENCNCNvMs5_NtB1c_7emitterNtB3o_12HumanEmitter18render_s
  14:     0x7ffd1094a689 - std[73d56390507a7f97]::sys::backtrace::__rust_end_short_backtrace::<std[73d56390507a7f97]::panicking::begin_panic<rustc_errors[97bcae2273874e96]::ExplicitBug>::{closure#0}, !>
  15:     0x7ffd1094a668 - std[73d56390507a7f97]::panicking::begin_panic::<rustc_errors[97bcae2273874e96]::ExplicitBug>
  16:     0x7ffd10963565 - <rustc_errors[97bcae2273874e96]::diagnostic::BugAbort as rustc_errors[97bcae2273874e96]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  17:     0x7ffd108a2082 - rustc_middle[13a9e5fe7a28e62a]::util::bug::span_bug_fmt::<rustc_span[cc6aa1b499af0ff2]::span_encoding::Span>
  18:     0x7ffd10884d2d - <rustc_middle[13a9e5fe7a28e62a]::ty::consts::Const>::to_value
  19:     0x7ffd10884b46 - <rustc_middle[13a9e5fe7a28e62a]::ty::consts::Const>::to_value
  20:     0x7ffd108a1f82 - rustc_middle[13a9e5fe7a28e62a]::util::bug::bug_fmt
  21:     0x7ffd0e2bd668 - <rustc_borrowck[5ec08bbd759d298d]::universal_regions::UniversalRegionIndices>::to_region_vid
  22:     0x7ffd0d56ddb4 - <rustc_borrowck[5ec08bbd759d298d]::type_check::InstantiateOpaqueType as rustc_trait_selection[5daf6fd25d6bcd0b]::traits::query::type_op::TypeOp>::fully_perform
  23:     0x7ffd0e224a8a - RINvMs6_NtCsj7lDhgBsAJy_9hashbrown3rawINtB6_8RawTablejE14reserve_rehashNCINvNtNtCs3huy2kDL4Qh_8indexmap3map4core8get_hashNtNtNtCs1GFuwugP2D6_12rustc_middle2ty6region6RegionNtNtCskZNMN7HLs2c_13rustc_type_ir11region_kind9RegionVidE0ECs88mwOPYfKXx_14rustc_bor
  24:     0x7ffd0e3488b1 - <rustc_borrowck[5ec08bbd759d298d]::type_check::TypeChecker>::push_region_constraints
  25:     0x7ffd0e2bd7fa - rustc_borrowck[5ec08bbd759d298d]::mir_borrowck
  26:     0x7ffd0e9a8d3b - rustc_query_impl[b576d443065d17ce]::plumbing::query_key_hash_verify_all
  27:     0x7ffd0e8f317e - RINvNtNtCsaUrYJe9wvMt_18rustc_query_system5query8plumbing17try_execute_queryINtCsfzVDcqYHeZC_16rustc_query_impl13DynamicConfigINtNtCs7D2qoXoqBdD_21rustc_data_structures9vec_cache8VecCacheNtNtCshy6thzVHTuU_10rustc_span6def_id10LocalDefIdINtNtNtCs1GFuwugP2D6
  28:     0x7ffd0e9b38df - rustc_query_impl[b576d443065d17ce]::plumbing::query_key_hash_verify_all
  29:     0x7ffd0dc1bd58 - <rustc_interface[c24d7a5c89a26a10]::passes::LintStoreExpandImpl as rustc_expand[df2b630de7570cd4]::base::LintStoreExpand>::pre_expansion_lint
  30:     0x7ffd0a819759 - rustc_interface[c24d7a5c89a26a10]::passes::analysis
  31:     0x7ffd0d7a86ca - <alloc[5914a2f25ef21312]::sync::Arc<rustc_session[4667223e94967deb]::cstore::CrateSource>>::drop_slow
  32:     0x7ffd0d6b8ecc - RINvNtNtCsaUrYJe9wvMt_18rustc_query_system5query8plumbing17try_execute_queryINtCsfzVDcqYHeZC_16rustc_query_impl13DynamicConfigINtNtB4_6caches11SingleCacheINtNtNtCs1GFuwugP2D6_12rustc_middle5query5erase6ErasedAhj0_EEKb0_KB3s_KB3s_ENtNtB1f_8plumbing9QueryCtx
  33:     0x7ffd0d7ae274 - rustc_query_impl[b576d443065d17ce]::query_system
  34:     0x7ffd0a7dfc16 - RINvNtNtCs9WzUIwO2dlX_3std3sys9backtrace28___rust_begin_short_backtraceNCNCNCINvMNtB6_6threadNtB1h_7Builder16spawn_unchecked_INtNtCs7EaMS2g59As_5alloc5boxed3BoxDINtNtNtCs3pOI3W5Bmr4_4core3ops8function6FnOnceuEp6OutputuNtNtB2G_6marker4SendEL_EuEs_000uECsjln
  35:     0x7ffd0a7d7fff - RINvNtNtCs9WzUIwO2dlX_3std3sys9backtrace28___rust_begin_short_backtraceNCNCNCINvMNtB6_6threadNtB1h_7Builder16spawn_unchecked_INtNtCs7EaMS2g59As_5alloc5boxed3BoxDINtNtNtCs3pOI3W5Bmr4_4core3ops8function6FnOnceuEp6OutputuNtNtB2G_6marker4SendEL_EuEs_000uECsjln
  36:     0x7ffd0a7d0679 - RINvNtNtCs9WzUIwO2dlX_3std3sys9backtrace28___rust_begin_short_backtraceNCNCINvNtCsgGgDSeYAMXA_15rustc_interface4util26run_in_thread_with_globalsNCINvB1e_31run_in_thread_pool_with_globalsNCINvNtB1g_9interface12run_compileruNCNvCsjlnXsBtVGr5_17rustc_driver_i
  37:     0x7ffd0a7e49c3 - RINvNtNtCs9WzUIwO2dlX_3std3sys9backtrace28___rust_begin_short_backtraceNCNCNCINvMNtB6_6threadNtB1h_7Builder16spawn_unchecked_INtNtCs7EaMS2g59As_5alloc5boxed3BoxDINtNtNtCs3pOI3W5Bmr4_4core3ops8function6FnOnceuEp6OutputuNtNtB2G_6marker4SendEL_EuEs_000uECsjln
  38:     0x7ffd0dbbb04d - alloc::boxed::impl$28::call_once
                               at /rustc/9cd60bd2ccc41bc898d2ad86728f14035d2df72d/library\alloc\src\boxed.rs:1976
  39:     0x7ffd0dbbb04d - alloc::boxed::impl$28::call_once
                               at /rustc/9cd60bd2ccc41bc898d2ad86728f14035d2df72d/library\alloc\src\boxed.rs:1976
  40:     0x7ffd0dbbb04d - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/9cd60bd2ccc41bc898d2ad86728f14035d2df72d/library\std\src\sys\pal\windows\thread.rs:56
  41:     0x7ffe45a5e8d7 - BaseThreadInitThunk
  42:     0x7ffe46e3bf2c - RtlUserThreadStart

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: please attach the file at `C:\Users\pk5ls\Desktop\Projects\untitled8\rustc-ice-2025-02-16T13_50_18-45760.txt` to your bug report

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [mir_borrowck] borrow-checking `Example::name::{constant#0}`
#1 [analysis] running analysis passes on this crate
end of query stack

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-default_field_values`#![feature(default_field_values)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions