Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal compiler error with 'impl_trait_in_bindings' feature #87295

Closed
chertov opened this issue Jul 19, 2021 · 1 comment · Fixed by #87383
Closed

Internal compiler error with 'impl_trait_in_bindings' feature #87295

chertov opened this issue Jul 19, 2021 · 1 comment · Fixed by #87383
Labels
C-bug Category: This is a bug. F-impl_trait_in_bindings `#![feature(impl_trait_in_bindings)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@chertov
Copy link

chertov commented Jul 19, 2021

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=44178d36861a0d770480156b511a3c15

Code

#![feature(impl_trait_in_bindings)]

use tokio; // 1.7.1
use std::pin::Pin;
use futures::future::{ Future, FutureExt, Fuse, OptionFuture };

enum State {Init}

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {

    let mut _keep_alive_rpc : Pin<Box<Fuse<OptionFuture<impl Future<Output = State>>>>> = Box::pin(OptionFuture::from(Some(async { State::Init })).fuse());
    
    Ok(())
}

Meta

rustc --version --verbose:

Nightly channel
Build using the Nightly version: 1.55.0-nightly

(2021-07-18 59216858a323978a9759)

Error output

error: internal compiler error: broken MIR in DefId(0:26 ~ playground[397a]::main::{closure#0}) (Terminator { source_info: SourceInfo { span: src/main.rs:12:91: 12:155 (#0), scope: scope[0] }, kind: _3 = Box::<futures::future::Fuse<OptionFuture<impl futures::Future>>>::pin(move _4) -> [return: bb5, unwind: bb7] }): call dest mismatch (std::pin::Pin<std::boxed::Box<futures::future::Fuse<futures::future::OptionFuture<impl futures::Future>>>> <- std::pin::Pin<std::boxed::Box<futures::future::Fuse<futures::future::OptionFuture<impl futures::Future>>>>): NoSolution
  --> src/main.rs:12:153
   |
12 | ...> = Box::pin(OptionFuture::from(Some(async { State::Init })).fuse());
   |                                                                      ^
   |
   = note: delayed at compiler/rustc_mir/src/borrow_check/type_check/mod.rs:253:27

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1050:13
Backtrace

stack backtrace:
   0: rust_begin_unwind
             at /rustc/59216858a323978a97593cba22b5ed84350a3783/library/std/src/panicking.rs:515:5
   1: std::panicking::begin_panic_fmt
             at /rustc/59216858a323978a97593cba22b5ed84350a3783/library/std/src/panicking.rs:457:5
   2: rustc_errors::HandlerInner::flush_delayed
   3: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   4: core::ptr::drop_in_place<rustc_session::parse::ParseSess>
   5: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
   6: core::ptr::drop_in_place<rustc_interface::interface::Compiler>
   7: rustc_span::with_source_map
   8: rustc_interface::interface::create_compiler_and_run
   9: scoped_tls::ScopedKey<T>::set

@chertov chertov added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 19, 2021
@jonas-schievink jonas-schievink added the F-impl_trait_in_bindings `#![feature(impl_trait_in_bindings)]` label Jul 19, 2021
@hellow554
Copy link
Contributor

Reduced to

#![feature(impl_trait_in_bindings)]

trait Trait {
    type Output;
}
impl Trait for () {
    type Output = i32;
}

struct Struct<F>(F);
impl<F> Struct<F> {
    pub fn new(_: F) -> Self {
        todo!()
    }
}

fn main() {
    let _do_not_waste: Struct<impl Trait<Output = i32>> = Struct::new(());
}

JohnTitor added a commit to JohnTitor/rust that referenced this issue Jul 23, 2021
…sts, r=oli-obk

Add regression tests for the impl_trait_in_bindings ICEs

Closes rust-lang#54600, closes rust-lang#54840, closes rust-lang#58504, closes rust-lang#58956, closes rust-lang#70971, closes rust-lang#79099, closes rust-lang#84919, closes rust-lang#86201, closes rust-lang#86642, closes rust-lang#87295

r? `@oli-obk`
@bors bors closed this as completed in 7c0c329 Jul 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-impl_trait_in_bindings `#![feature(impl_trait_in_bindings)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants