Skip to content

ICE: bound types encountered in super_relate_tys #110557

Closed

Description

@matthiaskrgr

Code

#![feature(non_lifetime_binders)]
#![crate_type = "lib"]

pub trait Lifetime<'a> {}

struct Foo2<Drop>
where
    for<'a> L: Lifetime<'a>,
{
    l: L,
}

impl<T: > Drop for Foo2<T>
where
    for<T: > T: Lifetime<'x>,
{
    fn drop(&mut self) {}
}

Meta

rustc --version --verbose:

rustc 1.71.0-nightly (c609da59d 2023-04-18)
binary: rustc
commit-hash: c609da59d9fc05b1c7dc879d79700ccd8140b5fc
commit-date: 2023-04-18
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.2

Error output

error[E0261]: use of undeclared lifetime name `'x`
  --> treereduce.out:15:26
   |
15 |     for<T: > T: Lifetime<'x>,
   |                          ^^ undeclared lifetime
   |
   = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
help: consider making the bound lifetime-generic with a new `'x` lifetime
   |
15 |     for<T: > T: for<'x> Lifetime<'x>,
   |                 +++++++
help: consider making the bound lifetime-generic with a new `'x` lifetime
   |
15 |     for<'x, T: > T: Lifetime<'x>,
   |         +++
help: consider introducing lifetime `'x` here
   |
13 | impl<'x, T: > Drop for Foo2<T>
   |      +++

error[E0412]: cannot find type `L` in this scope
 --> treereduce.out:8:13
  |
8 |     for<'a> L: Lifetime<'a>,
  |             ^ not found in this scope
  |
help: you might be missing a type parameter
  |
6 | struct Foo2<Drop, L>
  |                 +++

error[E0412]: cannot find type `L` in this scope
  --> treereduce.out:10:8
   |
10 |     l: L,
   |        ^ not found in this scope
   |
help: you might be missing a type parameter
   |
6  | struct Foo2<Drop, L>
   |                 +++

warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
 --> treereduce.out:1:12
  |
1 | #![feature(non_lifetime_binders)]
  |            ^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
  = note: `#[warn(incomplete_features)]` on by default
Backtrace

error: internal compiler error: /rustc/c609da59d9fc05b1c7dc879d79700ccd8140b5fc/compiler/rustc_middle/src/ty/relate.rs:408:13: bound types encountered in super_relate_tys

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/c609da59d9fc05b1c7dc879d79700ccd8140b5fc/compiler/rustc_errors/src/lib.rs:1643:9
stack backtrace:
   0:     0x7ff3e75653c2 - std::backtrace_rs::backtrace::libunwind::trace::h4acdb82da48c9833
                               at /rustc/c609da59d9fc05b1c7dc879d79700ccd8140b5fc/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7ff3e75653c2 - std::backtrace_rs::backtrace::trace_unsynchronized::hf2cc6a3a410a5594
                               at /rustc/c609da59d9fc05b1c7dc879d79700ccd8140b5fc/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7ff3e75653c2 - std::sys_common::backtrace::_print_fmt::hbbc6914b749d0ada
                               at /rustc/c609da59d9fc05b1c7dc879d79700ccd8140b5fc/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7ff3e75653c2 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3d5a35293018c1e6
                               at /rustc/c609da59d9fc05b1c7dc879d79700ccd8140b5fc/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7ff3e75c95df - core::fmt::write::hcd8095c096d51cb1
                               at /rustc/c609da59d9fc05b1c7dc879d79700ccd8140b5fc/library/core/src/fmt/mod.rs:1254:17
   5:     0x7ff3e7558401 - std::io::Write::write_fmt::hfb074efb44accf99
                               at /rustc/c609da59d9fc05b1c7dc879d79700ccd8140b5fc/library/std/src/io/mod.rs:1698:15
   6:     0x7ff3e75651c5 - std::sys_common::backtrace::_print::hf3de088e34eea71b
                               at /rustc/c609da59d9fc05b1c7dc879d79700ccd8140b5fc/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7ff3e75651c5 - std::sys_common::backtrace::print::h8c1956d8c9acf6e3
                               at /rustc/c609da59d9fc05b1c7dc879d79700ccd8140b5fc/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7ff3e7567e87 - std::panicking::default_hook::{{closure}}::h0f8c867eadb4985a
   9:     0x7ff3e7567c75 - std::panicking::default_hook::h749ec9b15ecb3c39
                               at /rustc/c609da59d9fc05b1c7dc879d79700ccd8140b5fc/library/std/src/panicking.rs:288:9
  10:     0x7ff3ea830cf5 - rustc_driver_impl[7fdb2e8792375136]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7ff3e75685c5 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::ha6bcd52ce2118341
                               at /rustc/c609da59d9fc05b1c7dc879d79700ccd8140b5fc/library/alloc/src/boxed.rs:1987:9
  12:     0x7ff3e75685c5 - std::panicking::rust_panic_with_hook::h553363ec26086b73
                               at /rustc/c609da59d9fc05b1c7dc879d79700ccd8140b5fc/library/std/src/panicking.rs:695:13
  13:     0x7ff3ead18461 - std[aef50eda90d64d90]::panicking::begin_panic::<rustc_errors[934a790ce3691480]::ExplicitBug>::{closure#0}
  14:     0x7ff3ead17456 - std[aef50eda90d64d90]::sys_common::backtrace::__rust_end_short_backtrace::<std[aef50eda90d64d90]::panicking::begin_panic<rustc_errors[934a790ce3691480]::ExplicitBug>::{closure#0}, !>
  15:     0x7ff3ead5a9b6 - std[aef50eda90d64d90]::panicking::begin_panic::<rustc_errors[934a790ce3691480]::ExplicitBug>
  16:     0x7ff3ead83c26 - <rustc_errors[934a790ce3691480]::HandlerInner>::bug::<&alloc[3ca5cc4d7c388e]::string::String>
  17:     0x7ff3ead838f0 - <rustc_errors[934a790ce3691480]::Handler>::bug::<&alloc[3ca5cc4d7c388e]::string::String>
  18:     0x7ff3ead4463b - rustc_middle[8054a8be7b277c97]::util::bug::opt_span_bug_fmt::<rustc_span[8c04062e23e0b099]::span_encoding::Span>::{closure#0}
  19:     0x7ff3ead43f1a - rustc_middle[8054a8be7b277c97]::ty::context::tls::with_opt::<rustc_middle[8054a8be7b277c97]::util::bug::opt_span_bug_fmt<rustc_span[8c04062e23e0b099]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  20:     0x7ff3ead43ee6 - rustc_middle[8054a8be7b277c97]::ty::context::tls::with_context_opt::<rustc_middle[8054a8be7b277c97]::ty::context::tls::with_opt<rustc_middle[8054a8be7b277c97]::util::bug::opt_span_bug_fmt<rustc_span[8c04062e23e0b099]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  21:     0x7ff3e89e6a7d - rustc_middle[8054a8be7b277c97]::util::bug::bug_fmt
  22:     0x7ff3ea03040a - rustc_middle[8054a8be7b277c97]::ty::relate::super_relate_tys::<rustc_hir_analysis[42144caad347631]::check::dropck::SimpleEqRelation>
  23:     0x7ff3e9e2f48f - <rustc_middle[8054a8be7b277c97]::ty::subst::GenericArg as rustc_middle[8054a8be7b277c97]::ty::relate::Relate>::relate::<rustc_hir_analysis[42144caad347631]::check::dropck::SimpleEqRelation>
  24:     0x7ff3e9e2f0b0 - <core[7c99772fdcabedb3]::result::Result<rustc_middle[8054a8be7b277c97]::ty::subst::GenericArg, rustc_middle[8054a8be7b277c97]::ty::error::TypeError> as rustc_type_ir[e1ddc2cff5d0a20e]::CollectAndApply<rustc_middle[8054a8be7b277c97]::ty::subst::GenericArg, &rustc_middle[8054a8be7b277c97]::ty::list::List<rustc_middle[8054a8be7b277c97]::ty::subst::GenericArg>>>::collect_and_apply::<core[7c99772fdcabedb3]::iter::adapters::map::Map<core[7c99772fdcabedb3]::iter::adapters::zip::Zip<core[7c99772fdcabedb3]::iter::adapters::copied::Copied<core[7c99772fdcabedb3]::slice::iter::Iter<rustc_middle[8054a8be7b277c97]::ty::subst::GenericArg>>, core[7c99772fdcabedb3]::iter::adapters::copied::Copied<core[7c99772fdcabedb3]::slice::iter::Iter<rustc_middle[8054a8be7b277c97]::ty::subst::GenericArg>>>, rustc_middle[8054a8be7b277c97]::ty::relate::relate_substs<rustc_hir_analysis[42144caad347631]::check::dropck::SimpleEqRelation>::{closure#0}>, <rustc_middle[8054a8be7b277c97]::ty::context::TyCtxt>::mk_substs_from_iter<core[7c99772fdcabedb3]::iter::adapters::map::Map<core[7c99772fdcabedb3]::iter::adapters::zip::Zip<core[7c99772fdcabedb3]::iter::adapters::copied::Copied<core[7c99772fdcabedb3]::slice::iter::Iter<rustc_middle[8054a8be7b277c97]::ty::subst::GenericArg>>, core[7c99772fdcabedb3]::iter::adapters::copied::Copied<core[7c99772fdcabedb3]::slice::iter::Iter<rustc_middle[8054a8be7b277c97]::ty::subst::GenericArg>>>, rustc_middle[8054a8be7b277c97]::ty::relate::relate_substs<rustc_hir_analysis[42144caad347631]::check::dropck::SimpleEqRelation>::{closure#0}>, core[7c99772fdcabedb3]::result::Result<rustc_middle[8054a8be7b277c97]::ty::subst::GenericArg, rustc_middle[8054a8be7b277c97]::ty::error::TypeError>>::{closure#0}>
  25:     0x7ff3e9e2ebd8 - <rustc_middle[8054a8be7b277c97]::ty::sty::TraitRef as rustc_middle[8054a8be7b277c97]::ty::relate::Relate>::relate::<rustc_hir_analysis[42144caad347631]::check::dropck::SimpleEqRelation>
  26:     0x7ff3e9e2e8a7 - <rustc_middle[8054a8be7b277c97]::ty::TraitPredicate as rustc_middle[8054a8be7b277c97]::ty::relate::Relate>::relate::<rustc_hir_analysis[42144caad347631]::check::dropck::SimpleEqRelation>
  27:     0x7ff3e9e2e57d - <core[7c99772fdcabedb3]::iter::adapters::copied::Copied<core[7c99772fdcabedb3]::slice::iter::Iter<rustc_middle[8054a8be7b277c97]::ty::Predicate>> as core[7c99772fdcabedb3]::iter::traits::iterator::Iterator>::try_fold::<(), core[7c99772fdcabedb3]::iter::traits::iterator::Iterator::any::check<rustc_middle[8054a8be7b277c97]::ty::Predicate, rustc_hir_analysis[42144caad347631]::check::dropck::ensure_drop_predicates_are_implied_by_item_defn::{closure#0}>::{closure#0}, core[7c99772fdcabedb3]::ops::control_flow::ControlFlow<()>>
  28:     0x7ff3e9e2d947 - rustc_hir_analysis[42144caad347631]::check::dropck::check_drop_impl
  29:     0x7ff3e9e2d2f7 - <rustc_middle[8054a8be7b277c97]::ty::context::TyCtxt>::calculate_dtor::<rustc_hir_analysis[42144caad347631]::check::dropck::check_drop_impl>::{closure#0}
  30:     0x7ff3e9e2ce21 - <rustc_middle[8054a8be7b277c97]::ty::context::TyCtxt>::calculate_dtor::<rustc_hir_analysis[42144caad347631]::check::dropck::check_drop_impl>
  31:     0x7ff3e9e2cb5b - rustc_hir_analysis[42144caad347631]::check::adt_destructor
  32:     0x7ff3e9cf5c1f - rustc_query_system[354c60129646c01e]::query::plumbing::try_execute_query::<rustc_query_impl[4ebfc2cbb59026c7]::queries::adt_destructor, rustc_query_impl[4ebfc2cbb59026c7]::plumbing::QueryCtxt>
  33:     0x7ff3e9cf5618 - <rustc_query_impl[4ebfc2cbb59026c7]::Queries as rustc_middle[8054a8be7b277c97]::ty::query::QueryEngine>::adt_destructor
  34:     0x7ff3e934594a - <rustc_middle[8054a8be7b277c97]::ty::adt::AdtDef>::destructor
  35:     0x7ff3e933e8f2 - rustc_hir_analysis[42144caad347631]::check::check::check_mod_item_types
  36:     0x7ff3e9e6fea1 - rustc_query_system[354c60129646c01e]::query::plumbing::try_execute_query::<rustc_query_impl[4ebfc2cbb59026c7]::queries::check_mod_item_types, rustc_query_impl[4ebfc2cbb59026c7]::plumbing::QueryCtxt>
  37:     0x7ff3e9e6fac9 - <rustc_query_impl[4ebfc2cbb59026c7]::Queries as rustc_middle[8054a8be7b277c97]::ty::query::QueryEngine>::check_mod_item_types
  38:     0x7ff3e9c0fbac - <rustc_middle[8054a8be7b277c97]::hir::map::Map>::for_each_module::<rustc_hir_analysis[42144caad347631]::check_crate::{closure#6}::{closure#0}>
  39:     0x7ff3e9c0bfab - rustc_hir_analysis[42144caad347631]::check_crate
  40:     0x7ff3e9c05e3d - rustc_interface[7925d28b3b6d3805]::passes::analysis
  41:     0x7ff3e9fa3712 - rustc_query_system[354c60129646c01e]::query::plumbing::try_execute_query::<rustc_query_impl[4ebfc2cbb59026c7]::queries::analysis, rustc_query_impl[4ebfc2cbb59026c7]::plumbing::QueryCtxt>
  42:     0x7ff3e9fa3420 - <rustc_query_impl[4ebfc2cbb59026c7]::Queries as rustc_middle[8054a8be7b277c97]::ty::query::QueryEngine>::analysis
  43:     0x7ff3e9e64ca6 - <std[aef50eda90d64d90]::thread::local::LocalKey<core[7c99772fdcabedb3]::cell::Cell<*const ()>>>::with::<rustc_middle[8054a8be7b277c97]::ty::context::tls::enter_context<<rustc_middle[8054a8be7b277c97]::ty::context::GlobalCtxt>::enter<rustc_driver_impl[7fdb2e8792375136]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[7c99772fdcabedb3]::result::Result<(), rustc_span[8c04062e23e0b099]::ErrorGuaranteed>>::{closure#0}, core[7c99772fdcabedb3]::result::Result<(), rustc_span[8c04062e23e0b099]::ErrorGuaranteed>>::{closure#0}, core[7c99772fdcabedb3]::result::Result<(), rustc_span[8c04062e23e0b099]::ErrorGuaranteed>>
  44:     0x7ff3e9a529a7 - <rustc_interface[7925d28b3b6d3805]::interface::Compiler>::enter::<rustc_driver_impl[7fdb2e8792375136]::run_compiler::{closure#1}::{closure#2}, core[7c99772fdcabedb3]::result::Result<core[7c99772fdcabedb3]::option::Option<rustc_interface[7925d28b3b6d3805]::queries::Linker>, rustc_span[8c04062e23e0b099]::ErrorGuaranteed>>
  45:     0x7ff3e9a4ca8f - rustc_span[8c04062e23e0b099]::set_source_map::<core[7c99772fdcabedb3]::result::Result<(), rustc_span[8c04062e23e0b099]::ErrorGuaranteed>, rustc_interface[7925d28b3b6d3805]::interface::run_compiler<core[7c99772fdcabedb3]::result::Result<(), rustc_span[8c04062e23e0b099]::ErrorGuaranteed>, rustc_driver_impl[7fdb2e8792375136]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  46:     0x7ff3e9a4c6a8 - <scoped_tls[6d453f3239404e]::ScopedKey<rustc_span[8c04062e23e0b099]::SessionGlobals>>::set::<rustc_interface[7925d28b3b6d3805]::interface::run_compiler<core[7c99772fdcabedb3]::result::Result<(), rustc_span[8c04062e23e0b099]::ErrorGuaranteed>, rustc_driver_impl[7fdb2e8792375136]::run_compiler::{closure#1}>::{closure#0}, core[7c99772fdcabedb3]::result::Result<(), rustc_span[8c04062e23e0b099]::ErrorGuaranteed>>
  47:     0x7ff3e9a4bcbb - std[aef50eda90d64d90]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[7925d28b3b6d3805]::util::run_in_thread_pool_with_globals<rustc_interface[7925d28b3b6d3805]::interface::run_compiler<core[7c99772fdcabedb3]::result::Result<(), rustc_span[8c04062e23e0b099]::ErrorGuaranteed>, rustc_driver_impl[7fdb2e8792375136]::run_compiler::{closure#1}>::{closure#0}, core[7c99772fdcabedb3]::result::Result<(), rustc_span[8c04062e23e0b099]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7c99772fdcabedb3]::result::Result<(), rustc_span[8c04062e23e0b099]::ErrorGuaranteed>>
  48:     0x7ff3ea101861 - <<std[aef50eda90d64d90]::thread::Builder>::spawn_unchecked_<rustc_interface[7925d28b3b6d3805]::util::run_in_thread_pool_with_globals<rustc_interface[7925d28b3b6d3805]::interface::run_compiler<core[7c99772fdcabedb3]::result::Result<(), rustc_span[8c04062e23e0b099]::ErrorGuaranteed>, rustc_driver_impl[7fdb2e8792375136]::run_compiler::{closure#1}>::{closure#0}, core[7c99772fdcabedb3]::result::Result<(), rustc_span[8c04062e23e0b099]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7c99772fdcabedb3]::result::Result<(), rustc_span[8c04062e23e0b099]::ErrorGuaranteed>>::{closure#1} as core[7c99772fdcabedb3]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  49:     0x7ff3e7572a85 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he0dee4d73e6ebe6e
                               at /rustc/c609da59d9fc05b1c7dc879d79700ccd8140b5fc/library/alloc/src/boxed.rs:1973:9
  50:     0x7ff3e7572a85 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hdfd4a296008e148d
                               at /rustc/c609da59d9fc05b1c7dc879d79700ccd8140b5fc/library/alloc/src/boxed.rs:1973:9
  51:     0x7ff3e7572a85 - std::sys::unix::thread::Thread::new::thread_start::h8f06ac6e30e47e34
                               at /rustc/c609da59d9fc05b1c7dc879d79700ccd8140b5fc/library/std/src/sys/unix/thread.rs:108:17
  52:     0x7ff3e730dbb5 - <unknown>
  53:     0x7ff3e738fd90 - <unknown>
  54:                0x0 - <unknown>

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.71.0-nightly (c609da59d 2023-04-18) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [adt_destructor] computing `Drop` impl for `Foo2`
#1 [check_mod_item_types] checking item types in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors; 1 warning emitted

Some errors have detailed explanations: E0261, E0412.
For more information about an error, try `rustc --explain E0261`.

Activity

  1. added
    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.
    C-bugCategory: This is a bug.
    on Apr 19, 2023
  2. added 2 commits that reference this issue on May 6, 2023
    5c4529b
    bcc9aa0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-non_lifetime_binders`#![feature(non_lifetime_binders)]`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