Skip to content

accessing private struct member in a macro triggers compiler panic #25386

Closed
@zmike

Description

@zmike

Using this macro:

macro_rules! check_ptr_exist {
    ($var:expr, $member:ident) => (
        (*$var.c_object).$member.is_some()
    );
}
window.rs:225:29: 10:24 error: field `c_object` of struct `interfaces::cef_client::CefClient` is private
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: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'capacity overflow', /home/larsberg/rust/src/libcore/option.rs:330

stack backtrace:
   1:     0x7f389b244019 - sys::backtrace::write::h6dd465a29c00292cqYr
   2:     0x7f389b24bd89 - panicking::on_panic::hce7ca60568ec6ad9low
   3:     0x7f389b20da62 - rt::unwind::begin_unwind_inner::h2ea6b65af87d2482v3v
   4:     0x7f389b20e827 - rt::unwind::begin_unwind_fmt::hecd98e7f8a3b6e1cB2v
   5:     0x7f389b24b966 - rust_begin_unwind
   6:     0x7f389b297284 - panicking::panic_fmt::hd9d434c1534722c4NKy
   7:     0x7f389858a9ff - codemap::CodeMap::span_to_lines::hd5bcc89a8db6c068VtA
   8:     0x7f38985d1c07 - diagnostic::emit::h30031222ffc58de3U7B
   9:     0x7f38985cf824 - diagnostic::EmitterWriter.Emitter::emit::h8650f6f90b911a76C4B
  10:     0x7f3898581591 - diagnostic::SpanHandler::span_err::hb240726d7d932f7aIAB
  11:     0x7f38991e8c0d - session::Session::span_err::h3dc9cf7be0f3e980wrq
  12:     0x7f3899d60aa4 - PrivacyVisitor<'a, 'tcx>::check_field::h42b479c9ea66632514a
  13:     0x7f3899d62c4d - PrivacyVisitor<'a, 'tcx>.Visitor<'v>::visit_expr::hfc9c6e63d9e29d5fkob
  14:     0x7f3899d63779 - PrivacyVisitor<'a, 'tcx>.Visitor<'v>::visit_expr::hfc9c6e63d9e29d5fkob
  15:     0x7f3899d63779 - PrivacyVisitor<'a, 'tcx>.Visitor<'v>::visit_expr::hfc9c6e63d9e29d5fkob
  16:     0x7f3899d63779 - PrivacyVisitor<'a, 'tcx>.Visitor<'v>::visit_expr::hfc9c6e63d9e29d5fkob
  17:     0x7f3899d6309a - PrivacyVisitor<'a, 'tcx>.Visitor<'v>::visit_expr::hfc9c6e63d9e29d5fkob
  18:     0x7f3899d63126 - PrivacyVisitor<'a, 'tcx>.Visitor<'v>::visit_expr::hfc9c6e63d9e29d5fkob
  19:     0x7f3899d6316e - PrivacyVisitor<'a, 'tcx>.Visitor<'v>::visit_expr::hfc9c6e63d9e29d5fkob
  20:     0x7f3899d63c42 - visit::Visitor::visit_fn::h13779281697168954307
  21:     0x7f3899d64676 - visit::walk_impl_item::h9531018899457863059
  22:     0x7f3899d61fdf - PrivacyVisitor<'a, 'tcx>.Visitor<'v>::visit_item::h66a2e730a6f7b526akb
  23:     0x7f3899d61def - PrivacyVisitor<'a, 'tcx>.Visitor<'v>::visit_item::h66a2e730a6f7b526akb
  24:     0x7f3899d6898b - check_crate::h2621f8f2bc7b0c62v2b
  25:     0x7f389b7859f3 - driver::phase_3_run_analysis_passes::hc6c9df64aa0dd2d3tGa
  26:     0x7f389b766dbc - driver::compile_input::hf267a3a644c56a8cQba
  27:     0x7f389b81ffd1 - run_compiler::hd83bb72e6a98a17365b
  28:     0x7f389b81d822 - boxed::F.FnBox<A>::call_box::h6617975357532431123
  29:     0x7f389b81cdc9 - rt::unwind::try::try_fn::h15749177775482334247
  30:     0x7f389b2be918 - rust_try_inner
  31:     0x7f389b2be905 - rust_try
  32:     0x7f389b81d070 - boxed::F.FnBox<A>::call_box::h14003238196261600415
  33:     0x7f389b24ab21 - sys::thread::Thread::new::thread_start::hfc58bae990d0713aR9u
  34:     0x7f3895b16554 - start_thread
  35:     0x7f389ae9cf3c - __clone
  36:                0x0 - <unknown>

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions