Closed wesleywiser closed 2 years ago
I believe the issue is that after inlining, test
is optimized to
fn test() -> () {
let mut _0: (); // return place in scope 0 at src/test/ui/issues/issue-74614.rs:4:14: 4:14
scope 1 (inlined std::mem::size_of::<T>) { // at src/test/ui/issues/issue-74614.rs:5:5: 5:29
}
bb0: {
_0 = const (); // scope 0 at src/test/ui/issues/issue-74614.rs:4:14: 6:2
return; // scope 0 at src/test/ui/issues/issue-74614.rs:6:2: 6:2
}
}
at which point, its T
type parameter is unused but we only call Instance::polymorphize
from codegen and not const eval. So the Instance
of test
during const eval is not polymorphized and so we trigger the assert in ensure_monomorphic_enough
.
@davidtwco does that sound right to you?
@davidtwco does that sound right to you?
I couldn't say for sure without digging into it myself but that sounds likely.
This compiles fine on nightly now: https://godbolt.org/z/8nEasbrPT.
We should just add a regression test and then we can close this.
This still fails for me locally with current master (d2c24aabcdd):
thread 'rustc' panicked at 'assertion failed: matches!(ty.kind(), ty :: Param(_))', compiler/rustc_const_eval/src/interpret/util.rs:55:37
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
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: rustc 1.58.0-dev running on aarch64-apple-darwin
note: compiler flags: -Z threads=1 -Z ui-testing -Z deduplicate-diagnostics=no -Z emit-future-incompat-report -Z polymorphize=on -Z mir-opt-level=3 -C codegen-units=1 -C prefer-dynamic -C rpath -C debuginfo=0
query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `foo::promoted[0]`
#1 [eval_to_const_value_raw] simplifying constant for the type system `foo::promoted[0]`
end of query stack
Not sure why it compiles on Godbolt.
Edit: Passes with yesterday's nightly but fails with locally compiled stage 1, will investigate.
The failed assertion is in line 55 here: https://github.com/rust-lang/rust/blob/6f53ddfa74ac3c10ceb63ad4a7a9c95e55853c87/compiler/rustc_const_eval/src/interpret/util.rs#L53-L61
Wrapped in if cfg!(debug_assertions)
it will not be checked with the prod compiler.
So this unfortunately not fixed and needs more than just a testcase.
@rustbot label -E-needs-test
fails with
backtrace
``` stack backtrace: 0: rust_begin_unwind at ./library/std/src/panicking.rs:493:5 1: core::panicking::panic_fmt at ./library/core/src/panicking.rs:92:14 2: core::panicking::panic at ./library/core/src/panicking.rs:50:5 3: