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: escaping bound vars in predicate Obligation in inherited.rs #109281

Closed
langston-barrett opened this issue Mar 17, 2023 · 2 comments · Fixed by #113648
Closed

ICE: escaping bound vars in predicate Obligation in inherited.rs #109281

langston-barrett opened this issue Mar 17, 2023 · 2 comments · Fixed by #113648
Labels
C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@langston-barrett
Copy link
Contributor

langston-barrett commented Mar 17, 2023

Found this while minimizing #109054 😄 So maybe related?

These didn't seem like duplicates.

Code

#![feature(type_alias_impl_trait)]
struct S;
type ReturnType<'a> = impl Eq + 'a;
impl std::ops::Deref for S {
    type Target = dyn Fn(&()) -> ReturnType;
    fn deref() -> &'static Self::Target {}
}

Meta

rustc --version --verbose:

rustc 1.70.0-nightly (511364e78 2023-03-16)
binary: rustc
commit-hash: 511364e7874dba9649a264100407e4bffe7b5425
commit-date: 2023-03-16
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 15.0.7

Error output

Backtrace

error: internal compiler error: compiler/rustc_hir_typeck/src/inherited.rs:105:13: escaping bound vars in predicate Obligation(predicate=Binder(TraitPredicate(<ReturnType<'_> as std::marker::Sized>, polarity:Positive), []), depth=0)
 --> melted.rs:6:19
  |
6 |     fn deref() -> &'static Self::Target {}
  |                   ^^^^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/511364e7874dba9649a264100407e4bffe7b5425/compiler/rustc_errors/src/lib.rs:995:33
stack backtrace:
   0:     0x7f4bd00b250a - std::backtrace_rs::backtrace::libunwind::trace::h245cf0f2a6c541d3
                               at /rustc/511364e7874dba9649a264100407e4bffe7b5425/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f4bd00b250a - std::backtrace_rs::backtrace::trace_unsynchronized::hb9c09f0c27ccd9c2
                               at /rustc/511364e7874dba9649a264100407e4bffe7b5425/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f4bd00b250a - std::sys_common::backtrace::_print_fmt::h80542a6be873a587
                               at /rustc/511364e7874dba9649a264100407e4bffe7b5425/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f4bd00b250a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h173aa0e4922bf51c
                               at /rustc/511364e7874dba9649a264100407e4bffe7b5425/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f4bd0115b3e - core::fmt::write::ha8661072c4235e29
                               at /rustc/511364e7874dba9649a264100407e4bffe7b5425/library/core/src/fmt/mod.rs:1254:17
   5:     0x7f4bd00a5375 - std::io::Write::write_fmt::hf0bf0ac3e42e8a7e
                               at /rustc/511364e7874dba9649a264100407e4bffe7b5425/library/std/src/io/mod.rs:1684:15
   6:     0x7f4bd00b22d5 - std::sys_common::backtrace::_print::h4af6a629a9994a8b
                               at /rustc/511364e7874dba9649a264100407e4bffe7b5425/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f4bd00b22d5 - std::sys_common::backtrace::print::hdccd3478dffb762f
                               at /rustc/511364e7874dba9649a264100407e4bffe7b5425/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f4bd00b504f - std::panicking::default_hook::{{closure}}::heabec2697510ca4b
                               at /rustc/511364e7874dba9649a264100407e4bffe7b5425/library/std/src/panicking.rs:271:22
   9:     0x7f4bd00b4d8b - std::panicking::default_hook::hf7d16e5638b7d15e
                               at /rustc/511364e7874dba9649a264100407e4bffe7b5425/library/std/src/panicking.rs:290:9
  10:     0x7f4bd339c1c5 - rustc_driver_impl[1234c7df5b953713]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f4bd00b588d - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hfc618573a7a4ac85
                               at /rustc/511364e7874dba9649a264100407e4bffe7b5425/library/alloc/src/boxed.rs:2002:9
  12:     0x7f4bd00b588d - std::panicking::rust_panic_with_hook::hcbf73c2ba2c5f60a
                               at /rustc/511364e7874dba9649a264100407e4bffe7b5425/library/std/src/panicking.rs:696:13
  13:     0x7f4bd35c6321 - std[8d8990c2ba4fc99a]::panicking::begin_panic::<rustc_errors[116146ae72f5b2a5]::ExplicitBug>::{closure#0}
  14:     0x7f4bd35c37e6 - std[8d8990c2ba4fc99a]::sys_common::backtrace::__rust_end_short_backtrace::<std[8d8990c2ba4fc99a]::panicking::begin_panic<rustc_errors[116146ae72f5b2a5]::ExplicitBug>::{closure#0}, !>
  15:     0x7f4bd35f5d66 - std[8d8990c2ba4fc99a]::panicking::begin_panic::<rustc_errors[116146ae72f5b2a5]::ExplicitBug>
  16:     0x7f4bd35c0666 - std[8d8990c2ba4fc99a]::panic::panic_any::<rustc_errors[116146ae72f5b2a5]::ExplicitBug>
  17:     0x7f4bd35bad02 - <rustc_errors[116146ae72f5b2a5]::HandlerInner>::span_bug::<rustc_span[a41f956c2bae68ea]::span_encoding::Span, &alloc[d45f47a36059466c]::string::String>
  18:     0x7f4bd35baad7 - <rustc_errors[116146ae72f5b2a5]::Handler>::span_bug::<rustc_span[a41f956c2bae68ea]::span_encoding::Span, &alloc[d45f47a36059466c]::string::String>
  19:     0x7f4bd3645e4b - rustc_middle[fef03dd4a87f24e7]::util::bug::opt_span_bug_fmt::<rustc_span[a41f956c2bae68ea]::span_encoding::Span>::{closure#0}
  20:     0x7f4bd3645e9a - rustc_middle[fef03dd4a87f24e7]::ty::context::tls::with_opt::<rustc_middle[fef03dd4a87f24e7]::util::bug::opt_span_bug_fmt<rustc_span[a41f956c2bae68ea]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f4bd3644166 - rustc_middle[fef03dd4a87f24e7]::ty::context::tls::with_context_opt::<rustc_middle[fef03dd4a87f24e7]::ty::context::tls::with_opt<rustc_middle[fef03dd4a87f24e7]::util::bug::opt_span_bug_fmt<rustc_span[a41f956c2bae68ea]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f4bd3644106 - rustc_middle[fef03dd4a87f24e7]::util::bug::opt_span_bug_fmt::<rustc_span[a41f956c2bae68ea]::span_encoding::Span>
  23:     0x7f4bd17938d4 - rustc_middle[fef03dd4a87f24e7]::util::bug::span_bug_fmt::<rustc_span[a41f956c2bae68ea]::span_encoding::Span>
  24:     0x7f4bd1794e12 - <rustc_hir_typeck[7583ab7f8f5b1ce2]::inherited::Inherited>::register_infer_ok_obligations::<rustc_middle[fef03dd4a87f24e7]::ty::Ty>
  25:     0x7f4bd238ca1d - rustc_hir_typeck[7583ab7f8f5b1ce2]::check::check_fn
  26:     0x7f4bd23766f4 - rustc_hir_typeck[7583ab7f8f5b1ce2]::typeck
  27:     0x7f4bd1d41c66 - rustc_query_system[e4d6cb21d96a044c]::query::plumbing::try_execute_query::<rustc_query_impl[8d521fe1c118fabd]::queries::typeck, rustc_query_impl[8d521fe1c118fabd]::plumbing::QueryCtxt>
  28:     0x7f4bd1d415c3 - <rustc_query_impl[8d521fe1c118fabd]::Queries as rustc_middle[fef03dd4a87f24e7]::ty::query::QueryEngine>::typeck
  29:     0x7f4bd35191b5 - <rustc_hir_analysis[f9cb05146d6e270d]::collect::type_of::find_opaque_ty_constraints_for_tait::ConstraintLocator>::check
  30:     0x7f4bd35166d2 - <rustc_hir_analysis[f9cb05146d6e270d]::collect::type_of::find_opaque_ty_constraints_for_tait::ConstraintLocator as rustc_hir[73843cfc1da40d3a]::intravisit::Visitor>::visit_nested_impl_item
  31:     0x7f4bd34f2566 - rustc_hir[73843cfc1da40d3a]::intravisit::walk_item::<rustc_hir_analysis[f9cb05146d6e270d]::collect::type_of::find_opaque_ty_constraints_for_tait::ConstraintLocator>
  32:     0x7f4bd35165fd - <rustc_hir_analysis[f9cb05146d6e270d]::collect::type_of::find_opaque_ty_constraints_for_tait::ConstraintLocator as rustc_hir[73843cfc1da40d3a]::intravisit::Visitor>::visit_nested_item
  33:     0x7f4bd34f0738 - rustc_hir[73843cfc1da40d3a]::intravisit::walk_mod::<rustc_hir_analysis[f9cb05146d6e270d]::collect::type_of::find_opaque_ty_constraints_for_tait::ConstraintLocator>
  34:     0x7f4bd3518b01 - rustc_hir_analysis[f9cb05146d6e270d]::collect::type_of::find_opaque_ty_constraints_for_tait
  35:     0x7f4bd2aa891d - rustc_hir_analysis[f9cb05146d6e270d]::collect::type_of::type_of
  36:     0x7f4bd1c8d38d - rustc_query_system[e4d6cb21d96a044c]::query::plumbing::try_execute_query::<rustc_query_impl[8d521fe1c118fabd]::queries::type_of, rustc_query_impl[8d521fe1c118fabd]::plumbing::QueryCtxt>
  37:     0x7f4bd1c8bf9d - <rustc_query_impl[8d521fe1c118fabd]::Queries as rustc_middle[fef03dd4a87f24e7]::ty::query::QueryEngine>::type_of
  38:     0x7f4bd20ab51b - rustc_hir_analysis[f9cb05146d6e270d]::check::check::check_mod_item_types
  39:     0x7f4bd29de645 - rustc_query_system[e4d6cb21d96a044c]::query::plumbing::try_execute_query::<rustc_query_impl[8d521fe1c118fabd]::queries::check_mod_item_types, rustc_query_impl[8d521fe1c118fabd]::plumbing::QueryCtxt>
  40:     0x7f4bd29de243 - <rustc_query_impl[8d521fe1c118fabd]::Queries as rustc_middle[fef03dd4a87f24e7]::ty::query::QueryEngine>::check_mod_item_types
  41:     0x7f4bd1700654 - <rustc_session[b62839d35778be9]::session::Session>::time::<(), rustc_hir_analysis[f9cb05146d6e270d]::check_crate::{closure#6}>
  42:     0x7f4bd16fd4f8 - rustc_hir_analysis[f9cb05146d6e270d]::check_crate
  43:     0x7f4bd16f4362 - rustc_interface[fc89f7f2ae9d232a]::passes::analysis
  44:     0x7f4bd2bb5e8c - rustc_query_system[e4d6cb21d96a044c]::query::plumbing::try_execute_query::<rustc_query_impl[8d521fe1c118fabd]::queries::analysis, rustc_query_impl[8d521fe1c118fabd]::plumbing::QueryCtxt>
  45:     0x7f4bd2bb5b80 - <rustc_query_impl[8d521fe1c118fabd]::Queries as rustc_middle[fef03dd4a87f24e7]::ty::query::QueryEngine>::analysis
  46:     0x7f4bd2a0de09 - <rustc_middle[fef03dd4a87f24e7]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[1234c7df5b953713]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[f4906066c81ab25f]::result::Result<(), rustc_span[a41f956c2bae68ea]::ErrorGuaranteed>>
  47:     0x7f4bd25a5e6d - <rustc_interface[fc89f7f2ae9d232a]::interface::Compiler>::enter::<rustc_driver_impl[1234c7df5b953713]::run_compiler::{closure#1}::{closure#2}, core[f4906066c81ab25f]::result::Result<core[f4906066c81ab25f]::option::Option<rustc_interface[fc89f7f2ae9d232a]::queries::Linker>, rustc_span[a41f956c2bae68ea]::ErrorGuaranteed>>
  48:     0x7f4bd25a3f56 - rustc_span[a41f956c2bae68ea]::with_source_map::<core[f4906066c81ab25f]::result::Result<(), rustc_span[a41f956c2bae68ea]::ErrorGuaranteed>, rustc_interface[fc89f7f2ae9d232a]::interface::run_compiler<core[f4906066c81ab25f]::result::Result<(), rustc_span[a41f956c2bae68ea]::ErrorGuaranteed>, rustc_driver_impl[1234c7df5b953713]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  49:     0x7f4bd25a34e9 - std[8d8990c2ba4fc99a]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[fc89f7f2ae9d232a]::util::run_in_thread_pool_with_globals<rustc_interface[fc89f7f2ae9d232a]::interface::run_compiler<core[f4906066c81ab25f]::result::Result<(), rustc_span[a41f956c2bae68ea]::ErrorGuaranteed>, rustc_driver_impl[1234c7df5b953713]::run_compiler::{closure#1}>::{closure#0}, core[f4906066c81ab25f]::result::Result<(), rustc_span[a41f956c2bae68ea]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f4906066c81ab25f]::result::Result<(), rustc_span[a41f956c2bae68ea]::ErrorGuaranteed>>
  50:     0x7f4bd2c8be8a - <<std[8d8990c2ba4fc99a]::thread::Builder>::spawn_unchecked_<rustc_interface[fc89f7f2ae9d232a]::util::run_in_thread_pool_with_globals<rustc_interface[fc89f7f2ae9d232a]::interface::run_compiler<core[f4906066c81ab25f]::result::Result<(), rustc_span[a41f956c2bae68ea]::ErrorGuaranteed>, rustc_driver_impl[1234c7df5b953713]::run_compiler::{closure#1}>::{closure#0}, core[f4906066c81ab25f]::result::Result<(), rustc_span[a41f956c2bae68ea]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f4906066c81ab25f]::result::Result<(), rustc_span[a41f956c2bae68ea]::ErrorGuaranteed>>::{closure#1} as core[f4906066c81ab25f]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  51:     0x7f4bd00bf783 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h255d5b0757ca4703
                               at /rustc/511364e7874dba9649a264100407e4bffe7b5425/library/alloc/src/boxed.rs:1988:9
  52:     0x7f4bd00bf783 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h93c5eec9856fe0a3
                               at /rustc/511364e7874dba9649a264100407e4bffe7b5425/library/alloc/src/boxed.rs:1988:9
  53:     0x7f4bd00bf783 - std::sys::unix::thread::Thread::new::thread_start::h28a60d678ab940df
                               at /rustc/511364e7874dba9649a264100407e4bffe7b5425/library/std/src/sys/unix/thread.rs:108:17
  54:     0x7f4bcfe29ff2 - start_thread
  55:     0x7f4bcfeacbfc - clone3
  56:                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.70.0-nightly (511364e78 2023-03-16) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib

query stack during panic:
#0 [typeck] type-checking `<impl at melted.rs:4:1: 4:27>::deref`
#1 [type_of] computing type of `ReturnType::{opaque#0}`
#2 [check_mod_item_types] checking item types in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

@rustbot label +S-bug-has-mcve +F-type_alias_impl_trait

@langston-barrett langston-barrett 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 Mar 17, 2023
@rustbot rustbot added S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` labels Mar 17, 2023
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Mar 21, 2023
@matthiaskrgr
Copy link
Member

Regression in nightly-2022-07-01

reproduced based of a modifiction of #88431 which does not need any feature gates and crashes stable:

use std::pin::Pin;

struct GameStateManager<'a> {
    gamestate_stack: Vec<Box<dyn GameState<'a> + 'a>>,
}

pub trait GameState<'a> {}

type FutureGameState<'a, 'b> = Pin<Box<impl for<'b> Fn() -> FutureGameState<'a, 'b> + 'a>>;

pub async fn get_replay_menu<'a>(
) -> Box<dyn for<'b> Fn(&'b mut GameStateManager<'a>) -> FutureGameState<'a, 'b> + 'a> {
    todo!()
}

@matthiaskrgr matthiaskrgr added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Jun 4, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jun 4, 2023
@apiraino
Copy link
Contributor

apiraino commented Jun 6, 2023

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-medium

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. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Development

Successfully merging a pull request may close this issue.

5 participants