Skip to content

Ffi safe lint ICE with type alias impl trait #64338

Closed
@bjorn3

Description

@bjorn3
#![feature(type_alias_impl_trait)]

type A = impl Fn();

fn ret_closure() -> A {
    || {}
}

extern "C" {
    fn a(_: A);
}

fn main() {}
error: internal compiler error: src/librustc_lint/types.rs:858: Unexpected type in foreign function

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:643:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.35/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.35/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:47
   3: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:36
   4: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:200
   5: std::panicking::default_hook
             at src/libstd/panicking.rs:214
   6: rustc::util::common::panic_hook
   7: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:481
   8: std::panicking::begin_panic
   9: rustc_errors::Handler::bug
  10: rustc::util::bug::opt_span_bug_fmt::{{closure}}
  11: rustc::ty::context::tls::with_opt::{{closure}}
  12: rustc::ty::context::tls::with_context_opt
  13: rustc::ty::context::tls::with_opt
  14: rustc::util::bug::opt_span_bug_fmt
  15: rustc::util::bug::bug_fmt
  16: rustc_lint::types::ImproperCTypesVisitor::check_type_for_ffi
  17: rustc_lint::types::ImproperCTypesVisitor::check_type_for_ffi_and_report_errors
  18: <rustc_lint::types::ImproperCTypes as rustc::lint::LateLintPass>::check_foreign_item
  19: rustc::hir::intravisit::walk_item
  20: rustc::hir::intravisit::Visitor::visit_nested_item
  21: rustc::lint::context::late_lint_mod
  22: rustc::ty::query::__query_compute::lint_mod
  23: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::lint_mod>::compute
  24: rustc::dep_graph::graph::DepGraph::with_task_impl
  25: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  26: rustc::lint::context::check_crate::{{closure}}::{{closure}}
  27: rustc::util::common::time
  28: rustc::util::common::time
  29: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:80
  30: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  31: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:80
  32: rustc_interface::passes::analysis::{{closure}}
  33: rustc::util::common::time
  34: rustc_interface::passes::analysis
  35: rustc::ty::query::__query_compute::analysis
  36: rustc::dep_graph::graph::DepGraph::with_task_impl
  37: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  38: rustc::ty::context::tls::enter_global
  39: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  40: rustc_interface::passes::create_global_ctxt::{{closure}}
  41: rustc_interface::passes::BoxedGlobalCtxt::enter
  42: rustc_interface::interface::run_compiler_in_existing_thread_pool
  43: std::thread::local::LocalKey<T>::with
  44: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stack during panic:
#0 [lint_mod] linting top-level module
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error


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.39.0-nightly (9eae1fc0e 2019-08-23) running on x86_64-unknown-linux-gnu

Metadata

Metadata

Assignees

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.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions