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: src/librustc_lint/types.rs:858: unexpected type in foreign function: T #65035

Closed
Centril opened this issue Oct 3, 2019 · 3 comments · Fixed by #65133
Closed

ICE: src/librustc_lint/types.rs:858: unexpected type in foreign function: T #65035

Centril opened this issue Oct 3, 2019 · 3 comments · Fixed by #65133
Assignees
Labels
A-ffi Area: Foreign Function Interface (FFI) A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. 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

@Centril
Copy link
Contributor

Centril commented Oct 3, 2019

fn _f<T>() {
    extern "C" {
        static _a: *const T;
    }
}

backtrace:

   Compiling playground v0.0.1 (/playground)
error: internal compiler error: src/librustc_lint/types.rs:858: unexpected type in foreign function: T

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:912:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:76
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:60
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1028
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1412
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:64
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:196
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:210
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:477
  12: std::panicking::begin_panic
  13: rustc_errors::HandlerInner::bug
  14: rustc_errors::Handler::bug
  15: rustc::util::bug::opt_span_bug_fmt::{{closure}}
  16: rustc::ty::context::tls::with_opt::{{closure}}
  17: rustc::ty::context::tls::with_context_opt
  18: rustc::ty::context::tls::with_opt
  19: rustc::util::bug::opt_span_bug_fmt
  20: rustc::util::bug::bug_fmt
  21: rustc_lint::types::ImproperCTypesVisitor::check_type_for_ffi
  22: rustc_lint::types::ImproperCTypesVisitor::check_type_for_ffi
  23: rustc_lint::types::ImproperCTypesVisitor::check_type_for_ffi_and_report_errors
  24: <rustc_lint::types::ImproperCTypes as rustc::lint::LateLintPass>::check_foreign_item
  25: rustc::hir::intravisit::walk_item
  26: rustc::hir::intravisit::Visitor::visit_nested_item
  27: rustc::hir::intravisit::walk_block
  28: rustc::hir::intravisit::walk_body
  29: rustc::hir::intravisit::walk_fn
  30: rustc::hir::intravisit::walk_item
  31: rustc::hir::intravisit::Visitor::visit_nested_item
  32: rustc::lint::context::late_lint_mod
  33: rustc::ty::query::__query_compute::lint_mod
  34: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::lint_mod>::compute
  35: rustc::dep_graph::graph::DepGraph::with_task_impl
  36: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  37: rustc::lint::context::check_crate::{{closure}}::{{closure}}
  38: rustc::util::common::time
  39: rustc::util::common::time
  40: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:80
  41: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  42: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:80
  43: rustc_interface::passes::analysis::{{closure}}
  44: rustc::util::common::time
  45: rustc_interface::passes::analysis
  46: rustc::ty::query::__query_compute::analysis
  47: rustc::dep_graph::graph::DepGraph::with_task_impl
  48: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  49: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  50: rustc_interface::passes::create_global_ctxt::{{closure}}
  51: rustc_interface::interface::run_compiler_in_existing_thread_pool
  52: std::thread::local::LocalKey<T>::with
  53: scoped_tls::ScopedKey<T>::set
  54: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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 (702b45e40 2019-10-01) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type lib

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

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

error: could not compile `playground`.
@Centril Centril added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-nominated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 3, 2019
@Centril
Copy link
Contributor Author

Centril commented Oct 3, 2019

Related to #65025.

@Centril Centril added A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. A-ffi Area: Foreign Function Interface (FFI) labels Oct 3, 2019
@jonas-schievink jonas-schievink added the C-bug Category: This is a bug. label Oct 3, 2019
@pnkfelix
Copy link
Member

pnkfelix commented Oct 3, 2019

triage: P-medium, removing nomination label.

@pnkfelix pnkfelix added P-medium Medium priority and removed I-nominated labels Oct 3, 2019
@Centril
Copy link
Contributor Author

Centril commented Oct 3, 2019

Curiously, this seems specific to statics... fn items correctly error:

fn _f<T>() {
    extern "C" {
        fn foo(_a: *const T);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ffi Area: Foreign Function Interface (FFI) A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. 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.

4 participants