Skip to content

ICE: "expected statement" with rustc --test #109816

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
matthiaskrgr opened this issue Mar 30, 2023 · 5 comments · Fixed by #110035
Closed

ICE: "expected statement" with rustc --test #109816

matthiaskrgr opened this issue Mar 30, 2023 · 5 comments · Fixed by #110035
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

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Mar 30, 2023

Summary

#[crate_type ="lib"]

#[test]
fn align_offset_weird_strides() {
    #[test]
    struct A5(u32, u8);
}

If I run this through RUST_BACKTRACE=full cargo clippy --fix --allow-dirty, I get

    Checking f v0.1.0 (/tmp/f)
error[E0601]: `main` function not found in crate `f`
 --> src/main.rs:7:2
  |
7 | }
  |  ^ consider adding a `main` function to `src/main.rs`

For more information about this error, try `rustc --explain E0601`.
error: could not compile `f` (bin "f") due to previous error
warning: build failed, waiting for other jobs to finish...
error: the `#[test]` attribute may only be used on a non-associated function
 --> src/main.rs:5:5
  |
5 |     #[test]
  |     ^^^^^^^ the `#[test]` macro causes a function to be run on a test and has no effect on non-functions
6 |     struct A5(u32, u8);
  |     ------------------- expected a non-associated function, found a struct
  |
help: replace with conditional compilation to make the item only exist when tests are being run
  |
5 |     #[cfg(test)]
  |

thread 'rustc' panicked at 'expected statement', compiler/rustc_expand/src/base.rs:173:18
stack backtrace:
   0:     0x7f7dd1965e8a - std::backtrace_rs::backtrace::libunwind::trace::hc07ec51854030801
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f7dd1965e8a - std::backtrace_rs::backtrace::trace_unsynchronized::hd5249f53d09c2c41
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f7dd1965e8a - std::sys_common::backtrace::_print_fmt::h7a58bb30aee44196
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f7dd1965e8a - <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:     0x7f7dd19c9e6f - core::fmt::write::h10777037b979b8b8
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/core/src/fmt/mod.rs:1254:17
   5:     0x7f7dd1958ac5 - std::io::Write::write_fmt::he1dc4aa4bd2563db
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/io/mod.rs:1698:15
   6:     0x7f7dd1965c55 - std::sys_common::backtrace::_print::h163c7799d3150ce8
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f7dd1965c55 - std::sys_common::backtrace::print::h3cf13564ddfd5c0e
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f7dd19688fe - std::panicking::default_hook::{{closure}}::h999811fec35f64bf
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/panicking.rs:269:22
   9:     0x7f7dd19686a5 - std::panicking::default_hook::he182d48ca482e8b2
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/panicking.rs:288:9
  10:     0x55b7265accf2 - clippy_driver[8cf76b931aebbb55]::ICE_HOOK::{closure#0}::{closure#0}
  11:     0x7f7dd19690f4 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h85e02727d0be9156
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/alloc/src/boxed.rs:2002:9
  12:     0x7f7dd19690f4 - std::panicking::rust_panic_with_hook::h2bc066147eaf9845
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/panicking.rs:694:13
  13:     0x7f7dd1968e22 - std::panicking::begin_panic_handler::{{closure}}::h1e4368c427832fe9
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/panicking.rs:579:13
  14:     0x7f7dd19662f6 - std::sys_common::backtrace::__rust_end_short_backtrace::h5466480ef33b438e
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/sys_common/backtrace.rs:150:18
  15:     0x7f7dd1968bc2 - rust_begin_unwind
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/panicking.rs:577:5
  16:     0x7f7dd19c6273 - core::panicking::panic_fmt::ha28b6d803d12671b
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/core/src/panicking.rs:67:14
  17:     0x7f7dd38877a5 - <smallvec[32ba563770dfe5c2]::SmallVec<[rustc_ast[b583ee7534cdfdf7]::ast::Stmt; 1usize]> as core[a19e7c0c634483f1]::iter::traits::collect::Extend<rustc_ast[b583ee7534cdfdf7]::ast::Stmt>>::extend::<core[a19e7c0c634483f1]::iter::adapters::map::Map<alloc[827ef145a957661e]::vec::into_iter::IntoIter<rustc_expand[992ebdc148211ee5]::base::Annotatable>, <rustc_expand[992ebdc148211ee5]::base::Annotatable>::expect_stmt>>
  18:     0x7f7dd3839c1d - <rustc_expand[992ebdc148211ee5]::expand::AstFragmentKind>::expect_from_annotatables::<alloc[827ef145a957661e]::vec::Vec<rustc_expand[992ebdc148211ee5]::base::Annotatable>>
  19:     0x7f7dd381baf6 - <rustc_expand[992ebdc148211ee5]::expand::MacroExpander>::fully_expand_fragment
  20:     0x7f7dd3ba89bd - <rustc_expand[992ebdc148211ee5]::expand::MacroExpander>::expand_crate
  21:     0x7f7dd3ba7803 - <rustc_session[cf9a7d3e591cdb18]::session::Session>::time::<rustc_ast[b583ee7534cdfdf7]::ast::Crate, rustc_interface[5bf2b96a334089ac]::passes::configure_and_expand::{closure#1}>
  22:     0x7f7dd3b6200d - rustc_interface[5bf2b96a334089ac]::passes::resolver_for_lowering
  23:     0x7f7dd443d215 - <std[6ff7f37a454f70cc]::thread::local::LocalKey<core[a19e7c0c634483f1]::cell::Cell<*const ()>>>::with::<rustc_middle[3082ae73db43cedc]::ty::context::tls::enter_context<rustc_query_system[1d2d9265d336f3ba]::query::plumbing::execute_job_incr<rustc_query_impl[7fc8fbd6a7380a6b]::queries::resolver_for_lowering, rustc_query_impl[7fc8fbd6a7380a6b]::plumbing::QueryCtxt>::{closure#2}, (&rustc_data_structures[cd2fe1ee8a53a3e]::steal::Steal<(rustc_middle[3082ae73db43cedc]::ty::ResolverAstLowering, alloc[827ef145a957661e]::rc::Rc<rustc_ast[b583ee7534cdfdf7]::ast::Crate>)>, rustc_query_system[1d2d9265d336f3ba]::dep_graph::graph::DepNodeIndex)>::{closure#0}, (&rustc_data_structures[cd2fe1ee8a53a3e]::steal::Steal<(rustc_middle[3082ae73db43cedc]::ty::ResolverAstLowering, alloc[827ef145a957661e]::rc::Rc<rustc_ast[b583ee7534cdfdf7]::ast::Crate>)>, rustc_query_system[1d2d9265d336f3ba]::dep_graph::graph::DepNodeIndex)>
  24:     0x7f7dd443cd6b - rustc_query_system[1d2d9265d336f3ba]::query::plumbing::try_execute_query::<rustc_query_impl[7fc8fbd6a7380a6b]::queries::resolver_for_lowering, rustc_query_impl[7fc8fbd6a7380a6b]::plumbing::QueryCtxt>
  25:     0x7f7dd443c8d0 - <rustc_query_impl[7fc8fbd6a7380a6b]::Queries as rustc_middle[3082ae73db43cedc]::ty::query::QueryEngine>::resolver_for_lowering
  26:     0x7f7dd3de0e32 - <rustc_interface[5bf2b96a334089ac]::queries::QueryResult<&rustc_middle[3082ae73db43cedc]::ty::context::GlobalCtxt>>::enter::<&rustc_data_structures[cd2fe1ee8a53a3e]::steal::Steal<(rustc_middle[3082ae73db43cedc]::ty::ResolverAstLowering, alloc[827ef145a957661e]::rc::Rc<rustc_ast[b583ee7534cdfdf7]::ast::Crate>)>, rustc_driver_impl[97cc8afb29750871]::run_compiler::{closure#1}::{closure#2}::{closure#2}>
  27:     0x7f7dd3ddfd90 - <rustc_interface[5bf2b96a334089ac]::interface::Compiler>::enter::<rustc_driver_impl[97cc8afb29750871]::run_compiler::{closure#1}::{closure#2}, core[a19e7c0c634483f1]::result::Result<core[a19e7c0c634483f1]::option::Option<rustc_interface[5bf2b96a334089ac]::queries::Linker>, rustc_span[e810f079a636b72c]::ErrorGuaranteed>>
  28:     0x7f7dd3dde011 - rustc_span[e810f079a636b72c]::with_source_map::<core[a19e7c0c634483f1]::result::Result<(), rustc_span[e810f079a636b72c]::ErrorGuaranteed>, rustc_interface[5bf2b96a334089ac]::interface::run_compiler<core[a19e7c0c634483f1]::result::Result<(), rustc_span[e810f079a636b72c]::ErrorGuaranteed>, rustc_driver_impl[97cc8afb29750871]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  29:     0x7f7dd3ddd5bf - std[6ff7f37a454f70cc]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[5bf2b96a334089ac]::util::run_in_thread_pool_with_globals<rustc_interface[5bf2b96a334089ac]::interface::run_compiler<core[a19e7c0c634483f1]::result::Result<(), rustc_span[e810f079a636b72c]::ErrorGuaranteed>, rustc_driver_impl[97cc8afb29750871]::run_compiler::{closure#1}>::{closure#0}, core[a19e7c0c634483f1]::result::Result<(), rustc_span[e810f079a636b72c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a19e7c0c634483f1]::result::Result<(), rustc_span[e810f079a636b72c]::ErrorGuaranteed>>
  30:     0x7f7dd452084e - <<std[6ff7f37a454f70cc]::thread::Builder>::spawn_unchecked_<rustc_interface[5bf2b96a334089ac]::util::run_in_thread_pool_with_globals<rustc_interface[5bf2b96a334089ac]::interface::run_compiler<core[a19e7c0c634483f1]::result::Result<(), rustc_span[e810f079a636b72c]::ErrorGuaranteed>, rustc_driver_impl[97cc8afb29750871]::run_compiler::{closure#1}>::{closure#0}, core[a19e7c0c634483f1]::result::Result<(), rustc_span[e810f079a636b72c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a19e7c0c634483f1]::result::Result<(), rustc_span[e810f079a636b72c]::ErrorGuaranteed>>::{closure#1} as core[a19e7c0c634483f1]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  31:     0x7f7dd19731d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hfe54f4b2f7bbb15c
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/alloc/src/boxed.rs:1988:9
  32:     0x7f7dd19731d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h63491a9a6e102885
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/alloc/src/boxed.rs:1988:9
  33:     0x7f7dd19731d5 - std::sys::unix::thread::Thread::new::thread_start::h7f7d825730b043c8
                               at /rustc/17c11672167827b0dd92c88ef69f24346d1286dd/library/std/src/sys/unix/thread.rs:108:17
  34:     0x7f7dd1625bb5 - <unknown>
  35:     0x7f7dd16a7d90 - <unknown>
  36:                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-clippy/issues/new

note: Clippy version: clippy 0.1.70 (17c1167 2023-03-29)

query stack during panic:
#0 [resolver_for_lowering] getting the resolver for lowering
end of query stack
error: could not compile `f` (bin "f" test) due to previous error

Version

rustc 1.70.0-nightly (17c116721 2023-03-29)
binary: rustc
commit-hash: 17c11672167827b0dd92c88ef69f24346d1286dd
commit-date: 2023-03-29
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 16.0.0

Error output

No response

@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Mar 30, 2023
@Alexendoo
Copy link
Member

Looks like this is an upstream one, it ices with a plain rustc --test

@matthiaskrgr
Copy link
Member Author

Ah I didn't check with --test 🙃 I'll move it

@matthiaskrgr matthiaskrgr changed the title clippy --fix causes panic: "expected statement" ICE: "expected statement" with rustc --test Mar 31, 2023
@matthiaskrgr matthiaskrgr transferred this issue from rust-lang/rust-clippy Mar 31, 2023
@matthiaskrgr
Copy link
Member Author

searched toolchains nightly-2020-11-19 through nightly-2023-03-31


Regression in nightly-2020-11-26


maybe #79326 ?

@jyn514 jyn514 added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. 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 3, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Apr 3, 2023
@apiraino
Copy link
Contributor

apiraino commented Apr 3, 2023

WG-prioritization assigning priority (Zulip discussion).

@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 3, 2023
@Ezrashaw
Copy link
Contributor

Ezrashaw commented Apr 7, 2023

@rustbot claim

I have a fix. Will post soon.

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.

6 participants