Skip to content

[Macro expansion] "failed to process buffered lint" #84195

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

Closed
ZippyMagician opened this issue Apr 14, 2021 · 3 comments · Fixed by #84222
Closed

[Macro expansion] "failed to process buffered lint" #84195

ZippyMagician opened this issue Apr 14, 2021 · 3 comments · Fixed by #84222
Assignees
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ZippyMagician
Copy link

Code

After testing, it's this macro here:

macro_rules! len {
    () => { 0 };
    ($item:literal) => { 1 };
    ($item:literal, $($extras:literal),*) => { 1 + len!($($extras),*); }
}

The semicolon in the third variant causes the error when used in a context such as:

macro_rules! operators {
    ($($chr:literal : $prec:literal; $left_rank:literal - $right_rank:literal),*) => {
        ...
            pub operators: [String; len!($($chr),*)] // This line here
        ...
    };
}

Meta

Note that prior to updating I was using 1.49.0, which did not error.
This errors on Nightly and Stable, I tested both (cargo +nightly check and cargo check both have the same result). Removing the semicolon causes the project to build fine and function as it did before updating.

rustc --version --verbose:

rustc 1.51.0 (2fd73fabe 2021-03-23)
binary: rustc
commit-hash: 2fd73fabe469357a12c2c974c140f67e7cdd76d0
commit-date: 2021-03-23
host: x86_64-unknown-linux-gnu
release: 1.51.0
LLVM version: 11.0.1

Error output

This error is repeated over and over again before the notification saying to submit the bug report

error: internal compiler error: failed to process buffered lint here
  --> src/utils/consts.rs:39:70
   |
39 |       ($item:literal, $($extras:literal),*) => { 1 + len!($($extras),*); }
   |                                                                        ^
...
73 | / operators! {
74 | |     '.': 11; 1-1,
75 | |     '^': 10; 1-1,
76 | |     '*': 9; 1-1, '/': 9; 1-1,
...  |
88 | |     ':': 0; 1-1
89 | | }
   | |_- in this macro invocation
   |
   = note: delayed at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/compiler/rustc_lint/src/early.rs:393:18
   = note: this error: internal compiler error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
Backtrace

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1018:13
stack backtrace:
   0:     0x7f8da84d6320 - std::backtrace_rs::backtrace::libunwind::trace::hdcf4f90f85129e83
                               at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7f8da84d6320 - std::backtrace_rs::backtrace::trace_unsynchronized::h2669e30cb82f6732
                               at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f8da84d6320 - std::sys_common::backtrace::_print_fmt::hfbda19e17f6db318
                               at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f8da84d6320 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1a8751bf59281272
                               at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7f8da854767f - core::fmt::write::h7aa6cd0067dca82a
                               at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/core/src/fmt/mod.rs:1094:17
   5:     0x7f8da84cab45 - std::io::Write::write_fmt::hd7dd3a1df9b6befb
                               at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/io/mod.rs:1580:15
   6:     0x7f8da84d9f0b - std::sys_common::backtrace::_print::h551e9ec8a9fa8106
                               at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7f8da84d9f0b - std::sys_common::backtrace::print::ha4b1c5e95fa040b3
                               at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7f8da84d9f0b - std::panicking::default_hook::{{closure}}::h0b34c9ab7fb9f857
                               at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/panicking.rs:208:50
   9:     0x7f8da84d99ed - std::panicking::default_hook::h3067e8318decd17a
                               at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/panicking.rs:225:9
  10:     0x7f8da8c9bd4d - rustc_driver::report_ice::h0582ed2432eb0d01
  11:     0x7f8da84da620 - std::panicking::rust_panic_with_hook::h81b8facc50f34daa
                               at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/panicking.rs:595:17
  12:     0x7f8da84da1f7 - std::panicking::begin_panic_handler::{{closure}}::ha376ab85d95a000e
                               at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/panicking.rs:497:13
  13:     0x7f8da84d67dc - std::sys_common::backtrace::__rust_end_short_backtrace::h6795c8afdd1a77e6
                               at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/sys_common/backtrace.rs:141:18
  14:     0x7f8da84da159 - rust_begin_unwind
                               at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/panicking.rs:493:5
  15:     0x7f8da84a607b - std::panicking::begin_panic_fmt::hf43a0025042538e2
                               at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/panicking.rs:435:5
  16:     0x7f8dab1066e9 - rustc_errors::HandlerInner::flush_delayed::ha043eb844eec51b4
  17:     0x7f8dab1051db - <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop::h20e6dc4c247e2972
  18:     0x7f8daa77faa6 - core::ptr::drop_in_place<rustc_session::parse::ParseSess>::ha7b7bc007b685a43
  19:     0x7f8daa78e341 - <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop::h0df1456cb7f7b3c5
  20:     0x7f8daa7747ed - core::ptr::drop_in_place<rustc_interface::interface::Compiler>::h4b05c244ac5fa340
  21:     0x7f8daa7740ed - rustc_span::with_source_map::h67cb68e15a9ffc39
  22:     0x7f8daa775f31 - rustc_interface::interface::create_compiler_and_run::he6a465670788f848
  23:     0x7f8daa78f6b8 - scoped_tls::ScopedKey<T>::set::h8de4c07d6e313e7a
  24:     0x7f8daa78fbd3 - std::sys_common::backtrace::__rust_begin_short_backtrace::h953d4096b984a1d5
  25:     0x7f8daa793505 - core::ops::function::FnOnce::call_once{{vtable.shim}}::hf2d8af4e3cccbbb1
  26:     0x7f8da84ea513 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3aa31cb6360b59d9
                               at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/alloc/src/boxed.rs:1546:9
  27:     0x7f8da84ea513 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h7719d3c7c5841461
                               at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/alloc/src/boxed.rs:1546:9
  28:     0x7f8da84ea513 - std::sys::unix::thread::Thread::new::thread_start::hfbe13ead469fd0bc
                               at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/sys/unix/thread.rs:71:17
  29:     0x7f8da8415609 - start_thread
  30:     0x7f8da8329293 - clone
  31:                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.53.0-nightly (132b4e5d1 2021-04-13) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
end of query stack

@ZippyMagician ZippyMagician added 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. labels Apr 14, 2021
@jyn514 jyn514 added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) regression-from-stable-to-stable Performance or correctness regression from one stable version to another. labels Apr 14, 2021
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Apr 14, 2021
@Aaron1011 Aaron1011 self-assigned this Apr 14, 2021
@apiraino
Copy link
Contributor

Assigning priority as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Apr 15, 2021
@Aaron1011
Copy link
Member

Aaron1011 commented Apr 15, 2021

@ZippyMagician: Can you share the original repository, or provide a self-contained reproduction of the issue?

@ZippyMagician
Copy link
Author

@Aaron1011 here is one I got to error in the same way:

macro_rules! len {
    () => { 0 };
    ($item:literal) => { 1 };
    ($item:literal, $($extras:literal),*) => { 1 + len!($($extras),*); }
}

macro_rules! slice {
    ($($item:literal),*) => {
        const SIZED: [&str; len!($($item),*)] = [$($item),*];
    }
}

slice!["first", "second", "third", "last"];

fn main() {
    println!("{:?}", SIZED);
}

I also noticed this warning that I believe I failed to include in the original issue:

warning: Error finalizing incremental compilation session directory `~/Projects/rust/bug_report/target/debug/incremental/bug_report-33rm2tncuoqcs/s-fxpjcgkcte-lqvmgv-working`: No such file or directory (os error 2)

If I remove the semicolon, this warning does not show up, and the program works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. 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.

5 participants