Closed
Description
rustc crashes on the following input, found by fuzz-rustc:
trait C{async fn b(){fn a()}}
$ rustc bug.rs
error[E0670]: `async fn` is not permitted in Rust 2015
--> bug.rs:1:9
|
1 | trait C{async fn b(){fn a()}}
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
= help: set `edition = "2018"` in `Cargo.toml`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error: expected one of `->`, `;`, `where`, or `{`, found `}`
--> bug.rs:1:28
|
1 | trait C{async fn b(){fn a()}}
| - ^ expected one of `->`, `;`, `where`, or `{`
| |
| while parsing this `fn`
error[E0706]: functions in traits cannot be declared `async`
--> bug.rs:1:9
|
1 | trait C{async fn b(){fn a()}}
| -----^^^^^^^^^^^^^^^
| |
| `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
error: free function without a body
--> bug.rs:1:22
|
1 | trait C{async fn b(){fn a()}}
| ^^^^^-
| |
| help: provide a definition for the function: `{ <body> }`
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_middle/src/hir/map/collector.rs:227:50
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
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-compiler&template=ice.md
note: rustc 1.53.0-nightly (a86612456 2021-04-11) running on x86_64-unknown-linux-gnu
query stack during panic:
thread 'rustc' panicked at 'already borrowed: BorrowMutError', /rustc/a8661245649f3d1c0dc5b23270bdac0bbd2d8f64/compiler/rustc_data_structures/src/sync.rs:481:16
stack backtrace:
0: 0x7ff7b6025e90 - std::backtrace_rs::backtrace::libunwind::trace::h6a5a16c17f2319af
at /rustc/a8661245649f3d1c0dc5b23270bdac0bbd2d8f64/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
1: 0x7ff7b6025e90 - std::backtrace_rs::backtrace::trace_unsynchronized::hcafc938d846f3b80
at /rustc/a8661245649f3d1c0dc5b23270bdac0bbd2d8f64/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7ff7b6025e90 - std::sys_common::backtrace::_print_fmt::h7b5e8e740a969b2e
at /rustc/a8661245649f3d1c0dc5b23270bdac0bbd2d8f64/library/std/src/sys_common/backtrace.rs:67:5
3: 0x7ff7b6025e90 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h111ecac9cf62ba00
at /rustc/a8661245649f3d1c0dc5b23270bdac0bbd2d8f64/library/std/src/sys_common/backtrace.rs:46:22
4: 0x7ff7b609711f - core::fmt::write::h7aa6cd0067dca82a
at /rustc/a8661245649f3d1c0dc5b23270bdac0bbd2d8f64/library/core/src/fmt/mod.rs:1094:17
5: 0x7ff7b601a805 - std::io::Write::write_fmt::h3f775e769673afe3
at /rustc/a8661245649f3d1c0dc5b23270bdac0bbd2d8f64/library/std/src/io/mod.rs:1580:15
...
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-compiler&template=ice.md
note: rustc 1.53.0-nightly (a86612456 2021-04-11) running on x86_64-unknown-linux-gnu
query stack during panic:
end of query stack
thread panicked while panicking. aborting.
Illegal instruction (core dumped)
The error happens on nightly and beta, but not on stable.