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 when using size_of on associated type projection that may not be Sized #115435

Open
iamanonymouscs opened this issue Sep 1, 2023 · 4 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@iamanonymouscs
Copy link

I tried this code. However it triggers an internal compiler error (ICE).

Code

trait MyTrait {
    type Target: ?Sized;
}

impl<A: ?Sized> MyTrait for A {
    type Target = A;
}

fn main() {
    bug_run::<dyn MyTrait<Target = u8>>();
}

fn bug_run<T: ?Sized>()
where
    <T as MyTrait>::Target: Sized,
{
    bug::<T>();
}

fn bug<T>() {
    std::mem::size_of::<T>();
}

Meta

rustc --version --verbose:


rustc 1.74.0-nightly (2f5df8a94 2023-08-31)
binary: rustc
commit-hash: 2f5df8a94bb3c5fae4e3fcbfc8ef20f1f976cb19
commit-date: 2023-08-31
host: x86_64-unknown-linux-gnu
release: 1.74.0-nightly
LLVM version: 17.0.0

Error output

warning: unused return value of `std::mem::size_of` that must be used
  --> bug_1.rs:21:5
   |
21 |     std::mem::size_of::<T>();
   |     ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_must_use)]` on by default
help: use `let _ = ...` to ignore the resulting value
   |
21 |     let _ = std::mem::size_of::<T>();
   |     +++++++
thread 'rustc' panicked at /rustc/2f5df8a94bb3c5fae4e3fcbfc8ef20f1f976cb19/compiler/rustc_codegen_ssa/src/mir/rvalue.rs:675:25:
assertion failed: bx.cx().type_is_sized(ty)
Backtrace

thread 'rustc' panicked at /rustc/2f5df8a94bb3c5fae4e3fcbfc8ef20f1f976cb19/compiler/rustc_codegen_ssa/src/mir/rvalue.rs:675:25:
assertion failed: bx.cx().type_is_sized(ty)
stack backtrace:
   0: rust_begin_unwind
             at /rustc/2f5df8a94bb3c5fae4e3fcbfc8ef20f1f976cb19/library/std/src/panicking.rs:619:5
   1: core::panicking::panic_fmt
             at /rustc/2f5df8a94bb3c5fae4e3fcbfc8ef20f1f976cb19/library/core/src/panicking.rs:72:14
   2: core::panicking::panic
             at /rustc/2f5df8a94bb3c5fae4e3fcbfc8ef20f1f976cb19/library/core/src/panicking.rs:127:5
   3: <rustc_codegen_ssa::mir::FunctionCx<rustc_codegen_llvm::builder::Builder>>::codegen_rvalue_operand
   4: rustc_codegen_ssa::mir::codegen_mir::<rustc_codegen_llvm::builder::Builder>
   5: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
   6: rustc_codegen_llvm::base::compile_codegen_unit
   7: rustc_codegen_ssa::base::codegen_crate::<rustc_codegen_llvm::LlvmCodegenBackend>
   8: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
   9: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
  10: rustc_interface::passes::start_codegen
  11: <rustc_middle::ty::context::GlobalCtxt>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_span::ErrorGuaranteed>>
  12: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: 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: please attach the file at `/home/coding/rustc-ice-2023-09-01T12:24:17.5235892Z-11165.txt` to your bug report

query stack during panic:
end of query stack
warning: 1 warning emitted

I'm confused because empty query stack😥
@iamanonymouscs iamanonymouscs 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 Sep 1, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 1, 2023
@matthiaskrgr matthiaskrgr added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Sep 1, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Sep 1, 2023
@matthiaskrgr
Copy link
Member

Regression in nightly-2020-11-16

commit[0] 2020-11-14: Auto merge of #78809 - vn-ki:fix-issue-76064, r=oli-obk
commit[1] 2020-11-14: Auto merge of #79049 - tmiasko:lower-intrinsics, r=jonas-schievink
commit[2] 2020-11-15: Auto merge of #79065 - Dylan-DPC:rollup-gag1drk, r=Dylan-DPC
commit[3] 2020-11-15: Auto merge of #78472 - hermitcore:builtins, r=Mark-Simulacrum
commit[4] 2020-11-15: Auto merge of #79070 - jonas-schievink:rollup-wacn2b8, r=jonas-schievink
commit[5] 2020-11-15: Auto merge of #79064 - ehuss:rustbook-logs, r=Mark-Simulacrum

@matthiaskrgr
Copy link
Member

This is a compiles without warning -> ice regression!

@compiler-errors compiler-errors self-assigned this Sep 1, 2023
@compiler-errors
Copy link
Member

This is the same root cause as #57893

@apiraino
Copy link
Contributor

apiraino commented Sep 4, 2023

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Sep 4, 2023
@Noratrieb Noratrieb removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 4, 2023
@compiler-errors compiler-errors removed their assignment Feb 28, 2024
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants