Skip to content

[Nightly ICE] Deep in proc macro: panicked at 'empty field list in the map' #75062

Closed
@jhwgh1968

Description

@jhwgh1968

Code

It is very finicky to reproduce. This GHE branch is as minimal as I could get without significantly changing the structure of the macro or having other errors cover it up. Apologies for the mess!

Updated 2020-08-04: I got it down to a total of only 130 lines of code. Please review the improved cargo expand output below.

Instructions:

  1. Clone the project: git clone -b nightly_ice https://github.com/jhwgh1968/rhai.git
  2. cd rhai/codegen
  3. RUST_BACKTRACE=1 cargo check --tests

Meta

The ICE was triggered by change in 44600aa2, where I simply changed the scoping on a nested inner struct generated by a macro from public to private.

rustc --version --verbose:

rustc 1.47.0-nightly (6c8927b0c 2020-07-26)
binary: rustc
commit-hash: 6c8927b0cf80ceee19386026cf9d7fd4fd9d486f
commit-date: 2020-07-26
host: x86_64-unknown-linux-gnu
release: 1.47.0-nightly
LLVM version: 10.0

Error output

On stable, errors regarding scoping are printed (this error is repeated many times):

error[E0603]: tuple struct `Token` is private
  --> tests/test_functions.rs:20:5
   |
20 | /     rhai::register_exported_fn!(
21 | |         m,
22 | |         "euclidean_distance".to_string(),
23 | |         raw_fn::distance_function
24 | |     );
   | |______^ private tuple struct
   |
note: the tuple struct `Token` is defined here
  --> tests/test_functions.rs:9:5
   |
9  |     #[export_fn]
   |     ^^^^^^^^^^^^
   = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)

On nightly, a backtrace occurs.

Backtrace

thread 'rustc' panicked at 'empty field list in the map', src/librustc_resolve/diagnostics.rs:1068:50
stack backtrace:
   0:     0x7fc302be4215 - backtrace::backtrace::libunwind::trace::h75aedf5f78e5147f
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1:     0x7fc302be4215 - backtrace::backtrace::trace_unsynchronized::h18fb73c9ac9ae753
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2:     0x7fc302be4215 - std::sys_common::backtrace::_print_fmt::h65f97470ff13ec84
                               at src/libstd/sys_common/backtrace.rs:78
   3:     0x7fc302be4215 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hee061c54ddc9f024
                               at src/libstd/sys_common/backtrace.rs:59
   4:     0x7fc302c2041c - core::fmt::write::hfbd2baad61ed21a8
                               at src/libcore/fmt/mod.rs:1117
   5:     0x7fc302bd5f52 - std::io::Write::write_fmt::h72f9bd227f40dc62
                               at src/libstd/io/mod.rs:1508
   6:     0x7fc302be90b0 - std::sys_common::backtrace::_print::h2d2cd8fe02feb5fa
                               at src/libstd/sys_common/backtrace.rs:62
   7:     0x7fc302be90b0 - std::sys_common::backtrace::print::h801b12991252ba7c
                               at src/libstd/sys_common/backtrace.rs:49
   8:     0x7fc302be90b0 - std::panicking::default_hook::{{closure}}::h25fc1fbf3b63b5c8
                               at src/libstd/panicking.rs:198
   9:     0x7fc302be8dfc - std::panicking::default_hook::h62c897957a5e0f26
                               at src/libstd/panicking.rs:217
  10:     0x7fc30336f719 - rustc_driver::report_ice::h54e3b417084b44b0
  11:     0x7fc2f87eb936 - <alloc::boxed::Box<F> as core::ops::function::Fn<A>>::call::h9c411e66d4b5afe3
                               at /rustc/6c8927b0cf80ceee19386026cf9d7fd4fd9d486f/src/liballoc/boxed.rs:1088
  12:     0x7fc2f87b8ec5 - proc_macro::bridge::client::<impl proc_macro::bridge::Bridge>::enter::{{closure}}::{{closure}}::h967b1f123fdc59e1
                               at /rustc/6c8927b0cf80ceee19386026cf9d7fd4fd9d486f/src/libproc_macro/bridge/client.rs:318
  13:     0x7fc302be9828 - std::panicking::rust_panic_with_hook::hb8a276f163c59810
                               at src/libstd/panicking.rs:530
  14:     0x7fc302be93fb - rust_begin_unwind
                               at src/libstd/panicking.rs:437
  15:     0x7fc302c1cfc1 - core::panicking::panic_fmt::h9cc57011b345cfad
                               at src/libcore/panicking.rs:85
  16:     0x7fc302c1cba3 - core::option::expect_failed::hf0849e257b6323a4
                               at src/libcore/option.rs:1265
  17:     0x7fc3041229b9 - rustc_resolve::Resolver::resolve_crate::h9141d40acb3e873e
  18:     0x7fc30350bc0d - rustc_interface::passes::configure_and_expand_inner::h99f6e5687869f977
  19:     0x7fc303576b99 - rustc_interface::passes::configure_and_expand::{{closure}}::ha0a6222929510b34
  20:     0x7fc303561450 - rustc_data_structures::box_region::PinnedGenerator<I,A,R>::new::h6510d01dfe55aa38
  21:     0x7fc30350a881 - rustc_interface::passes::configure_and_expand::h266ae77065114d38
  22:     0x7fc303523514 - rustc_interface::queries::Queries::expansion::h02073762737d1d86
  23:     0x7fc30332a303 - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::h3b5436b320054acc
  24:     0x7fc3033c9277 - rustc_span::with_source_map::hd3215c6d07150bbc
  25:     0x7fc30332bfb6 - rustc_interface::interface::create_compiler_and_run::hc502b394ead637d1
  26:     0x7fc30335532d - scoped_tls::ScopedKey<T>::set::hb09c39dbfa5a4396
  27:     0x7fc30337b4a2 - std::sys_common::backtrace::__rust_begin_short_backtrace::h4fa4ac8c571754e6
  28:     0x7fc30333826e - core::ops::function::FnOnce::call_once{{vtable.shim}}::h23cc72206c0cf83b
  29:     0x7fc302bf7d3a - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h3e41d894970cea2f
                               at /rustc/6c8927b0cf80ceee19386026cf9d7fd4fd9d486f/src/liballoc/boxed.rs:1074
  30:     0x7fc302bf7d3a - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h9a318bb00b7f8871
                               at /rustc/6c8927b0cf80ceee19386026cf9d7fd4fd9d486f/src/liballoc/boxed.rs:1074
  31:     0x7fc302bf7d3a - std::sys::unix::thread::Thread::new::thread_start::hf522342530b04cb6
                               at src/libstd/sys/unix/thread.rs:87
  32:     0x7fc302af9422 - start_thread
  33:     0x7fc302a0fbf3 - __GI___clone
  34:                0x0 - <unknown>

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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.47.0-nightly (6c8927b0c 2020-07-26) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental

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

query stack during panic:
end of query stack

cargo expand with pub struct (updated 2020-08-04)

#![feature(prelude_import)]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std;
use rhai::module_resolvers::*;
use rhai::plugin::*;
use rhai::Module;
pub mod raw_fn {
    use rhai::plugin::*;
    use rhai::FLOAT;
    pub fn distance_function(x1: FLOAT, y1: FLOAT, x2: FLOAT, y2: FLOAT) -> FLOAT {
        ((y2 - y1).abs().powf(2.0) + (x2 - x1).abs().powf(2.0)).sqrt()
    }
    #[allow(unused)]
    pub mod rhai_fn__distance_function {
        use super::*;
        pub struct Token();
        impl PluginFunction for Token {
            fn call(
                &self,
                args: &mut [&mut Dynamic],
                pos: Position,
            ) -> Result<Dynamic, Box<EvalAltResult>> {
                Ok(Dynamic::from(distance_function()))
            }
        }
        pub fn Token__callable() -> CallableFunction {
            CallableFunction::from_plugin(Token())
        }
    }
}
extern crate test;
#[cfg(test)]
#[rustc_test_marker]
pub const raw_fn_test: test::TestDescAndFn = test::TestDescAndFn {
    desc: test::TestDesc {
        name: test::StaticTestName("raw_fn_test"),
        ignore: false,
        allow_fail: false,
        should_panic: test::ShouldPanic::No,
        test_type: test::TestType::IntegrationTest,
    },
    testfn: test::StaticTestFn(|| test::assert_test_result(raw_fn_test())),
};
fn raw_fn_test() {
    let mut m = Module::new();
    m.set_fn(
        "euclidean_distance".to_string(),
        rhai::FnAccess::Public,
        raw_fn::rhai_fn__distance_function::Token()
            .input_types()
            .as_ref(),
    );
}
#[main]
pub fn main() -> () {
    extern crate test;
    test::test_main_static(&[&raw_fn_test])
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-proc-macrosArea: Procedural macrosC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ICEBreaker-Cleanup-CrewHelping to "clean up" bugs with minimal examples and bisectionsP-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.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