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

univariant: field #2 comes after unsized field #123134

Closed
lylythechosenone opened this issue Mar 27, 2024 · 6 comments · Fixed by #129970
Closed

univariant: field #2 comes after unsized field #123134

lylythechosenone opened this issue Mar 27, 2024 · 6 comments · Fixed by #129970
Labels
A-layout Area: Memory layout of types C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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

@lylythechosenone
Copy link

Code

I'm not sure what exactly causes the ICE, but it happened in commit 0bb2479 on my fork of wgpu (lylythechosenone/wgpu).

Meta

rustc --version --verbose:

rustc 1.76.0 (07dca489a 2024-02-04)
binary: rustc
commit-hash: 07dca489ac2d933c78d3c5158e3f43beefeb02ce
commit-date: 2024-02-04
host: aarch64-apple-darwin
release: 1.76.0
LLVM version: 17.0.6

Error output

error: internal compiler error: no errors encountered even though `span_delayed_bug` issued

error: internal compiler error: univariant: field #2 comes after unsized field
Backtrace

error: internal compiler error: no errors encountered even though `span_delayed_bug` issued

error: internal compiler error: univariant: field #2 comes after unsized field
|
= note: delayed at compiler/rustc_middle/src/ty/layout.rs:286:23
           0: std::backtrace::Backtrace::create
           1: <rustc_errors::DiagCtxtInner>::emit_diagnostic_without_consuming
           2: <rustc_errors::DiagCtxtInner>::emit_diagnostic
           3: <rustc_errors::DiagCtxt>::span_delayed_bug::<rustc_span::span_encoding::Span, alloc::string::String>
           4: <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt> as rustc_abi::layout::LayoutCalculator>::delayed_bug
           5: rustc_abi::layout::univariant::<rustc_target::abi::FieldIdx, rustc_target::abi::VariantIdx, rustc_target::abi::Layout, rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>>
           6: <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt> as rustc_abi::layout::LayoutCalculator>::univariant::<rustc_target::abi::FieldIdx, rustc_target::abi::VariantIdx, rustc_target::abi::Layout>
           7: <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt> as rustc_abi::layout::LayoutCalculator>::layout_of_struct_or_enum::<rustc_target::abi::FieldIdx, rustc_target::abi::VariantIdx, rustc_target::abi::Layout, rustc_ty_utils::layout::layout_of_uncached::{closure#10}, core::iter::adapters::flatten::Flatten<core::option::IntoIter<core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::iter::adapters::enumerate::Enumerate<core::slice::iter::Iter<rustc_middle::ty::VariantDef>>, <rustc_index::slice::IndexSlice<rustc_target::abi::VariantIdx, rustc_middle::ty::VariantDef>>::iter_enumerated::{closure#0}>, <rustc_middle::ty::adt::AdtDef>::discriminants::{closure#0}>, rustc_ty_utils::layout::layout_of_uncached::{closure#11}::{closure#0}::{closure#0}>>>>
           8: rustc_ty_utils::layout::layout_of_uncached
           9: rustc_ty_utils::layout::layout_of
          10: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::layout_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 16]>>
          11: <rustc_query_impl::query_impl::layout_of::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::Ty>)>>::call_once
          12: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::Ty>, rustc_middle::query::erase::Erased<[u8; 16]>>, false, true, false>, rustc_query_impl::plumbing::QueryCtxt, true>
          13: rustc_query_impl::query_impl::layout_of::get_query_incr::__rust_end_short_backtrace
          14: <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt> as rustc_middle::ty::layout::LayoutOf>::spanned_layout_of
          15: core::iter::adapters::try_process::<core::iter::adapters::by_ref_sized::ByRefSized<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::ty::FieldDef>, rustc_ty_utils::layout::layout_of_uncached::{closure#8}::{closure#0}>>, rustc_target::abi::Layout, core::result::Result<core::convert::Infallible, &rustc_middle::ty::layout::LayoutError>, <core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::ty::FieldDef>, rustc_ty_utils::layout::layout_of_uncached::{closure#8}::{closure#0}> as core::iter::traits::iterator::Iterator>::try_collect<rustc_index::vec::IndexVec<rustc_target::abi::FieldIdx, rustc_target::abi::Layout>>::{closure#0}, rustc_index::vec::IndexVec<rustc_target::abi::FieldIdx, rustc_target::abi::Layout>>
          16: core::iter::adapters::try_process::<core::iter::adapters::by_ref_sized::ByRefSized<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::ty::VariantDef>, rustc_ty_utils::layout::layout_of_uncached::{closure#8}>>, rustc_index::vec::IndexVec<rustc_target::abi::FieldIdx, rustc_target::abi::Layout>, core::result::Result<core::convert::Infallible, &rustc_middle::ty::layout::LayoutError>, <core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::ty::VariantDef>, rustc_ty_utils::layout::layout_of_uncached::{closure#8}> as core::iter::traits::iterator::Iterator>::try_collect<rustc_index::vec::IndexVec<rustc_target::abi::VariantIdx, rustc_index::vec::IndexVec<rustc_target::abi::FieldIdx, rustc_target::abi::Layout>>>::{closure#0}, rustc_index::vec::IndexVec<rustc_target::abi::VariantIdx, rustc_index::vec::IndexVec<rustc_target::abi::FieldIdx, rustc_target::abi::Layout>>>
          17: rustc_ty_utils::layout::layout_of_uncached
          18: rustc_ty_utils::layout::layout_of
          19: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::layout_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 16]>>
          20: <rustc_query_impl::query_impl::layout_of::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::Ty>)>>::call_once
          21: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::Ty>, rustc_middle::query::erase::Erased<[u8; 16]>>, false, true, false>, rustc_query_impl::plumbing::QueryCtxt, true>
          22: rustc_query_impl::query_impl::layout_of::get_query_incr::__rust_end_short_backtrace
          23: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::Ty>, rustc_middle::query::erase::Erased<[u8; 16]>>>
          24: <rustc_mir_transform::const_prop::CanConstProp>::check
          25: <rustc_mir_transform::const_prop_lint::ConstPropLint as rustc_mir_transform::pass_manager::MirLint>::run_lint
          26: rustc_mir_transform::pass_manager::run_passes_inner
          27: rustc_mir_transform::run_analysis_to_runtime_passes
          28: rustc_mir_transform::mir_drops_elaborated_and_const_checked
          29: 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]>>
          30: <rustc_query_impl::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId)>>::call_once
          31: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
          32: rustc_query_impl::query_impl::mir_drops_elaborated_and_const_checked::get_query_incr::__rust_end_short_backtrace
          33: rustc_mir_transform::optimized_mir
          34: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
          35: <rustc_query_impl::query_impl::optimized_mir::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId)>>::call_once
          36: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
          37: rustc_query_impl::query_impl::optimized_mir::get_query_incr::__rust_end_short_backtrace
          38: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::query::erase::Erased<[u8; 8]>>>
          39: <clippy_lints::redundant_clone::RedundantClone as rustc_lint::passes::LateLintPass>::check_fn
          40: rustc_hir::intravisit::walk_impl_item::<rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>
          41: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_nested_impl_item
          42: rustc_hir::intravisit::walk_item::<rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>
          43: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_nested_item
          44: rustc_hir::intravisit::walk_item::<rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass>>
          45: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_nested_item
          46: rustc_lint::late::late_lint_crate
          47: <rustc_session::session::Session>::time::<(), rustc_lint::late::check_crate::{closure#0}::{closure#0}>
          48: <rustc_data_structures::sync::parallel::ParallelGuard>::run::<(), rustc_lint::late::check_crate::{closure#0}>
          49: rustc_data_structures::sync::parallel::disabled::join::<rustc_lint::late::check_crate::{closure#0}, rustc_lint::late::check_crate::{closure#1}, (), ()>
          50: rustc_lint::late::check_crate
          51: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#6}::{closure#1}::{closure#0}::{closure#0}::{closure#2}::{closure#0}>
          52: <rustc_data_structures::sync::parallel::ParallelGuard>::run::<(), rustc_interface::passes::analysis::{closure#6}::{closure#1}::{closure#0}::{closure#0}::{closure#2}>
          53: std::panicking::try::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#6}::{closure#1}::{closure#0}>>
          54: <rustc_data_structures::sync::parallel::ParallelGuard>::run::<(), rustc_interface::passes::analysis::{closure#6}::{closure#1}::{closure#0}>
          55: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#6}>
          56: rustc_interface::passes::analysis
          57: 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; 1]>>
          58: <rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, ())>>::call_once
          59: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
          60: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
          61: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#0}::{closure#0}::{closure#3}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
          62: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#0}::{closure#0}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
          63: rustc_span::create_session_globals_then::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}>
          64: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
          65: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
          66: std::sys::unix::thread::Thread::new::thread_start
          67: __pthread_joiner_wake
        

note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new?template=ice.yml

note: rustc 1.76.0 (07dca489a 2024-02-04) running on aarch64-apple-darwin

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

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

query stack during panic:
end of query stack
note: Clippy version: clippy 0.1.76 (07dca489 2024-02-04)

note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new?template=ice.yml

note: rustc 1.76.0 (07dca489a 2024-02-04) running on aarch64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C incremental=[REDACTED]

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

query stack during panic:
end of query stack
note: Clippy version: clippy 0.1.76 (07dca489 2024-02-04)

@lylythechosenone lylythechosenone added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 27, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 27, 2024
@compiler-errors compiler-errors added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Mar 27, 2024
@lylythechosenone
Copy link
Author

@compiler-errors I'm not really sure how to minimize it. Currently, I have no idea which struct is causing the error, nor why. I have tried using cargo-minimize, but it did do very much at all. Let me know if there's something else I should try.

P.S. the scope of the changes isn't too huge, and I'm 100% sure that the issue relates to the new ?Sized bounds on Api types.

@jieyouxu
Copy link
Member

ERROR rustc_abi::layout dl=TargetDataLayout { endian: little, i1_align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(1 bytes) }, i8_align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(1 bytes) }, i16_align: AbiAndPrefAlign { abi: Align(2 bytes), pref: Align(2 bytes) }, i32_align: AbiAndPrefAlign { abi: Align(4 bytes), pref: Align(4 bytes) }, i64_align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, i128_align: AbiAndPrefAlign { abi: Align(16 bytes), pref: Align(16 bytes) }, f16_align: AbiAndPrefAlign { abi: Align(2 bytes), pref: Align(2 bytes) }, f32_align: AbiAndPrefAlign { abi: Align(4 bytes), pref: Align(4 bytes) }, f64_align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, f128_align: AbiAndPrefAlign { abi: Align(16 bytes), pref: Align(16 bytes) }, pointer_size: Size(8 bytes), pointer_align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, aggregate_align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, vector_align: [(Size(8 bytes), AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }), (Size(16 bytes), AbiAndPrefAlign { abi: Align(16 bytes), pref: Align(16 bytes) })], instruction_address_space: AddressSpace(0), c_enum_min_size: I32 }, fields=[Layout { size: Size(0 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, abi: Aggregate { sized: false }, fields: Arbitrary { offsets: [], memory_index: [] }, largest_niche: None, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes) }, Layout { size: Size(0 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, abi: Aggregate { sized: false }, fields: Arbitrary { offsets: [], memory_index: [] }, largest_niche: None, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes) }], repr=ReprOptions { int: None, align: None, pack: None, flags: , field_shuffle_seed: 779237850841490393 }, kind=AlwaysSized
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: univariant: field #2 comes after unsized field

@lylythechosenone
Copy link
Author

Alright I may have actually just found it. It seems like it's in this struct:

pub struct OpenDevice<A: Api>
where
    A::Device: Sized,
    A::Queue: Sized,
{
    pub device: A::Device,
    pub queue: A::Queue,
}

@lukas-code
Copy link
Member

Here is a self-contained reproducer, can probably be minimized further: playground link

trait Api: Sized {
    type Device: ?Sized;
}

struct OpenDevice<A: Api>
where
    A::Device: Sized,
{
    device: A::Device,
    queue: (),
}

trait Adapter {
    type A: Api;

    fn open() -> OpenDevice<Self::A>
    where
        <Self::A as Api>::Device: Sized;
}

struct ApiS;

impl Api for ApiS {
    type Device = [u8];
}

impl<T> Adapter for T {
    type A = ApiS;

    fn open() -> OpenDevice<Self::A>
    where
        <Self::A as Api>::Device: Sized,
    {
        unreachable!()
    }
}

@jieyouxu jieyouxu added A-layout Area: Memory layout of types S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue and removed E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 27, 2024
@lylythechosenone
Copy link
Author

@lukas-code thank you very much. I was gone else I would've done that myself 😅.

@matthiaskrgr
Copy link
Member

Regression in nightly-2023-08-30
looking for regression commit between 2023-08-29 and 2023-08-30
fetching (via remote github) commits from max(4e78abb, 2023-08-27) to 84a9f4c
ending github query because we found starting sha: 4e78abb
get_commits_between returning commits, len: 13
commit[0] 2023-08-28: Auto merge of #115326 - matthiaskrgr:rollup-qsoa8ar, r=matthiaskrgr
commit[1] 2023-08-28: Auto merge of #115182 - RalfJung:abi-compat-sign, r=b-naber
commit[2] 2023-08-29: Auto merge of #115309 - hermitcore:hermit-net-init, r=cuviper
commit[3] 2023-08-29: Auto merge of #115260 - scottmcm:not-quite-so-cold, r=WaffleLapkin
commit[4] 2023-08-29: Auto merge of #115312 - hermitcore:hermit-is_interrupted, r=thomcc
commit[5] 2023-08-29: Auto merge of #113859 - Manishearth:vec-as-mut-ptr-stacked-borrow, r=dtolnay
commit[6] 2023-08-29: Auto merge of #114795 - RalfJung:cell-swap, r=dtolnay
commit[7] 2023-08-29: Auto merge of #115277 - RalfJung:is_1zst, r=davidtwco
commit[8] 2023-08-29: Auto merge of #114894 - Zoxc:sharded-cfg-cleanup2, r=cjgillot
commit[9] 2023-08-29: Auto merge of #112775 - c410-f3r:t3st3ss, r=petrochenkov
commit[10] 2023-08-29: Auto merge of #115183 - flip1995:clippyup, r=Manishearth,oli-obk
commit[11] 2023-08-29: Auto merge of #115354 - matthiaskrgr:rollup-4cotcxz, r=matthiaskrgr
commit[12] 2023-08-29: Auto merge of #114114 - keith:ks/always-add-lc_build_version-for-metadata-object-files, r=wesleywiser
ERROR: no CI builds available between 4e78abb and 84a9f4c within last 167 days

bors added a commit to rust-lang-ci/rust that referenced this issue Mar 28, 2024
skip known panics lint for impossible items

fixes rust-lang#123134

For items with impossible predicates like `[u8]: Sized` it's possible to have locals that are "Sized", but cannot be const-propped in any meaningful way. To avoid this issue, we can just skip the known panics lint for items that have impossible predicates.
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Apr 15, 2024
@bors bors closed this as completed in e2dc1a1 Sep 17, 2024
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Sep 17, 2024
layout computation: gracefully handle unsized types in unexpected locations

This PR reworks the layout computation to eagerly return an error when encountering an unsized field where a sized field was expected, rather than delaying a bug and attempting to recover a layout. This is required, because with trivially false where clauses like `[T]: Sized`, any field can possible be an unsized type, without causing a compile error.

Since this PR removes the `delayed_bug` method from the `LayoutCalculator` trait, it essentially becomes the same as the `HasDataLayout` trait, so I've also refactored the `LayoutCalculator` to be a simple wrapper struct around a type that implements `HasDataLayout`.

The majority of the diff is whitespace changes, so viewing with whitespace ignored is advised.

implements rust-lang/rust#123169 (comment)

r? `@compiler-errors` or compiler

fixes rust-lang/rust#123134
fixes rust-lang/rust#124182
fixes rust-lang/rust#126939
fixes rust-lang/rust#127737
lnicola pushed a commit to lnicola/rust-analyzer that referenced this issue Sep 25, 2024
layout computation: gracefully handle unsized types in unexpected locations

This PR reworks the layout computation to eagerly return an error when encountering an unsized field where a sized field was expected, rather than delaying a bug and attempting to recover a layout. This is required, because with trivially false where clauses like `[T]: Sized`, any field can possible be an unsized type, without causing a compile error.

Since this PR removes the `delayed_bug` method from the `LayoutCalculator` trait, it essentially becomes the same as the `HasDataLayout` trait, so I've also refactored the `LayoutCalculator` to be a simple wrapper struct around a type that implements `HasDataLayout`.

The majority of the diff is whitespace changes, so viewing with whitespace ignored is advised.

implements rust-lang/rust#123169 (comment)

r? `@compiler-errors` or compiler

fixes rust-lang/rust#123134
fixes rust-lang/rust#124182
fixes rust-lang/rust#126939
fixes rust-lang/rust#127737
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-layout Area: Memory layout of types C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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
6 participants