Skip to content

Returning Result<T, Box<dyn std::error::Error>> from async task crashes rust compiler #810

Closed
@aodhneine

Description

@aodhneine

Platform

:: uname -a
Linux voyager 5.6.4-gentoo #1 SMP Sun Apr 26 14:39:09 UTC 2020 x86_64 Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz GenuineIntel GNU/Linux

rustc version:

:: rustc --version
rustc 1.45.0-nightly (f93bb2a50 2020-05-25)

cargo version:

:: cargo --version
cargo 1.45.0-nightly (500b2bd01 2020-05-18)

Code

type NewResult<T> = Result<T, Box<dyn std::error::Error>>;

fn main() -> NewResult<()> {
    async_std::task::block_on(async {
        let handle = async_std::task::spawn(async move {
            return NewResult::<()>::Ok(());
         });
         handle.await?;
         return NewResult::<()>::Ok(());
    })?;

    return Ok(());
}

Bug
This code results in following internal compiler error:

:: cargo build -j16 --verbose
   Compiling issue_test_return_async_std v0.1.0 (/home/julia/tmp/issue_test_return_async_std)
     Running `rustc --crate-name issue_test_return_async_std --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -Cembed-bitcode=no -C debuginfo=2 -C metadata=6995fa926d1dae26 -C extra-filename=-6995fa926d1dae26 --out-dir /home/julia/tmp/issue_test_return_async_std/target/debug/deps -C incremental=/home/julia/tmp/issue_test_return_async_std/target/debug/incremental -L dependency=/home/julia/tmp/issue_test_return_async_std/target/debug/deps --extern async_std=/home/julia/tmp/issue_test_return_async_std/target/debug/deps/libasync_std-c7ce65bf6fabb5ef.rlib`
error: internal compiler error: src/librustc_middle/ich/impls_ty.rs:94: StableHasher: unexpected region '_#3r

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:907:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.45.0-nightly (f93bb2a50 2020-05-25) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

error: aborting due to previous error

error: could not compile `issue_test_return_async_std`.

Caused by:
  process didn't exit successfully: `rustc --crate-name issue_test_return_async_std --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -Cembed-bitcode=no -C debuginfo=2 -C metadata=6995fa926d1dae26 -C extra-filename=-6995fa926d1dae26 --out-dir /home/julia/tmp/issue_test_return_async_std/target/debug/deps -C incremental=/home/julia/tmp/issue_test_return_async_std/target/debug/incremental -L dependency=/home/julia/tmp/issue_test_return_async_std/target/debug/deps --extern async_std=/home/julia/tmp/issue_test_return_async_std/target/debug/deps/libasync_std-c7ce65bf6fabb5ef.rlib` (exit code: 101)
::

Cargo.toml:

[package]
name = "issue_test_return_async_std"
version = "0.1.0"
authors = ["aodhneine <[email protected]>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[dependencies.async-std]
version = "1.6.0"

Everything above can be found here: https://paste.debian.net/1150415/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions