Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ice: Mismatched open/close delims #116781

Closed
matthiaskrgr opened this issue Oct 16, 2023 · 4 comments · Fixed by #116889
Closed

ice: Mismatched open/close delims #116781

matthiaskrgr opened this issue Oct 16, 2023 · 4 comments · Fixed by #116889
Assignees
Labels
A-parser Area: The parsing of Rust source code to an AST C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Oct 16, 2023

File: /tmp/im/4E62E62441812AD57206CF6AE50F4E62991CAC86A8E1D805B18CC629F7D6C5AA.rs

auto-reduced (treereduce-rust):

macro_rules! make_struct {
    ($name:ident) => {
        #[derive(Debug)]
        struct Foo {
            #[cfg]
            field: fn(T::B($id1), T::B($id2)),
        }
    };
}

make_struct!(param_name);

original:

// check-pass

macro_rules! make_struct {
    ($name:ident) => {
        #[derive(Debug)]
        struct Foo {
            #[cfg(not(FALSE))]
            field: fn(T::B($id1), T::B($id2))
        }
    }
}

make_struct!(param_name);

fn main() {}

Version information

rustc 1.75.0-nightly (64368d027 2023-10-15)
binary: rustc
commit-hash: 64368d0279c41699fffd7980304488d65a42ba32
commit-date: 2023-10-15
host: x86_64-unknown-linux-gnu
release: 1.75.0-nightly
LLVM version: 17.0.2

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error: expected pattern, found `$`
  --> /tmp/im/4E62E62441812AD57206CF6AE50F4E62991CAC86A8E1D805B18CC629F7D6C5AA.rs:8:28
   |
8  |             field: fn(T::B($id1), T::B($id2))
   |                            ^^^^ expected pattern
...
13 | make_struct!(param_name);
   | ------------------------ in this macro invocation
   |
   = note: this error originates in the macro `make_struct` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected `:`, found `::`
  --> /tmp/im/4E62E62441812AD57206CF6AE50F4E62991CAC86A8E1D805B18CC629F7D6C5AA.rs:8:36
   |
6  |         struct Foo {
   |                --- while parsing this struct
7  |             #[cfg(not(FALSE))]
8  |             field: fn(T::B($id1), T::B($id2))
   |                                    ^^ expected `:`
...
13 | make_struct!(param_name);
   | ------------------------ in this macro invocation
   |
   = note: this error originates in the macro `make_struct` (in Nightly builds, run with -Z macro-backtrace for more info)

thread 'rustc' panicked at compiler/rustc_parse/src/parser/attr_wrapper.rs:409:17:
assertion `left == right` failed: Mismatched open/close delims: open=Brace close=/tmp/im/4E62E62441812AD57206CF6AE50F4E62991CAC86A8E1D805B18CC629F7D6C5AA.rs:8:45: 8:46 (#4)
  left: Brace
 right: Parenthesis
stack backtrace:
   0:     0x7ffbcab628ec - std::backtrace_rs::backtrace::libunwind::trace::h07ab3bc21cf862ce
                               at /rustc/64368d0279c41699fffd7980304488d65a42ba32/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7ffbcab628ec - std::backtrace_rs::backtrace::trace_unsynchronized::h5ca72d50ab1b2eeb
                               at /rustc/64368d0279c41699fffd7980304488d65a42ba32/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7ffbcab628ec - std::sys_common::backtrace::_print_fmt::hb9f77b89692d6d73
                               at /rustc/64368d0279c41699fffd7980304488d65a42ba32/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7ffbcab628ec - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h48fe59c0b4f194df
                               at /rustc/64368d0279c41699fffd7980304488d65a42ba32/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7ffbcabca370 - core::fmt::rt::Argument::fmt::h576d5accdc6c04cd
                               at /rustc/64368d0279c41699fffd7980304488d65a42ba32/library/core/src/fmt/rt.rs:142:9
   5:     0x7ffbcabca370 - core::fmt::write::h8fce9012b8f77a61
                               at /rustc/64368d0279c41699fffd7980304488d65a42ba32/library/core/src/fmt/mod.rs:1117:17
   6:     0x7ffbcab55baf - std::io::Write::write_fmt::he75f9b8a4bb09750
                               at /rustc/64368d0279c41699fffd7980304488d65a42ba32/library/std/src/io/mod.rs:1762:15
   7:     0x7ffbcab626d4 - std::sys_common::backtrace::_print::h5888ddb340763531
                               at /rustc/64368d0279c41699fffd7980304488d65a42ba32/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7ffbcab626d4 - std::sys_common::backtrace::print::hd04b6456bfa7442a
                               at /rustc/64368d0279c41699fffd7980304488d65a42ba32/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7ffbcab65507 - std::panicking::default_hook::{{closure}}::hf663a73e245092af
  10:     0x7ffbcab6524a - std::panicking::default_hook::ha6afd4cd28754d7b
                               at /rustc/64368d0279c41699fffd7980304488d65a42ba32/library/std/src/panicking.rs:292:9
  11:     0x7ffbcd718bda - std[41c1d254b4d8ee37]::panicking::update_hook::<alloc[df3d2ae1c63c0059]::boxed::Box<rustc_driver_impl[fdf22ace854e8ad3]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7ffbcab65ca8 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h829c11900fb8a8ac
                               at /rustc/64368d0279c41699fffd7980304488d65a42ba32/library/alloc/src/boxed.rs:2021:9
  13:     0x7ffbcab65ca8 - std::panicking::rust_panic_with_hook::hc84ea4df24f6431b
                               at /rustc/64368d0279c41699fffd7980304488d65a42ba32/library/std/src/panicking.rs:735:13
  14:     0x7ffbcab65a01 - std::panicking::begin_panic_handler::{{closure}}::h45a88c37641f7e07
                               at /rustc/64368d0279c41699fffd7980304488d65a42ba32/library/std/src/panicking.rs:609:13
  15:     0x7ffbcab62e06 - std::sys_common::backtrace::__rust_end_short_backtrace::hf5a9ccc085289d9e
                               at /rustc/64368d0279c41699fffd7980304488d65a42ba32/library/std/src/sys_common/backtrace.rs:170:18
  16:     0x7ffbcab65732 - rust_begin_unwind
                               at /rustc/64368d0279c41699fffd7980304488d65a42ba32/library/std/src/panicking.rs:597:5
  17:     0x7ffbcabc6995 - core::panicking::panic_fmt::hfd410b1fd7beeb74
                               at /rustc/64368d0279c41699fffd7980304488d65a42ba32/library/core/src/panicking.rs:72:14
  18:     0x7ffbcabc6ff1 - core::panicking::assert_failed_inner::h167cf81470035446
  19:     0x7ffbcdd51f77 - core[a979f648d5a1b559]::panicking::assert_failed::<rustc_ast[cc6975eba0fb785]::token::Delimiter, rustc_ast[cc6975eba0fb785]::token::Delimiter>
  20:     0x7ffbcf06f4c5 - <rustc_parse[5d7049d4dc4888fb]::parser::attr_wrapper::LazyAttrTokenStreamImpl as rustc_ast[cc6975eba0fb785]::tokenstream::ToAttrTokenStream>::to_attr_token_stream
  21:     0x7ffbcf502905 - <rustc_builtin_macros[6b4e0a7826f98660]::cfg_eval::CfgEval as rustc_ast[cc6975eba0fb785]::mut_visit::MutVisitor>::flat_map_item
  22:     0x7ffbcf38dce6 - rustc_builtin_macros[6b4e0a7826f98660]::cfg_eval::cfg_eval
  23:     0x7ffbcf38f47d - <rustc_builtin_macros[6b4e0a7826f98660]::derive::Expander as rustc_expand[41330b176b000abf]::base::MultiItemModifier>::expand::{closure#0}
  24:     0x7ffbceff4270 - <rustc_resolve[e104bfe13d185273]::Resolver as rustc_expand[41330b176b000abf]::base::ResolverExpand>::resolve_derives
  25:     0x7ffbceff3f52 - <rustc_builtin_macros[6b4e0a7826f98660]::derive::Expander as rustc_expand[41330b176b000abf]::base::MultiItemModifier>::expand
  26:     0x7ffbcf1abf4d - <rustc_expand[41330b176b000abf]::expand::MacroExpander>::fully_expand_fragment
  27:     0x7ffbcf1aa56e - <rustc_expand[41330b176b000abf]::expand::MacroExpander>::expand_crate
  28:     0x7ffbcf683ce4 - rustc_interface[f7706cd485e32c9a]::passes::resolver_for_lowering
  29:     0x7ffbcf68316b - rustc_query_impl[98cff80e9247e0c0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[98cff80e9247e0c0]::query_impl::resolver_for_lowering::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b6d0bd77387cd2da]::query::erase::Erased<[u8; 8usize]>>
  30:     0x7ffbcf4abfb3 - rustc_query_system[41316a175d5feef2]::query::plumbing::try_execute_query::<rustc_query_impl[98cff80e9247e0c0]::DynamicConfig<rustc_query_system[41316a175d5feef2]::query::caches::SingleCache<rustc_middle[b6d0bd77387cd2da]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[98cff80e9247e0c0]::plumbing::QueryCtxt, false>
  31:     0x7ffbcf4ab649 - rustc_query_impl[98cff80e9247e0c0]::query_impl::resolver_for_lowering::get_query_non_incr::__rust_end_short_backtrace
  32:     0x7ffbcf4b0d48 - std[41c1d254b4d8ee37]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[f7706cd485e32c9a]::util::run_in_thread_with_globals<rustc_interface[f7706cd485e32c9a]::interface::run_compiler<core[a979f648d5a1b559]::result::Result<(), rustc_span[4150561a1ad8cade]::ErrorGuaranteed>, rustc_driver_impl[fdf22ace854e8ad3]::run_compiler::{closure#1}>::{closure#0}, core[a979f648d5a1b559]::result::Result<(), rustc_span[4150561a1ad8cade]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a979f648d5a1b559]::result::Result<(), rustc_span[4150561a1ad8cade]::ErrorGuaranteed>>
  33:     0x7ffbcf4b0233 - <<std[41c1d254b4d8ee37]::thread::Builder>::spawn_unchecked_<rustc_interface[f7706cd485e32c9a]::util::run_in_thread_with_globals<rustc_interface[f7706cd485e32c9a]::interface::run_compiler<core[a979f648d5a1b559]::result::Result<(), rustc_span[4150561a1ad8cade]::ErrorGuaranteed>, rustc_driver_impl[fdf22ace854e8ad3]::run_compiler::{closure#1}>::{closure#0}, core[a979f648d5a1b559]::result::Result<(), rustc_span[4150561a1ad8cade]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a979f648d5a1b559]::result::Result<(), rustc_span[4150561a1ad8cade]::ErrorGuaranteed>>::{closure#1} as core[a979f648d5a1b559]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  34:     0x7ffbcab70c25 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h36be55b332499764
                               at /rustc/64368d0279c41699fffd7980304488d65a42ba32/library/alloc/src/boxed.rs:2007:9
  35:     0x7ffbcab70c25 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h82dea3e1c390a3bb
                               at /rustc/64368d0279c41699fffd7980304488d65a42ba32/library/alloc/src/boxed.rs:2007:9
  36:     0x7ffbcab70c25 - std::sys::unix::thread::Thread::new::thread_start::h9fb84af69b7425e4
                               at /rustc/64368d0279c41699fffd7980304488d65a42ba32/library/std/src/sys/unix/thread.rs:108:17
  37:     0x7ffbca9139eb - <unknown>
  38:     0x7ffbca9977cc - <unknown>
  39:                0x0 - <unknown>

error: 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.75.0-nightly (64368d027 2023-10-15) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [resolver_for_lowering] getting the resolver for lowering
end of query stack
error: aborting due to 2 previous errors


@matthiaskrgr matthiaskrgr added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Oct 16, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 16, 2023
@matthiaskrgr
Copy link
Member Author

Regression in nightly-2021-04-12
finding bors merge commits
found 9 bors merge commits in the specified range
commit[0] 2021-04-10: Auto merge of #84016 - Aaron1011:new-preexp-tests, r=petrochenkov
commit[1] 2021-04-10: Auto merge of #84023 - Aaron1011:derive-invoc-order, r=petrochenkov
commit[2] 2021-04-11: Auto merge of #84053 - RalfJung:liballoc-miri, r=Manishearth
commit[3] 2021-04-11: Auto merge of #84071 - nagisa:nixos-patching-fix, r=Mark-Simulacrum
commit[4] 2021-04-11: Auto merge of #83806 - JohnTitor:issue-51446, r=estebank
commit[5] 2021-04-11: Auto merge of #82608 - Aaron1011:feature/final-preexp-tts, r=petrochenkov
commit[6] 2021-04-11: Auto merge of #84063 - LingMan:patch-1, r=nagisa
commit[7] 2021-04-11: Auto merge of #81469 - tweksteen:android_set_message, r=m-ou-se
commit[8] 2021-04-11: Auto merge of #83482 - hyd-dev:uwtable, r=nagisa

@mu001999

This comment was marked as outdated.

@fmease fmease added A-parser Area: The parsing of Rust source code to an AST and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Oct 16, 2023
@mu001999 mu001999 removed their assignment Oct 17, 2023
@mu001999
Copy link
Contributor

mu001999 commented Oct 17, 2023

Reduced reproduction:

#[derive(Debug)]
struct Foo {
    #[cfg(all())]
    field: fn(($), $),
}

@mu001999
Copy link
Contributor

@rustbot claim

bors added a commit to rust-lang-ci/rust that referenced this issue Oct 28, 2023
Eat close paren if capture_cfg to avoid unbalanced parens

Fixes rust-lang#116781
@bors bors closed this as completed in 88ae8c9 Oct 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area: The parsing of Rust source code to an AST C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants