Skip to content

allowing missing_const_for_fn for test causes ICE #10032

Closed
@Byter09

Description

@Byter09

Summary

At first missing_const_for_fn wants me to annotate this test:

#[test]
fn selective() {
    // we set mutation chance to 1 to guarantee it
    let swap = Swap::new(1.0);

    let remove = Remove::new(1.0, 1.try_into().unwrap());

    let combination = Combination::selective().and(swap).and(remove);
    let mut rng = SmallRng::seed_from_u64(0);
    let mut array = vec![0_u8, 1, 2, 3, 4];

    combination.mutate(&mut array, &mut rng);

    // only the remove mutation ran and removed 2
    assert_eq!(array, [0, 1, 3, 4]);
}
Clippy

error: this could be a `const fn`
 --> src/operators/mutation/combination.rs:156:5
  |
156 | /     fn random() {
157 | |         // we set mutation chance to 1 to guarantee it
158 | |         let add = Add::new(1.0, None);
159 | |
...   |
171 | |         assert_eq!(array, [229, 0, 1, 237, 3, 4]);
172 | |     }
  | |_____^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_const_for_fn
  = note: `-D clippy::missing-const-for-fn` implied by `-D clippy::nursery`

error: this could be a `const fn`
 --> src/operators/mutation/combination.rs:175:5
  |
175 | /     fn selective() {
176 | |         // we set mutation chance to 1 to guarantee it
177 | |         let swap = Swap::new(1.0);
178 | |
...   |
189 | |         assert_eq!(array, [0, 1, 3, 4]);
190 | |     }
  | |_____^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_const_for_fn

error: could not compile `meiosis` due to 2 previous errors

First of, annotating a test with that lint already sounds wrong to me. I figured "okay, I need this to be clippy-clean now" so I simply added the allow to the test and I ended up with the error output you see below. Same result if I add it to the test module itself.

I could not produce a minimal verifiable example as I'm a bit unsure how to do that in this case, however removing let combination = Combination::selective().and(swap).and(remove); stops triggering it. The permalink to the file in its current state is here: https://gitlab.com/bit-refined/meiosis/-/blob/d1dda3873a6e64e2f67792075f393ed18dd00315/src/operators/mutation/combination.rs#L177

If I figure out how to reduce this I may add a comment later, but I'm rather busy at the moment :/
EDIT: Okay I've tried around a bit and the moment I touch anything or try to remove generic parameters it just doesn't trigger anymore. Am really unsure how to minimize this.
EDIT 2: Currently letting DustMite have a go to see if it can reduce this for me.
EDIT 3: It's still running. Once I get it down to a reasonable level I'll either post the code or a tarball.

Also, apologies if there is already an issue to this, but I tried my best and couldn't find one.

Version

rustc 1.67.0-nightly (53e4b9dd7 2022-12-04)
binary: rustc
commit-hash: 53e4b9dd74c29cc9308b8d0f10facac70bb101a7
commit-date: 2022-12-04
host: x86_64-unknown-linux-gnu
release: 1.67.0-nightly
LLVM version: 15.0.4

Error output

Backtrace

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: Missing value for constant, but no error reported?
 --> src/operators/mutation/combination.rs:165:58
  |
165 |         let combination = Combination::random().and(add).and(random);
  |                                                          ^^^
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/const_evaluatable.rs:71:22

error: internal compiler error: `report_selection_error` did not emit an error
 --> src/operators/mutation/combination.rs:165:58
  |
165 |         let combination = Combination::random().and(add).and(random);
  |                                                          ^^^
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:549:22

error: internal compiler error: `ErrorGuaranteed` without an error
 --> src/operators/mutation/combination.rs:165:58
  |
165 |         let combination = Combination::random().and(add).and(random);
  |                                                          ^^^
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:1324:31

error: internal compiler error: expected fullfillment errors
|
= note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:450:23

error: internal compiler error: Missing value for constant, but no error reported?
 --> src/operators/mutation/combination.rs:170:9
  |
170 |         combination.mutate(&mut array, &mut rng);
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/const_evaluatable.rs:71:22

error: internal compiler error: `report_selection_error` did not emit an error
 --> src/operators/mutation/combination.rs:170:9
  |
170 |         combination.mutate(&mut array, &mut rng);
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:549:22

error: internal compiler error: `ErrorGuaranteed` without an error
 --> src/operators/mutation/combination.rs:170:9
  |
170 |         combination.mutate(&mut array, &mut rng);
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:1324:31

error: internal compiler error: TyKind::Error constructed but no error reported
|
= note: delayed at /rustc/53e4b9dd74c29cc9308b8d0f10facac70bb101a7/compiler/rustc_middle/src/ty/relate.rs:425:59

error: internal compiler error: Missing value for constant, but no error reported?
 --> src/operators/mutation/combination.rs:185:62
  |
185 |         let combination = Combination::selective().and(swap).and(remove);
  |                                                              ^^^
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/const_evaluatable.rs:71:22

error: internal compiler error: `report_selection_error` did not emit an error
 --> src/operators/mutation/combination.rs:185:62
  |
185 |         let combination = Combination::selective().and(swap).and(remove);
  |                                                              ^^^
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:549:22

error: internal compiler error: `ErrorGuaranteed` without an error
 --> src/operators/mutation/combination.rs:185:62
  |
185 |         let combination = Combination::selective().and(swap).and(remove);
  |                                                              ^^^
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:1324:31

error: internal compiler error: Missing value for constant, but no error reported?
 --> src/operators/mutation/combination.rs:190:9
  |
190 |         combination.mutate(&mut array, &mut rng);
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/const_evaluatable.rs:71:22

error: internal compiler error: `report_selection_error` did not emit an error
 --> src/operators/mutation/combination.rs:190:9
  |
190 |         combination.mutate(&mut array, &mut rng);
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:549:22

error: internal compiler error: `ErrorGuaranteed` without an error
 --> src/operators/mutation/combination.rs:190:9
  |
190 |         combination.mutate(&mut array, &mut rng);
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:1324:31

error: internal compiler error: TyKind::Error constructed but no error reported
|
= note: delayed at compiler/rustc_mir_build/src/build/mod.rs:637:18

error: internal compiler error: broken MIR in DefId(0:2855 ~ meiosis[3b82]::operators::mutation::combination::tests::random#1) ("return type"): bad type [type error]
 --> src/operators/mutation/combination.rs:159:5
  |
159 |     fn random() {
  |     ^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:520:13

error: internal compiler error: TyKind::Error constructed but no error reported
|
= note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:768:20

error: internal compiler error: broken MIR in DefId(0:2855 ~ meiosis[3b82]::operators::mutation::combination::tests::random#1) (LocalDecl { mutability: Mut, local_info: None, internal: false, is_block_tail: None, ty: [type error], user_ty: None, source_info: SourceInfo { span: src/operators/mutation/combination.rs:159:5: 159:16 (#0), scope: scope[0] } }): bad type [type error]
 --> src/operators/mutation/combination.rs:159:5
  |
159 |     fn random() {
  |     ^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:520:13

error: internal compiler error: broken MIR in DefId(0:2859 ~ meiosis[3b82]::operators::mutation::combination::tests::selective#1) ("return type"): bad type [type error]
 --> src/operators/mutation/combination.rs:179:5
  |
179 |     fn selective() {
  |     ^^^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:520:13

error: internal compiler error: broken MIR in DefId(0:2859 ~ meiosis[3b82]::operators::mutation::combination::tests::selective#1) (LocalDecl { mutability: Mut, local_info: None, internal: false, is_block_tail: None, ty: [type error], user_ty: None, source_info: SourceInfo { span: src/operators/mutation/combination.rs:179:5: 179:19 (#0), scope: scope[0] } }): bad type [type error]
 --> src/operators/mutation/combination.rs:179:5
  |
179 |     fn selective() {
  |     ^^^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:520:13

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1610:13
stack backtrace:
 0:     0x7f0bf1eac25a - std::backtrace_rs::backtrace::libunwind::trace::h217eb04aed2c45de
                             at /rustc/53e4b9dd74c29cc9308b8d0f10facac70bb101a7/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
 1:     0x7f0bf1eac25a - std::backtrace_rs::backtrace::trace_unsynchronized::h8d7ebe2490fc8887
                             at /rustc/53e4b9dd74c29cc9308b8d0f10facac70bb101a7/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
 2:     0x7f0bf1eac25a - std::sys_common::backtrace::_print_fmt::hf5be7add3e3c061b
                             at /rustc/53e4b9dd74c29cc9308b8d0f10facac70bb101a7/library/std/src/sys_common/backtrace.rs:65:5
 3:     0x7f0bf1eac25a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc3f0b6fc09e1404b
                             at /rustc/53e4b9dd74c29cc9308b8d0f10facac70bb101a7/library/std/src/sys_common/backtrace.rs:44:22
 4:     0x7f0beddc8ece - core::fmt::write::h21bd73c842f4e089
                             at /rustc/53e4b9dd74c29cc9308b8d0f10facac70bb101a7/library/core/src/fmt/mod.rs:1208:17
 5:     0x7f0bf1ea0575 - std::io::Write::write_fmt::hc308562d08004f3e
                             at /rustc/53e4b9dd74c29cc9308b8d0f10facac70bb101a7/library/std/src/io/mod.rs:1682:15
 6:     0x7f0bf1eac025 - std::sys_common::backtrace::_print::h35dbc8fac7f76168
                             at /rustc/53e4b9dd74c29cc9308b8d0f10facac70bb101a7/library/std/src/sys_common/backtrace.rs:47:5
 7:     0x7f0bf1eac025 - std::sys_common::backtrace::print::h73d53422718fe2c6
                             at /rustc/53e4b9dd74c29cc9308b8d0f10facac70bb101a7/library/std/src/sys_common/backtrace.rs:34:9
 8:     0x7f0bf1eae3af - std::panicking::default_hook::{{closure}}::h48456de670413439
                             at /rustc/53e4b9dd74c29cc9308b8d0f10facac70bb101a7/library/std/src/panicking.rs:267:22
 9:     0x7f0bf1eae0eb - std::panicking::default_hook::h133845cf05f47840
                             at /rustc/53e4b9dd74c29cc9308b8d0f10facac70bb101a7/library/std/src/panicking.rs:286:9
10:     0x7f0bf1eaeb8c - std::panicking::rust_panic_with_hook::hb428246b31e531d9
                             at /rustc/53e4b9dd74c29cc9308b8d0f10facac70bb101a7/library/std/src/panicking.rs:688:13
11:     0x7f0bf1137051 - std[2f49e04a49785d41]::panicking::begin_panic::<rustc_errors[3f04fd9a36ec0931]::ExplicitBug>::{closure#0}
12:     0x7f0bf1135916 - std[2f49e04a49785d41]::sys_common::backtrace::__rust_end_short_backtrace::<std[2f49e04a49785d41]::panicking::begin_panic<rustc_errors[3f04fd9a36ec0931]::ExplicitBug>::{closure#0}, !>
13:     0x7f0bf112cde6 - std[2f49e04a49785d41]::panicking::begin_panic::<rustc_errors[3f04fd9a36ec0931]::ExplicitBug>
14:     0x7f0bf11317a6 - std[2f49e04a49785d41]::panic::panic_any::<rustc_errors[3f04fd9a36ec0931]::ExplicitBug>
15:     0x7f0bf05cf0f6 - <rustc_errors[3f04fd9a36ec0931]::HandlerInner>::flush_delayed::<alloc[279ad31ef126e141]::vec::Vec<rustc_errors[3f04fd9a36ec0931]::diagnostic::Diagnostic>, &str>
16:     0x7f0bf023526e - <rustc_interface[e2cb08752aecdf39]::passes::QueryContext>::enter::<<rustc_interface[e2cb08752aecdf39]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[e1ff35b71d1701d9]::result::Result<alloc[279ad31ef126e141]::boxed::Box<dyn core[e1ff35b71d1701d9]::any::Any>, rustc_errors[3f04fd9a36ec0931]::ErrorGuaranteed>>
17:     0x7f0bf0232ac4 - <rustc_interface[e2cb08752aecdf39]::queries::Queries>::ongoing_codegen
18:     0x7f0bf0231c91 - <rustc_interface[e2cb08752aecdf39]::interface::Compiler>::enter::<rustc_driver[b218747198152f07]::run_compiler::{closure#1}::{closure#2}, core[e1ff35b71d1701d9]::result::Result<core[e1ff35b71d1701d9]::option::Option<rustc_interface[e2cb08752aecdf39]::queries::Linker>, rustc_errors[3f04fd9a36ec0931]::ErrorGuaranteed>>
19:     0x7f0bf022cc78 - rustc_span[323ba4f8bef90746]::with_source_map::<core[e1ff35b71d1701d9]::result::Result<(), rustc_errors[3f04fd9a36ec0931]::ErrorGuaranteed>, rustc_interface[e2cb08752aecdf39]::interface::run_compiler<core[e1ff35b71d1701d9]::result::Result<(), rustc_errors[3f04fd9a36ec0931]::ErrorGuaranteed>, rustc_driver[b218747198152f07]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
20:     0x7f0bf022c765 - <scoped_tls[b7ce8b7e4286e02d]::ScopedKey<rustc_span[323ba4f8bef90746]::SessionGlobals>>::set::<rustc_interface[e2cb08752aecdf39]::interface::run_compiler<core[e1ff35b71d1701d9]::result::Result<(), rustc_errors[3f04fd9a36ec0931]::ErrorGuaranteed>, rustc_driver[b218747198152f07]::run_compiler::{closure#1}>::{closure#0}, core[e1ff35b71d1701d9]::result::Result<(), rustc_errors[3f04fd9a36ec0931]::ErrorGuaranteed>>
21:     0x7f0bf022bd52 - std[2f49e04a49785d41]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[e2cb08752aecdf39]::util::run_in_thread_pool_with_globals<rustc_interface[e2cb08752aecdf39]::interface::run_compiler<core[e1ff35b71d1701d9]::result::Result<(), rustc_errors[3f04fd9a36ec0931]::ErrorGuaranteed>, rustc_driver[b218747198152f07]::run_compiler::{closure#1}>::{closure#0}, core[e1ff35b71d1701d9]::result::Result<(), rustc_errors[3f04fd9a36ec0931]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e1ff35b71d1701d9]::result::Result<(), rustc_errors[3f04fd9a36ec0931]::ErrorGuaranteed>>
22:     0x7f0bf09a5458 - <<std[2f49e04a49785d41]::thread::Builder>::spawn_unchecked_<rustc_interface[e2cb08752aecdf39]::util::run_in_thread_pool_with_globals<rustc_interface[e2cb08752aecdf39]::interface::run_compiler<core[e1ff35b71d1701d9]::result::Result<(), rustc_errors[3f04fd9a36ec0931]::ErrorGuaranteed>, rustc_driver[b218747198152f07]::run_compiler::{closure#1}>::{closure#0}, core[e1ff35b71d1701d9]::result::Result<(), rustc_errors[3f04fd9a36ec0931]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e1ff35b71d1701d9]::result::Result<(), rustc_errors[3f04fd9a36ec0931]::ErrorGuaranteed>>::{closure#1} as core[e1ff35b71d1701d9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
23:     0x7f0bf1eb5df3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5d679a3e0eef548a
                             at /rustc/53e4b9dd74c29cc9308b8d0f10facac70bb101a7/library/alloc/src/boxed.rs:2000:9
24:     0x7f0bf1eb5df3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5129455b92134839
                             at /rustc/53e4b9dd74c29cc9308b8d0f10facac70bb101a7/library/alloc/src/boxed.rs:2000:9
25:     0x7f0bf1eb5df3 - std::sys::unix::thread::Thread::new::thread_start::haa6aecc225cb6cab
                             at /rustc/53e4b9dd74c29cc9308b8d0f10facac70bb101a7/library/std/src/sys/unix/thread.rs:108:17
26:     0x7f0bed9fe8fd - <unknown>
27:     0x7f0beda80a60 - <unknown>
28:                0x0 - <unknown>

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-ICEIssue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions