Skip to content

ICE: compiler/rustc_lint/src/types.rs:859:17: malformed transparent type #87496

Closed
@chengniansun

Description

@chengniansun

Code

#[repr(transparent)]
struct TransparentCustomZst(());
extern "C" {
    fn good17(p: TransparentCustomZst);
}

Meta

rustc --version --verbose:

rustc 1.56.0-nightly (9c25eb7aa 2021-07-25)
binary: rustc
commit-hash: 9c25eb7aa3a71fb951564b0ddf131be59c2c951d
commit-date: 2021-07-25
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 12.0.1

Error output

warning: struct is never constructed: `TransparentCustomZst`
 --> mutant.rs:2:8
  |
2 | struct TransparentCustomZst(());
  |        ^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: function is never used: `good17`
 --> mutant.rs:4:5
  |
4 |     fn good17(p: TransparentCustomZst);
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: internal compiler error: compiler/rustc_lint/src/types.rs:859:17: malformed transparent type

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1034:9
note: run with `RUST_BACKTRACE=1` environment variable to display a 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 (9c25eb7aa 2021-07-25) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type staticlib

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; 2 warnings emitted
Backtrace

warning: struct is never constructed: `TransparentCustomZst`
 --> mutant.rs:2:8
  |
2 | struct TransparentCustomZst(());
  |        ^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: function is never used: `good17`
 --> mutant.rs:4:5
  |
4 |     fn good17(p: TransparentCustomZst);
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: internal compiler error: compiler/rustc_lint/src/types.rs:859:17: malformed transparent type

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1034: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_variant_for_ffi
   8: rustc_lint::types::ImproperCTypesVisitor::check_type_for_ffi
   9: rustc_lint::types::ImproperCTypesVisitor::check_type_for_ffi_and_report_errors
  10: rustc_lint::types::ImproperCTypesVisitor::check_foreign_fn
  11: <rustc_lint::types::ImproperCTypesDeclarations as rustc_lint::passes::LateLintPass>::check_foreign_item
  12: rustc_hir::intravisit::Visitor::visit_nested_foreign_item
  13: rustc_hir::intravisit::walk_item
  14: rustc_hir::intravisit::Visitor::visit_nested_item
  15: rustc_lint::late::late_lint_mod
  16: rustc_query_system::query::plumbing::get_query_impl
  17: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::lint_mod
  18: rustc_data_structures::sync::join
  19: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  20: rustc_session::utils::<impl rustc_session::session::Session>::time
  21: rustc_interface::passes::analysis
  22: rustc_query_system::query::plumbing::get_query_impl
  23: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  24: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  25: rustc_span::with_source_map
  26: rustc_interface::interface::create_compiler_and_run
  27: 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 (9c25eb7aa 2021-07-25) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type staticlib

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; 2 warnings emitted

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions