Closed
Description
auto-reduced (treereduce-rust):
#![feature(specialization)]
pub trait Foo {
fn abc() -> u32;
}
pub trait Marker {}
impl<T> Foo for T {
default fn abc(f: fn(&T), t: &T) -> u32 {
16
}
}
impl<T: Marker> Foo for T {
fn def() -> u32 {
Self::abc()
}
}
original:
// run-pass
#![feature(specialization)]
//~^ WARN the feature `specialization` is incomplete
pub trait Foo {
fn abc() -> u32;
fn def() -> u32;
}
pub trait Marker {}
impl Marker for () {}
impl<T> Foo for T {
default fn abc(f: fn(&T), t: &T) -> u32 { 16 }
default fn def() -> u32 { 42 }
}
impl<T: Marker> Foo for T {
fn def() -> u32 {
Self::abc()
}
}
fn main() {
assert_eq!(<()>::def(), 16);
assert_eq!(<i32>::def(), 42);
}
Version information
rustc 1.78.0-nightly (ee9c7c940 2024-02-14)
binary: rustc
commit-hash: ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46
commit-date: 2024-02-14
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zpolymorphize=on -Zinline-mir=yes
Program output
error[E0407]: method `def` is not a member of trait `Foo`
--> /tmp/icemaker_global_tempdir.M7q9vo4k970Y/rustc_testrunner_tmpdir_reporting.QyBQD8LaDYVe/mvce.rs:16:5
|
16 | / fn def() -> u32 {
17 | | Self::abc()
18 | | }
| |_____^ not a member of trait `Foo`
warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
--> /tmp/icemaker_global_tempdir.M7q9vo4k970Y/rustc_testrunner_tmpdir_reporting.QyBQD8LaDYVe/mvce.rs:1:12
|
1 | #![feature(specialization)]
| ^^^^^^^^^^^^^^
|
= note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
= help: consider using `min_specialization` instead, which is more stable and complete
= note: `#[warn(incomplete_features)]` on by default
error[E0601]: `main` function not found in crate `mvce`
--> /tmp/icemaker_global_tempdir.M7q9vo4k970Y/rustc_testrunner_tmpdir_reporting.QyBQD8LaDYVe/mvce.rs:19:2
|
19 | }
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.M7q9vo4k970Y/rustc_testrunner_tmpdir_reporting.QyBQD8LaDYVe/mvce.rs`
error[E0050]: method `abc` has 2 parameters but the declaration in trait `Foo::abc` has 0
--> /tmp/icemaker_global_tempdir.M7q9vo4k970Y/rustc_testrunner_tmpdir_reporting.QyBQD8LaDYVe/mvce.rs:10:23
|
4 | fn abc() -> u32;
| ---------------- trait requires 0 parameters
...
10 | default fn abc(f: fn(&T), t: &T) -> u32 {
| ^^^^^^^^^^^^^ expected 0 parameters, found 2
warning: unused variable: `f`
--> /tmp/icemaker_global_tempdir.M7q9vo4k970Y/rustc_testrunner_tmpdir_reporting.QyBQD8LaDYVe/mvce.rs:10:20
|
10 | default fn abc(f: fn(&T), t: &T) -> u32 {
| ^ help: if this is intentional, prefix it with an underscore: `_f`
|
= note: `#[warn(unused_variables)]` on by default
warning: unused variable: `t`
--> /tmp/icemaker_global_tempdir.M7q9vo4k970Y/rustc_testrunner_tmpdir_reporting.QyBQD8LaDYVe/mvce.rs:10:31
|
10 | default fn abc(f: fn(&T), t: &T) -> u32 {
| ^ help: if this is intentional, prefix it with an underscore: `_t`
thread 'rustc' panicked at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/compiler/rustc_middle/src/mir/tcx.rs:133:61:
index out of bounds: the len is 1 but the index is 1
stack backtrace:
0: 0x7f1870d8ce46 - std::backtrace_rs::backtrace::libunwind::trace::h5168cb64cb843b87
at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
1: 0x7f1870d8ce46 - std::backtrace_rs::backtrace::trace_unsynchronized::hbbff473666b784c6
at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7f1870d8ce46 - std::sys_common::backtrace::_print_fmt::h6c61b632e6cc7949
at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/sys_common/backtrace.rs:68:5
3: 0x7f1870d8ce46 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h974a6b559c2b8d41
at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/sys_common/backtrace.rs:44:22
4: 0x7f1870ddd46c - core::fmt::rt::Argument::fmt::hf6a5273aff56768c
at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/core/src/fmt/rt.rs:142:9
5: 0x7f1870ddd46c - core::fmt::write::h1caffe3a78971207
at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/core/src/fmt/mod.rs:1120:17
6: 0x7f1870d807ef - std::io::Write::write_fmt::h2caf2bb3485e27a5
at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/io/mod.rs:1854:15
7: 0x7f1870d8cbf4 - std::sys_common::backtrace::_print::h0414d95b24b9ea44
at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/sys_common/backtrace.rs:47:5
8: 0x7f1870d8cbf4 - std::sys_common::backtrace::print::hfdf60e3b3d06625d
at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/sys_common/backtrace.rs:34:9
9: 0x7f1870d8f93b - std::panicking::default_hook::{{closure}}::h3c1109072cde0ade
10: 0x7f1870d8f689 - std::panicking::default_hook::hfe3c076d4f24ecbe
at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/panicking.rs:292:9
11: 0x7f1873bf563c - std[2308076c1424b998]::panicking::update_hook::<alloc[33ce0ef41c101337]::boxed::Box<rustc_driver_impl[d317596fd5f90102]::install_ice_hook::{closure#0}>>::{closure#0}
12: 0x7f1870d900a0 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h8a55f98e23703736
at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/alloc/src/boxed.rs:2030:9
13: 0x7f1870d900a0 - std::panicking::rust_panic_with_hook::hc147efcd5d482f2c
at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/panicking.rs:785:13
14: 0x7f1870d8fde2 - std::panicking::begin_panic_handler::{{closure}}::h6174f0cd2a065d90
at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/panicking.rs:659:13
15: 0x7f1870d8d326 - std::sys_common::backtrace::__rust_end_short_backtrace::h770b1c8f4d2029d4
at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/sys_common/backtrace.rs:171:18
16: 0x7f1870d8fb14 - rust_begin_unwind
at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/panicking.rs:647:5
17: 0x7f1870dd9975 - core::panicking::panic_fmt::h66e8ea0facb42563
at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/core/src/panicking.rs:72:14
18: 0x7f1870dd9bc2 - core::panicking::panic_bounds_check::h178a976047dd7a3b
at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/core/src/panicking.rs:208:5
19: 0x7f18730fc93a - <rustc_mir_transform[c0673d0b3c528a53]::remove_zsts::RemoveZsts as rustc_middle[efc8e2d5742a68dd]::mir::MirPass>::run_pass
20: 0x7f1874e1420f - rustc_mir_transform[c0673d0b3c528a53]::pass_manager::run_passes_inner
21: 0x7f1875157fbd - rustc_mir_transform[c0673d0b3c528a53]::optimized_mir
22: 0x7f1874e92975 - rustc_query_impl[ecef4a4fa1cc3689]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ecef4a4fa1cc3689]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[efc8e2d5742a68dd]::query::erase::Erased<[u8; 8usize]>>
23: 0x7f1874e93020 - rustc_query_system[8b26caae5283da17]::query::plumbing::try_execute_query::<rustc_query_impl[ecef4a4fa1cc3689]::DynamicConfig<rustc_query_system[8b26caae5283da17]::query::caches::DefIdCache<rustc_middle[efc8e2d5742a68dd]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[ecef4a4fa1cc3689]::plumbing::QueryCtxt, false>
24: 0x7f1874e9279e - rustc_query_impl[ecef4a4fa1cc3689]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
25: 0x7f18757f01d8 - rustc_middle[efc8e2d5742a68dd]::query::plumbing::query_get_at::<rustc_query_system[8b26caae5283da17]::query::caches::DefIdCache<rustc_middle[efc8e2d5742a68dd]::query::erase::Erased<[u8; 8usize]>>>
26: 0x7f1875800c32 - rustc_query_impl[ecef4a4fa1cc3689]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ecef4a4fa1cc3689]::query_impl::unused_generic_params::dynamic_query::{closure#2}::{closure#0}, rustc_middle[efc8e2d5742a68dd]::query::erase::Erased<[u8; 4usize]>>
27: 0x7f187580041b - rustc_query_system[8b26caae5283da17]::query::plumbing::try_execute_query::<rustc_query_impl[ecef4a4fa1cc3689]::DynamicConfig<rustc_query_system[8b26caae5283da17]::query::caches::DefaultCache<rustc_middle[efc8e2d5742a68dd]::ty::instance::InstanceDef, rustc_middle[efc8e2d5742a68dd]::query::erase::Erased<[u8; 4usize]>>, false, false, false>, rustc_query_impl[ecef4a4fa1cc3689]::plumbing::QueryCtxt, false>
28: 0x7f187580012c - rustc_query_impl[ecef4a4fa1cc3689]::query_impl::unused_generic_params::get_query_non_incr::__rust_end_short_backtrace
29: 0x7f18757fbc2c - rustc_interface[e88069c12facd435]::passes::analysis
30: 0x7f18757fb229 - rustc_query_impl[ecef4a4fa1cc3689]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ecef4a4fa1cc3689]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[efc8e2d5742a68dd]::query::erase::Erased<[u8; 1usize]>>
31: 0x7f1875c3afe5 - rustc_query_system[8b26caae5283da17]::query::plumbing::try_execute_query::<rustc_query_impl[ecef4a4fa1cc3689]::DynamicConfig<rustc_query_system[8b26caae5283da17]::query::caches::SingleCache<rustc_middle[efc8e2d5742a68dd]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[ecef4a4fa1cc3689]::plumbing::QueryCtxt, false>
32: 0x7f1875c3ad49 - rustc_query_impl[ecef4a4fa1cc3689]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
33: 0x7f1875c44695 - rustc_interface[e88069c12facd435]::interface::run_compiler::<core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>, rustc_driver_impl[d317596fd5f90102]::run_compiler::{closure#0}>::{closure#0}
34: 0x7f1875dc5ad8 - std[2308076c1424b998]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[e88069c12facd435]::util::run_in_thread_with_globals<rustc_interface[e88069c12facd435]::util::run_in_thread_pool_with_globals<rustc_interface[e88069c12facd435]::interface::run_compiler<core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>, rustc_driver_impl[d317596fd5f90102]::run_compiler::{closure#0}>::{closure#0}, core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>>::{closure#0}, core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>>
35: 0x7f1875dc5904 - <<std[2308076c1424b998]::thread::Builder>::spawn_unchecked_<rustc_interface[e88069c12facd435]::util::run_in_thread_with_globals<rustc_interface[e88069c12facd435]::util::run_in_thread_pool_with_globals<rustc_interface[e88069c12facd435]::interface::run_compiler<core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>, rustc_driver_impl[d317596fd5f90102]::run_compiler::{closure#0}>::{closure#0}, core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>>::{closure#0}, core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>>::{closure#1} as core[db7e23408f407db6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
36: 0x7f1870d991e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hbe12538a3d7e111d
at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/alloc/src/boxed.rs:2016:9
37: 0x7f1870d991e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h306728bac30291a0
at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/alloc/src/boxed.rs:2016:9
38: 0x7f1870d991e5 - std::sys::pal::unix::thread::Thread::new::thread_start::hec142a176366d167
at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/sys/pal/unix/thread.rs:108:17
39: 0x7f1870b809eb - <unknown>
40: 0x7f1870c047cc - <unknown>
41: 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.78.0-nightly (ee9c7c940 2024-02-14) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z polymorphize=on -Z inline-mir=yes -Z dump-mir-dir=dir
query stack during panic:
#0 [optimized_mir] optimizing MIR for `<impl at /tmp/icemaker_global_tempdir.M7q9vo4k970Y/rustc_testrunner_tmpdir_reporting.QyBQD8LaDYVe/mvce.rs:15:1: 15:26>::def`
#1 [unused_generic_params] determining which generic parameters are unused by `<impl at /tmp/icemaker_global_tempdir.M7q9vo4k970Y/rustc_testrunner_tmpdir_reporting.QyBQD8LaDYVe/mvce.rs:15:1: 15:26>::def`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors; 3 warnings emitted
Some errors have detailed explanations: E0050, E0407, E0601.
For more information about an error, try `rustc --explain E0050`.
Metadata
Metadata
Assignees
Labels
Unstable option: Polymorphization.Category: This is a bug.`#![feature(specialization)]`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Status: This bug is tracked inside the repo by a `known-bug` test.Relevant to the compiler team, which will review and decide on the PR/issue.This issue requires the use of incomplete features.This issue requires a nightly compiler in some way.