rust-lang/rust

ICE `expected statement` --test

matthiaskrgr opened this issue · 1 comments

Code

rustc --test file.rs

#[test]
mod FOO2 {
    fn r#final() {
        #[test] 
        fn fooS(&'late u8) {}
        bar(-16);
    }
}

Meta

rustc --version --verbose:

rustc 1.72.0-nightly (e6d4725c7 2023-06-05)
binary: rustc
commit-hash: e6d4725c76f3b526c74454bc51afdf6daf133506
commit-date: 2023-06-05
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.4

Error output

<output>
Backtrace

error: functions used as tests can not have any arguments
 --> treereduce.out:5:9
  |
5 |         fn fooS(&'late u8) {}
  |         ^^^^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at 'expected statement', compiler/rustc_expand/src/base.rs:174:18
stack backtrace:
   0:     0x7f7491b69ba1 - trace
                               at /rustc/e6d4725c76f3b526c74454bc51afdf6daf133506/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f7491b69ba1 - trace_unsynchronized<std::sys_common::backtrace::_print_fmt::{closure_env#1}>
                               at /rustc/e6d4725c76f3b526c74454bc51afdf6daf133506/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f7491b69ba1 - _print_fmt
                               at /rustc/e6d4725c76f3b526c74454bc51afdf6daf133506/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f7491b69ba1 - fmt
                               at /rustc/e6d4725c76f3b526c74454bc51afdf6daf133506/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f7491bca18f - fmt
                               at /rustc/e6d4725c76f3b526c74454bc51afdf6daf133506/library/core/src/fmt/rt.rs:138:9
   5:     0x7f7491bca18f - write
                               at /rustc/e6d4725c76f3b526c74454bc51afdf6daf133506/library/core/src/fmt/mod.rs:1094:21
   6:     0x7f7491b5ce51 - write_fmt<std::sys::unix::stdio::Stderr>
                               at /rustc/e6d4725c76f3b526c74454bc51afdf6daf133506/library/std/src/io/mod.rs:1713:15
   7:     0x7f7491b699b5 - _print
                               at /rustc/e6d4725c76f3b526c74454bc51afdf6daf133506/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f7491b699b5 - print
                               at /rustc/e6d4725c76f3b526c74454bc51afdf6daf133506/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f7491b6c677 - {closure#1}
  10:     0x7f7491b6c464 - default_hook
                               at /rustc/e6d4725c76f3b526c74454bc51afdf6daf133506/library/std/src/panicking.rs:288:9
  11:     0x7f7494da03eb - rustc_driver_impl[19f317ad306b3be2]::install_ice_hook::{closure#0}
  12:     0x7f7491b6cdbd - call<(&core::panic::panic_info::PanicInfo), (dyn core::ops::function::Fn<(&core::panic::panic_info::PanicInfo), Output=()> + core::marker::Send + core::marker::Sync), alloc::alloc::Global>
                               at /rustc/e6d4725c76f3b526c74454bc51afdf6daf133506/library/alloc/src/boxed.rs:1999:9
  13:     0x7f7491b6cdbd - rust_panic_with_hook
                               at /rustc/e6d4725c76f3b526c74454bc51afdf6daf133506/library/std/src/panicking.rs:709:13
  14:     0x7f7491b6cb11 - {closure#0}
                               at /rustc/e6d4725c76f3b526c74454bc51afdf6daf133506/library/std/src/panicking.rs:595:13
  15:     0x7f7491b69fd6 - __rust_end_short_backtrace<std::panicking::begin_panic_handler::{closure_env#0}, !>
                               at /rustc/e6d4725c76f3b526c74454bc51afdf6daf133506/library/std/src/sys_common/backtrace.rs:151:18
  16:     0x7f7491b6c8a2 - begin_panic_handler
                               at /rustc/e6d4725c76f3b526c74454bc51afdf6daf133506/library/std/src/panicking.rs:593:5
  17:     0x7f7491bc6413 - panic_fmt
                               at /rustc/e6d4725c76f3b526c74454bc51afdf6daf133506/library/core/src/panicking.rs:67:14
  18:     0x7f749393ae62 - <smallvec[816c5806f2fd16a1]::SmallVec<[rustc_ast[991827be689883d]::ast::Stmt; 1usize]> as core[89b1b7d1b31a1e7d]::iter::traits::collect::Extend<rustc_ast[991827be689883d]::ast::Stmt>>::extend::<core[89b1b7d1b31a1e7d]::iter::adapters::map::Map<alloc[bb2455db20450995]::vec::into_iter::IntoIter<rustc_expand[b112cc884c002b49]::base::Annotatable>, <rustc_expand[b112cc884c002b49]::base::Annotatable>::expect_stmt>>
  19:     0x7f7493900d8d - <rustc_expand[b112cc884c002b49]::expand::AstFragmentKind>::expect_from_annotatables::<alloc[bb2455db20450995]::vec::Vec<rustc_expand[b112cc884c002b49]::base::Annotatable>>
  20:     0x7f74938ed201 - <rustc_expand[b112cc884c002b49]::expand::MacroExpander>::fully_expand_fragment
  21:     0x7f7493dd3fb7 - <rustc_expand[b112cc884c002b49]::expand::MacroExpander>::expand_crate
  22:     0x7f7493dd3260 - <rustc_session[23023510f27a6956]::session::Session>::time::<rustc_ast[991827be689883d]::ast::Crate, rustc_interface[e4001d1c190a5888]::passes::configure_and_expand::{closure#1}>
  23:     0x7f7493d87658 - rustc_interface[e4001d1c190a5888]::passes::resolver_for_lowering
  24:     0x7f749429a91a - rustc_query_impl[1543b9ffeb56b6f4]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1543b9ffeb56b6f4]::query_impl::resolver_for_lowering::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ef323c168d9384f4]::query::erase::Erased<[u8; 8usize]>>
  25:     0x7f749429a909 - <rustc_query_impl[1543b9ffeb56b6f4]::query_impl::resolver_for_lowering::dynamic_query::{closure#2} as core[89b1b7d1b31a1e7d]::ops::function::FnOnce<(rustc_middle[ef323c168d9384f4]::ty::context::TyCtxt, ())>>::call_once
  26:     0x7f74941efa7c - rustc_query_system[494966daf0575a9b]::query::plumbing::try_execute_query::<rustc_query_impl[1543b9ffeb56b6f4]::DynamicConfig<rustc_query_system[494966daf0575a9b]::query::caches::SingleCache<rustc_middle[ef323c168d9384f4]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[1543b9ffeb56b6f4]::plumbing::QueryCtxt, false>
  27:     0x7f74947244c7 - rustc_query_impl[1543b9ffeb56b6f4]::query_impl::resolver_for_lowering::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7f749441e413 - <rustc_middle[ef323c168d9384f4]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[19f317ad306b3be2]::run_compiler::{closure#1}::{closure#2}::{closure#2}, &rustc_data_structures[7856cba86f978d37]::steal::Steal<(rustc_middle[ef323c168d9384f4]::ty::ResolverAstLowering, alloc[bb2455db20450995]::rc::Rc<rustc_ast[991827be689883d]::ast::Crate>)>>
  29:     0x7f7493fd9c86 - <rustc_interface[e4001d1c190a5888]::interface::Compiler>::enter::<rustc_driver_impl[19f317ad306b3be2]::run_compiler::{closure#1}::{closure#2}, core[89b1b7d1b31a1e7d]::result::Result<core[89b1b7d1b31a1e7d]::option::Option<rustc_interface[e4001d1c190a5888]::queries::Linker>, rustc_span[c9fd14582bbb5db9]::ErrorGuaranteed>>
  30:     0x7f7493fd7370 - std[4cc418835f9904b9]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[e4001d1c190a5888]::util::run_in_thread_pool_with_globals<rustc_interface[e4001d1c190a5888]::interface::run_compiler<core[89b1b7d1b31a1e7d]::result::Result<(), rustc_span[c9fd14582bbb5db9]::ErrorGuaranteed>, rustc_driver_impl[19f317ad306b3be2]::run_compiler::{closure#1}>::{closure#0}, core[89b1b7d1b31a1e7d]::result::Result<(), rustc_span[c9fd14582bbb5db9]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[89b1b7d1b31a1e7d]::result::Result<(), rustc_span[c9fd14582bbb5db9]::ErrorGuaranteed>>
  31:     0x7f7493fd6b15 - <<std[4cc418835f9904b9]::thread::Builder>::spawn_unchecked_<rustc_interface[e4001d1c190a5888]::util::run_in_thread_pool_with_globals<rustc_interface[e4001d1c190a5888]::interface::run_compiler<core[89b1b7d1b31a1e7d]::result::Result<(), rustc_span[c9fd14582bbb5db9]::ErrorGuaranteed>, rustc_driver_impl[19f317ad306b3be2]::run_compiler::{closure#1}>::{closure#0}, core[89b1b7d1b31a1e7d]::result::Result<(), rustc_span[c9fd14582bbb5db9]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[89b1b7d1b31a1e7d]::result::Result<(), rustc_span[c9fd14582bbb5db9]::ErrorGuaranteed>>::{closure#1} as core[89b1b7d1b31a1e7d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  32:     0x7f7491b772b5 - call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>
                               at /rustc/e6d4725c76f3b526c74454bc51afdf6daf133506/library/alloc/src/boxed.rs:1985:9
  33:     0x7f7491b772b5 - call_once<(), alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>, alloc::alloc::Global>
                               at /rustc/e6d4725c76f3b526c74454bc51afdf6daf133506/library/alloc/src/boxed.rs:1985:9
  34:     0x7f7491b772b5 - thread_start
                               at /rustc/e6d4725c76f3b526c74454bc51afdf6daf133506/library/std/src/sys/unix/thread.rs:108:17
  35:     0x7f749191144b - <unknown>
  36:     0x7f7491994e40 - <unknown>
  37:                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.72.0-nightly (e6d4725c7 2023-06-05) 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 4 previous errors

reduced even more

fn a() {
	#[test] 
	fn b(c) {}
}