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 parse_attribute called in non-attribute position #5729

Closed
matthiaskrgr opened this issue Mar 30, 2023 · 2 comments · Fixed by #5732
Closed

ICE parse_attribute called in non-attribute position #5729

matthiaskrgr opened this issue Mar 30, 2023 · 2 comments · Fixed by #5732
Labels
a-macros bug Panic, non-idempotency, invalid code, etc.

Comments

@matthiaskrgr
Copy link
Member

cfg_if::cfg_if! {
    if {
    } else if #(&cpus) {
    } else [libc::CTL_HW, libc::HW_NCPU, 0, 0]
}
thread 'main' panicked at 'parse_attribute called in non-attribute position', compiler/rustc_parse/src/parser/attr.rs:122:13
stack backtrace:
   0:     0x7f29d1f65e8a - std::backtrace_rs::backtrace::libunwind::trace::hc07ec51854030801
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f29d1f65e8a - std::backtrace_rs::backtrace::trace_unsynchronized::hd5249f53d09c2c41
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f29d1f65e8a - std::sys_common::backtrace::_print_fmt::h7a58bb30aee44196
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f29d1f65e8a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4f2b7c295e3f8019
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f29d1fc9e6f - core::fmt::write::h10777037b979b8b8
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/core/src/fmt/mod.rs:1254:17
   5:     0x7f29d1f58ac5 - std::io::Write::write_fmt::he1dc4aa4bd2563db
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/io/mod.rs:1698:15
   6:     0x7f29d1f65c55 - std::sys_common::backtrace::_print::h163c7799d3150ce8
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f29d1f65c55 - std::sys_common::backtrace::print::h3cf13564ddfd5c0e
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f29d1f688fe - std::panicking::default_hook::{{closure}}::h999811fec35f64bf
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/panicking.rs:269:22
   9:     0x7f29d1f686a5 - std::panicking::default_hook::he182d48ca482e8b2
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/panicking.rs:288:9
  10:     0x7f29d1f68f6e - std::panicking::rust_panic_with_hook::h2bc066147eaf9845
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/panicking.rs:690:13
  11:     0x7f29d1f68e22 - std::panicking::begin_panic_handler::{{closure}}::h1e4368c427832fe9
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/panicking.rs:579:13
  12:     0x7f29d1f662f6 - std::sys_common::backtrace::__rust_end_short_backtrace::h5466480ef33b438e
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/sys_common/backtrace.rs:150:18
  13:     0x7f29d1f68bc2 - rust_begin_unwind
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/panicking.rs:577:5
  14:     0x7f29d1fc6273 - core::panicking::panic_fmt::ha28b6d803d12671b
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/core/src/panicking.rs:67:14
  15:     0x7f29d3cfc986 - <rustc_parse[b1dd6c1f496ef2d0]::parser::Parser>::collect_tokens_trailing_token::<rustc_ast[b583ee7534cdfdf7]::ast::Attribute, <rustc_parse[b1dd6c1f496ef2d0]::parser::Parser>::collect_tokens_no_attrs<rustc_ast[b583ee7534cdfdf7]::ast::Attribute, <rustc_parse[b1dd6c1f496ef2d0]::parser::Parser>::parse_attribute::{closure#0}>::{closure#0}>
  16:     0x7f29d5a12f95 - <rustc_parse[b1dd6c1f496ef2d0]::parser::Parser>::parse_attribute
  17:     0x55e3b79ae66d - rustfmt_nightly[e3445ded4feb3b46]::parse::macros::cfg_if::parse_cfg_if_inner
  18:     0x55e3b7a5c219 - <rustfmt_nightly[e3445ded4feb3b46]::modules::visitor::CfgIfVisitor as rustc_ast[b583ee7534cdfdf7]::visit::Visitor>::visit_mac_call
  19:     0x55e3b79ee2f1 - rustc_ast[b583ee7534cdfdf7]::visit::walk_item::<rustfmt_nightly[e3445ded4feb3b46]::modules::visitor::CfgIfVisitor>
  20:     0x55e3b7a8458d - <rustfmt_nightly[e3445ded4feb3b46]::modules::ModResolver>::visit_cfg_if
  21:     0x55e3b7a849c6 - <rustfmt_nightly[e3445ded4feb3b46]::modules::ModResolver>::visit_mod_from_ast
  22:     0x55e3b7a84015 - <rustfmt_nightly[e3445ded4feb3b46]::modules::ModResolver>::visit_crate
  23:     0x55e3b7942533 - rustfmt_nightly[e3445ded4feb3b46]::formatting::format_project::<rustfmt_nightly[e3445ded4feb3b46]::Session<std[6ff7f37a454f70cc]::io::stdio::Stdout>>
  24:     0x55e3b793f9d0 - <scoped_tls[abd3470abb840dd8]::ScopedKey<rustc_span[e810f079a636b72c]::SessionGlobals>>::with::<<rustfmt_nightly[e3445ded4feb3b46]::Session<std[6ff7f37a454f70cc]::io::stdio::Stdout>>::format_input_inner::{closure#0}, core[a19e7c0c634483f1]::result::Result<rustfmt_nightly[e3445ded4feb3b46]::FormatReport, rustfmt_nightly[e3445ded4feb3b46]::ErrorKind>>
  25:     0x55e3b793ca7f - <scoped_tls[abd3470abb840dd8]::ScopedKey<rustc_span[e810f079a636b72c]::SessionGlobals>>::set::<rustc_span[e810f079a636b72c]::create_session_if_not_set_then<core[a19e7c0c634483f1]::result::Result<rustfmt_nightly[e3445ded4feb3b46]::FormatReport, rustfmt_nightly[e3445ded4feb3b46]::ErrorKind>, <rustfmt_nightly[e3445ded4feb3b46]::Session<std[6ff7f37a454f70cc]::io::stdio::Stdout>>::format_input_inner::{closure#0}>::{closure#0}, core[a19e7c0c634483f1]::result::Result<rustfmt_nightly[e3445ded4feb3b46]::FormatReport, rustfmt_nightly[e3445ded4feb3b46]::ErrorKind>>
  26:     0x55e3b7965650 - <rustfmt_nightly[e3445ded4feb3b46]::Session<std[6ff7f37a454f70cc]::io::stdio::Stdout>>::format
  27:     0x55e3b7954b05 - rustfmt[fd29d8685e71f599]::format_and_emit_report::<std[6ff7f37a454f70cc]::io::stdio::Stdout>
  28:     0x55e3b7963b89 - <rustfmt_nightly[e3445ded4feb3b46]::Session<std[6ff7f37a454f70cc]::io::stdio::Stdout>>::override_config::<rustfmt[fd29d8685e71f599]::format::{closure#0}, ()>
  29:     0x55e3b7953865 - rustfmt[fd29d8685e71f599]::execute
  30:     0x55e3b7951221 - rustfmt[fd29d8685e71f599]::main
  31:     0x55e3b7964483 - std[6ff7f37a454f70cc]::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>
  32:     0x55e3b7962cc9 - std[6ff7f37a454f70cc]::rt::lang_start::<()>::{closure#0}
  33:     0x7f29d1f4969e - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hd8ec26e1d0256733
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/core/src/ops/function.rs:287:13
  34:     0x7f29d1f4969e - std::panicking::try::do_call::ha93a022fbffe13f1
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/panicking.rs:485:40
  35:     0x7f29d1f4969e - std::panicking::try::hb1493baa50505ff7
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/panicking.rs:449:19
  36:     0x7f29d1f4969e - std::panic::catch_unwind::h68d19a9efbc50ca2
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/panic.rs:140:14
  37:     0x7f29d1f4969e - std::rt::lang_start_internal::{{closure}}::hfefbc424423bf0ab
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/rt.rs:148:48
  38:     0x7f29d1f4969e - std::panicking::try::do_call::h33a3e76f78055d3b
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/panicking.rs:485:40
  39:     0x7f29d1f4969e - std::panicking::try::hf16a19af84a23805
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/panicking.rs:449:19
  40:     0x7f29d1f4969e - std::panic::catch_unwind::hfd39d2618b0c9350
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/panic.rs:140:14
  41:     0x7f29d1f4969e - std::rt::lang_start_internal::h8eb39434a671d889
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/rt.rs:148:20
  42:     0x55e3b79558a5 - main
  43:     0x7f29d1bc3790 - <unknown>
  44:     0x7f29d1bc384a - __libc_start_main
  45:     0x55e3b7938c59 - <unknown>
  46:                0x0 - <unknown>
@ytmimi ytmimi added bug Panic, non-idempotency, invalid code, etc. a-macros labels Mar 30, 2023
@matthiaskrgr
Copy link
Member Author

Probably related:

cfg_if::cfg_if! { if # }
error: internal compiler error: the following error was constructed but not emitted

error: expected one of `!` or `[`, found `<eof>`
 --> /tmp/im4/treereduce.out:1:22
  |
1 | cfg_if::cfg_if! { if # }
  |                      ^ expected one of `!` or `[`

thread 'main' panicked at 'error was constructed but not emitted', compiler/rustc_errors/src/diagnostic_builder.rs:780:21
stack backtrace:
   0: rust_begin_unwind
             at /rustc/3a8a131e9509c478ece1c58fe0ea2d49463d2300/library/std/src/panicking.rs:577:5
   1: core::panicking::panic_fmt
             at /rustc/3a8a131e9509c478ece1c58fe0ea2d49463d2300/library/core/src/panicking.rs:67:14
   2: <rustc_errors::diagnostic_builder::DiagnosticBuilderInner as core::ops::drop::Drop>::drop
   3: rustfmt_nightly::parse::macros::cfg_if::parse_cfg_if_inner
   4: <rustfmt_nightly::modules::visitor::CfgIfVisitor as rustc_ast::visit::Visitor>::visit_mac_call
   5: rustc_ast::visit::walk_item::<rustfmt_nightly::modules::visitor::CfgIfVisitor>
   6: <rustfmt_nightly::modules::ModResolver>::visit_cfg_if
   7: <rustfmt_nightly::modules::ModResolver>::visit_mod_from_ast
   8: <rustfmt_nightly::modules::ModResolver>::visit_crate
   9: rustfmt_nightly::formatting::format_project::<rustfmt_nightly::Session<std::io::stdio::Stdout>>
  10: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::with::<<rustfmt_nightly::Session<std::io::stdio::Stdout>>::format_input_inner::{closure#0}, core::result::Result<rustfmt_nightly::FormatReport, rustfmt_nightly::ErrorKind>>
  11: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_span::create_session_if_not_set_then<core::result::Result<rustfmt_nightly::FormatReport, rustfmt_nightly::ErrorKind>, <rustfmt_nightly::Session<std::io::stdio::Stdout>>::format_input_inner::{closure#0}>::{closure#0}, core::result::Result<rustfmt_nightly::FormatReport, rustfmt_nightly::ErrorKind>>
  12: <rustfmt_nightly::Session<std::io::stdio::Stdout>>::format
  13: rustfmt::format_and_emit_report::<std::io::stdio::Stdout>
  14: <rustfmt_nightly::Session<std::io::stdio::Stdout>>::override_config::<rustfmt::format::{closure#0}, ()>
  15: rustfmt::execute
  16: rustfmt::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace

@ytmimi
Copy link
Contributor

ytmimi commented Apr 3, 2023

Probably related:

cfg_if::cfg_if! { if # }

I believe this particular case was resolved by #5731, since the error has to do with constructing but not emitting the diagnostic error. Additionally, I'm unable to reproduce this with the latest master a3b2bfc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-macros bug Panic, non-idempotency, invalid code, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants