Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE cannot relate region: LUB(ReErased, ReEarlyBound(0, 'm)) #102649

Closed
lulf opened this issue Oct 4, 2022 · 2 comments · Fixed by #103008
Closed

ICE cannot relate region: LUB(ReErased, ReEarlyBound(0, 'm)) #102649

lulf opened this issue Oct 4, 2022 · 2 comments · Fixed by #103008
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@lulf
Copy link

lulf commented Oct 4, 2022

Code

#![feature(type_alias_impl_trait)]
use core::future::Future;

pub trait Ctx {}

pub trait MyTrait {
    type AssocT<'m, C>: Future<Output = ()> + 'm where Self: 'm, C: Ctx + 'm;
    fn run<'d, C: Ctx + 'd>(&mut self, c: C) -> Self::AssocT<'_, C>;
}


pub struct MyType;

impl MyTrait for MyType {
    type AssocT<'m, C> = impl Future<Output = ()> + 'm where Self: 'm, C: Ctx + 'm;
    fn run<'d, C: Ctx + 'd>(&mut self, c: C) -> Self::AssocT<'_, C> {
        async move {}
    }
}

fn main() {
    let t = MyType;
}

This code compiled previously before 14th or 15th of September. Changing the trait and impl signature to the following resolves the issue:

fn run<'d, C: Ctx + 'd>(&'d mut self, c: C) -> Self::AssocT<'d, C> {}

Meta

rustc --version --verbose:

vimrustc 1.66.0-nightly (f83e0266c 2022-10-03)
binary: rustc
commit-hash: f83e0266cf7aaa4b41505c49a5fd9c2363166522
commit-date: 2022-10-03
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.2

Error output

$ rustc --edition 2021 reproducer.rs
error: internal compiler error: compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs:536:17: cannot relate region: LUB(ReErased, ReEarlyBound(0, 'm))

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/f83e0266cf7aaa4b41505c49a5fd9c2363166522/compiler/rustc_errors/src/lib.rs:1502:9
stack backtrace:
   0:     0x7f475c16e2c0 - std::backtrace_rs::backtrace::libunwind::trace::h8bef98145e8b4a7a
                               at /rustc/f83e0266cf7aaa4b41505c49a5fd9c2363166522/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7f475c16e2c0 - std::backtrace_rs::backtrace::trace_unsynchronized::h884a114ee7151f03
                               at /rustc/f83e0266cf7aaa4b41505c49a5fd9c2363166522/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f475c16e2c0 - std::sys_common::backtrace::_print_fmt::h33549345de6dd0db
                               at /rustc/f83e0266cf7aaa4b41505c49a5fd9c2363166522/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f475c16e2c0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h6e8e2f017d79e892
                               at /rustc/f83e0266cf7aaa4b41505c49a5fd9c2363166522/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f475c1c908e - core::fmt::write::hb1df21bd773a5653
                               at /rustc/f83e0266cf7aaa4b41505c49a5fd9c2363166522/library/core/src/fmt/mod.rs:1209:17
   5:     0x7f475c15ef45 - std::io::Write::write_fmt::hf7ace98ee4d4a789
                               at /rustc/f83e0266cf7aaa4b41505c49a5fd9c2363166522/library/std/src/io/mod.rs:1679:15
   6:     0x7f475c171063 - std::sys_common::backtrace::_print::hda272844eda63bd4
                               at /rustc/f83e0266cf7aaa4b41505c49a5fd9c2363166522/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f475c171063 - std::sys_common::backtrace::print::hb489bccc5fe542b8
                               at /rustc/f83e0266cf7aaa4b41505c49a5fd9c2363166522/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f475c171063 - std::panicking::default_hook::{{closure}}::hcc3f0f529811be33
                               at /rustc/f83e0266cf7aaa4b41505c49a5fd9c2363166522/library/std/src/panicking.rs:267:22
   9:     0x7f475c170d3a - std::panicking::default_hook::h4653c51128d6524a
                               at /rustc/f83e0266cf7aaa4b41505c49a5fd9c2363166522/library/std/src/panicking.rs:286:9
  10:     0x7f475ea91361 - <rustc_driver[86460aa2afb1a73]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[6691c7ba772eb8a7]::ops::function::FnOnce<(&core[6691c7ba772eb8a7]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f475c17189b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h8ef52a0480ee1d1a
                               at /rustc/f83e0266cf7aaa4b41505c49a5fd9c2363166522/library/alloc/src/boxed.rs:1952:9
  12:     0x7f475c17189b - std::panicking::rust_panic_with_hook::hb2c5046733952922
                               at /rustc/f83e0266cf7aaa4b41505c49a5fd9c2363166522/library/std/src/panicking.rs:673:13
  13:     0x7f475fab1d81 - std[90f0bfaf7a72c976]::panicking::begin_panic::<rustc_errors[f737c1d71245afc]::ExplicitBug>::{closure#0}
  14:     0x7f475faaf716 - std[90f0bfaf7a72c976]::sys_common::backtrace::__rust_end_short_backtrace::<std[90f0bfaf7a72c976]::panicking::begin_panic<rustc_errors[f737c1d71245afc]::ExplicitBug>::{closure#0}, !>
  15:     0x7f475fa23d26 - std[90f0bfaf7a72c976]::panicking::begin_panic::<rustc_errors[f737c1d71245afc]::ExplicitBug>
  16:     0x7f475fa23d16 - std[90f0bfaf7a72c976]::panic::panic_any::<rustc_errors[f737c1d71245afc]::ExplicitBug>
  17:     0x7f475fa21a4f - <rustc_errors[f737c1d71245afc]::HandlerInner>::bug::<&alloc[9f52e81ebd85d442]::string::String>
  18:     0x7f475fa215d0 - <rustc_errors[f737c1d71245afc]::Handler>::bug::<&alloc[9f52e81ebd85d442]::string::String>
  19:     0x7f475fac5bad - rustc_middle[d18795f51201f2a5]::ty::context::tls::with_context_opt::<rustc_middle[d18795f51201f2a5]::ty::context::tls::with_opt<rustc_middle[d18795f51201f2a5]::util::bug::opt_span_bug_fmt<rustc_span[cea4515b6f862b04]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
  20:     0x7f475fac5d86 - rustc_middle[d18795f51201f2a5]::util::bug::opt_span_bug_fmt::<rustc_span[cea4515b6f862b04]::span_encoding::Span>
  21:     0x7f475d45b7d3 - rustc_middle[d18795f51201f2a5]::util::bug::bug_fmt
  22:     0x7f475d51c017 - <rustc_infer[28caf03e3952e555]::infer::lexical_region_resolve::LexicalResolver>::lub_concrete_regions
  23:     0x7f475d51ac0d - <rustc_infer[28caf03e3952e555]::infer::lexical_region_resolve::LexicalResolver>::bound_is_met
  24:     0x7f475d5183a7 - rustc_infer[28caf03e3952e555]::infer::lexical_region_resolve::resolve
  25:     0x7f475e25b9e9 - <rustc_infer[28caf03e3952e555]::infer::InferCtxt>::resolve_regions_and_report_errors
  26:     0x7f475e24a18a - <rustc_infer[28caf03e3952e555]::infer::InferCtxt>::check_region_obligations_and_report_errors
  27:     0x7f475e2fa501 - <rustc_infer[28caf03e3952e555]::infer::InferCtxtBuilder>::enter::<(), rustc_hir_analysis[7db4355bae85e653]::check::check::check_opaque_meets_bounds::{closure#0}>
  28:     0x7f475e2d883b - rustc_hir_analysis[7db4355bae85e653]::check::check::check_item_type
  29:     0x7f475e2d528e - rustc_hir_analysis[7db4355bae85e653]::check::check::check_mod_item_types
  30:     0x7f475e1a0448 - rustc_query_system[e3917d4c8d9d3254]::query::plumbing::try_execute_query::<rustc_query_impl[65d67f218f2be4ec]::plumbing::QueryCtxt, rustc_query_system[e3917d4c8d9d3254]::query::caches::DefaultCache<rustc_span[cea4515b6f862b04]::def_id::LocalDefId, ()>>
  31:     0x7f475e4ae7e9 - rustc_query_system[e3917d4c8d9d3254]::query::plumbing::get_query::<rustc_query_impl[65d67f218f2be4ec]::queries::check_mod_item_types, rustc_query_impl[65d67f218f2be4ec]::plumbing::QueryCtxt>
  32:     0x7f475e74b9ac - <rustc_middle[d18795f51201f2a5]::hir::map::Map>::for_each_module::<rustc_hir_analysis[7db4355bae85e653]::check_crate::{closure#6}::{closure#0}>
  33:     0x7f475ddfb715 - rustc_hir_analysis[7db4355bae85e653]::check_crate
  34:     0x7f475ddfb3e7 - rustc_interface[cd728dbb42118d1]::passes::analysis
  35:     0x7f475e7f9ee4 - rustc_query_system[e3917d4c8d9d3254]::query::plumbing::try_execute_query::<rustc_query_impl[65d67f218f2be4ec]::plumbing::QueryCtxt, rustc_query_system[e3917d4c8d9d3254]::query::caches::DefaultCache<(), core[6691c7ba772eb8a7]::result::Result<(), rustc_errors[f737c1d71245afc]::ErrorGuaranteed>>>
  36:     0x7f475e7f9c17 - rustc_query_system[e3917d4c8d9d3254]::query::plumbing::get_query::<rustc_query_impl[65d67f218f2be4ec]::queries::analysis, rustc_query_impl[65d67f218f2be4ec]::plumbing::QueryCtxt>
  37:     0x7f475d75d214 - <rustc_interface[cd728dbb42118d1]::passes::QueryContext>::enter::<rustc_driver[86460aa2afb1a73]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[6691c7ba772eb8a7]::result::Result<(), rustc_errors[f737c1d71245afc]::ErrorGuaranteed>>
  38:     0x7f475d757da9 - rustc_interface[cd728dbb42118d1]::interface::create_compiler_and_run::<core[6691c7ba772eb8a7]::result::Result<(), rustc_errors[f737c1d71245afc]::ErrorGuaranteed>, rustc_driver[86460aa2afb1a73]::run_compiler::{closure#1}>
  39:     0x7f475d7566b2 - <scoped_tls[80487f1a6bb2f374]::ScopedKey<rustc_span[cea4515b6f862b04]::SessionGlobals>>::set::<rustc_interface[cd728dbb42118d1]::interface::run_compiler<core[6691c7ba772eb8a7]::result::Result<(), rustc_errors[f737c1d71245afc]::ErrorGuaranteed>, rustc_driver[86460aa2afb1a73]::run_compiler::{closure#1}>::{closure#0}, core[6691c7ba772eb8a7]::result::Result<(), rustc_errors[f737c1d71245afc]::ErrorGuaranteed>>
  40:     0x7f475d75639f - std[90f0bfaf7a72c976]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[cd728dbb42118d1]::util::run_in_thread_pool_with_globals<rustc_interface[cd728dbb42118d1]::interface::run_compiler<core[6691c7ba772eb8a7]::result::Result<(), rustc_errors[f737c1d71245afc]::ErrorGuaranteed>, rustc_driver[86460aa2afb1a73]::run_compiler::{closure#1}>::{closure#0}, core[6691c7ba772eb8a7]::result::Result<(), rustc_errors[f737c1d71245afc]::ErrorGuaranteed>>::{closure#0}, core[6691c7ba772eb8a7]::result::Result<(), rustc_errors[f737c1d71245afc]::ErrorGuaranteed>>
  41:     0x7f475e8a4b80 - <<std[90f0bfaf7a72c976]::thread::Builder>::spawn_unchecked_<rustc_interface[cd728dbb42118d1]::util::run_in_thread_pool_with_globals<rustc_interface[cd728dbb42118d1]::interface::run_compiler<core[6691c7ba772eb8a7]::result::Result<(), rustc_errors[f737c1d71245afc]::ErrorGuaranteed>, rustc_driver[86460aa2afb1a73]::run_compiler::{closure#1}>::{closure#0}, core[6691c7ba772eb8a7]::result::Result<(), rustc_errors[f737c1d71245afc]::ErrorGuaranteed>>::{closure#0}, core[6691c7ba772eb8a7]::result::Result<(), rustc_errors[f737c1d71245afc]::ErrorGuaranteed>>::{closure#1} as core[6691c7ba772eb8a7]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  42:     0x7f475c17b373 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1d1291a36c8a17bd
                               at /rustc/f83e0266cf7aaa4b41505c49a5fd9c2363166522/library/alloc/src/boxed.rs:1938:9
  43:     0x7f475c17b373 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h256ed32ae3e64946
                               at /rustc/f83e0266cf7aaa4b41505c49a5fd9c2363166522/library/alloc/src/boxed.rs:1938:9
  44:     0x7f475c17b373 - std::sys::unix::thread::Thread::new::thread_start::h3822392bfa05e4bf
                               at /rustc/f83e0266cf7aaa4b41505c49a5fd9c2363166522/library/std/src/sys/unix/thread.rs:108:17
  45:     0x7f475be8ce2d - start_thread
  46:     0x7f475bf121b0 - __clone3
  47:                0x0 - <unknown>
Backtrace

error: internal compiler error: compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs:536:17: cannot relate region: LUB(ReErased, ReEarlyBound(0, 'm))

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/f83e0266cf7aaa4b41505c49a5fd9c2363166522/compiler/rustc_errors/src/lib.rs:1502:9
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: std::panic::panic_any::<rustc_errors::ExplicitBug>
   2: <rustc_errors::HandlerInner>::bug::<&alloc::string::String>
   3: <rustc_errors::Handler>::bug::<&alloc::string::String>
   4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
   5: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>
   6: rustc_middle::util::bug::bug_fmt
   7: <rustc_infer::infer::lexical_region_resolve::LexicalResolver>::lub_concrete_regions
   8: <rustc_infer::infer::lexical_region_resolve::LexicalResolver>::bound_is_met
   9: rustc_infer::infer::lexical_region_resolve::resolve
  10: <rustc_infer::infer::InferCtxt>::resolve_regions_and_report_errors
  11: <rustc_infer::infer::InferCtxt>::check_region_obligations_and_report_errors
  12: <rustc_infer::infer::InferCtxtBuilder>::enter::<(), rustc_hir_analysis::check::check::check_opaque_meets_bounds::{closure#0}>
  13: rustc_hir_analysis::check::check::check_item_type
  14: rustc_hir_analysis::check::check::check_mod_item_types
  15: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, ()>>
  16: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::check_mod_item_types, rustc_query_impl::plumbing::QueryCtxt>
  17: <rustc_middle::hir::map::Map>::for_each_module::<rustc_hir_analysis::check_crate::{closure#6}::{closure#0}>
  18: rustc_hir_analysis::check_crate
  19: rustc_interface::passes::analysis
  20: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), core::result::Result<(), rustc_errors::ErrorGuaranteed>>>
  21: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  22: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  23: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>
  24: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


@lulf lulf added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 4, 2022
@lulf lulf changed the title ICE when using wrong lifetimes for assoc type ICE cannot relate region: LUB(ReErased, ReEarlyBound(0, 'm)) Oct 4, 2022
@Noratrieb
Copy link
Member

Might have something to do with #102510

@Noratrieb
Copy link
Member

searched nightlies: from nightly-2022-01-01 to nightly-2022-10-04
regressed nightly: nightly-2022-09-11
searched commit range: 1d37ed6...2287107
regressed commit: 2287107

bisected with cargo-bisect-rustc v0.6.4

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --access github --timeout 30 --start 2022-01-01 --regress ice 

Yes, bisection points to the same commit

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 13, 2022
…li-obk

replace ReErased with fresh region vars in opaque types

See inline comments.

Prior art rust-lang#102943. cc `@compiler-errors` `@oli-obk`

Fixes rust-lang#100267
Fixes rust-lang#101940
Fixes rust-lang#102649
Fixes rust-lang#102510
@bors bors closed this as completed in 059bbf7 Oct 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
2 participants