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 in DefId (equate_normalized_input_or_output failed with NoSolution) #90612

Closed
tuxmark5 opened this issue Nov 5, 2021 · 1 comment · Fixed by #90801
Closed
Labels
C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs

Comments

@tuxmark5
Copy link

tuxmark5 commented Nov 5, 2021

I tried this code:

#![feature(generic_associated_types)]

use std::marker::PhantomData;

trait Family: Sized {
    type Item<'a>;
    
    fn apply_all<F>(&self, f: F)
    where
        F: FamilyItemFn<Self> { }
}

struct Array<T>(PhantomData<T>);

impl<T: 'static> Family for Array<T> {
    type Item<'a> = &'a T;
}

trait FamilyItemFn<T: Family> {
    fn apply(&self, item: T::Item<'_>);
}

impl<T, F> FamilyItemFn<T> for F
where 
    T: Family,
    for<'a> F: Fn(T::Item<'a>)
{
    fn apply(&self, item: T::Item<'_>) {
        (*self)(item);
    }
}

fn process<T: 'static>(array: Array<T>) {
    // Works
    array.apply_all(|x: &T| { });
    
    // ICE: NoSolution
    array.apply_all(|x: <Array<T> as Family>::Item<'_>| { });
}

This should compile and work, but instead it ICEs.

It doesn't ICE if I remove the generic parameter from Array or use array.apply_all(|x: &T| { });

Meta

rustc --version --verbose:

rustc 1.58.0-nightly (1f12ac872 2021-10-17)
binary: rustc
commit-hash: 1f12ac87296ac61ec002e0243e7ad5a50364da35
commit-date: 2021-10-17
host: x86_64-unknown-linux-gnu
release: 1.58.0-nightly
LLVM version: 13.0.0

Backtrace

error: internal compiler error: broken MIR in DefId(0:30 ~ test[68ae]::process::{closure#1}) (bb0[0]): equate_normalized_input_or_output: `&[closure@test.rs:46:21: 46:60]==&[closure@test.rs:46:21: 46:60]` failed with `NoSolution`
  --> test.rs:46:60
   |
46 |     array.apply_all(|x: <Array<T> as Family>::Item<'_>| { });
   |                                                            ^
   |
   = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:330:27

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1165:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/1f12ac87296ac61ec002e0243e7ad5a50364da35/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/1f12ac87296ac61ec002e0243e7ad5a50364da35/library/core/src/panicking.rs:100:14
   2: core::panicking::panic_display
   3: rustc_errors::HandlerInner::flush_delayed
   4: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   5: core::ptr::drop_in_place<rustc_session::parse::ParseSess>
   6: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
   7: core::ptr::drop_in_place<rustc_interface::interface::Compiler>
   8: rustc_span::with_source_map
   9: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

@tuxmark5 tuxmark5 added the C-bug Category: This is a bug. label Nov 5, 2021
@jackh726 jackh726 added the F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs label Nov 5, 2021
@b-naber
Copy link
Contributor

b-naber commented Nov 9, 2021

Seems related to #90638

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 13, 2021
…e_inputs_output, r=jackh726

Normalize both arguments of `equate_normalized_input_or_output`

Fixes rust-lang#90638
Fixes rust-lang#90612

Temporary fix for a more complex underlying problem stemming from an inability to normalize closure substs during typecheck.

r? `@jackh726`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 13, 2021
…e_inputs_output, r=jackh726

Normalize both arguments of `equate_normalized_input_or_output`

Fixes rust-lang#90638
Fixes rust-lang#90612

Temporary fix for a more complex underlying problem stemming from an inability to normalize closure substs during typecheck.

r? ``@jackh726``
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 13, 2021
…e_inputs_output, r=jackh726

Normalize both arguments of `equate_normalized_input_or_output`

Fixes rust-lang#90638
Fixes rust-lang#90612

Temporary fix for a more complex underlying problem stemming from an inability to normalize closure substs during typecheck.

r? ```@jackh726```
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 13, 2021
…e_inputs_output, r=jackh726

Normalize both arguments of `equate_normalized_input_or_output`

Fixes rust-lang#90638
Fixes rust-lang#90612

Temporary fix for a more complex underlying problem stemming from an inability to normalize closure substs during typecheck.

r? ````@jackh726````
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 15, 2021
…e_inputs_output, r=jackh726

Normalize both arguments of `equate_normalized_input_or_output`

Fixes rust-lang#90638
Fixes rust-lang#90612

Temporary fix for a more complex underlying problem stemming from an inability to normalize closure substs during typecheck.

r? `@jackh726`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 15, 2021
…e_inputs_output, r=jackh726

Normalize both arguments of `equate_normalized_input_or_output`

Fixes rust-lang#90638
Fixes rust-lang#90612

Temporary fix for a more complex underlying problem stemming from an inability to normalize closure substs during typecheck.

r? ``@jackh726``
JohnTitor added a commit to JohnTitor/rust that referenced this issue Nov 16, 2021
…e_inputs_output, r=jackh726

Normalize both arguments of `equate_normalized_input_or_output`

Fixes rust-lang#90638
Fixes rust-lang#90612

Temporary fix for a more complex underlying problem stemming from an inability to normalize closure substs during typecheck.

r? ```@jackh726```
@bors bors closed this as completed in 21bff4a Nov 16, 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-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants