Open
Description
openedon Aug 24, 2021
Code
#![feature(specialization)]
trait Foo {
type Bar;
}
impl<T> Foo for T {
default type Bar = u32;
}
impl Foo for i32 {
type Bar = i32;
}
extern "C" {
#[allow(unused)]
// OK as Foo::Bar is explicitly defined for i32
static OK: <i32 as Foo>::Bar;
#[allow(unused)]
// ICE in the improper_ctypes lint
// as Foo::Bar is only default implemented for ()
static ICE: <() as Foo>::Bar;
}
Rust Playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=d12c793a1779bb8d40110fe9ccf87ff5
Meta
rustc --version --verbose
:
rustc 1.56.0-nightly (a49e38e67 2021-08-23)
binary: rustc
commit-hash: a49e38e672c60da788360e088f00ad12353e3913
commit-date: 2021-08-23
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 13.0.0
Error output
error: internal compiler error: compiler/rustc_lint/src/types.rs:1119:32: unexpected type in foreign function: <() as Foo>::Bar
Backtrace
Compiling playground v0.0.1 (/playground)
warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
--> src/main.rs:1:12
|
1 | #![feature(specialization)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
= help: consider using `min_specialization` instead, which is more stable and complete
error: internal compiler error: compiler/rustc_lint/src/types.rs:1119:32: unexpected type in foreign function: <() as Foo>::Bar
thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1145:9
stack backtrace:
0: std::panicking::begin_panic
1: std::panic::panic_any
2: rustc_errors::HandlerInner::bug
3: rustc_errors::Handler::bug
4: rustc_middle::ty::context::tls::with_opt
5: rustc_middle::util::bug::opt_span_bug_fmt
6: rustc_middle::util::bug::bug_fmt
7: rustc_lint::types::ImproperCTypesVisitor::check_type_for_ffi
8: rustc_lint::types::ImproperCTypesVisitor::check_type_for_ffi_and_report_errors
9: <rustc_lint::types::ImproperCTypesDeclarations as rustc_lint::passes::LateLintPass>::check_foreign_item
10: rustc_hir::intravisit::Visitor::visit_nested_foreign_item
11: rustc_hir::intravisit::walk_item
12: rustc_hir::intravisit::Visitor::visit_nested_item
13: rustc_lint::late::late_lint_mod
14: rustc_query_system::query::plumbing::get_query_impl
15: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::lint_mod
16: rustc_data_structures::sync::join
17: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
18: rustc_session::utils::<impl rustc_session::session::Session>::time
19: rustc_interface::passes::analysis
20: rustc_query_system::query::plumbing::get_query_impl
21: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
22: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
23: rustc_span::with_source_map
24: scoped_tls::ScopedKey<T>::set
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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.56.0-nightly (a49e38e67 2021-08-23) running on x86_64-unknown-linux-gnu
note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type bin
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
warning: `playground` (bin "playground") generated 1 warning
error: could not compile `playground`; 1 warning emitted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
Area: Lints (warnings about flaws in source code) such as unused_mut.Category: This is a bug.`#![feature(specialization)]`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Lint: improper_ctypesStatus: This bug is tracked inside the repo by a `known-bug` test.Relevant to the compiler team, which will review and decide on the PR/issue.ICE tracked in rust-lang/glacier.This issue requires the use of incomplete features.