Skip to content

ICE: not a tail expression #121647

Closed
Closed

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

macro_rules! the_macro {
    ( $foo:stmt ; $bar:stmt ; ) => {
        #[cfg()]
        $foo

        #[cfg(bar)]
        $bar
    };
}

fn the_function() {
    the_macro!( (); (); );
}

original:

macro_rules! the_macro {
    ( $foo:stmt ; $bar:stmt ; ) => {
        #[cfg(incomplete_features)]
        $foo
        
        #[cfg(bar)]
        $bar
    };
}

fn the_function() {
    the_macro!( (); (); );
}

Version information

rustc 1.78.0-nightly (b79db437d 2024-02-26)
binary: rustc
commit-hash: b79db437dccd496948bb1819d36ed51598563a98
commit-date: 2024-02-26
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --crate-type=lib

Program output

warning: function `the_function` is never used
  --> /tmp/icemaker_global_tempdir.fJLXUZMXByi7/rustc_testrunner_tmpdir_reporting.upzqZTcLzog2/mvce.rs:11:4
   |
11 | fn the_function() {
   |    ^^^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: 1 warning emitted

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: not a tail expression
  --> /tmp/icemaker_global_tempdir.fJLXUZMXByi7/rustc_testrunner_tmpdir_reporting.upzqZTcLzog2/mvce.rs:12:17
   |
12 |     the_macro!( (); (); );
   |                 ^^
   |
note: delayed at compiler/rustc_parse/src/parser/diagnostics.rs:818:43
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxt>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         3: <rustc_parse::parser::Parser>::attr_on_non_tail_expr
         4: <rustc_parse::parser::Parser>::parse_full_stmt
         5: <rustc_expand::mbe::macro_rules::ParserAnyMacro>::make
         6: <rustc_expand::expand::MacroExpander>::fully_expand_fragment
         7: <rustc_expand::expand::MacroExpander>::expand_crate
         8: rustc_interface::passes::resolver_for_lowering
         9: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::resolver_for_lowering::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        10: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        11: rustc_query_impl::query_impl::resolver_for_lowering::get_query_non_incr::__rust_end_short_backtrace
        12: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
        13: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
        14: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        15: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/b79db437dccd496948bb1819d36ed51598563a98/library/alloc/src/boxed.rs:2016:9
        16: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/b79db437dccd496948bb1819d36ed51598563a98/library/alloc/src/boxed.rs:2016:9
        17: std::sys::pal::unix::thread::Thread::new::thread_start
                   at /rustc/b79db437dccd496948bb1819d36ed51598563a98/library/std/src/sys/pal/unix/thread.rs:108:17
        18: <unknown>
        19: <unknown>
  --> /tmp/icemaker_global_tempdir.fJLXUZMXByi7/rustc_testrunner_tmpdir_reporting.upzqZTcLzog2/mvce.rs:12:17
   |
12 |     the_macro!( (); (); );
   |                 ^^

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.78.0-nightly (b79db437d 2024-02-26) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -Z dump-mir-dir=dir

query stack during panic:
end of query stack

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on Feb 26, 2024
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Feb 26, 2024
  3. matthiaskrgr commented on Feb 26, 2024

    @matthiaskrgr
    MemberAuthor

    It seems the not a tail expression pops up since #120586 cc @ShE3py

    The code starts ICEing in general since #117988 cc @estebank

  4. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    A-parserArea: The lexing & parsing of Rust source code to an AST
    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
    S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issue
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    and removed
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Feb 26, 2024
  5. ShE3py commented on Feb 26, 2024

    @ShE3py
    Contributor

    @rustbot claim

  6. added a commit that references this issue on Feb 26, 2024
    ec5c5b7
  7. added a commit that references this issue on Feb 27, 2024
    d9e5d74
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-parserArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions