Open cushionbadak opened 4 months ago
Regression in https://github.com/rust-lang-ci/rust/commit/069f6d7553b3ae77ee3af528020da952b05802ad
The PR introducing the regression in this rollup is #123491: Fix ICE in eval_body_using_ecx
searched nightlies: from nightly-2023-01-01 to nightly-2024-05-30 regressed nightly: nightly-2024-04-17 searched commit range: https://github.com/rust-lang/rust/compare/ccfcd950b333fed046275dd8d54fe736ca498aa7...1cec373f65eb76e8e4b4d1847213cf3ec6c292b6 regressed commit: https://github.com/rust-lang/rust/commit/1dea922ea6e74f99a0e97de5cdb8174e4dea0444
Code
(hand-reduced)
(original)
```Rust //! This test demonstrates a bug where we accidentally //! detected opaque types in struct fields, but only if nested //! in projections of another opaque type. #![feature(impl_trait_in_assoc_type)] struct Bar; trait Trait: Sized { type Assoc2; type Assoc; fn foo() -> Self::Assoc; } impl Trait for Bar { type Assoc2 = impl std::fmt::Debug; type Assoc = impl Iterator- ;
fn foo() -> Self::Assoc {
vec![Foo { field: () }].into_iter()
//~^ ERROR mismatched types
}
}
struct Foo {
field:
::Assoc2,
}
fn main() {}
//@ check-pass
enum Foo {
A = 5,
B = 42,
}
enum Bar {
C = 42,
D = 99,
}
#[repr(C)]
union Union {
foo: &'static Foo,
bar: &'static Bar,
u8: &'static u8,
}
static BAR: u8 = 42;
static FOO: (&Foo, &Bar) = unsafe {(
Union { u8: &BAR }.foo,
Union { u8: &BAR }.bar,
)};
static FOO2: (&Foo, &::Assoc2) = unsafe {(std::mem::transmute(&BAR), std::mem::transmute(&BAR))};
fn main() {}
```
Meta
rustc --version --verbose
:Error output
Command:
rustc
Backtrace
``` error: internal compiler error: compiler/rustc_middle/src/ty/layout.rs:382:26: SizeSkeleton::compute(&Foo): layout errored (Unknown(Alias(Projection, AliasTy { args: [Foo], def_id: DefId(2:2141 ~ core[cbba]::ptr::metadata::Pointee::Metadata) }))), yet tail `::Assoc2` is not a type parameter or a projection
thread 'rustc' panicked at compiler/rustc_middle/src/ty/layout.rs:382:26:
Box
stack backtrace:
0: std::panicking::begin_panic::
1: ::emit_producing_guarantee
2: rustc_middle::util::bug::opt_span_bug_fmt::::{closure#0}
3: rustc_middle::ty::context::tls::with_opt::::{closure#0}, !>::{closure#0}
4: rustc_middle::ty::context::tls::with_context_opt::::{closure#0}, !>::{closure#0}, !>
5: rustc_middle::util::bug::bug_fmt
6: ::compute
7: ::check_transmutes
8: rustc_hir_typeck::typeck
[... omitted 1 frame ...]
9: rustc_hir_analysis::check::check::check_item_type
10: rustc_hir_analysis::check::wfcheck::check_well_formed
[... omitted 1 frame ...]
11: rustc_middle::query::plumbing::query_ensure_error_guaranteed::>, ()>
12: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
[... omitted 1 frame ...]
13: rustc_hir_analysis::check_crate
14: rustc_interface::passes::run_required_analyses
15: rustc_interface::passes::analysis
[... omitted 1 frame ...]
16: >::enter::, rustc_driver_impl::run_compiler::{closure#0}::{closure#1}::{closure#3}>
17: rustc_interface::interface::run_compiler::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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 `/Volumes/T7/workspace/240529_100chaos_tree_combine_typ/icefiles/rustc-ice-2024-05-30T06_54_29-96455.txt` to your bug report
query stack during panic:
#0 [typeck] type-checking `FOO2`
#1 [check_well_formed] checking that `FOO2` is well-formed
#2 [check_mod_type_wf] checking that types are well-formed in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors
```
Note
compiler/rustc_middle/src/ty/layout.rs L382-L385
https://github.com/rust-lang/rust/blob/debd22da66cfa97c74040ebf68e420672ac8560e/compiler/rustc_middle/src/ty/layout.rs#L373-L385124031 (Fixed)
109078 (Fixed)