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 with multiple attributes on a test function #100263

Open
HaimYosefHaim opened this issue Aug 8, 2022 · 1 comment
Open

ICE with multiple attributes on a test function #100263

HaimYosefHaim opened this issue Aug 8, 2022 · 1 comment
Labels
C-bug Category: This is a bug. F-custom_test_frameworks `#![feature(custom_test_frameworks)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@HaimYosefHaim
Copy link

HaimYosefHaim commented Aug 8, 2022

Error happened when I added the test_case attribute from the test-case crate without adding the required use.
Error does not occur if I replace test_case with a different non-existing attribute.
Seems to have something to do with the std::prelude::v1::test_case macro.

Code

main.rs -

#[cfg(test)]
mod tests {
    #[test_case]
    #[tokio::test]
    fn foo() {}
}

Cargo.toml -

[dev-dependencies]
tokio = { version = "*", features = ["macros"] }

Meta

rustc --version --verbose:

rustc 1.62.1 (e092d0b6b 2022-07-16)
binary: rustc
commit-hash: e092d0b6b43f2de967af0887873151bb1c0b18d3
commit-date: 2022-07-16
host: x86_64-unknown-linux-gnu
release: 1.62.1
LLVM version: 14.0.5

Same error occurs on the latest nightly.

Error output

error[E0658]: use of unstable library feature 'custom_test_frameworks': custom test frameworks are an unstable feature
 --> src/main.rs:3:7
  |
3 |     #[test_case]
  |       ^^^^^^^^^
  |
  = note: see issue #50297 <https://github.com/rust-lang/rust/issues/50297> for more information

thread 'rustc' panicked at 'attribute is missing tokens: Attribute { kind: Normal(AttrItem { path: Path { span: src/main.rs:3:5: 3:17 (#4), segments: [PathSegment { ident: rustc_test_marker#4, id: NodeId(4294967040), args: None }], tokens: None }, args: Empty, tokens: None }, None), id: AttrId(38), style: Outer, span: src/main.rs:3:5: 3:17 (#4) }', compiler/rustc_ast/src/attr/mod.rs:305:36
stack backtrace:
   0:     0x7f11250aefbd - std::backtrace_rs::backtrace::libunwind::trace::h8e036432725b1c57
                               at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f11250aefbd - std::backtrace_rs::backtrace::trace_unsynchronized::h4f83092254c85869
                               at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f11250aefbd - std::sys_common::backtrace::_print_fmt::h9728b5e056a3ece3
                               at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f11250aefbd - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h48bb4bd2928827d2
                               at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f112510ac4c - core::fmt::write::h909e69a2c24f44cc
                               at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/fmt/mod.rs:1196:17
   5:     0x7f11250a0731 - std::io::Write::write_fmt::h7f4b8ab8af89e9ef
                               at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/io/mod.rs:1654:15
   6:     0x7f11250b1cd5 - std::sys_common::backtrace::_print::hff4838ebf14a2171
                               at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f11250b1cd5 - std::sys_common::backtrace::print::h2499280374189ad9
                               at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f11250b1cd5 - std::panicking::default_hook::{{closure}}::h8b270fc55eeb284e
                               at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:295:22
   9:     0x7f11250b1949 - std::panicking::default_hook::h3217e229d6e9d13c
                               at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:314:9
  10:     0x7f1125876571 - rustc_driver[b4654d3c4d4292dd]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f11250b24a6 - std::panicking::rust_panic_with_hook::h9acb8048b738d2e0
                               at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:702:17
  12:     0x7f11250b22a7 - std::panicking::begin_panic_handler::{{closure}}::h70f3b839526af6dc
                               at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:588:13
  13:     0x7f11250af474 - std::sys_common::backtrace::__rust_end_short_backtrace::h1ecf2cee857fbe0a
                               at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7f11250b1fd9 - rust_begin_unwind
                               at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:584:5
  15:     0x7f1125077253 - core::panicking::panic_fmt::h9f8393e7fd56d655
                               at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:142:14
  16:     0x7f11281c1d29 - <&mut <rustc_ast[c9de826133865101]::tokenstream::AttrAnnotatedTokenStream>::to_tokenstream::{closure#0} as core[dbea6f494faa966e]::ops::function::FnOnce<(&(rustc_ast[c9de826133865101]::tokenstream::AttrAnnotatedTokenTree, rustc_ast[c9de826133865101]::tokenstream::Spacing),)>>::call_once
  17:     0x7f11278b3c5e - <alloc[9c8de9aaaf44fea]::vec::Vec<(rustc_ast[c9de826133865101]::tokenstream::TokenTree, rustc_ast[c9de826133865101]::tokenstream::Spacing)> as alloc[9c8de9aaaf44fea]::vec::spec_from_iter::SpecFromIter<(rustc_ast[c9de826133865101]::tokenstream::TokenTree, rustc_ast[c9de826133865101]::tokenstream::Spacing), core[dbea6f494faa966e]::iter::adapters::flatten::FlatMap<core[dbea6f494faa966e]::slice::iter::Iter<(rustc_ast[c9de826133865101]::tokenstream::AttrAnnotatedTokenTree, rustc_ast[c9de826133865101]::tokenstream::Spacing)>, smallvec[5b0714cf081bc802]::IntoIter<[(rustc_ast[c9de826133865101]::tokenstream::TokenTree, rustc_ast[c9de826133865101]::tokenstream::Spacing); 1usize]>, <rustc_ast[c9de826133865101]::tokenstream::AttrAnnotatedTokenStream>::to_tokenstream::{closure#0}>>>::from_iter
  18:     0x7f11281c2053 - <rustc_ast[c9de826133865101]::tokenstream::AttrAnnotatedTokenStream>::to_tokenstream
  19:     0x7f112801d42f - rustc_parse[a5896d463c55fe93]::prepend_attrs
  20:     0x7f1127fbea34 - rustc_parse[a5896d463c55fe93]::to_token_stream::<rustc_ast[c9de826133865101]::ptr::P<rustc_ast[c9de826133865101]::ast::Item>>
  21:     0x7f11274b2910 - <rustc_expand[4b90c4bd066cda8b]::expand::MacroExpander>::fully_expand_fragment
  22:     0x7f1127fae17e - <rustc_expand[4b90c4bd066cda8b]::expand::MacroExpander>::expand_crate
  23:     0x7f11279165e4 - <rustc_session[a2f3190f51a45935]::session::Session>::time::<core[dbea6f494faa966e]::result::Result<rustc_ast[c9de826133865101]::ast::Crate, rustc_errors[4633ef6e4608f9c1]::ErrorGuaranteed>, rustc_interface[9f664daa3237129]::passes::configure_and_expand::{closure#1}>
  24:     0x7f112790f893 - rustc_interface[9f664daa3237129]::passes::configure_and_expand
  25:     0x7f1127936a17 - <rustc_interface[9f664daa3237129]::queries::Queries>::expansion
  26:     0x7f11278df629 - <rustc_interface[9f664daa3237129]::interface::Compiler>::enter::<rustc_driver[b4654d3c4d4292dd]::run_compiler::{closure#1}::{closure#2}, core[dbea6f494faa966e]::result::Result<core[dbea6f494faa966e]::option::Option<rustc_interface[9f664daa3237129]::queries::Linker>, rustc_errors[4633ef6e4608f9c1]::ErrorGuaranteed>>
  27:     0x7f112790809f - rustc_span[1d0b4d44d1f53955]::with_source_map::<core[dbea6f494faa966e]::result::Result<(), rustc_errors[4633ef6e4608f9c1]::ErrorGuaranteed>, rustc_interface[9f664daa3237129]::interface::create_compiler_and_run<core[dbea6f494faa966e]::result::Result<(), rustc_errors[4633ef6e4608f9c1]::ErrorGuaranteed>, rustc_driver[b4654d3c4d4292dd]::run_compiler::{closure#1}>::{closure#1}>
  28:     0x7f11278e0374 - rustc_interface[9f664daa3237129]::interface::create_compiler_and_run::<core[dbea6f494faa966e]::result::Result<(), rustc_errors[4633ef6e4608f9c1]::ErrorGuaranteed>, rustc_driver[b4654d3c4d4292dd]::run_compiler::{closure#1}>
  29:     0x7f11278ddc12 - <scoped_tls[ab1554bfb6e7ab15]::ScopedKey<rustc_span[1d0b4d44d1f53955]::SessionGlobals>>::set::<rustc_interface[9f664daa3237129]::interface::run_compiler<core[dbea6f494faa966e]::result::Result<(), rustc_errors[4633ef6e4608f9c1]::ErrorGuaranteed>, rustc_driver[b4654d3c4d4292dd]::run_compiler::{closure#1}>::{closure#0}, core[dbea6f494faa966e]::result::Result<(), rustc_errors[4633ef6e4608f9c1]::ErrorGuaranteed>>
  30:     0x7f11278f4dff - std[8996aeeb2a45fe64]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[9f664daa3237129]::util::run_in_thread_pool_with_globals<rustc_interface[9f664daa3237129]::interface::run_compiler<core[dbea6f494faa966e]::result::Result<(), rustc_errors[4633ef6e4608f9c1]::ErrorGuaranteed>, rustc_driver[b4654d3c4d4292dd]::run_compiler::{closure#1}>::{closure#0}, core[dbea6f494faa966e]::result::Result<(), rustc_errors[4633ef6e4608f9c1]::ErrorGuaranteed>>::{closure#0}, core[dbea6f494faa966e]::result::Result<(), rustc_errors[4633ef6e4608f9c1]::ErrorGuaranteed>>
  31:     0x7f11278f4f39 - <<std[8996aeeb2a45fe64]::thread::Builder>::spawn_unchecked_<rustc_interface[9f664daa3237129]::util::run_in_thread_pool_with_globals<rustc_interface[9f664daa3237129]::interface::run_compiler<core[dbea6f494faa966e]::result::Result<(), rustc_errors[4633ef6e4608f9c1]::ErrorGuaranteed>, rustc_driver[b4654d3c4d4292dd]::run_compiler::{closure#1}>::{closure#0}, core[dbea6f494faa966e]::result::Result<(), rustc_errors[4633ef6e4608f9c1]::ErrorGuaranteed>>::{closure#0}, core[dbea6f494faa966e]::result::Result<(), rustc_errors[4633ef6e4608f9c1]::ErrorGuaranteed>>::{closure#1} as core[dbea6f494faa966e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  32:     0x7f11250bc3c3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h191d5c5ea3edb31d
                               at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/alloc/src/boxed.rs:1872:9
  33:     0x7f11250bc3c3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h42ef7cb2ae640a31
                               at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/alloc/src/boxed.rs:1872:9
  34:     0x7f11250bc3c3 - std::sys::unix::thread::Thread::new::thread_start::he47f7169665dab60
                               at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/sys/unix/thread.rs:108:17
  35:     0x7f1124fdb609 - start_thread
                               at /build/glibc-SzIz7B/glibc-2.31/nptl/pthread_create.c:477:8
  36:     0x7f1124ef4133 - clone
                               at /build/glibc-SzIz7B/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95
  37:                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.62.1 (e092d0b6b 2022-07-16) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
end of query stack
For more information about this error, try `rustc --explain E0658`.
error: could not compile `ice` due to previous error
Backtrace

thread 'rustc' panicked at 'attribute is missing tokens: Attribute { kind: Normal(AttrItem { path: Path { span: src/main.rs:3:5: 3:17 (#4), segments: [PathSegment { ident: rustc_test_marker#4, id: NodeId(4294967040), args: None }], tokens: None }, args: Empty, tokens: None }, None), id: AttrId(38), style: Outer, span: src/main.rs:3:5: 3:17 (#4) }', compiler/rustc_ast/src/attr/mod.rs:305:36
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:142:14
   2: <&mut <rustc_ast::tokenstream::AttrAnnotatedTokenStream>::to_tokenstream::{closure#0} as core::ops::function::FnOnce<(&(rustc_ast::tokenstream::AttrAnnotatedTokenTree, rustc_ast::tokenstream::Spacing),)>>::call_once
   3: <alloc::vec::Vec<(rustc_ast::tokenstream::TokenTree, rustc_ast::tokenstream::Spacing)> as alloc::vec::spec_from_iter::SpecFromIter<(rustc_ast::tokenstream::TokenTree, rustc_ast::tokenstream::Spacing), core::iter::adapters::flatten::FlatMap<core::slice::iter::Iter<(rustc_ast::tokenstream::AttrAnnotatedTokenTree, rustc_ast::tokenstream::Spacing)>, smallvec::IntoIter<[(rustc_ast::tokenstream::TokenTree, rustc_ast::tokenstream::Spacing); 1]>, <rustc_ast::tokenstream::AttrAnnotatedTokenStream>::to_tokenstream::{closure#0}>>>::from_iter
   4: <rustc_ast::tokenstream::AttrAnnotatedTokenStream>::to_tokenstream
   5: rustc_parse::prepend_attrs
   6: rustc_parse::to_token_stream::<rustc_ast::ptr::P<rustc_ast::ast::Item>>
   7: <rustc_expand::expand::MacroExpander>::fully_expand_fragment
   8: <rustc_expand::expand::MacroExpander>::expand_crate
   9: <rustc_session::session::Session>::time::<core::result::Result<rustc_ast::ast::Crate, rustc_errors::ErrorGuaranteed>, rustc_interface::passes::configure_and_expand::{closure#1}>
  10: rustc_interface::passes::configure_and_expand
  11: <rustc_interface::queries::Queries>::expansion
  12: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorGuaranteed>>
  13: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
  14: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>
  15: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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.62.1 (e092d0b6b 2022-07-16) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
end of query stack
For more information about this error, try `rustc --explain E0658`.
error: could not compile `ice` due to previous error

@HaimYosefHaim HaimYosefHaim 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 Aug 8, 2022
@Enselic
Copy link
Member

Enselic commented Aug 1, 2023

@rustbot label F-custom_test_frameworks requires-nightly

@rustbot rustbot added F-custom_test_frameworks `#![feature(custom_test_frameworks)]` requires-nightly This issue requires a nightly compiler in some way. labels Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-custom_test_frameworks `#![feature(custom_test_frameworks)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. 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.

3 participants