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

async fn with elided lifetime causes rustc panic #62517

Open
hackerer1c opened this issue Jul 9, 2019 · 1 comment

Comments

Projects
None yet
3 participants
@hackerer1c
Copy link

commented Jul 9, 2019

Code to reproduce:

use futures::Stream;
use std::any::Any;

async fn foo(x: &str) -> impl Stream<Item = Box<dyn Any>> {}

and then run cargo check... (with full backtrace)

thread 'rustc' panicked at 'assertion failed: !erased_self_ty.has_escaping_bound_vars()', src/librustc/ty/util.rs:356:9
stack backtrace:
   0:        0x1054341e2 - std::panicking::default_hook::{{closure}}::h732feb85026a4422
   1:        0x105433eab - std::panicking::default_hook::h832638be7920e1d9
   2:        0x10410d3a3 - rustc::util::common::panic_hook::h50956d861d3d8265
   3:        0x105434aa1 - std::panicking::rust_panic_with_hook::h2746b02166e15af2
   4:        0x10409f2a5 - std::panicking::begin_panic::h230090070c2be599
   5:        0x104015c5d - rustc::ty::util::<impl rustc::ty::context::TyCtxt>::required_region_bounds::h2bfd0992e0240e65
   6:        0x1041b295b - rustc::infer::opaque_types::Instantiator::fold_opaque_ty::h6a2109340442464e
   7:        0x1042616a2 - <rustc::ty::fold::BottomUpFolder<F,G,H> as rustc::ty::fold::TypeFolder>::fold_ty::h7aa13d9636d94705
   8:        0x103e0765a - rustc::ty::fold::TypeFoldable::fold_with::h6eb10112104db7f6
   9:        0x1041b2d17 - rustc::infer::opaque_types::Instantiator::fold_opaque_ty::h6a2109340442464e
  10:        0x102eee399 - <rustc::ty::fold::BottomUpFolder<F,G,H> as rustc::ty::fold::TypeFolder>::fold_ty::h362061237fa87a5f
  11:        0x102e9619f - rustc_typeck::check::FnCtxt::instantiate_opaque_types_from_value::hdd338307918cfee6
  12:        0x102e8bcaa - rustc_typeck::check::check_fn::hac7bd15dbe73baf3
  13:        0x102fd07f4 - rustc::ty::context::GlobalCtxt::enter_local::h324ac2ec2e12e0e2
  14:        0x102e8b1ac - rustc_typeck::check::typeck_tables_of::h8a6866c5ac4e4538
  15:        0x102eab71e - rustc::ty::query::__query_compute::typeck_tables_of::h461c35490ac0925d
  16:        0x102f4d49b - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute::hb6ba7a7a89baca84
  17:        0x102edc256 - rustc::dep_graph::graph::DepGraph::with_task_impl::h729ba93c71ed6836
  18:        0x102facd48 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::ha9abd6cc76593f28
  19:        0x102eab71e - rustc::ty::query::__query_compute::typeck_tables_of::h461c35490ac0925d
  20:        0x102f4d49b - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute::hb6ba7a7a89baca84
  21:        0x102edc256 - rustc::dep_graph::graph::DepGraph::with_task_impl::h729ba93c71ed6836
  22:        0x102facd48 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::ha9abd6cc76593f28
  23:        0x103017d8c - rustc_typeck::collect::checked_type_of::h6778c833e01799c6
  24:        0x10301781e - rustc_typeck::collect::type_of::h1264787cfb7a8feb
  25:        0x102ead1cb - rustc::ty::query::__query_compute::type_of::h8914623b8a89443b
  26:        0x102f4d0cb - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::type_of>::compute::h9e129d1cba94e459
  27:        0x102ed5816 - rustc::dep_graph::graph::DepGraph::with_task_impl::h2b7ac820718424f6
  28:        0x102f86f98 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::h5ff957fa238b670a
  29:        0x102ff2a47 - rustc::hir::intravisit::walk_expr::hb0db1b8ea3eea671
  30:        0x103005314 - rustc::hir::intravisit::Visitor::visit_fn::hc5e7e3e1abe9958f
  31:        0x102fe36c3 - rustc::hir::intravisit::walk_impl_item::h4d45bdab776530c9
  32:        0x102eae0c8 - rustc::hir::map::Map::visit_item_likes_in_module::ha9769faef02af1e0
  33:        0x103013444 - rustc_typeck::collect::collect_mod_item_types::h2ec1a0c87fa3d49d
  34:        0x102eac5de - rustc::ty::query::__query_compute::collect_mod_item_types::heaa821ee7f695a15
  35:        0x102f4d75b - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::collect_mod_item_types>::compute::h5f889db1173afe74
  36:        0x102ed5e38 - rustc::dep_graph::graph::DepGraph::with_task_impl::h2ef3fa01ca8acb95
  37:        0x102f7346e - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::h308b4698a27c8896
  38:        0x102ecb422 - rustc_typeck::check_crate::{{closure}}::{{closure}}::h9655a64665552d1e
  39:        0x102eae94d - rustc::util::common::time::h272405b2b749ed07
  40:        0x103058fee - rustc_typeck::check_crate::h484f134202177825
  41:        0x102acdfdf - rustc_interface::passes::analysis::hd60757f4c2b698a8
  42:        0x102a5f012 - rustc::ty::query::__query_compute::analysis::h78ec8ee67474784a
  43:        0x102a60fe5 - rustc::dep_graph::graph::DepGraph::with_task_impl::h4ac160ddc37c9308
  44:        0x1029de862 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::he04d60713b4447ef
  45:        0x1029f9bec - rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}::h056779aae72902db
  46:        0x102b10acb - rustc_interface::passes::create_global_ctxt::{{closure}}::hfa8388d59c8efa62
  47:        0x1029fc489 - rustc_interface::interface::run_compiler_in_existing_thread_pool::hff72514f7ca933dc
  48:        0x102a0c9a4 - std::thread::local::LocalKey<T>::with::h91a2674509ca585e
  49:        0x102a1cbb2 - scoped_tls::ScopedKey<T>::set::h03f39cddb2457ca3
  50:        0x102a34245 - syntax::with_globals::h6d4146eff33e9bc1
  51:        0x102a569ba - std::sys_common::backtrace::__rust_begin_short_backtrace::hc2071b1843657bff
  52:        0x105443f3f - __rust_maybe_catch_panic
  53:        0x1029e4237 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h1ae87809d2a636db
  54:        0x105417cce - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::hffc2c905ed2b6268
  55:        0x105442d5e - std::sys::unix::thread::Thread::new::thread_start::h6ca51316935dd8c4
  56:     0x7fff5b16f2eb - _pthread_body
  57:     0x7fff5b172249 - _pthread_start
query stack during panic:
#0 [typeck_tables_of] processing `s3::Foo::bar`
#1 [typeck_tables_of] processing `s3::Foo::bar::{{closure}}#0`
#2 [type_of] processing `s3::Foo::bar::{{closure}}#0`
#3 [collect_mod_item_types] collecting item types in module `s3`
#4 [analysis] running analysis passes on this crate
end of query stack

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.38.0-nightly (78ca1bda3 2019-07-08) running on x86_64-apple-darwin

note: compiler flags: -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

This also reproduces when &str is replaced with &_ (where _ is any type), but does't reproduce with &'static _.

@hackerer1c

This comment has been minimized.

Copy link
Author

commented Jul 9, 2019

This situation also reproduces:

async fn foo<'a>(x: &'a str) -> impl Stream<Item = Box<Any>> {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.