Closed
Description
auto-reduced (treereduce-rust):
type Tait = impl FnOnce() -> ();
fn reify_as_tait() -> Thunk<Tait> {
Thunk::new(|mut cont| {
Thunk(f);
cont
})
}
struct Thunk<F>(F);
impl<F> Thunk<F> {
fn new(f: F) -> Self
where
F: ContFn,
{
Thunk(f)
}
}
trait ContFn {}
impl<F: FnOnce(Tait) -> ()> ContFn for F {}
original code
original:
// This doesn't work, because we don't flow information from opaque types
// into function arguments via the function's generic parameters
// into function arguments via the function's generic parameters
#![feature(type_alias_impl_trait)]
fn reify_as() -> Thunk<impl FnOnce(Continuation) -> Continuation> {
Thunk::f(|mut type_alias_impl_trait| { //~ ERROR type annotations needed
cont.reify_as();
new
})
}
type Tait = impl FnOnce(Continuation) -> Continuation;
fn reify_as_tait() -> Thunk<Tait> {
Thunk::new(|mut cont| { //~ ERROR type annotations needed
Thunk(f);
cont
})
}
#[must_use]
struct Thunk<F>(F);
impl<F> Thunk<F> {
fn new(f: F) -> Self
where
F: ContFn,
{
Thunk(f)
}
}
trait ContFn {
fn new(f: F) -> Self
where
F: ContFn,
{
Thunk(f)
}
}
impl<F: FnOnce(Tait) -> Continuation> ContFn for F {}
struct Continuation;
impl Continuation {
fn reify_as(&mut self) {
Thunk(f)
}
}
fn main() {}
Version information
rustc 1.80.0-nightly (0f40f14b6 2024-05-07)
binary: rustc
commit-hash: 0f40f14b61430792cc0ea316f424685041e8443e
commit-date: 2024-05-07
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.4
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
error[E0425]: cannot find value `f` in this scope
--> /tmp/icemaker_global_tempdir.uneTSWoqJYf7/rustc_testrunner_tmpdir_reporting.An8mk6KXI2K2/mvce.rs:5:15
|
5 | Thunk(f);
| ^ not found in this scope
error[E0658]: `impl Trait` in type aliases is unstable
--> /tmp/icemaker_global_tempdir.uneTSWoqJYf7/rustc_testrunner_tmpdir_reporting.An8mk6KXI2K2/mvce.rs:1:13
|
1 | type Tait = impl FnOnce() -> ();
| ^^^^^^^^^^^^^^^^^^^
|
= note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
= note: this compiler was built on 2024-05-07; consider upgrading it if it is out of date
error[E0601]: `main` function not found in crate `mvce`
--> /tmp/icemaker_global_tempdir.uneTSWoqJYf7/rustc_testrunner_tmpdir_reporting.An8mk6KXI2K2/mvce.rs:23:44
|
23 | impl<F: FnOnce(Tait) -> ()> ContFn for F {}
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.uneTSWoqJYf7/rustc_testrunner_tmpdir_reporting.An8mk6KXI2K2/mvce.rs`
error: internal compiler error: compiler/rustc_infer/src/infer/mod.rs:957:17: opaque types got hidden types registered from within subtype predicate: Alias(Opaque, AliasTy { args: [], def_id: DefId(0:16 ~ mvce[7b81]::Tait::{opaque#0}) }) vs ()
--> /tmp/icemaker_global_tempdir.uneTSWoqJYf7/rustc_testrunner_tmpdir_reporting.An8mk6KXI2K2/mvce.rs:6:9
|
6 | cont
| ^^^^
thread 'rustc' panicked at compiler/rustc_infer/src/infer/mod.rs:957:17:
Box<dyn Any>
stack backtrace:
0: 0x77fd7d334b35 - std::backtrace_rs::backtrace::libunwind::trace::h16226f415edd7020
at /rustc/0f40f14b61430792cc0ea316f424685041e8443e/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
1: 0x77fd7d334b35 - std::backtrace_rs::backtrace::trace_unsynchronized::hd074bfbed0466e66
at /rustc/0f40f14b61430792cc0ea316f424685041e8443e/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x77fd7d334b35 - std::sys_common::backtrace::_print_fmt::h6bd81933b11821e3
at /rustc/0f40f14b61430792cc0ea316f424685041e8443e/library/std/src/sys_common/backtrace.rs:68:5
3: 0x77fd7d334b35 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h65a05c4cbe1ebf40
at /rustc/0f40f14b61430792cc0ea316f424685041e8443e/library/std/src/sys_common/backtrace.rs:44:22
4: 0x77fd7d383cfb - core::fmt::rt::Argument::fmt::h033c76ea7ea75413
at /rustc/0f40f14b61430792cc0ea316f424685041e8443e/library/core/src/fmt/rt.rs:165:63
5: 0x77fd7d383cfb - core::fmt::write::h33ad7509b2338e1d
at /rustc/0f40f14b61430792cc0ea316f424685041e8443e/library/core/src/fmt/mod.rs:1157:21
6: 0x77fd7d3298ff - std::io::Write::write_fmt::hf66d49f3041f55e8
at /rustc/0f40f14b61430792cc0ea316f424685041e8443e/library/std/src/io/mod.rs:1835:15
7: 0x77fd7d33490e - std::sys_common::backtrace::_print::h2ca303a605610994
at /rustc/0f40f14b61430792cc0ea316f424685041e8443e/library/std/src/sys_common/backtrace.rs:47:5
8: 0x77fd7d33490e - std::sys_common::backtrace::print::h592d77d1173200d4
at /rustc/0f40f14b61430792cc0ea316f424685041e8443e/library/std/src/sys_common/backtrace.rs:34:9
9: 0x77fd7d337279 - std::panicking::default_hook::{{closure}}::h4da60be94553ec4b
10: 0x77fd7d336fbd - std::panicking::default_hook::h40234bfa16395ce9
at /rustc/0f40f14b61430792cc0ea316f424685041e8443e/library/std/src/panicking.rs:298:9
11: 0x77fd79cbdb20 - std[8d7719e78985e352]::panicking::update_hook::<alloc[836d2b0baf2f5989]::boxed::Box<rustc_driver_impl[589f8a1b01aee9f6]::install_ice_hook::{closure#0}>>::{closure#0}
12: 0x77fd7d337976 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hceeefca90c01e520
at /rustc/0f40f14b61430792cc0ea316f424685041e8443e/library/alloc/src/boxed.rs:2036:9
13: 0x77fd7d337976 - std::panicking::rust_panic_with_hook::h9534e82f08371dbb
at /rustc/0f40f14b61430792cc0ea316f424685041e8443e/library/std/src/panicking.rs:799:13
14: 0x77fd79ced2a4 - std[8d7719e78985e352]::panicking::begin_panic::<rustc_errors[fd86f5e87ff11908]::ExplicitBug>::{closure#0}
15: 0x77fd79ce9c56 - std[8d7719e78985e352]::sys_common::backtrace::__rust_end_short_backtrace::<std[8d7719e78985e352]::panicking::begin_panic<rustc_errors[fd86f5e87ff11908]::ExplicitBug>::{closure#0}, !>
16: 0x77fd79ce5206 - std[8d7719e78985e352]::panicking::begin_panic::<rustc_errors[fd86f5e87ff11908]::ExplicitBug>
17: 0x77fd79cf6431 - <rustc_errors[fd86f5e87ff11908]::diagnostic::BugAbort as rustc_errors[fd86f5e87ff11908]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
18: 0x77fd79f56488 - <rustc_errors[fd86f5e87ff11908]::DiagCtxt>::span_bug::<rustc_span[fbdf81e3d6e3d53e]::span_encoding::Span, alloc[836d2b0baf2f5989]::string::String>
19: 0x77fd79f8d3fd - rustc_middle[bc0899ebf53e261d]::util::bug::opt_span_bug_fmt::<rustc_span[fbdf81e3d6e3d53e]::span_encoding::Span>::{closure#0}
20: 0x77fd79f8d72a - rustc_middle[bc0899ebf53e261d]::ty::context::tls::with_opt::<rustc_middle[bc0899ebf53e261d]::util::bug::opt_span_bug_fmt<rustc_span[fbdf81e3d6e3d53e]::span_encoding::Span>::{closure#0}, !>::{closure#0}
21: 0x77fd79f72e2b - rustc_middle[bc0899ebf53e261d]::ty::context::tls::with_context_opt::<rustc_middle[bc0899ebf53e261d]::ty::context::tls::with_opt<rustc_middle[bc0899ebf53e261d]::util::bug::opt_span_bug_fmt<rustc_span[fbdf81e3d6e3d53e]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
22: 0x77fd79f71b57 - rustc_middle[bc0899ebf53e261d]::util::bug::span_bug_fmt::<rustc_span[fbdf81e3d6e3d53e]::span_encoding::Span>
23: 0x77fd7bbced1a - <rustc_infer[2b5dcaad1be1da29]::infer::InferCtxt>::subtype_predicate
24: 0x77fd77c9f174 - <rustc_trait_selection[2e2c9bd5c426cc94]::traits::fulfill::FulfillProcessor as rustc_data_structures[554e4596a38298e5]::obligation_forest::ObligationProcessor>::process_obligation
25: 0x77fd7b00d723 - <rustc_data_structures[554e4596a38298e5]::obligation_forest::ObligationForest<rustc_trait_selection[2e2c9bd5c426cc94]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[2e2c9bd5c426cc94]::traits::fulfill::FulfillProcessor>
26: 0x77fd7b802794 - <rustc_hir_typeck[d2375d88677be9f7]::fn_ctxt::FnCtxt>::coerce
27: 0x77fd7b820a44 - <rustc_hir_typeck[d2375d88677be9f7]::fn_ctxt::FnCtxt>::check_block_with_expected
28: 0x77fd7b82bdd5 - <rustc_hir_typeck[d2375d88677be9f7]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
29: 0x77fd7b7ed7b3 - rustc_hir_typeck[d2375d88677be9f7]::check::check_fn
30: 0x77fd7b7e3250 - rustc_hir_typeck[d2375d88677be9f7]::typeck
31: 0x77fd7b7e2ca3 - rustc_query_impl[f12a8811d86a62d9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f12a8811d86a62d9]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[bc0899ebf53e261d]::query::erase::Erased<[u8; 8usize]>>
32: 0x77fd7b5d00b1 - rustc_query_system[6d5fb7023970bca8]::query::plumbing::try_execute_query::<rustc_query_impl[f12a8811d86a62d9]::DynamicConfig<rustc_query_system[6d5fb7023970bca8]::query::caches::VecCache<rustc_span[fbdf81e3d6e3d53e]::def_id::LocalDefId, rustc_middle[bc0899ebf53e261d]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[f12a8811d86a62d9]::plumbing::QueryCtxt, false>
33: 0x77fd7b5cedcc - rustc_query_impl[f12a8811d86a62d9]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
34: 0x77fd7b98502f - rustc_middle[bc0899ebf53e261d]::query::plumbing::query_get_at::<rustc_query_system[6d5fb7023970bca8]::query::caches::VecCache<rustc_span[fbdf81e3d6e3d53e]::def_id::LocalDefId, rustc_middle[bc0899ebf53e261d]::query::erase::Erased<[u8; 8usize]>>>
35: 0x77fd79e24bb5 - <rustc_hir_analysis[7f78c912bc544423]::collect::type_of::opaque::TaitConstraintLocator>::check
36: 0x77fd79de71e2 - <rustc_hir_analysis[7f78c912bc544423]::collect::type_of::opaque::TaitConstraintLocator as rustc_hir[b4c4e1f6e3b963a3]::intravisit::Visitor>::visit_nested_item
37: 0x77fd7bd74398 - rustc_hir_analysis[7f78c912bc544423]::collect::type_of::type_of_opaque
38: 0x77fd7bd73c8f - rustc_query_impl[f12a8811d86a62d9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f12a8811d86a62d9]::query_impl::type_of_opaque::dynamic_query::{closure#2}::{closure#0}, rustc_middle[bc0899ebf53e261d]::query::erase::Erased<[u8; 8usize]>>
39: 0x77fd7b0877d7 - rustc_query_system[6d5fb7023970bca8]::query::plumbing::try_execute_query::<rustc_query_impl[f12a8811d86a62d9]::DynamicConfig<rustc_query_system[6d5fb7023970bca8]::query::caches::DefIdCache<rustc_middle[bc0899ebf53e261d]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[f12a8811d86a62d9]::plumbing::QueryCtxt, false>
40: 0x77fd7c00d39e - rustc_query_impl[f12a8811d86a62d9]::query_impl::type_of_opaque::get_query_non_incr::__rust_end_short_backtrace
41: 0x77fd7b6996bc - rustc_middle[bc0899ebf53e261d]::query::plumbing::query_get_at::<rustc_query_system[6d5fb7023970bca8]::query::caches::DefIdCache<rustc_middle[bc0899ebf53e261d]::query::erase::Erased<[u8; 8usize]>>>
42: 0x77fd78a574f6 - rustc_hir_analysis[7f78c912bc544423]::collect::type_of::type_of
43: 0x77fd7b088be6 - rustc_query_impl[f12a8811d86a62d9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f12a8811d86a62d9]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[bc0899ebf53e261d]::query::erase::Erased<[u8; 8usize]>>
44: 0x77fd7b0877d7 - rustc_query_system[6d5fb7023970bca8]::query::plumbing::try_execute_query::<rustc_query_impl[f12a8811d86a62d9]::DynamicConfig<rustc_query_system[6d5fb7023970bca8]::query::caches::DefIdCache<rustc_middle[bc0899ebf53e261d]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[f12a8811d86a62d9]::plumbing::QueryCtxt, false>
45: 0x77fd7b0872db - rustc_query_impl[f12a8811d86a62d9]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
46: 0x77fd7b6996bc - rustc_middle[bc0899ebf53e261d]::query::plumbing::query_get_at::<rustc_query_system[6d5fb7023970bca8]::query::caches::DefIdCache<rustc_middle[bc0899ebf53e261d]::query::erase::Erased<[u8; 8usize]>>>
47: 0x77fd7bf25dd0 - rustc_hir_analysis[7f78c912bc544423]::check::check::check_item_type
48: 0x77fd7b6b0dcc - rustc_hir_analysis[7f78c912bc544423]::check::wfcheck::check_well_formed
49: 0x77fd7b6af89d - rustc_query_impl[f12a8811d86a62d9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f12a8811d86a62d9]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[bc0899ebf53e261d]::query::erase::Erased<[u8; 1usize]>>
50: 0x77fd7b6af040 - rustc_query_system[6d5fb7023970bca8]::query::plumbing::try_execute_query::<rustc_query_impl[f12a8811d86a62d9]::DynamicConfig<rustc_query_system[6d5fb7023970bca8]::query::caches::VecCache<rustc_hir[b4c4e1f6e3b963a3]::hir_id::OwnerId, rustc_middle[bc0899ebf53e261d]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[f12a8811d86a62d9]::plumbing::QueryCtxt, false>
51: 0x77fd7b6aedbf - rustc_query_impl[f12a8811d86a62d9]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
52: 0x77fd7b6acd01 - rustc_hir_analysis[7f78c912bc544423]::check::wfcheck::check_mod_type_wf
53: 0x77fd7b6acb47 - rustc_query_impl[f12a8811d86a62d9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f12a8811d86a62d9]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[bc0899ebf53e261d]::query::erase::Erased<[u8; 1usize]>>
54: 0x77fd7bb1ce30 - rustc_query_system[6d5fb7023970bca8]::query::plumbing::try_execute_query::<rustc_query_impl[f12a8811d86a62d9]::DynamicConfig<rustc_query_system[6d5fb7023970bca8]::query::caches::DefaultCache<rustc_span[fbdf81e3d6e3d53e]::def_id::LocalModDefId, rustc_middle[bc0899ebf53e261d]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[f12a8811d86a62d9]::plumbing::QueryCtxt, false>
55: 0x77fd7bb1cbdb - rustc_query_impl[f12a8811d86a62d9]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
56: 0x77fd7b5cd0dc - rustc_hir_analysis[7f78c912bc544423]::check_crate
57: 0x77fd7b9b9047 - rustc_interface[1dc2dcc2b864e855]::passes::analysis
58: 0x77fd7b9b8b87 - rustc_query_impl[f12a8811d86a62d9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f12a8811d86a62d9]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[bc0899ebf53e261d]::query::erase::Erased<[u8; 1usize]>>
59: 0x77fd7bdd0225 - rustc_query_system[6d5fb7023970bca8]::query::plumbing::try_execute_query::<rustc_query_impl[f12a8811d86a62d9]::DynamicConfig<rustc_query_system[6d5fb7023970bca8]::query::caches::SingleCache<rustc_middle[bc0899ebf53e261d]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[f12a8811d86a62d9]::plumbing::QueryCtxt, false>
60: 0x77fd7bdcff89 - rustc_query_impl[f12a8811d86a62d9]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
61: 0x77fd7bc2e70e - rustc_interface[1dc2dcc2b864e855]::interface::run_compiler::<core[b90f87831ee46a2c]::result::Result<(), rustc_span[fbdf81e3d6e3d53e]::ErrorGuaranteed>, rustc_driver_impl[589f8a1b01aee9f6]::run_compiler::{closure#0}>::{closure#1}
62: 0x77fd7bc0be49 - std[8d7719e78985e352]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[1dc2dcc2b864e855]::util::run_in_thread_with_globals<rustc_interface[1dc2dcc2b864e855]::util::run_in_thread_pool_with_globals<rustc_interface[1dc2dcc2b864e855]::interface::run_compiler<core[b90f87831ee46a2c]::result::Result<(), rustc_span[fbdf81e3d6e3d53e]::ErrorGuaranteed>, rustc_driver_impl[589f8a1b01aee9f6]::run_compiler::{closure#0}>::{closure#1}, core[b90f87831ee46a2c]::result::Result<(), rustc_span[fbdf81e3d6e3d53e]::ErrorGuaranteed>>::{closure#0}, core[b90f87831ee46a2c]::result::Result<(), rustc_span[fbdf81e3d6e3d53e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b90f87831ee46a2c]::result::Result<(), rustc_span[fbdf81e3d6e3d53e]::ErrorGuaranteed>>
63: 0x77fd7bc0bbf8 - <<std[8d7719e78985e352]::thread::Builder>::spawn_unchecked_<rustc_interface[1dc2dcc2b864e855]::util::run_in_thread_with_globals<rustc_interface[1dc2dcc2b864e855]::util::run_in_thread_pool_with_globals<rustc_interface[1dc2dcc2b864e855]::interface::run_compiler<core[b90f87831ee46a2c]::result::Result<(), rustc_span[fbdf81e3d6e3d53e]::ErrorGuaranteed>, rustc_driver_impl[589f8a1b01aee9f6]::run_compiler::{closure#0}>::{closure#1}, core[b90f87831ee46a2c]::result::Result<(), rustc_span[fbdf81e3d6e3d53e]::ErrorGuaranteed>>::{closure#0}, core[b90f87831ee46a2c]::result::Result<(), rustc_span[fbdf81e3d6e3d53e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b90f87831ee46a2c]::result::Result<(), rustc_span[fbdf81e3d6e3d53e]::ErrorGuaranteed>>::{closure#2} as core[b90f87831ee46a2c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
64: 0x77fd7d3417bb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8236c067dabb3bba
at /rustc/0f40f14b61430792cc0ea316f424685041e8443e/library/alloc/src/boxed.rs:2022:9
65: 0x77fd7d3417bb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h842b37a516a98fc8
at /rustc/0f40f14b61430792cc0ea316f424685041e8443e/library/alloc/src/boxed.rs:2022:9
66: 0x77fd7d3417bb - std::sys::pal::unix::thread::Thread::new::thread_start::h82e010f2c7789ffb
at /rustc/0f40f14b61430792cc0ea316f424685041e8443e/library/std/src/sys/pal/unix/thread.rs:108:17
67: 0x77fd76aa955a - <unknown>
68: 0x77fd76b26a3c - <unknown>
69: 0x0 - <unknown>
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: please make sure that you have updated to the latest nightly
note: rustc 1.80.0-nightly (0f40f14b6 2024-05-07) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [typeck] type-checking `reify_as_tait`
#1 [type_of_opaque] computing type of opaque `Tait::{opaque#0}`
#2 [type_of] computing type of `Tait::{opaque#0}`
#3 [check_well_formed] checking that `Tait::{opaque#0}` is well-formed
#4 [check_mod_type_wf] checking that types are well-formed in top-level module
#5 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0425, E0601, E0658.
For more information about an error, try `rustc --explain E0425`.
@rustbot label +F-type_alias_impl_trait
Metadata
Metadata
Assignees
Labels
Category: This is a bug.`#[feature(type_alias_impl_trait)]`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Status: This bug is tracked inside the repo by a `known-bug` test.Status: A Minimal Complete and Verifiable Example has been found for this issueRelevant to the compiler team, which will review and decide on the PR/issue.