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: impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> #88236

Closed
WaffleLapkin opened this issue Aug 22, 2021 · 8 comments · Fixed by #92007 or #94081
Closed

ICE: impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> #88236

WaffleLapkin opened this issue Aug 22, 2021 · 8 comments · Fixed by #92007 or #94081
Assignees
Labels
A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@WaffleLapkin
Copy link
Member

Code

trait Hrtb<'a> {
    type Assoc;
}

impl<'a> Hrtb<'a> for () {
    type Assoc = ();
}

fn make_impl() -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> {}

(playground)

Comment

I was trying to make an associated type of hrtb-impl Trait Send without changing the Trait. I was mostly expecting that this won't work, but this also ICEs.

Meta

rustc 1.56.0-nightly (d3e2578c3 2021-08-21) running on x86_64-unknown-linux-gnu

Error output

thread 'rustc' panicked at 'Normalizing [Binder(TraitPredicate(<impl for<'a> std::marker::Send as std::marker::Sized>), []), Binder(OutlivesPredicate(impl for<'a> std::marker::Send, ReLateBound(DebruijnIndex(1), BoundRegion { var: 0, kind: BrNamed(DefId(0:19 ~ playground[14a5]::make_impl::{opaque#0}::'a), 'a) })), []), Binder(TraitPredicate(<impl for<'a> std::marker::Send as std::marker::Send>), [])] without wrapping in a `Binder`', compiler/rustc_trait_selection/src/traits/project.rs:332:9
Backtrace

stack backtrace:
   0: rust_begin_unwind
             at /rustc/d3e2578c31688619ddc0a10ddf8543bf4ebcba5b/library/std/src/panicking.rs:517:5
   1: std::panicking::begin_panic_fmt
             at /rustc/d3e2578c31688619ddc0a10ddf8543bf4ebcba5b/library/std/src/panicking.rs:460:5
   2: rustc_trait_selection::traits::project::AssocTypeNormalizer::fold
   3: rustc_trait_selection::traits::project::normalize
   4: <rustc_infer::infer::InferCtxt as rustc_trait_selection::infer::InferCtxtExt>::partially_normalize_associated_types_in
   5: rustc_trait_selection::opaque_types::Instantiator::fold_opaque_ty
   6: <rustc_middle::ty::fold::BottomUpFolder<F,G,H> as rustc_middle::ty::fold::TypeFolder>::fold_ty
   7: rustc_middle::ty::fold::TypeFoldable::fold_with
   8: rustc_trait_selection::opaque_types::Instantiator::fold_opaque_ty
   9: <rustc_middle::ty::fold::BottomUpFolder<F,G,H> as rustc_middle::ty::fold::TypeFolder>::fold_ty
  10: rustc_trait_selection::opaque_types::Instantiator::instantiate_opaque_types_in_map
  11: rustc_typeck::check::fn_ctxt::_impl::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::instantiate_opaque_types_from_value
  12: rustc_typeck::check::check::check_fn
  13: rustc_infer::infer::InferCtxtBuilder::enter
  14: rustc_typeck::check::typeck
  15: rustc_query_system::query::plumbing::get_query_impl
  16: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck
  17: rustc_middle::ty::context::TyCtxt::typeck_opt_const_arg
  18: rustc_mir_build::build::mir_built
  19: rustc_query_system::query::plumbing::get_query_impl
  20: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_built
  21: rustc_mir::transform::check_unsafety::unsafety_check_result
  22: core::ops::function::FnOnce::call_once
  23: rustc_query_system::query::plumbing::get_query_impl
  24: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::unsafety_check_result
  25: rustc_mir::transform::mir_const
  26: rustc_query_system::query::plumbing::get_query_impl
  27: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_const
  28: rustc_mir::transform::mir_promoted
  29: rustc_query_system::query::plumbing::get_query_impl
  30: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_promoted
  31: rustc_mir::borrow_check::mir_borrowck
  32: core::ops::function::FnOnce::call_once
  33: rustc_query_system::query::plumbing::get_query_impl
  34: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_borrowck
  35: rustc_typeck::collect::type_of::type_of
  36: rustc_query_system::query::plumbing::get_query_impl
  37: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::type_of
  38: rustc_typeck::check::check::check_item_type
  39: rustc_middle::hir::map::Map::visit_item_likes_in_module
  40: rustc_typeck::check::check::check_mod_item_types
  41: rustc_query_system::query::plumbing::get_query_impl
  42: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_item_types
  43: rustc_session::utils::<impl rustc_session::session::Session>::time
  44: rustc_typeck::check_crate
  45: rustc_interface::passes::analysis
  46: rustc_query_system::query::plumbing::get_query_impl
  47: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  48: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  49: rustc_span::with_source_map
  50: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stack during panic:
#0 [typeck] type-checking `make_impl`
#1 [mir_built] building MIR for `make_impl`
#2 [unsafety_check_result] unsafety-checking `make_impl`
#3 [mir_const] processing MIR for `make_impl`
#4 [mir_promoted] processing `make_impl`
#5 [mir_borrowck] borrow-checking `make_impl`
#6 [type_of] computing type of `make_impl::{opaque#0}`
#7 [check_mod_item_types] checking item types in top-level module
#8 [analysis] running analysis passes on this crate
end of query stack

@WaffleLapkin WaffleLapkin 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 Aug 22, 2021
@jonas-schievink jonas-schievink added A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Aug 22, 2021
@apiraino
Copy link
Contributor

Assigning priority as discussed in the Zulip thread of the Prioritization Working Group.

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Aug 23, 2021
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Sep 10, 2021
@steffahn
Copy link
Member

It's doing a stack overflow now

@rustbot label I-crash

@rustbot rustbot added the I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. label Jan 13, 2022
@steffahn
Copy link
Member

Might make sense to bisect the point between 1.56 and 1.57 where the crash was introduced.

@rustbot label E-needs-bisection

@rustbot rustbot added the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label Jan 13, 2022
@WaffleLapkin
Copy link
Member Author

So, bisection shows that the ICE->crash change happened in nightly-2021-09-22 (also fun fact, nightly-2021-09-21 doesn't exist?). The commit search doesn't work, so this is all we have right now.

@rustbot label -E-needs-bisection

@rustbot rustbot removed the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label Jan 13, 2022
@steffahn
Copy link
Member

steffahn commented Jan 13, 2022

It's doing a stack overflow now

Might make sense to bisect the point between 1.56 and 1.57 where the crash was introduced.

git bisect (yes, that's kinda tedious...) points to 34de78f, part of #89045

cc @oli-obk

@oli-obk oli-obk self-assigned this Jan 13, 2022
@WaffleLapkin
Copy link
Member Author

@steffahn I haven't noticed that you've already found the commit, so I tried to search for it too 😅

There is rustup-toolchain-install-master that allows to install rustc from CI. With that I found the PR merge commit (dda2a0e) in like 5 minutes :D

Very handy tool

@steffahn
Copy link
Member

Oh, that's nice. So I wouldn't have had to re-compile the compiler like 10 times to do that bisection? 😅

@oli-obk
Copy link
Contributor

oli-obk commented Feb 11, 2022

Reopening because the fix was reverted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants