Closed
Description
rustc crashes on the following input, found by fuzz_rustc:
trait a{async fn e(){Ok(())}}
$ rustc bug.rs
error[E0670]: `async fn` is not permitted in Rust 2015
--> bug.rs:1:9
|
1 | trait a{async fn e(){Ok(())}}
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
= help: pass `--edition 2021` to `rustc`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
warning: trait `a` should have an upper camel case name
--> bug.rs:1:7
|
1 | trait a{async fn e(){Ok(())}}
| ^ help: convert the identifier to upper camel case: `A`
|
= note: `#[warn(non_camel_case_types)]` on by default
error[E0706]: functions in traits cannot be declared `async`
--> bug.rs:1:9
|
1 | trait a{async fn e(){Ok(())}}
| -----^^^^^^^
| |
| `async` because of this
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
error[E0601]: `main` function not found in crate `bug`
--> bug.rs:1:30
|
1 | trait a{async fn e(){Ok(())}}
| ^ consider adding a `main` function to `bug.rs`
error: internal compiler error: compiler/rustc_hir_analysis/src/check/fn_ctxt/suggestions.rs:884:29: failed to get output type of async function
--> bug.rs:1:21
|
1 | trait a{async fn e(){Ok(())}}
| ^
thread 'rustc' panicked at 'Box<dyn Any>', /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/compiler/rustc_errors/src/lib.rs:1441:9
stack backtrace:
0: 0x7f2a7216c5b0 - std::backtrace_rs::backtrace::libunwind::trace::h0bf6f02637fe6971
at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
1: 0x7f2a7216c5b0 - std::backtrace_rs::backtrace::trace_unsynchronized::hca573de4ebdee142
at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7f2a7216c5b0 - std::sys_common::backtrace::_print_fmt::h78a3b0f3fa5431ce
at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/sys_common/backtrace.rs:66:5
3: 0x7f2a7216c5b0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h388012888db78658
at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/sys_common/backtrace.rs:45:22
4: 0x7f2a721c859e - core::fmt::write::h8541eee12bfb22e1
at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/core/src/fmt/mod.rs:1209:17
5: 0x7f2a7215c835 - std::io::Write::write_fmt::haf5892ef07750179
at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/io/mod.rs:1680:15
6: 0x7f2a7216f353 - std::sys_common::backtrace::_print::hd2a58ab324867b58
at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/sys_common/backtrace.rs:48:5
7: 0x7f2a7216f353 - std::sys_common::backtrace::print::h62650e0a0854a421
at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/sys_common/backtrace.rs:35:9
8: 0x7f2a7216f353 - std::panicking::default_hook::{{closure}}::h0c0249b3670af819
at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/panicking.rs:267:22
9: 0x7f2a7216f02a - std::panicking::default_hook::hdd3bdd204a1e5f34
at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/panicking.rs:286:9
10: 0x7f2a74aab641 - rustc_driver[1f63e0707e3aafaf]::DEFAULT_HOOK::{closure#0}::{closure#0}
11: 0x7f2a7216fb8b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h6f493fd9c4eb244a
at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/alloc/src/boxed.rs:1952:9
12: 0x7f2a7216fb8b - std::panicking::rust_panic_with_hook::hcdeb5a66936a633b
at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/panicking.rs:673:13
13: 0x7f2a74cecbf1 - std[7bd0f41fe60b70b6]::panicking::begin_panic::<rustc_errors[d5334a4a25fbb394]::ExplicitBug>::{closure#0}
14: 0x7f2a74ceb3f6 - std[7bd0f41fe60b70b6]::sys_common::backtrace::__rust_end_short_backtrace::<std[7bd0f41fe60b70b6]::panicking::begin_panic<rustc_errors[d5334a4a25fbb394]::ExplicitBug>::{closure#0}, !>
15: 0x7f2a74cea236 - std[7bd0f41fe60b70b6]::panicking::begin_panic::<rustc_errors[d5334a4a25fbb394]::ExplicitBug>
16: 0x7f2a74d53076 - std[7bd0f41fe60b70b6]::panic::panic_any::<rustc_errors[d5334a4a25fbb394]::ExplicitBug>
17: 0x7f2a74d52f3f - <rustc_errors[d5334a4a25fbb394]::HandlerInner>::span_bug::<rustc_span[ddec628aeed15f05]::span_encoding::Span, &alloc[9f2f41052ee9385c]::string::String>
18: 0x7f2a74d52be0 - <rustc_errors[d5334a4a25fbb394]::Handler>::span_bug::<rustc_span[ddec628aeed15f05]::span_encoding::Span, &alloc[9f2f41052ee9385c]::string::String>
19: 0x7f2a74d54108 - rustc_middle[a8ed4a0dc47aac3]::ty::context::tls::with_context_opt::<rustc_middle[a8ed4a0dc47aac3]::ty::context::tls::with_opt<rustc_middle[a8ed4a0dc47aac3]::util::bug::opt_span_bug_fmt<rustc_span[ddec628aeed15f05]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
20: 0x7f2a74d53f86 - rustc_middle[a8ed4a0dc47aac3]::util::bug::opt_span_bug_fmt::<rustc_span[ddec628aeed15f05]::span_encoding::Span>
21: 0x7f2a736a6bb4 - rustc_middle[a8ed4a0dc47aac3]::util::bug::span_bug_fmt::<rustc_span[ddec628aeed15f05]::span_encoding::Span>
22: 0x7f2a74cac533 - <rustc_hir_analysis[a6a5d63f9823a7da]::check::fn_ctxt::FnCtxt>::suggest_missing_break_or_return_expr::{closure#2}
23: 0x7f2a74cac456 - <rustc_hir_analysis[a6a5d63f9823a7da]::check::fn_ctxt::FnCtxt>::suggest_missing_break_or_return_expr
24: 0x7f2a74da27ff - <rustc_hir_analysis[a6a5d63f9823a7da]::check::coercion::CoerceMany<&rustc_hir[b10a2ea55ce97d34]::hir::Expr>>::report_return_mismatched_types
25: 0x7f2a736b07b0 - <rustc_hir_analysis[a6a5d63f9823a7da]::check::fn_ctxt::FnCtxt>::check_block_with_expected
26: 0x7f2a73687bfe - <rustc_hir_analysis[a6a5d63f9823a7da]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
27: 0x7f2a736895cf - <rustc_hir_analysis[a6a5d63f9823a7da]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
28: 0x7f2a736aec2f - <rustc_hir_analysis[a6a5d63f9823a7da]::check::fn_ctxt::FnCtxt>::check_block_with_expected
29: 0x7f2a73687bfe - <rustc_hir_analysis[a6a5d63f9823a7da]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
30: 0x7f2a73fe2ba6 - <rustc_hir_analysis[a6a5d63f9823a7da]::check::fn_ctxt::FnCtxt>::check_return_expr
31: 0x7f2a73fd9850 - rustc_hir_analysis[a6a5d63f9823a7da]::check::check::check_fn
32: 0x7f2a7373957b - <rustc_hir_analysis[a6a5d63f9823a7da]::check::fn_ctxt::FnCtxt>::check_expr_closure
33: 0x7f2a7368ab3d - <rustc_hir_analysis[a6a5d63f9823a7da]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
34: 0x7f2a73705d79 - <rustc_hir_analysis[a6a5d63f9823a7da]::check::fn_ctxt::FnCtxt>::check_argument_types
35: 0x7f2a736c57a8 - <rustc_hir_analysis[a6a5d63f9823a7da]::check::fn_ctxt::FnCtxt>::check_call
36: 0x7f2a736879ad - <rustc_hir_analysis[a6a5d63f9823a7da]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
37: 0x7f2a73fe2ba6 - <rustc_hir_analysis[a6a5d63f9823a7da]::check::fn_ctxt::FnCtxt>::check_return_expr
38: 0x7f2a73fd9850 - rustc_hir_analysis[a6a5d63f9823a7da]::check::check::check_fn
39: 0x7f2a73fcb13c - <rustc_hir_analysis[a6a5d63f9823a7da]::check::inherited::InheritedBuilder>::enter::<rustc_hir_analysis[a6a5d63f9823a7da]::check::typeck_with_fallback<rustc_hir_analysis[a6a5d63f9823a7da]::check::typeck::{closure#0}>::{closure#1}, &rustc_middle[a8ed4a0dc47aac3]::ty::context::TypeckResults>
40: 0x7f2a73fca00c - rustc_hir_analysis[a6a5d63f9823a7da]::check::typeck
41: 0x7f2a740ea595 - rustc_query_system[a76597d842537d9]::query::plumbing::try_execute_query::<rustc_query_impl[1e7ed5a7eb258aab]::plumbing::QueryCtxt, rustc_query_system[a76597d842537d9]::query::caches::DefaultCache<rustc_span[ddec628aeed15f05]::def_id::LocalDefId, &rustc_middle[a8ed4a0dc47aac3]::ty::context::TypeckResults>>
42: 0x7f2a749ac1ee - <rustc_query_impl[1e7ed5a7eb258aab]::Queries as rustc_middle[a8ed4a0dc47aac3]::ty::query::QueryEngine>::typeck
43: 0x7f2a747dcdf7 - rustc_data_structures[fec937313883fa6d]::sync::par_for_each_in::<&[rustc_span[ddec628aeed15f05]::def_id::LocalDefId], <rustc_middle[a8ed4a0dc47aac3]::hir::map::Map>::par_body_owners<rustc_hir_analysis[a6a5d63f9823a7da]::check::typeck_item_bodies::{closure#0}>::{closure#0}>
44: 0x7f2a747dcbb3 - rustc_hir_analysis[a6a5d63f9823a7da]::check::typeck_item_bodies
45: 0x7f2a746fe66a - rustc_query_system[a76597d842537d9]::query::plumbing::try_execute_query::<rustc_query_impl[1e7ed5a7eb258aab]::plumbing::QueryCtxt, rustc_query_system[a76597d842537d9]::query::caches::DefaultCache<(), ()>>
46: 0x7f2a746fe397 - rustc_query_system[a76597d842537d9]::query::plumbing::get_query::<rustc_query_impl[1e7ed5a7eb258aab]::queries::typeck_item_bodies, rustc_query_impl[1e7ed5a7eb258aab]::plumbing::QueryCtxt>
47: 0x7f2a744a37cf - <rustc_session[8b98ba4aacc9d309]::session::Session>::time::<(), rustc_hir_analysis[a6a5d63f9823a7da]::check_crate::{closure#7}>
48: 0x7f2a744a339f - rustc_hir_analysis[a6a5d63f9823a7da]::check_crate
49: 0x7f2a744a2ea7 - rustc_interface[cf2fa28a67e8bef]::passes::analysis
50: 0x7f2a748359e4 - rustc_query_system[a76597d842537d9]::query::plumbing::try_execute_query::<rustc_query_impl[1e7ed5a7eb258aab]::plumbing::QueryCtxt, rustc_query_system[a76597d842537d9]::query::caches::DefaultCache<(), core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>>>
51: 0x7f2a74835717 - rustc_query_system[a76597d842537d9]::query::plumbing::get_query::<rustc_query_impl[1e7ed5a7eb258aab]::queries::analysis, rustc_query_impl[1e7ed5a7eb258aab]::plumbing::QueryCtxt>
52: 0x7f2a73764044 - <rustc_interface[cf2fa28a67e8bef]::passes::QueryContext>::enter::<rustc_driver[1f63e0707e3aafaf]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>>
53: 0x7f2a73760496 - <rustc_interface[cf2fa28a67e8bef]::interface::Compiler>::enter::<rustc_driver[1f63e0707e3aafaf]::run_compiler::{closure#1}::{closure#2}, core[fae631be8e3c81b5]::result::Result<core[fae631be8e3c81b5]::option::Option<rustc_interface[cf2fa28a67e8bef]::queries::Linker>, rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>>
54: 0x7f2a7375b43c - rustc_span[ddec628aeed15f05]::with_source_map::<core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>, rustc_interface[cf2fa28a67e8bef]::interface::create_compiler_and_run<core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>, rustc_driver[1f63e0707e3aafaf]::run_compiler::{closure#1}>::{closure#1}>
55: 0x7f2a7375ae3f - rustc_interface[cf2fa28a67e8bef]::interface::create_compiler_and_run::<core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>, rustc_driver[1f63e0707e3aafaf]::run_compiler::{closure#1}>
56: 0x7f2a7375a032 - <scoped_tls[4da31d6f3f5146b7]::ScopedKey<rustc_span[ddec628aeed15f05]::SessionGlobals>>::set::<rustc_interface[cf2fa28a67e8bef]::interface::run_compiler<core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>, rustc_driver[1f63e0707e3aafaf]::run_compiler::{closure#1}>::{closure#0}, core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>>
57: 0x7f2a7375950f - std[7bd0f41fe60b70b6]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[cf2fa28a67e8bef]::util::run_in_thread_pool_with_globals<rustc_interface[cf2fa28a67e8bef]::interface::run_compiler<core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>, rustc_driver[1f63e0707e3aafaf]::run_compiler::{closure#1}>::{closure#0}, core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>>::{closure#0}, core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>>
58: 0x7f2a7375937f - <<std[7bd0f41fe60b70b6]::thread::Builder>::spawn_unchecked_<rustc_interface[cf2fa28a67e8bef]::util::run_in_thread_pool_with_globals<rustc_interface[cf2fa28a67e8bef]::interface::run_compiler<core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>, rustc_driver[1f63e0707e3aafaf]::run_compiler::{closure#1}>::{closure#0}, core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>>::{closure#0}, core[fae631be8e3c81b5]::result::Result<(), rustc_errors[d5334a4a25fbb394]::ErrorGuaranteed>>::{closure#1} as core[fae631be8e3c81b5]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
59: 0x7f2a72179793 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc67cb2c032770d7f
at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/alloc/src/boxed.rs:1938:9
60: 0x7f2a72179793 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he79e59a805a8533c
at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/alloc/src/boxed.rs:1938:9
61: 0x7f2a72179793 - std::sys::unix::thread::Thread::new::thread_start::hae509166483801f9
at /rustc/db0597f5619d5ed93feca28e61226d3581cc7867/library/std/src/sys/unix/thread.rs:108:17
62: 0x7f2a71e94b43 - start_thread
at ./nptl/./nptl/pthread_create.c:442:8
63: 0x7f2a71f26a00 - clone3
at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
64: 0x0 - <unknown>
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-compiler&template=ice.md
note: rustc 1.66.0-nightly (db0597f56 2022-10-11) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [typeck] type-checking `a::e`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors; 1 warning emitted
Some errors have detailed explanations: E0601, E0670, E0706.
For more information about an error, try `rustc --explain E0601`.