Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ICE] default field values with computed const generics #134298

Closed
jhpratt opened this issue Dec 14, 2024 · 0 comments · Fixed by #134314
Closed

[ICE] default field values with computed const generics #134298

jhpratt opened this issue Dec 14, 2024 · 0 comments · Fixed by #134314
Labels
F-default_field_values `#![feature(default_field_values)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jhpratt
Copy link
Member

jhpratt commented Dec 14, 2024

code (playground):

#![feature(default_field_values)]

struct Value<const VALUE: u8>;

impl<const VALUE: u8> Value<VALUE> {
    pub const VALUE: Self = Self;
}

pub struct WithUse {
    _use: Value<{ 1 - 1 }> = Value::VALUE
}

const _: WithUse = WithUse { .. };
output with backtrace
    Checking time v0.3.37 (/home/jhpratt/tmp/time)
note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: error performing operation: fully_perform
  --> src/lib.rs:13:20
   |
13 | const _: WithUse = WithUse { .. };
   |                    ^^^^^^^^^^^^^^
   |
note: delayed at /rustc/327c7ee4367ea587a49eff1d4715f462ab6db5f0/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs:87:25
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         3: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, alloc::string::String>
         4: <rustc_borrowck::type_check::TypeChecker>::ascribe_user_type
         5: <rustc_borrowck::type_check::TypeVerifier as rustc_middle::mir::visit::Visitor>::visit_body
         6: rustc_borrowck::type_check::type_check
         7: rustc_borrowck::nll::compute_regions
         8: rustc_borrowck::do_mir_borrowck
         9: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        10: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
        11: rustc_query_impl::query_impl::mir_borrowck::get_query_incr::__rust_end_short_backtrace
        12: rustc_mir_transform::mir_drops_elaborated_and_const_checked
        13: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        14: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
        15: rustc_query_impl::query_impl::mir_drops_elaborated_and_const_checked::get_query_incr::__rust_end_short_backtrace
        16: rustc_mir_transform::mir_for_ctfe
        17: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_for_ctfe::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        18: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
        19: rustc_query_impl::query_impl::mir_for_ctfe::get_query_incr::__rust_end_short_backtrace
        20: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::load_mir
        21: rustc_const_eval::const_eval::eval_queries::eval_to_allocation_raw_provider
        22: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 24]>>
        23: <rustc_query_impl::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>)>>::call_once
        24: <rustc_query_system::query::plumbing::execute_job_incr<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>, rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt>::{closure#2}::{closure#2} as core::ops::function::FnOnce<((rustc_query_impl::plumbing::QueryCtxt, rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>, rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>), rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>)>>::call_once
        25: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>, rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
        26: rustc_query_impl::query_impl::eval_to_allocation_raw::get_query_incr::__rust_end_short_backtrace
        27: rustc_const_eval::const_eval::eval_queries::eval_to_const_value_raw_provider
        28: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::eval_to_const_value_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 24]>>
        29: <rustc_query_impl::query_impl::eval_to_const_value_raw::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>)>>::call_once
        30: <rustc_query_system::query::plumbing::execute_job_incr<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>, rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt>::{closure#2}::{closure#2} as core::ops::function::FnOnce<((rustc_query_impl::plumbing::QueryCtxt, rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>, rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>), rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>)>>::call_once
        31: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>, rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
        32: rustc_query_impl::query_impl::eval_to_const_value_raw::get_query_incr::__rust_end_short_backtrace
        33: <rustc_middle::hir::map::Map>::par_body_owners::<rustc_hir_analysis::check_crate::{closure#3}>::{closure#0}
        34: rustc_hir_analysis::check_crate
        35: rustc_interface::passes::run_required_analyses
        36: rustc_interface::passes::analysis
        37: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
        38: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
        39: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
        40: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        41: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
        42: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        43: std::sys::pal::unix::thread::Thread::new::thread_start
        44: start_thread
        45: __GI___clone3
  --> src/lib.rs:13:20
   |
13 | const _: WithUse = WithUse { .. };
   |                    ^^^^^^^^^^^^^^

error: internal compiler error: error performing operation: fully_perform
  --> src/lib.rs:13:20
   |
13 | const _: WithUse = WithUse { .. };
   |                    ^^^^^^^^^^^^^^
   |
note: delayed at /rustc/327c7ee4367ea587a49eff1d4715f462ab6db5f0/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs:87:25
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         3: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, alloc::string::String>
         4: <rustc_borrowck::type_check::TypeChecker>::ascribe_user_type
         5: <rustc_borrowck::type_check::TypeVerifier as rustc_middle::mir::visit::Visitor>::visit_const_operand
         6: <rustc_borrowck::type_check::TypeVerifier as rustc_middle::mir::visit::Visitor>::visit_body
         7: rustc_borrowck::type_check::type_check
         8: rustc_borrowck::nll::compute_regions
         9: rustc_borrowck::do_mir_borrowck
        10: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        11: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
        12: rustc_query_impl::query_impl::mir_borrowck::get_query_incr::__rust_end_short_backtrace
        13: rustc_mir_transform::mir_drops_elaborated_and_const_checked
        14: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        15: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
        16: rustc_query_impl::query_impl::mir_drops_elaborated_and_const_checked::get_query_incr::__rust_end_short_backtrace
        17: rustc_mir_transform::mir_for_ctfe
        18: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_for_ctfe::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        19: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
        20: rustc_query_impl::query_impl::mir_for_ctfe::get_query_incr::__rust_end_short_backtrace
        21: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::load_mir
        22: rustc_const_eval::const_eval::eval_queries::eval_to_allocation_raw_provider
        23: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 24]>>
        24: <rustc_query_impl::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>)>>::call_once
        25: <rustc_query_system::query::plumbing::execute_job_incr<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>, rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt>::{closure#2}::{closure#2} as core::ops::function::FnOnce<((rustc_query_impl::plumbing::QueryCtxt, rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>, rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>), rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>)>>::call_once
        26: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>, rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
        27: rustc_query_impl::query_impl::eval_to_allocation_raw::get_query_incr::__rust_end_short_backtrace
        28: rustc_const_eval::const_eval::eval_queries::eval_to_const_value_raw_provider
        29: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::eval_to_const_value_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 24]>>
        30: <rustc_query_impl::query_impl::eval_to_const_value_raw::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>)>>::call_once
        31: <rustc_query_system::query::plumbing::execute_job_incr<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>, rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt>::{closure#2}::{closure#2} as core::ops::function::FnOnce<((rustc_query_impl::plumbing::QueryCtxt, rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>, rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>), rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>)>>::call_once
        32: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>, rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
        33: rustc_query_impl::query_impl::eval_to_const_value_raw::get_query_incr::__rust_end_short_backtrace
        34: <rustc_middle::hir::map::Map>::par_body_owners::<rustc_hir_analysis::check_crate::{closure#3}>::{closure#0}
        35: rustc_hir_analysis::check_crate
        36: rustc_interface::passes::run_required_analyses
        37: rustc_interface::passes::analysis
        38: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
        39: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
        40: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
        41: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        42: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
        43: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        44: std::sys::pal::unix::thread::Thread::new::thread_start
        45: start_thread
        46: __GI___clone3
  --> src/lib.rs:13:20
   |
13 | const _: WithUse = WithUse { .. };
   |                    ^^^^^^^^^^^^^^

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 `/home/jhpratt/tmp/time/rustc-ice-2024-12-14T05_03_34-1069365.txt` to your bug report

note: compiler flags: --crate-type lib -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:
end of query stack
error: could not compile `time` (lib)

Caused by:
  process didn't exit successfully: `/home/jhpratt/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name time --edition=2021 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata -C embed-bitcode=no -C debuginfo=2 --check-cfg 'cfg(docsrs)' --check-cfg 'cfg(feature, values())' -C metadata=7237f24f287a5418 -C extra-filename=-7182b2b746fa29ed --out-dir /home/jhpratt/tmp/time/target/debug/deps -C incremental=/home/jhpratt/tmp/time/target/debug/incremental -L dependency=/home/jhpratt/tmp/time/target/debug/deps` (exit status: 101)

rustc --version -v

rustc 1.85.0-nightly (327c7ee43 2024-12-13)
binary: rustc
commit-hash: 327c7ee4367ea587a49eff1d4715f462ab6db5f0
commit-date: 2024-12-13
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.5

cc @estebank

@jhpratt jhpratt added F-default_field_values `#![feature(default_field_values)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 14, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 14, 2024
@jhpratt jhpratt removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 14, 2024
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Dec 16, 2024
…ue-const, r=estebank

Make sure to use normalized ty for unevaluated const in default struct value

This cleans up the way that we construct the `mir::Const::Unevaluated` for default struct values. We were previously using `from_unevaluated`, which doesn't normalize the type, and is really only used for inline assembly. Other codepaths (such as `ExprKind::NamedConst`) use the type from the body.

Also, let's stop using `literal_operand`, which also is really not meant for calls other than for literal comparisons in pattern lowering.

Also move all of the tests to a separate subdirectory so they don't need to have the same prefix on all the test files.

Fixes rust-lang#134298
r? estebank or reassign
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 16, 2024
…ue-const, r=estebank

Make sure to use normalized ty for unevaluated const in default struct value

This cleans up the way that we construct the `mir::Const::Unevaluated` for default struct values. We were previously using `from_unevaluated`, which doesn't normalize the type, and is really only used for inline assembly. Other codepaths (such as `ExprKind::NamedConst`) use the type from the body.

Also, let's stop using `literal_operand`, which also is really not meant for calls other than for literal comparisons in pattern lowering.

Also move all of the tests to a separate subdirectory so they don't need to have the same prefix on all the test files.

Fixes rust-lang#134298
r? estebank or reassign
@bors bors closed this as completed in 050e0cc Dec 16, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Dec 16, 2024
Rollup merge of rust-lang#134314 - compiler-errors:default-struct-value-const, r=estebank

Make sure to use normalized ty for unevaluated const in default struct value

This cleans up the way that we construct the `mir::Const::Unevaluated` for default struct values. We were previously using `from_unevaluated`, which doesn't normalize the type, and is really only used for inline assembly. Other codepaths (such as `ExprKind::NamedConst`) use the type from the body.

Also, let's stop using `literal_operand`, which also is really not meant for calls other than for literal comparisons in pattern lowering.

Also move all of the tests to a separate subdirectory so they don't need to have the same prefix on all the test files.

Fixes rust-lang#134298
r? estebank or reassign
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-default_field_values `#![feature(default_field_values)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants