Skip to content

ICE when aliasing impl Future #65679

Closed
@hugecheese

Description

@hugecheese

Version: rustc 1.40.0-nightly (0e8a4b441 2019-10-16)

#![feature(type_alias_impl_trait)]

type Fut = impl std::future::Future;

fn take(_: fn() -> Fut) {}

fn main() {
    take(|| async {});
    take(|| async {});
}

The second function call is necessary. It will compile and run just fine with only one call.

Output:

thread 'rustc' panicked at 'instantiated twice: DefId(0:12 ~ rustbug[51aa]::Fut[0])/OpaqueTypeDecl { substs: [], definition_span: src/main.rs:9:13: 9:13, concrete_ty: _, has_required_region_bounds: false, origin: TypeAlias }', src/librustc_typeck/check/mod.rs:2739:13
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::panicking::default_hook::{{closure}}
   4: std::panicking::default_hook
   5: rustc_driver::report_ice
   6: std::panicking::rust_panic_with_hook
   7: std::panicking::continue_panic_fmt
   8: std::panicking::begin_panic_fmt
   9: rustc_typeck::check::FnCtxt::instantiate_opaque_types_from_value
  10: rustc_typeck::check::check_fn
  11: rustc_typeck::check::closure::<impl rustc_typeck::check::FnCtxt>::check_expr_closure
  12: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  13: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  14: rustc_typeck::check::FnCtxt::check_argument_types
  15: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt>::confirm_builtin_call
  16: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt>::check_call
  17: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  18: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  19: rustc_typeck::check::FnCtxt::check_stmt
  20: rustc_typeck::check::FnCtxt::check_block_with_expected
  21: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  22: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  23: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_return_expr
  24: rustc_typeck::check::check_fn
  25: rustc::ty::context::GlobalCtxt::enter_local
  26: rustc_typeck::check::typeck_tables_of
  27: rustc::ty::query::__query_compute::typeck_tables_of
  28: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
  29: rustc::dep_graph::graph::DepGraph::with_task_impl
  30: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  31: rustc_typeck::collect::find_opaque_ty_constraints::ConstraintLocator::check
  32: rustc::hir::intravisit::Visitor::visit_nested_item
  33: rustc_typeck::collect::find_opaque_ty_constraints
  34: rustc_typeck::collect::checked_type_of
  35: rustc_typeck::collect::type_of
  36: rustc::ty::query::__query_compute::type_of
  37: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::type_of>::compute
  38: rustc::dep_graph::graph::DepGraph::with_task_impl
  39: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  40: <rustc_typeck::collect::CollectItemTypesVisitor as rustc::hir::intravisit::Visitor>::visit_item
  41: rustc::hir::map::Map::visit_item_likes_in_module
  42: rustc_typeck::collect::collect_mod_item_types
  43: rustc::ty::query::__query_compute::collect_mod_item_types
  44: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::collect_mod_item_types>::compute
  45: rustc::dep_graph::graph::DepGraph::with_task_impl
  46: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  47: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::ensure_query
  48: rustc_typeck::check_crate::{{closure}}::{{closure}}
  49: rustc::util::common::time
  50: rustc_typeck::check_crate
  51: rustc_interface::passes::analysis
  52: rustc::ty::query::__query_compute::analysis
  53: rustc::dep_graph::graph::DepGraph::with_task_impl
  54: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  55: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  56: rustc_interface::passes::create_global_ctxt::{{closure}}
  57: rustc_interface::passes::BoxedGlobalCtxt::enter
  58: rustc_interface::interface::run_compiler_in_existing_thread_pool
  59: std::thread::local::LocalKey<T>::with
  60: scoped_tls::ScopedKey<T>::set
  61: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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.40.0-nightly (0e8a4b441 2019-10-16) running on x86_64-apple-darwin

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

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

query stack during panic:
#0 [typeck_tables_of] processing `main`
#1 [type_of] processing `Fut`
#2 [collect_mod_item_types] collecting item types in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`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.glacierICE tracked in rust-lang/glacier.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions