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 when aliasing impl Future #65679

Closed
hugecheese opened this issue Oct 21, 2019 · 1 comment · Fixed by #65753
Closed

ICE when aliasing impl Future #65679

hugecheese opened this issue Oct 21, 2019 · 1 comment · Fixed by #65753
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. 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) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@hugecheese
Copy link

hugecheese commented Oct 21, 2019

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
@JohnTitor JohnTitor added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-async-await Area: Async & Await A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` labels Oct 22, 2019
@sinkuu
Copy link
Contributor

sinkuu commented Oct 22, 2019

This may be irrelevant to async-await, as we can replace Future with any trait and still reproduces:

type T = impl Sized;
fn take(_: fn() -> T) {}
fn main() {
    take(|| {});
    take(|| {});
}

@JohnTitor JohnTitor removed the A-async-await Area: Async & Await label Oct 22, 2019
@jonas-schievink jonas-schievink added requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 22, 2019
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Oct 22, 2019
Centril added a commit to Centril/rust that referenced this issue Oct 24, 2019
Don't assert for different instance on impl trait alias

Closes rust-lang#65679
r? @Centril @nikomatsakis
@bors bors closed this as completed in 1b03671 Oct 25, 2019
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. 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) ❄️ requires-nightly This issue requires a nightly compiler in some way. 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