Repository: rust
Issue: ICE: internal compiler error: error: the type `T` has an unknown layout
Labels: I-ICE,T-compiler,C-bug,F-arbitrary_self_types,F-dispatch_from_dyn,A-layout,S-has-mcve,S-bug-has-test

<!--
[31mICE[0m: Rustc ./262A9BA0DF4B165BBD8CDCFC430912B842BDC3426FDC3EAB4CAF199F52751966.rs '' 'error: internal compiler error: receiver when `Self = (dyn Trait<T> + 'static)` should have a ScalarPair ABI; found None', 'error: internal compiler error: receiver when `Self = (dyn Trait<T> + 'static)` should have a ScalarPair ABI; found None'
File: /tmp/im/262A9BA0DF4B165BBD8CDCFC430912B842BDC3426FDC3EAB4CAF199F52751966.rs
-->

snippet:
````rust
#![feature(arbitrary_self_types, dispatch_from_dyn)]

use std::ops::{Deref, DispatchFromDyn};

trait Trait<T: Deref<Target = Self> + DispatchFromDyn<T>> {
    fn MONO_BUF(self: T) -> dyn Trait<T>;
}

fn main() {}


````

Version information
````
rustc 1.80.0-nightly (366da30d5 2024-05-31)
binary: rustc
commit-hash: 366da30d554719e7490950aeea5d3f3a5927e313
commit-date: 2024-05-31
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.6

````

Command:
`/home/matthias/.rustup/toolchains/master/bin/rustc `

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary><strong>Program output</strong></summary>
<p>

```
warning: trait `Trait` is never used
 --> /tmp/icemaker_global_tempdir.LMPz7J6APUgI/rustc_testrunner_tmpdir_reporting.JILMpr3PO0Dq/mvce.rs:5:7
  |
5 | trait Trait<T: Deref<Target = Self> + DispatchFromDyn<T>> {
  |       ^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: trait method `MONO_BUF` should have a snake case name
 --> /tmp/icemaker_global_tempdir.LMPz7J6APUgI/rustc_testrunner_tmpdir_reporting.JILMpr3PO0Dq/mvce.rs:6:8
  |
6 |     fn MONO_BUF(self: T) -> dyn Trait<T>;
  |        ^^^^^^^^ help: convert the identifier to snake case: `mono_buf`
  |
  = note: `#[warn(non_snake_case)]` on by default

warning: 2 warnings emitted

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: the type `T` has an unknown layout
                                 while computing layout for type T/#1
 --> /tmp/icemaker_global_tempdir.LMPz7J6APUgI/rustc_testrunner_tmpdir_reporting.JILMpr3PO0Dq/mvce.rs:6:5
  |
6 |     fn MONO_BUF(self: T) -> dyn Trait<T>;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
note: delayed at compiler/rustc_trait_selection/src/traits/object_safety.rs:507:35 - disabled backtrace
 --> /tmp/icemaker_global_tempdir.LMPz7J6APUgI/rustc_testrunner_tmpdir_reporting.JILMpr3PO0Dq/mvce.rs:6:5
  |
6 |     fn MONO_BUF(self: T) -> dyn Trait<T>;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: internal compiler error: receiver when `Self = ()` should have a Scalar ABI; found None
 --> /tmp/icemaker_global_tempdir.LMPz7J6APUgI/rustc_testrunner_tmpdir_reporting.JILMpr3PO0Dq/mvce.rs:6:5
  |
6 |     fn MONO_BUF(self: T) -> dyn Trait<T>;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
note: delayed at compiler/rustc_trait_selection/src/traits/object_safety.rs:523:31 - disabled backtrace
 --> /tmp/icemaker_global_tempdir.LMPz7J6APUgI/rustc_testrunner_tmpdir_reporting.JILMpr3PO0Dq/mvce.rs:6:5
  |
6 |     fn MONO_BUF(self: T) -> dyn Trait<T>;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: internal compiler error: receiver when `Self = (dyn Trait<T> + 'static)` should have a ScalarPair ABI; found None
 --> /tmp/icemaker_global_tempdir.LMPz7J6APUgI/rustc_testrunner_tmpdir_reporting.JILMpr3PO0Dq/mvce.rs:6:5
  |
6 |     fn MONO_BUF(self: T) -> dyn Trait<T>;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
note: delayed at compiler/rustc_trait_selection/src/traits/object_safety.rs:541:31 - disabled backtrace
 --> /tmp/icemaker_global_tempdir.LMPz7J6APUgI/rustc_testrunner_tmpdir_reporting.JILMpr3PO0Dq/mvce.rs:6:5
  |
6 |     fn MONO_BUF(self: T) -> dyn Trait<T>;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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: rustc 1.80.0-nightly (366da30d5 2024-05-31) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack

```

</p>
</details>

<!--
query stack:

-->
@rustbot label +F-arbitrary_self_types +F-dispatch_from_dyn