Skip to content

ICE: #cfg usage in a macro call #73663

Closed
@kaczmarczyck

Description

@kaczmarczyck

I get an ICE when trying to use #[cfg(feature = "with_ctap2_1")] inside a map-like macro call.

I tried this code:

https://github.com/kaczmarczyck/OpenSK/commits/internal-compiler-error
The last commit does NOT reproduce the error, but shows the 2 line diff to commit
kaczmarczyck/OpenSK@4fec405
that is reproducing the problem.

Please clone the branch above, run ./setup.sh if you want to check that everything works, then execute:
RUST_BACKTRACE=1 cargo test --release --features std --verbose

I expected a regular compiler error (or a successful test).

Instead, the above mentioned ICE occurred.

Meta

rustc --version --verbose:

rustc 1.42.0-nightly (f43c34a13 2020-02-02)
binary: rustc
commit-hash: f43c34a134358471726f25fe5973b8c7e177c825
commit-date: 2020-02-02
host: x86_64-unknown-linux-gnu
release: 1.42.0-nightly
LLVM version: 9.0

Backtrace:

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/librustc_resolve/late.rs:1994:35
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:77
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1052
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1428
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   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:204
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:224
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:474
  12: rust_begin_unwind
             at src/libstd/panicking.rs:378
  13: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
  14: core::panicking::panic
             at src/libcore/panicking.rs:52
  15: rustc_resolve::late::LateResolutionVisitor::resolve_expr
  16: rustc_resolve::late::LateResolutionVisitor::resolve_expr
  17: <rustc_resolve::late::LateResolutionVisitor as syntax::visit::Visitor>::visit_block
  18: rustc_resolve::late::LateResolutionVisitor::resolve_expr
  19: <rustc_resolve::late::LateResolutionVisitor as syntax::visit::Visitor>::visit_local
  20: <rustc_resolve::late::LateResolutionVisitor as syntax::visit::Visitor>::visit_block
  21: <rustc_resolve::late::LateResolutionVisitor as syntax::visit::Visitor>::visit_fn
  22: syntax::visit::walk_item
  23: rustc_resolve::late::LateResolutionVisitor::resolve_item
  24: syntax::visit::walk_item
  25: rustc_resolve::late::LateResolutionVisitor::resolve_item
  26: syntax::visit::walk_item
  27: rustc_resolve::late::LateResolutionVisitor::resolve_item
  28: syntax::visit::walk_item
  29: rustc_resolve::late::LateResolutionVisitor::resolve_item
  30: syntax::visit::walk_crate
  31: rustc_resolve::Resolver::resolve_crate
  32: rustc_interface::passes::configure_and_expand_inner
  33: rustc_interface::passes::configure_and_expand::{{closure}}
  34: rustc_data_structures::box_region::PinnedGenerator<I,A,R>::new
  35: rustc_interface::passes::configure_and_expand
  36: rustc_interface::queries::Queries::expansion
  37: rustc_interface::interface::run_compiler_in_existing_thread_pool
  38: scoped_tls::ScopedKey<T>::set
  39: syntax::attr::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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: rustc 1.42.0-nightly (f43c34a13 2020-02-02) running on x86_64-unknown-linux-gnu
note: compiler flags: -C opt-level=3
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
error: could not compile `ctap2`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions