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

ICE (broken MIR) with GAT + tuple type inference #93141

Closed
SevenO2 opened this issue Jan 21, 2022 · 2 comments · Fixed by #93226
Closed

ICE (broken MIR) with GAT + tuple type inference #93141

SevenO2 opened this issue Jan 21, 2022 · 2 comments · Fixed by #93226
Assignees
Labels
A-GATs Area: Generic associated types (GATs) A-incr-comp Area: Incremental compilation C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs glacier ICE tracked in rust-lang/glacier. 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

@SevenO2
Copy link

SevenO2 commented Jan 21, 2022

I included the (commented out) workaround I found in case it's helpful.

Bonus

uncomment fn fail2 for a different ICE (Likely a duplicate of #92954)

Code

#![feature(generic_associated_types)]

pub trait Fooey: Sized {
    type Context<'c> where Self: 'c;
    /* // workaround
    type CallMe; */

    // fn fail2(callback: impl for<'c> Fn(&mut Self::Context<'c>)) -> Box<dyn for<'c> Fn(&mut Self::Context<'c>)> {
    //     Box::new(callback)
    // }
}

/* // workaround
pub struct Handle<E: Fooey>(Option<E::CallMe>); */
pub struct Handle<E: Fooey>(Option<Box<dyn for<'c> Fn(&mut E::Context<'c>)>>);

fn tuple<T>() -> (Option<T>,) { (Option::None,) }

pub struct FooImpl {}
impl Fooey for FooImpl {
    type Context<'c> = &'c ();
    /* // workaround
    type CallMe = Box<dyn for<'c> Fn(&mut Self::Context<'c>)>; */
}

impl FooImpl {
    pub fn fail1() -> Handle<Self> {
        let (tx,) = tuple();
        Handle(tx)
    }
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.60.0-nightly (1bd4fdc94 2022-01-12)
binary: rustc
commit-hash: 1bd4fdc943513e1004f498bbf289279c9784fc6f
commit-date: 2022-01-12
host: x86_64-pc-windows-msvc
release: 1.60.0-nightly
LLVM version: 13.0.0

Error output

warning: Error finalizing incremental compilation session directory `\\?\C:\{CODEDIR}\ice\target\debug\incremental\ice-39n3zl63hdtbj\s-g6aobrx569-1gdp4fd-working`: The system cannot find the file specified. (os error 2)

error: internal compiler error: broken MIR in DefId(0:18 ~ ice[d6e3]::{impl#1}::fail1) ((_2.0: std::option::Option<std::boxed::Box<dyn for<'r, 'c> std::ops::Fn(&'r mut <FooImpl as Fooey>::Context<'c>)>>)): bad field access (std::option::Option<std::boxed::Box<dyn for<'r, 'c> std::ops::Fn(&'r mut &'c ())>>: std::option::Option<std::boxed::Box<dyn for<'r, 'c> std::ops::Fn(&'r mut <FooImpl as Fooey>::Context<'c>)>>): NoSolution
  --> src\main.rs:29:14
   |
29 |         let (tx,) = tuple();
   |              ^^
   |
   = note: delayed at compiler\rustc_borrowck\src\type_check\mod.rs:319:27

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

stack backtrace:
   0:     0x7ffd6e2f609f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hee8a33be9cbca634
   1:     0x7ffd6e32510a - core::fmt::write::hb90322eafe83ee3b
   2:     0x7ffd6e2e7308 - <std::io::IoSliceMut as core::fmt::Debug>::fmt::h65fc8b4617290485
   3:     0x7ffd6e2f9acb - std::panicking::take_hook::h0b31ee4140f1c0b3
   4:     0x7ffd6e2f95c4 - std::panicking::take_hook::h0b31ee4140f1c0b3
   5:     0x7ffd6e943c99 - <rustc_middle[10899ac215e07fa4]::ty::SymbolName as core[a132f262969784d3]::fmt::Debug>::fmt
   6:     0x7ffd6e2fa1f6 - std::panicking::rust_panic_with_hook::h82a702bd362db81c
   7:     0x7ffd6e2f9ffb - <std::panicking::begin_panic_handler::StrPanicPayload as core::panic::BoxMeUp>::get::h0345b9cc73fc451e
   8:     0x7ffd6e2f69e7 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hee8a33be9cbca634
   9:     0x7ffd6e2f9cf9 - rust_begin_unwind
  10:     0x7ffd6e357a20 - core::panicking::panic_fmt::h45d28ddfb378495a
  11:     0x7ffd730e00a7 - <rustc_errors[d623bed5aaf56acd]::ErrorReported as core[a132f262969784d3]::fmt::Debug>::fmt
  12:     0x7ffd730dcd18 - <rustc_errors[d623bed5aaf56acd]::HandlerInner>::delay_as_bug
  13:     0x7ffd730d8822 - <rustc_errors[d623bed5aaf56acd]::HandlerInner as core[a132f262969784d3]::ops::drop::Drop>::drop
  14:     0x7ffd6e93d4e4 - <rustc_middle[10899ac215e07fa4]::ty::SymbolName as core[a132f262969784d3]::fmt::Debug>::fmt
  15:     0x7ffd6e9405d7 - <rustc_middle[10899ac215e07fa4]::ty::SymbolName as core[a132f262969784d3]::fmt::Debug>::fmt
  16:     0x7ffd6e8d0b3c - <rustc_target[25420bd4fd783bf8]::abi::call::Reg>::i32
  17:     0x7ffd6e8d2600 - <rustc_target[25420bd4fd783bf8]::abi::call::Reg>::i32
  18:     0x7ffd6e8f3131 - <rustc_target[25420bd4fd783bf8]::abi::call::Reg>::i32
  19:     0x7ffd6e8d5ab7 - <rustc_target[25420bd4fd783bf8]::abi::call::Reg>::i32
  20:     0x7ffd6e8d46fc - <rustc_target[25420bd4fd783bf8]::abi::call::Reg>::i32
  21:     0x7ffd6e8f90a8 - <rustc_middle[10899ac215e07fa4]::ty::SymbolName as core[a132f262969784d3]::fmt::Debug>::fmt
  22:     0x7ffd6e309bac - std::sys::windows::thread::Thread::new::heeee0f662b911fa1
  23:     0x7ffde0d57034 - BaseThreadInitThunk
  24:     0x7ffde2442651 - RtlUserThreadStart

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.60.0-nightly (1bd4fdc94 2022-01-12) running on x86_64-pc-windows-msvc

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

query stack during panic:
end of query stack

@SevenO2 SevenO2 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 Jan 21, 2022
@SevenO2 SevenO2 changed the title ICE with GAT + tuple type inference ICE (broken MIR) with GAT + tuple type inference Jan 21, 2022
@pierwill
Copy link
Member

@rustbot label +A-incr-comp

@rustbot rustbot added the A-incr-comp Area: Incremental compilation label Jan 21, 2022
@compiler-errors
Copy link
Member

@rustbot claim

@jackh726 jackh726 added the F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs label Jan 23, 2022
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Jan 23, 2022
@bors bors closed this as completed in 5adef28 Jan 24, 2022
@fmease fmease added the A-GATs Area: Generic associated types (GATs) label Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-GATs Area: Generic associated types (GATs) A-incr-comp Area: Incremental compilation C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs glacier ICE tracked in rust-lang/glacier. 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.

7 participants