Skip to content

ICE: var types encountered in super_relate_tys -Zsave-analysis #100484

Closed

Description

./src/test/ui/traits/alias/self-in-generics.rs

Code

#![feature(trait_alias)]

pub trait SelfInput = Fn(&mut Self);

pub fn f(_f: &dyn SelfInput) {}
//~^ ERROR the trait alias `SelfInput` cannot be made into an object [E0038]

fn main() {}

Meta

rustc --version --verbose:

rustc 1.65.0-nightly (e8dc8bca2 2022-08-13)
binary: rustc
commit-hash: e8dc8bca2118ec1ed5970790614f0b81e9167f10
commit-date: 2022-08-13
host: x86_64-unknown-linux-gnu
release: 1.65.0-nightly
LLVM version: 15.0.0

Error output

rustc ./self-in-generics.rs -Zsave-analysis

<output>
Backtrace

error[E0038]: the trait alias `SelfInput` cannot be made into an object
 --> ./self-in-generics.rs:5:19
  |
5 | pub fn f(_f: &dyn SelfInput) {}
  |                   ^^^^^^^^^
  |
  = note: it cannot use `Self` as a type parameter in a supertrait or `where`-clause

error: internal compiler error: /rustc/e8dc8bca2118ec1ed5970790614f0b81e9167f10/compiler/rustc_middle/src/ty/relate.rs:412:13: var types encountered in super_relate_tys

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/e8dc8bca2118ec1ed5970790614f0b81e9167f10/compiler/rustc_errors/src/lib.rs:1391:9
stack backtrace:
   0:     0x7f17d2a46220 - std::backtrace_rs::backtrace::libunwind::trace::hdfd7439c4ac437b8
                               at /rustc/e8dc8bca2118ec1ed5970790614f0b81e9167f10/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7f17d2a46220 - std::backtrace_rs::backtrace::trace_unsynchronized::h6c473f268a0da94d
                               at /rustc/e8dc8bca2118ec1ed5970790614f0b81e9167f10/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f17d2a46220 - std::sys_common::backtrace::_print_fmt::h6b48bf233902d36b
                               at /rustc/e8dc8bca2118ec1ed5970790614f0b81e9167f10/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f17d2a46220 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9b66d5b5ab6d8b74
                               at /rustc/e8dc8bca2118ec1ed5970790614f0b81e9167f10/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f17d2aa12ee - core::fmt::write::h8d6bde4a67b5a644
                               at /rustc/e8dc8bca2118ec1ed5970790614f0b81e9167f10/library/core/src/fmt/mod.rs:1202:17
   5:     0x7f17d2a36f35 - std::io::Write::write_fmt::ha5ed2fe9bc688052
                               at /rustc/e8dc8bca2118ec1ed5970790614f0b81e9167f10/library/std/src/io/mod.rs:1672:15
   6:     0x7f17d2a48ee3 - std::sys_common::backtrace::_print::hcc6babf718d978b5
                               at /rustc/e8dc8bca2118ec1ed5970790614f0b81e9167f10/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f17d2a48ee3 - std::sys_common::backtrace::print::h66a498b3cfc1608c
                               at /rustc/e8dc8bca2118ec1ed5970790614f0b81e9167f10/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f17d2a48ee3 - std::panicking::default_hook::{{closure}}::h78975c9fdf2e25ac
                               at /rustc/e8dc8bca2118ec1ed5970790614f0b81e9167f10/library/std/src/panicking.rs:295:22
   9:     0x7f17d2a48bcf - std::panicking::default_hook::h3938825ac353f447
                               at /rustc/e8dc8bca2118ec1ed5970790614f0b81e9167f10/library/std/src/panicking.rs:314:9
  10:     0x7f17d5285424 - <rustc_driver[a5410d64bf022668]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[9ef3251603221d4a]::ops::function::FnOnce<(&core[9ef3251603221d4a]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f17d2a4971d - std::panicking::rust_panic_with_hook::h47eb8ecd1bd91d17
                               at /rustc/e8dc8bca2118ec1ed5970790614f0b81e9167f10/library/std/src/panicking.rs:702:17
  12:     0x7f17d6229151 - std[2e6ea336b53db173]::panicking::begin_panic::<rustc_errors[f4cb041045aad9b5]::ExplicitBug>::{closure#0}
  13:     0x7f17d6228956 - std[2e6ea336b53db173]::sys_common::backtrace::__rust_end_short_backtrace::<std[2e6ea336b53db173]::panicking::begin_panic<rustc_errors[f4cb041045aad9b5]::ExplicitBug>::{closure#0}, !>
  14:     0x7f17d6209616 - std[2e6ea336b53db173]::panicking::begin_panic::<rustc_errors[f4cb041045aad9b5]::ExplicitBug>
  15:     0x7f17d624df36 - std[2e6ea336b53db173]::panic::panic_any::<rustc_errors[f4cb041045aad9b5]::ExplicitBug>
  16:     0x7f17d624dd8d - <rustc_errors[f4cb041045aad9b5]::HandlerInner>::bug::<&alloc[a4b47a688312783c]::string::String>
  17:     0x7f17d624dae0 - <rustc_errors[f4cb041045aad9b5]::Handler>::bug::<&alloc[a4b47a688312783c]::string::String>
  18:     0x7f17d62761ad - rustc_middle[9190505212f11309]::ty::context::tls::with_context_opt::<rustc_middle[9190505212f11309]::ty::context::tls::with_opt<rustc_middle[9190505212f11309]::util::bug::opt_span_bug_fmt<rustc_span[812c5506f6a7d0a0]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
  19:     0x7f17d6278016 - rustc_middle[9190505212f11309]::util::bug::opt_span_bug_fmt::<rustc_span[812c5506f6a7d0a0]::span_encoding::Span>
  20:     0x7f17d3c24e03 - rustc_middle[9190505212f11309]::util::bug::bug_fmt
  21:     0x7f17d3c7059e - rustc_middle[9190505212f11309]::ty::relate::super_relate_tys::<rustc_infer[81b9f5767b02f5f7]::infer::combine::Generalizer>
  22:     0x7f17d3c72a8d - <rustc_infer[81b9f5767b02f5f7]::infer::combine::Generalizer as rustc_middle[9190505212f11309]::ty::relate::TypeRelation>::tys
  23:     0x7f17d3c6ca65 - rustc_middle[9190505212f11309]::ty::relate::super_relate_tys::<rustc_infer[81b9f5767b02f5f7]::infer::combine::Generalizer>
  24:     0x7f17d3c72a8d - <rustc_infer[81b9f5767b02f5f7]::infer::combine::Generalizer as rustc_middle[9190505212f11309]::ty::relate::TypeRelation>::tys
  25:     0x7f17d3c6cc59 - rustc_middle[9190505212f11309]::ty::relate::super_relate_tys::<rustc_infer[81b9f5767b02f5f7]::infer::combine::Generalizer>
  26:     0x7f17d3c72a8d - <rustc_infer[81b9f5767b02f5f7]::infer::combine::Generalizer as rustc_middle[9190505212f11309]::ty::relate::TypeRelation>::tys
  27:     0x7f17d43e1ad8 - <core[9ef3251603221d4a]::result::Result<rustc_middle[9190505212f11309]::ty::subst::GenericArg, rustc_middle[9190505212f11309]::ty::error::TypeError> as rustc_type_ir[680b48bf35fe5177]::InternIteratorElement<rustc_middle[9190505212f11309]::ty::subst::GenericArg, &rustc_middle[9190505212f11309]::ty::list::List<rustc_middle[9190505212f11309]::ty::subst::GenericArg>>>::intern_with::<core[9ef3251603221d4a]::iter::adapters::map::Map<core[9ef3251603221d4a]::iter::adapters::zip::Zip<core[9ef3251603221d4a]::iter::adapters::copied::Copied<core[9ef3251603221d4a]::slice::iter::Iter<rustc_middle[9190505212f11309]::ty::subst::GenericArg>>, core[9ef3251603221d4a]::iter::adapters::copied::Copied<core[9ef3251603221d4a]::slice::iter::Iter<rustc_middle[9190505212f11309]::ty::subst::GenericArg>>>, rustc_middle[9190505212f11309]::ty::relate::relate_substs<rustc_infer[81b9f5767b02f5f7]::infer::combine::Generalizer>::{closure#0}>, <rustc_middle[9190505212f11309]::ty::context::TyCtxt>::mk_substs<core[9ef3251603221d4a]::iter::adapters::map::Map<core[9ef3251603221d4a]::iter::adapters::zip::Zip<core[9ef3251603221d4a]::iter::adapters::copied::Copied<core[9ef3251603221d4a]::slice::iter::Iter<rustc_middle[9190505212f11309]::ty::subst::GenericArg>>, core[9ef3251603221d4a]::iter::adapters::copied::Copied<core[9ef3251603221d4a]::slice::iter::Iter<rustc_middle[9190505212f11309]::ty::subst::GenericArg>>>, rustc_middle[9190505212f11309]::ty::relate::relate_substs<rustc_infer[81b9f5767b02f5f7]::infer::combine::Generalizer>::{closure#0}>>::{closure#0}>
  28:     0x7f17d43e1772 - <&rustc_middle[9190505212f11309]::ty::list::List<rustc_middle[9190505212f11309]::ty::subst::GenericArg> as rustc_middle[9190505212f11309]::ty::relate::Relate>::relate::<rustc_infer[81b9f5767b02f5f7]::infer::combine::Generalizer>
  29:     0x7f17d43e1645 - <rustc_middle[9190505212f11309]::ty::sty::ExistentialProjection as rustc_middle[9190505212f11309]::ty::relate::Relate>::relate::<rustc_infer[81b9f5767b02f5f7]::infer::combine::Generalizer>
  30:     0x7f17d45ea115 - <rustc_infer[81b9f5767b02f5f7]::infer::combine::Generalizer as rustc_middle[9190505212f11309]::ty::relate::TypeRelation>::binders::<rustc_middle[9190505212f11309]::ty::sty::ExistentialProjection>
  31:     0x7f17d45e7821 - <&mut <&rustc_middle[9190505212f11309]::ty::list::List<rustc_middle[9190505212f11309]::ty::sty::Binder<rustc_middle[9190505212f11309]::ty::sty::ExistentialPredicate>> as rustc_middle[9190505212f11309]::ty::relate::Relate>::relate<rustc_infer[81b9f5767b02f5f7]::infer::combine::Generalizer>::{closure#2} as core[9ef3251603221d4a]::ops::function::FnOnce<((rustc_middle[9190505212f11309]::ty::sty::Binder<rustc_middle[9190505212f11309]::ty::sty::ExistentialPredicate>, rustc_middle[9190505212f11309]::ty::sty::Binder<rustc_middle[9190505212f11309]::ty::sty::ExistentialPredicate>),)>>::call_once
  32:     0x7f17d45e6459 - <core[9ef3251603221d4a]::result::Result<rustc_middle[9190505212f11309]::ty::sty::Binder<rustc_middle[9190505212f11309]::ty::sty::ExistentialPredicate>, rustc_middle[9190505212f11309]::ty::error::TypeError> as rustc_type_ir[680b48bf35fe5177]::InternIteratorElement<rustc_middle[9190505212f11309]::ty::sty::Binder<rustc_middle[9190505212f11309]::ty::sty::ExistentialPredicate>, &rustc_middle[9190505212f11309]::ty::list::List<rustc_middle[9190505212f11309]::ty::sty::Binder<rustc_middle[9190505212f11309]::ty::sty::ExistentialPredicate>>>>::intern_with::<core[9ef3251603221d4a]::iter::adapters::map::Map<core[9ef3251603221d4a]::iter::adapters::zip::Zip<alloc[a4b47a688312783c]::vec::into_iter::IntoIter<rustc_middle[9190505212f11309]::ty::sty::Binder<rustc_middle[9190505212f11309]::ty::sty::ExistentialPredicate>>, alloc[a4b47a688312783c]::vec::into_iter::IntoIter<rustc_middle[9190505212f11309]::ty::sty::Binder<rustc_middle[9190505212f11309]::ty::sty::ExistentialPredicate>>>, <&rustc_middle[9190505212f11309]::ty::list::List<rustc_middle[9190505212f11309]::ty::sty::Binder<rustc_middle[9190505212f11309]::ty::sty::ExistentialPredicate>> as rustc_middle[9190505212f11309]::ty::relate::Relate>::relate<rustc_infer[81b9f5767b02f5f7]::infer::combine::Generalizer>::{closure#2}>, <rustc_middle[9190505212f11309]::ty::context::TyCtxt>::mk_poly_existential_predicates<core[9ef3251603221d4a]::iter::adapters::map::Map<core[9ef3251603221d4a]::iter::adapters::zip::Zip<alloc[a4b47a688312783c]::vec::into_iter::IntoIter<rustc_middle[9190505212f11309]::ty::sty::Binder<rustc_middle[9190505212f11309]::ty::sty::ExistentialPredicate>>, alloc[a4b47a688312783c]::vec::into_iter::IntoIter<rustc_middle[9190505212f11309]::ty::sty::Binder<rustc_middle[9190505212f11309]::ty::sty::ExistentialPredicate>>>, <&rustc_middle[9190505212f11309]::ty::list::List<rustc_middle[9190505212f11309]::ty::sty::Binder<rustc_middle[9190505212f11309]::ty::sty::ExistentialPredicate>> as rustc_middle[9190505212f11309]::ty::relate::Relate>::relate<rustc_infer[81b9f5767b02f5f7]::infer::combine::Generalizer>::{closure#2}>>::{closure#0}>
  33:     0x7f17d4366178 - <&rustc_middle[9190505212f11309]::ty::list::List<rustc_middle[9190505212f11309]::ty::sty::Binder<rustc_middle[9190505212f11309]::ty::sty::ExistentialPredicate>> as rustc_middle[9190505212f11309]::ty::relate::Relate>::relate::<rustc_infer[81b9f5767b02f5f7]::infer::combine::Generalizer>
  34:     0x7f17d3c6e1fc - rustc_middle[9190505212f11309]::ty::relate::super_relate_tys::<rustc_infer[81b9f5767b02f5f7]::infer::combine::Generalizer>
  35:     0x7f17d3c72a8d - <rustc_infer[81b9f5767b02f5f7]::infer::combine::Generalizer as rustc_middle[9190505212f11309]::ty::relate::TypeRelation>::tys
  36:     0x7f17d3c6ca65 - rustc_middle[9190505212f11309]::ty::relate::super_relate_tys::<rustc_infer[81b9f5767b02f5f7]::infer::combine::Generalizer>
  37:     0x7f17d3c72a8d - <rustc_infer[81b9f5767b02f5f7]::infer::combine::Generalizer as rustc_middle[9190505212f11309]::ty::relate::TypeRelation>::tys
  38:     0x7f17d3beb829 - <rustc_infer[81b9f5767b02f5f7]::infer::equate::Equate as rustc_middle[9190505212f11309]::ty::relate::TypeRelation>::tys
  39:     0x7f17d3f8952e - <rustc_typeck[937edb05eaf6069e]::check::fn_ctxt::FnCtxt>::check_pat
  40:     0x7f17d3f85cbc - rustc_typeck[937edb05eaf6069e]::check::check::check_fn
  41:     0x7f17d3f78c2e - <rustc_infer[81b9f5767b02f5f7]::infer::InferCtxtBuilder>::enter::<&rustc_middle[9190505212f11309]::ty::context::TypeckResults, <rustc_typeck[937edb05eaf6069e]::check::inherited::InheritedBuilder>::enter<rustc_typeck[937edb05eaf6069e]::check::typeck_with_fallback<rustc_typeck[937edb05eaf6069e]::check::typeck::{closure#0}>::{closure#1}, &rustc_middle[9190505212f11309]::ty::context::TypeckResults>::{closure#0}>
  42:     0x7f17d3f76674 - rustc_typeck[937edb05eaf6069e]::check::typeck
  43:     0x7f17d48a1f3f - rustc_query_system[88e27f7cc16d83bb]::query::plumbing::try_execute_query::<rustc_query_impl[b52b8bfa962b42d5]::plumbing::QueryCtxt, rustc_query_system[88e27f7cc16d83bb]::query::caches::DefaultCache<rustc_span[812c5506f6a7d0a0]::def_id::LocalDefId, &rustc_middle[9190505212f11309]::ty::context::TypeckResults>>
  44:     0x7f17d5186dd8 - <rustc_query_impl[b52b8bfa962b42d5]::Queries as rustc_middle[9190505212f11309]::ty::query::QueryEngine>::typeck
  45:     0x7f17d5291593 - <rustc_save_analysis[3877f789714e4297]::dump_visitor::DumpVisitor as rustc_hir[9122b05cfb5f69c7]::intravisit::Visitor>::visit_item
  46:     0x7f17d52896a6 - <rustc_save_analysis[3877f789714e4297]::dump_visitor::DumpVisitor as rustc_hir[9122b05cfb5f69c7]::intravisit::Visitor>::visit_nested_item
  47:     0x7f17d52b33f7 - rustc_hir[9122b05cfb5f69c7]::intravisit::walk_mod::<rustc_save_analysis[3877f789714e4297]::dump_visitor::DumpVisitor>
  48:     0x7f17d528d8ef - <rustc_save_analysis[3877f789714e4297]::dump_visitor::DumpVisitor>::process_crate
  49:     0x7f17d5264628 - <rustc_middle[9190505212f11309]::dep_graph::dep_node::DepKind as rustc_query_system[88e27f7cc16d83bb]::dep_graph::DepKind>::with_deps::<rustc_save_analysis[3877f789714e4297]::process_crate<rustc_save_analysis[3877f789714e4297]::DumpHandler>::{closure#0}, ()>
  50:     0x7f17d4ab5dbb - <rustc_interface[6f1edf494a475c31]::passes::QueryContext>::enter::<rustc_driver[a5410d64bf022668]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[9ef3251603221d4a]::result::Result<(), rustc_errors[f4cb041045aad9b5]::ErrorGuaranteed>>
  51:     0x7f17d4aaff0e - <rustc_interface[6f1edf494a475c31]::interface::Compiler>::enter::<rustc_driver[a5410d64bf022668]::run_compiler::{closure#1}::{closure#2}, core[9ef3251603221d4a]::result::Result<core[9ef3251603221d4a]::option::Option<rustc_interface[6f1edf494a475c31]::queries::Linker>, rustc_errors[f4cb041045aad9b5]::ErrorGuaranteed>>
  52:     0x7f17d4aab9fc - rustc_span[812c5506f6a7d0a0]::with_source_map::<core[9ef3251603221d4a]::result::Result<(), rustc_errors[f4cb041045aad9b5]::ErrorGuaranteed>, rustc_interface[6f1edf494a475c31]::interface::create_compiler_and_run<core[9ef3251603221d4a]::result::Result<(), rustc_errors[f4cb041045aad9b5]::ErrorGuaranteed>, rustc_driver[a5410d64bf022668]::run_compiler::{closure#1}>::{closure#1}>
  53:     0x7f17d4aab3e2 - rustc_interface[6f1edf494a475c31]::interface::create_compiler_and_run::<core[9ef3251603221d4a]::result::Result<(), rustc_errors[f4cb041045aad9b5]::ErrorGuaranteed>, rustc_driver[a5410d64bf022668]::run_compiler::{closure#1}>
  54:     0x7f17d4aa9f81 - <scoped_tls[beaf390a5842bbf2]::ScopedKey<rustc_span[812c5506f6a7d0a0]::SessionGlobals>>::set::<rustc_interface[6f1edf494a475c31]::interface::run_compiler<core[9ef3251603221d4a]::result::Result<(), rustc_errors[f4cb041045aad9b5]::ErrorGuaranteed>, rustc_driver[a5410d64bf022668]::run_compiler::{closure#1}>::{closure#0}, core[9ef3251603221d4a]::result::Result<(), rustc_errors[f4cb041045aad9b5]::ErrorGuaranteed>>
  55:     0x7f17d4aa9c6f - std[2e6ea336b53db173]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[6f1edf494a475c31]::util::run_in_thread_pool_with_globals<rustc_interface[6f1edf494a475c31]::interface::run_compiler<core[9ef3251603221d4a]::result::Result<(), rustc_errors[f4cb041045aad9b5]::ErrorGuaranteed>, rustc_driver[a5410d64bf022668]::run_compiler::{closure#1}>::{closure#0}, core[9ef3251603221d4a]::result::Result<(), rustc_errors[f4cb041045aad9b5]::ErrorGuaranteed>>::{closure#0}, core[9ef3251603221d4a]::result::Result<(), rustc_errors[f4cb041045aad9b5]::ErrorGuaranteed>>
  56:     0x7f17d50af689 - <<std[2e6ea336b53db173]::thread::Builder>::spawn_unchecked_<rustc_interface[6f1edf494a475c31]::util::run_in_thread_pool_with_globals<rustc_interface[6f1edf494a475c31]::interface::run_compiler<core[9ef3251603221d4a]::result::Result<(), rustc_errors[f4cb041045aad9b5]::ErrorGuaranteed>, rustc_driver[a5410d64bf022668]::run_compiler::{closure#1}>::{closure#0}, core[9ef3251603221d4a]::result::Result<(), rustc_errors[f4cb041045aad9b5]::ErrorGuaranteed>>::{closure#0}, core[9ef3251603221d4a]::result::Result<(), rustc_errors[f4cb041045aad9b5]::ErrorGuaranteed>>::{closure#1} as core[9ef3251603221d4a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  57:     0x7f17d2a53513 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha625c10cb002aafd
                               at /rustc/e8dc8bca2118ec1ed5970790614f0b81e9167f10/library/alloc/src/boxed.rs:1935:9
  58:     0x7f17d2a53513 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he99a54320e05f7cf
                               at /rustc/e8dc8bca2118ec1ed5970790614f0b81e9167f10/library/alloc/src/boxed.rs:1935:9
  59:     0x7f17d2a53513 - std::sys::unix::thread::Thread::new::thread_start::he2b2cf9ce0aef6b5
                               at /rustc/e8dc8bca2118ec1ed5970790614f0b81e9167f10/library/std/src/sys/unix/thread.rs:108:17
  60:     0x7f17d27b378d - <unknown>
  61:     0x7f17d28348e4 - clone
  62:                0x0 - <unknown>

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.65.0-nightly (e8dc8bca2 2022-08-13) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z save-analysis

query stack during panic:
#0 [typeck] type-checking `f`
end of query stack
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0038`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions