Skip to content

Incoherent impls are still allowed on opaque types  #86411

Closed
@matthewjasper

Description

@matthewjasper

I tried this code (modified version of #74298):

#![feature(min_type_alias_impl_trait)]

type X<T> = impl Sized;

fn f<T>() -> X<T> {}

trait Y {
    fn g(&self) {}
}

impl Y for (X<()>,) {}
impl Y for (X<i32>,) {}

fn main() {
    (f::<()>(),).g();
}

I expected to see this happen: incoherent impls error

Instead, this happened: ICE during codegen

Meta

rustc --version --verbose:

rustc 1.54.0-nightly (657bc0188 2021-05-31)
binary: rustc
commit-hash: 657bc01888e6297257655585f9c475a0801db6d2
commit-date: 2021-05-31
host: x86_64-unknown-linux-gnu
release: 1.54.0-nightly
LLVM version: 12.0.1
Backtrace


thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1021:13
stack backtrace:
   0:     0x7f8294e6af80 - std::backtrace_rs::backtrace::libunwind::trace::h1a39bd9a98540471
                               at /rustc/657bc01888e6297257655585f9c475a0801db6d2/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7f8294e6af80 - std::backtrace_rs::backtrace::trace_unsynchronized::h21a1eeae7103ab3f
                               at /rustc/657bc01888e6297257655585f9c475a0801db6d2/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f8294e6af80 - std::sys_common::backtrace::_print_fmt::hc9ffbae9ed6a9871
                               at /rustc/657bc01888e6297257655585f9c475a0801db6d2/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f8294e6af80 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h17510753a34a3f09
                               at /rustc/657bc01888e6297257655585f9c475a0801db6d2/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7f8294ed89ac - core::fmt::write::h1e5a1f350e43b10f
                               at /rustc/657bc01888e6297257655585f9c475a0801db6d2/library/core/src/fmt/mod.rs:1110:17
   5:     0x7f8294e5c805 - std::io::Write::write_fmt::h06ec27c6d028baf1
                               at /rustc/657bc01888e6297257655585f9c475a0801db6d2/library/std/src/io/mod.rs:1588:15
   6:     0x7f8294e6eddb - std::sys_common::backtrace::_print::h1a02603349b1dc60
                               at /rustc/657bc01888e6297257655585f9c475a0801db6d2/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7f8294e6eddb - std::sys_common::backtrace::print::h0fc317d31c48cd9b
                               at /rustc/657bc01888e6297257655585f9c475a0801db6d2/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7f8294e6eddb - std::panicking::default_hook::{{closure}}::ha522601c22d7057b
                               at /rustc/657bc01888e6297257655585f9c475a0801db6d2/library/std/src/panicking.rs:208:50
   9:     0x7f8294e6e8b1 - std::panicking::default_hook::hd50ab173af9a3ce8
                               at /rustc/657bc01888e6297257655585f9c475a0801db6d2/library/std/src/panicking.rs:225:9
  10:     0x7f829563f78d - rustc_driver::report_ice::h0bbc0ae77d597594
  11:     0x7f8294e6f5e6 - std::panicking::rust_panic_with_hook::hb5a01416e02405ad
                               at /rustc/657bc01888e6297257655585f9c475a0801db6d2/library/std/src/panicking.rs:626:17
  12:     0x7f8294e6f0c7 - std::panicking::begin_panic_handler::{{closure}}::hf1dda5d5c0706ee0
                               at /rustc/657bc01888e6297257655585f9c475a0801db6d2/library/std/src/panicking.rs:519:13
  13:     0x7f8294e6b45c - std::sys_common::backtrace::__rust_end_short_backtrace::h56c02e9609085b17
                               at /rustc/657bc01888e6297257655585f9c475a0801db6d2/library/std/src/sys_common/backtrace.rs:141:18
  14:     0x7f8294e6f029 - rust_begin_unwind
                               at /rustc/657bc01888e6297257655585f9c475a0801db6d2/library/std/src/panicking.rs:515:5
  15:     0x7f8294e37eeb - std::panicking::begin_panic_fmt::h5889dddec113b3e8
                               at /rustc/657bc01888e6297257655585f9c475a0801db6d2/library/std/src/panicking.rs:457:5
  16:     0x7f8297ac5969 - rustc_errors::HandlerInner::flush_delayed::h71762d6b78304836
  17:     0x7f8297ac441d - <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop::h4ee3903f55419f69
  18:     0x7f8297140d06 - core::ptr::drop_in_place<rustc_session::parse::ParseSess>::hd706f063b3ef96ed
  19:     0x7f829714334e - <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop::h30ee59f057910eb2
  20:     0x7f82971464dd - core::ptr::drop_in_place<rustc_interface::interface::Compiler>::hf2f304d3f5096f94
  21:     0x7f8297145f50 - rustc_span::with_source_map::h6ee13da35fa72295
  22:     0x7f8297148ac8 - scoped_tls::ScopedKey<T>::set::h9c6565b722913393
  23:     0x7f829716d9db - std::sys_common::backtrace::__rust_begin_short_backtrace::hdcf17779193f6d57
  24:     0x7f82971447b5 - core::ops::function::FnOnce::call_once{{vtable.shim}}::hf48084e1b458d4b2
  25:     0x7f8294e7bad7 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf00ff0dfc0b9e39f
                               at /rustc/657bc01888e6297257655585f9c475a0801db6d2/library/alloc/src/boxed.rs:1575:9
  26:     0x7f8294e7bad7 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h236979b1b61b3517
                               at /rustc/657bc01888e6297257655585f9c475a0801db6d2/library/alloc/src/boxed.rs:1575:9
  27:     0x7f8294e7bad7 - std::sys::unix::thread::Thread::new::thread_start::h8f357e546e4775fa
                               at /rustc/657bc01888e6297257655585f9c475a0801db6d2/library/std/src/sys/unix/thread.rs:71:17
  28:     0x7f8294dba609 - start_thread
  29:     0x7f8294cce293 - clone
  30:                0x0 - <unknown>

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.54.0-nightly (657bc0188 2021-05-31) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z verbose -C debuginfo=1 -C linker=/opt/compiler-explorer/gcc-11.1.0/bin/gcc --crate-type bin


Metadata

Metadata

Assignees

Labels

A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessT-typesRelevant to the types team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions