rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.33k stars 12.59k forks source link

ICE: internal compiler error: error: the type `T` has an unknown layout #125810

Open matthiaskrgr opened 4 months ago

matthiaskrgr commented 4 months ago

snippet:

#![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

Program output

``` warning: trait `Trait` is never used --> /tmp/icemaker_global_tempdir.LMPz7J6APUgI/rustc_testrunner_tmpdir_reporting.JILMpr3PO0Dq/mvce.rs:5:7 | 5 | trait Trait + DispatchFromDyn> { | ^^^^^ | = 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; | ^^^^^^^^ 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; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | 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; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | 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; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: internal compiler error: receiver when `Self = (dyn Trait + '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; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | 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; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 ```

@rustbot label +F-arbitrary_self_types +F-dispatch_from_dyn

GrigorenkoPV commented 3 months ago

~Regression in nightly-2021-09-02 (29ef6cf1637aa8317f8911f93f14e18d404c1b0e...50171c310cd15e1b2d3723766ce64e2e4d6696fc)~ Sorry, misinformation.

In actuality, it started to ICE ever since nightly-2018-11-04, before that there was no DispatchFromDyn in std::ops