Closed Cassin01 closed 2 years ago
A test case without actix and the trait:
#![feature(async_closure)]
use std::future::Future;
type FA<R> = dyn FnOnce() -> R + 'static;
fn master() -> FA<impl Future<Output = ()>> {
async move || -> () { () }
}
Error still is:
VecMap([(OpaqueTypeKey { def_id: DefId(0:9 ~ issue_96270[73e3]::master::{opaque#0}), substs: [] }, OpaqueTypeDecl { hidden_type: OpaqueHiddenType { span: src/lib.rs:6:19: 6:43 (#5), ty: _ }, origin: FnReturn(DefId(0:8 ~ issue_96270[73e3]::master)) })])
The issue seems to arise from the type alias and impl Trait
as its return type. Since if you inline it, you get a good error message:
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return
--> src/lib.rs:4:33
|
4 | fn master() -> dyn FnOnce() -> (impl Future<Output = ()> + 'static) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0562`.
error: could not compile `issue-96270` due to previous error
Code
Meta
rustc --version --verbose
:Error output
Backtrace
``` ❯ cargo run Compiling actix01 v0.1.0 (/Users/NAME/all_year/web-site/actix01) thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_infer/src/infer/opaque_typ es.rs:428:47 stack backtrace: 0: 0x10bd86104 -::fmt::h7d1c
4e9dbb122fe4
1: 0x10bde055b - core::fmt::write::h1dd7703407456672
2: 0x10bd78798 - std::io::Write::write_fmt::hd35189fe8d4c5666
3: 0x10bd894bd - std::panicking::default_hook::{{closure}}::hd40c7909795a526f
4: 0x10bd891a1 - std::panicking::default_hook::h81168ea2d25114b0
5: 0x11b4d615d - rustc_driver[3cbd82847cf296fb]::DEFAULT_HOOK::{closure#0}::{closure#0}
6: 0x10bd89c26 - std::panicking::rust_panic_with_hook::hd052369e2a2de97f
7: 0x10bd89a2a - std::panicking::begin_panic_handler::{{closure}}::h92e3b3cc0c31bfe6
8: 0x10bd86587 - std::sys_common::backtrace::__rust_end_short_backtrace::h2f15c15bd4f44f08
9: 0x10bd8973a - _rust_begin_unwind
10: 0x10be09c43 - core::panicking::panic_fmt::h4c5d9b17dced048f
11: 0x10be09b27 - core::panicking::panic::h0b65e708c1acc353
12: 0x11f864e03 - ::handle_opaque_type::{closure#0}
13: 0x11f864848 - ::handle_opaque_type
14: 0x11f8e8354 - ::tys
15: 0x11f7eeee2 - ::relate::
16: 0x11f6ef66a - ::commit_if_ok::, rustc_middle[b15ac2f09a9de55b]::ty::error::TypeError, ::eq::{closure#0}>
17: 0x11f74a35c - rustc_trait_selection[a92e31b53c3de38f]::traits::project::project_and_unify_type
18: 0x11f6f1a25 - ::commit_if_ok::
19: 0x11f73bb3a - ::evaluate_pr
edicate_recursively
20: 0x11f6f6459 - ::probe::, ::evaluation_pr
obe<::evaluate_root_obligation::{closure
#0}>::{closure#0}>
21: 0x11f72dabf - ::evaluate_ro
ot_obligation
22: 0x11e893334 - ::enter_with_canonical::, core[976a65f03211a467]::re
sult::Result, rustc_traits[2edef877ef4cfff6]::evaluate_obligation::evaluate_obligation::{closure#0}>
23: 0x11e92e8a0 - rustc_traits[2edef877ef4cfff6]::evaluate_obligation::evaluate_obligation
24: 0x11ed8b77f - ::with_deps::<>::with_task_impl>, core[976a65f03211a467]::result::Result>::{c
losure#0}, core[976a65f03211a467]::result::Result>
25: 0x11ee0284a - >::with_task::>, core[976a65f03211a467]::result::Result>
26: 0x11ecadcad - rustc_query_system[15f37b9c69565f8a]::query::plumbing::get_query::
27: 0x11ef33069 - ::evaluate_obligation
28: 0x11f725b86 - ::evaluate_obligation
29: 0x11f725c8f - ::evaluate_obligation_no_overflow
30: 0x11f776eb6 - >> as core[976a65f03211a467]::iter::traits::iterator::Iterator>::try_fold::<(), core[976a65f03211a467]::iter::
traits::iterator::Iterator::all::check, ::suggest_impl_trait::{closure#5}::{closure#0}>::{
closure#0}, core[976a65f03211a467]::ops::control_flow::ControlFlow<()>>
31: 0x11f706070 - ::suggest_impl_trait
32: 0x11f71b45e - ::report_selection_error
33: 0x11f7263c8 - ::report_fulfillment_error
34: 0x11f716b22 - ::report_fulfillment_errors
35: 0x11e03ddcf - ::type_inference_fallback
36: 0x11e18efb0 - ::enter::<&rustc_middle[b15ac2f0
9a9de55b]::ty::context::TypeckResults, ::enter<
rustc_typeck[ab8d13ddb4ec143f]::check::typeck_with_fallback::{closure#1}, &rustc_middle[b15ac2f09a9de55b]::ty::context::TypeckResults>::{closure#0}>
37: 0x11e12cc71 - rustc_typeck[ab8d13ddb4ec143f]::check::typeck
38: 0x11ee0ea5b - >::with_task::
39: 0x11ebd8655 - rustc_query_system[15f37b9c69565f8a]::query::plumbing::try_execute_query::>
40: 0x11eccf8de - rustc_query_system[15f37b9c69565f8a]::query::plumbing::get_query::
41: 0x11f9cf919 - ::typeck_opt_const_arg
42: 0x11e5ae51a - rustc_mir_build[4e3932fe37748ce5]::build::mir_built
43: 0x11ed8af09 - ::with_deps::<>::with_task_impl, &rustc_data_structures[16dd00d5237e3cef]::steal::Steal>::{closure#0
}, &rustc_data_structures[16dd00d5237e3cef]::steal::Steal>
44: 0x11edfe3cd - >::with_task::, &rustc_data_structu
res[16dd00d5237e3cef]::steal::Steal>
45: 0x11ebb77e5 - rustc_query_system[15f37b9c69565f8a]::query::plumbing::try_execute_query::, &rustc_data_stru
ctures[16dd00d5237e3cef]::steal::Steal>>
46: 0x11ecd207e - rustc_query_system[15f37b9c69565f8a]::query::plumbing::get_query::
47: 0x11ef30c77 - ::mir_built
48: 0x11dec728b - rustc_mir_transform[29f25866498b7f99]::check_unsafety::unsafety_check_result
49: 0x11dec3c33 - >::call_once
50: 0x11ee0fb0b - >::with_task::
51: 0x11ebda815 - rustc_query_system[15f37b9c69565f8a]::query::plumbing::try_execute_query::>
52: 0x11ecb689e - rustc_query_system[15f37b9c69565f8a]::query::plumbing::get_query::
53: 0x11deacbd1 - rustc_mir_transform[29f25866498b7f99]::mir_const
54: 0x11ed8af09 - ::with_deps::<>::with_task_impl, &rustc_data_structures[16dd00d5237e3cef]::steal::Steal>::{closure#0
}, &rustc_data_structures[16dd00d5237e3cef]::steal::Steal>
55: 0x11edfe3cd - >::with_task::, &rustc_data_structu
res[16dd00d5237e3cef]::steal::Steal>
56: 0x11ebb77e5 - rustc_query_system[15f37b9c69565f8a]::query::plumbing::try_execute_query::, &rustc_data_stru
ctures[16dd00d5237e3cef]::steal::Steal>>
57: 0x11ecd21bb - rustc_query_system[15f37b9c69565f8a]::query::plumbing::get_query::
58: 0x11ef30ca7 - ::mir_const
59: 0x11dead724 - rustc_mir_transform[29f25866498b7f99]::mir_promoted
60: 0x11ed8afc9 - ::with_deps::<>::with_task_impl, (&rustc_data_structures[16dd00d5237e3cef]::steal::Steal, &rustc_dat
a_structures[16dd00d5237e3cef]::steal::Steal>)>::{closure#0}, (&rustc_data_structures[16dd00d52
37e3cef]::steal::Steal, &rustc_data_structures[16dd00d5237e3cef]::steal:
:Steal>)>
61: 0x11edfe90a - >::with_task::, (&rustc_data_struct
ures[16dd00d5237e3cef]::steal::Steal, &rustc_data_structures[16dd00d5237
e3cef]::steal::Steal>)>
62: 0x11ec9d4ac - rustc_query_system[15f37b9c69565f8a]::query::plumbing::get_query::
63: 0x11ef30e27 - ::mir_promoted
64: 0x11e7a3883 - rustc_borrowck[96025d6d88d0c618]::mir_borrowck
65: 0x11e77b3d3 - >::call_once
66: 0x11ee0f57b - >::with_task::
67: 0x11ebd9735 - rustc_query_system[15f37b9c69565f8a]::query::plumbing::try_execute_query::>
68: 0x11ec9c743 - rustc_query_system[15f37b9c69565f8a]::query::plumbing::get_query::
69: 0x11e2b4dab - rustc_typeck[ab8d13ddb4ec143f]::collect::type_of::type_of
70: 0x11ee1922b - >::with_task::
71: 0x11ebf8a11 - rustc_query_system[15f37b9c69565f8a]::query::plumbing::try_execute_query::>
72: 0x11eccfb9d - rustc_query_system[15f37b9c69565f8a]::query::plumbing::get_query::
73: 0x11e0c9812 - rustc_typeck[ab8d13ddb4ec143f]::check::check::check_item_type
74: 0x11e2921a8 - ::visit_item_likes_in_module::
75: 0x11e0cece5 - rustc_typeck[ab8d13ddb4ec143f]::check::check::check_mod_item_types
76: 0x11ee10626 - >::with_task::
77: 0x11ebdc984 - rustc_query_system[15f37b9c69565f8a]::query::plumbing::try_execute_query::>
78: 0x11ecb03bb - rustc_query_system[15f37b9c69565f8a]::query::plumbing::get_query::
79: 0x11e291053 - ::for_each_module::
80: 0x11e15eea0 - ::time::<(), rustc_typeck[ab8d13ddb4e
c143f]::check_crate::{closure#6}>
81: 0x11e15c512 - rustc_typeck[ab8d13ddb4ec143f]::check_crate
82: 0x11b5b2bda - rustc_interface[379c4e9a5969b218]::passes::analysis
83: 0x11ee37a17 - >::with_task::>
84: 0x11ec34246 - rustc_query_system[15f37b9c69565f8a]::query::plumbing::try_execute_query::>>
85: 0x11eccfcbf - rustc_query_system[15f37b9c69565f8a]::query::plumbing::get_query::
86: 0x11b4957ed - ::enter::>
87: 0x11b47901a - ::enter::, rustc_errors[4f0dbc95d6bf05e9]::ErrorGuaranteed>>
88: 0x11b4dc2d8 - rustc_span[d307e707487d1bd]::with_source_map::, rustc_interface[379c4e9a5969b218]::interface::create_compiler_a
nd_run, rustc_driver[3c
bd82847cf296fb]::run_compiler::{closure#1}>::{closure#1}>
89: 0x11b479ada - rustc_interface[379c4e9a5969b218]::interface::create_compiler_and_run::, rustc_driver[3cbd82847cf296fb]::run_co
mpiler::{closure#1}>
90: 0x11b472fd5 - >::
set::, rustc_driver[3cbd82847cf296fb]::run_compiler::{closure#1}>::{closure#0},
core[976a65f03211a467]::result::Result<(), rustc_errors[4f0dbc95d6bf05e9]::ErrorGuaranteed>>
91: 0x11b49dc79 - std[88d32b739ab0a2e9]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver[3cb
d82847cf296fb]::run_compiler::{closure#1}>::{closure#0}, core[976a65f03211a467]::result::Result<(), rustc_errors[4f
0dbc95d6bf05e9]::ErrorGuaranteed>>::{closure#0}, core[976a65f03211a467]::result::Result<(), rustc_errors[4f0dbc95d6
bf05e9]::ErrorGuaranteed>>
92: 0x11b49e4a1 - <::spawn_unchecked_, rustc_driver[3cbd82847cf296fb]::r
un_compiler::{closure#1}>::{closure#0}, core[976a65f03211a467]::result::Result<(), rustc_errors[4f0dbc95d6bf05e9]::
ErrorGuaranteed>>::{closure#0}, core[976a65f03211a467]::result::Result<(), rustc_errors[4f0dbc95d6bf05e9]::ErrorGua
ranteed>>::{closure#1} as core[976a65f03211a467]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
93: 0x10bd92e27 - std::sys::unix::thread::Thread::new::thread_start::hdb038b603eab1d5f
94: 0x7ff81264a4f4 - __pthread_start
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-com
piler&template=ice.md
note: rustc 1.62.0-nightly (4ca19e09d 2022-04-19) running on x86_64-apple-darwin
note: compiler flags: --crate-type bin -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incrementa
l
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `<[closure@src/main.rs:7:5: 9:6] as core::ops::funct
ion::FnOnce<()>>::Output == impl core::future::future::Future