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: relating different kinds: {const error}: &'static str KeyNil #123457

Closed
matthiaskrgr opened this issue Apr 4, 2024 · 4 comments · Fixed by #123673
Closed

ICE: relating different kinds: {const error}: &'static str KeyNil #123457

matthiaskrgr opened this issue Apr 4, 2024 · 4 comments · Fixed by #123673
Assignees
Labels
A-inference Area: Type inference C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

use core::marker::PhantomData;

pub trait ContainsKey<const K: &'static str> {}

pub trait KeySchema {}

pub struct KeyNil;
impl KeySchema for KeyNil {}

pub struct KeyCons<Tail, const KEY_ID: &'static str> {}

pub trait SubsetExcept<Parent: KeySchema>: KeySchema {}

impl<Schema, PossibleParent, const K: &'static str> SubsetExcept<PossibleParent, K> for Schema
where
    Schema: KeySchema,
    (): KeySchema,
    Self: ContainsKey<K>,
    [(); PossibleParent::SIZE - Schema::SIZE]: Sized,
    [(); check_valid_subset::<(), Schema, K>()]: Sized,
{
}

impl<Tail> ContainsKey<K> for KeyCons<Tail, KEY_ID> {}

pub struct RestrictedStringMap<S: KeySchema> {
    _schema: PhantomData<S>,
}

impl<S: KeySchema> RestrictedStringMap<S> {
    pub fn empty_schema() -> RestrictedStringMap<KeyNil> {}

    //
    pub fn remove_key<NewSchema: KeySchema>(self) -> RestrictedStringMap<NewSchema>
    where
        Self:,
        S:,
        NewSchema: SubsetExcept<S, K>,
        [(); S::SIZE - NewSchema::SIZE]: Sized,
    {
    }
}

fn foo() {
    let map: RestrictedStringMap<KeyNil> = RestrictedStringMap::<KeyNil>::empty_schema();

    let map: RestrictedStringMap<KeyCons<KeyNil, "k1">> = map.remove_key::<_, "k2">();
}
original code

original:

use core::marker::PhantomData;

pub trait ContainsKey<const K: &'static str> {}

pub trait KeySchema {}

pub struct KeyNil;
impl KeySchema for KeyNil {}

pub struct KeyCons<Tail, const KEY_ID: &'static str> {}

pub trait SubsetExcept<Parent: KeySchema>: KeySchema {}

impl<Schema, PossibleParent, const K: &'static str> SubsetExcept<PossibleParent, K> for Schema
where
    Schema: KeySchema,
    (): KeySchema,
    Self: ContainsKey<K>,
    [(); PossibleParent::SIZE - Schema::SIZE]: Sized,
    [(); check_valid_subset::<(), Schema, K>()]: Sized,
{
}

impl<Tail, const KEY_ID: &'static str> ContainsKey<K> for KeyCons<Tail, KEY_ID> {}

pub struct RestrictedStringMap<S: KeySchema> {
    _schema: PhantomData<S>,
}

impl<S: KeySchema> RestrictedStringMap<S> {
    pub fn empty_schema() -> RestrictedStringMap<KeyNil> {}

    //
    pub fn remove_key<NewSchema: KeySchema>(self) -> RestrictedStringMap<NewSchema>
    where
        Self:,
        S:,
        NewSchema: SubsetExcept<S, K>,
        [(); S::SIZE - NewSchema::SIZE]: Sized,
    {
    }
}

fn foo() {
    let map: RestrictedStringMap<KeyNil> = RestrictedStringMap::<KeyNil>::empty_schema();

    let map: RestrictedStringMap<KeyCons<KeyNil, "k1">> = map.remove_key::<_, "k2">();
}

Version information

rustc 1.79.0-nightly (a77322c16 2024-04-02)
binary: rustc
commit-hash: a77322c16f188402fa22a5e87100acce42433cbc
commit-date: 2024-04-02
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.2

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --edition=2021

Program output

error: generic parameters may not be used in const operations
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:19:10
   |
19 |     [(); PossibleParent::SIZE - Schema::SIZE]: Sized,
   |          ^^^^^^^^^^^^^^^^^^^^ cannot perform const operation using `PossibleParent`
   |
   = note: type parameters may not be used in const expressions
   = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:19:33
   |
19 |     [(); PossibleParent::SIZE - Schema::SIZE]: Sized,
   |                                 ^^^^^^^^^^^^ cannot perform const operation using `Schema`
   |
   = note: type parameters may not be used in const expressions
   = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:20:35
   |
20 |     [(); check_valid_subset::<(), Schema, K>()]: Sized,
   |                                   ^^^^^^ cannot perform const operation using `Schema`
   |
   = note: type parameters may not be used in const expressions
   = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:20:43
   |
20 |     [(); check_valid_subset::<(), Schema, K>()]: Sized,
   |                                           ^ cannot perform const operation using `K`
   |
   = help: const parameters may only be used as standalone arguments, i.e. `K`
   = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:39:14
   |
39 |         [(); S::SIZE - NewSchema::SIZE]: Sized,
   |              ^^^^^^^ cannot perform const operation using `S`
   |
   = note: type parameters may not be used in const expressions
   = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error: generic parameters may not be used in const operations
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:39:24
   |
39 |         [(); S::SIZE - NewSchema::SIZE]: Sized,
   |                        ^^^^^^^^^^^^^^^ cannot perform const operation using `NewSchema`
   |
   = note: type parameters may not be used in const expressions
   = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions

error[E0412]: cannot find type `K` in this scope
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:24:24
   |
24 | impl<Tail> ContainsKey<K> for KeyCons<Tail, KEY_ID> {}
   |                        ^ not found in this scope
   |
help: you might be missing a type parameter
   |
24 | impl<Tail, K> ContainsKey<K> for KeyCons<Tail, KEY_ID> {}
   |          +++

error[E0412]: cannot find type `KEY_ID` in this scope
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:24:45
   |
24 | impl<Tail> ContainsKey<K> for KeyCons<Tail, KEY_ID> {}
   |                                             ^^^^^^ not found in this scope
   |
help: you might be missing a type parameter
   |
24 | impl<Tail, KEY_ID> ContainsKey<K> for KeyCons<Tail, KEY_ID> {}
   |          ++++++++

error[E0412]: cannot find type `K` in this scope
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:38:36
   |
30 | impl<S: KeySchema> RestrictedStringMap<S> {
   |      - similarly named type parameter `S` defined here
...
38 |         NewSchema: SubsetExcept<S, K>,
   |                                    ^
   |
help: a type parameter with a similar name exists
   |
38 |         NewSchema: SubsetExcept<S, S>,
   |                                    ~
help: you might be missing a type parameter
   |
30 | impl<S: KeySchema, K> RestrictedStringMap<S> {
   |                  +++

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:48:2
   |
48 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs`

error[E0747]: unresolved item provided when a constant was expected
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:24:45
   |
24 | impl<Tail> ContainsKey<K> for KeyCons<Tail, KEY_ID> {}
   |                                             ^^^^^^
   |
help: if this generic argument was intended as a const parameter, surround it with braces
   |
24 | impl<Tail> ContainsKey<K> for KeyCons<Tail, { KEY_ID }> {}
   |                                             +        +

error: `&'static str` is forbidden as the type of a const generic parameter
 --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:3:32
  |
3 | pub trait ContainsKey<const K: &'static str> {}
  |                                ^^^^^^^^^^^^
  |
  = note: the only supported types are integers, `bool` and `char`
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
  |
1 + #![feature(adt_const_params)]
  |

error[E0392]: type parameter `Tail` is never used
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:10:20
   |
10 | pub struct KeyCons<Tail, const KEY_ID: &'static str> {}
   |                    ^^^^ unused type parameter
   |
   = help: consider removing `Tail`, referring to it in a field, or using a marker such as `PhantomData`
   = help: if you intended `Tail` to be a const parameter, use `const Tail: /* Type */` instead

error: `&'static str` is forbidden as the type of a const generic parameter
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:10:40
   |
10 | pub struct KeyCons<Tail, const KEY_ID: &'static str> {}
   |                                        ^^^^^^^^^^^^
   |
   = note: the only supported types are integers, `bool` and `char`
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
   |
1  + #![feature(adt_const_params)]
   |

error[E0107]: trait takes 1 generic argument but 2 generic arguments were supplied
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:14:53
   |
14 | impl<Schema, PossibleParent, const K: &'static str> SubsetExcept<PossibleParent, K> for Schema
   |                                                     ^^^^^^^^^^^^                 - help: remove this generic argument
   |                                                     |
   |                                                     expected 1 generic argument
   |
note: trait defined here, with 1 generic parameter: `Parent`
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:12:11
   |
12 | pub trait SubsetExcept<Parent: KeySchema>: KeySchema {}
   |           ^^^^^^^^^^^^ ------

error[E0425]: cannot find function `check_valid_subset` in this scope
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:20:10
   |
20 |     [(); check_valid_subset::<(), Schema, K>()]: Sized,
   |          ^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0207]: the const parameter `K` is not constrained by the impl trait, self type, or predicates
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:14:30
   |
14 | impl<Schema, PossibleParent, const K: &'static str> SubsetExcept<PossibleParent, K> for Schema
   |                              ^^^^^^^^^^^^^^^^^^^^^ unconstrained const parameter
   |
   = note: expressions using a const parameter must map each value to a distinct output value
   = note: proving the result of expressions other than the parameter are unique is not supported

error: `&'static str` is forbidden as the type of a const generic parameter
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:14:39
   |
14 | impl<Schema, PossibleParent, const K: &'static str> SubsetExcept<PossibleParent, K> for Schema
   |                                       ^^^^^^^^^^^^
   |
   = note: the only supported types are integers, `bool` and `char`
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
   |
1  + #![feature(adt_const_params)]
   |

error[E0747]: unresolved item provided when a constant was expected
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:24:24
   |
24 | impl<Tail> ContainsKey<K> for KeyCons<Tail, KEY_ID> {}
   |                        ^
   |
help: if this generic argument was intended as a const parameter, surround it with braces
   |
24 | impl<Tail> ContainsKey<{ K }> for KeyCons<Tail, KEY_ID> {}
   |                        +   +

error[E0107]: trait takes 1 generic argument but 2 generic arguments were supplied
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:38:20
   |
38 |         NewSchema: SubsetExcept<S, K>,
   |                    ^^^^^^^^^^^^    - help: remove this generic argument
   |                    |
   |                    expected 1 generic argument
   |
note: trait defined here, with 1 generic parameter: `Parent`
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:12:11
   |
12 | pub trait SubsetExcept<Parent: KeySchema>: KeySchema {}
   |           ^^^^^^^^^^^^ ------

error[E0308]: mismatched types
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:31:30
   |
31 |     pub fn empty_schema() -> RestrictedStringMap<KeyNil> {}
   |            ------------      ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `RestrictedStringMap<KeyNil>`, found `()`
   |            |
   |            implicitly returns `()` as its body has no tail or `return` expression
   |
   = note: expected struct `RestrictedStringMap<KeyNil>`
           found unit type `()`

error[E0308]: mismatched types
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:34:54
   |
34 |     pub fn remove_key<NewSchema: KeySchema>(self) -> RestrictedStringMap<NewSchema>
   |            ----------                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `RestrictedStringMap<NewSchema>`, found `()`
   |            |
   |            implicitly returns `()` as its body has no tail or `return` expression
   |
   = note: expected struct `RestrictedStringMap<NewSchema>`
           found unit type `()`

error[E0277]: the trait bound `KeyCons<KeyNil, "k1">: KeySchema` is not satisfied
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:47:14
   |
47 |     let map: RestrictedStringMap<KeyCons<KeyNil, "k1">> = map.remove_key::<_, "k2">();
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `KeySchema` is not implemented for `KeyCons<KeyNil, "k1">`
   |
   = help: the trait `KeySchema` is implemented for `KeyNil`
note: required by a bound in `RestrictedStringMap`
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:26:35
   |
26 | pub struct RestrictedStringMap<S: KeySchema> {
   |                                   ^^^^^^^^^ required by this bound in `RestrictedStringMap`

error[E0107]: method takes 1 generic argument but 2 generic arguments were supplied
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:47:63
   |
47 |     let map: RestrictedStringMap<KeyCons<KeyNil, "k1">> = map.remove_key::<_, "k2">();
   |                                                               ^^^^^^^^^^      ---- help: remove this generic argument
   |                                                               |
   |                                                               expected 1 generic argument
   |
note: method defined here, with 1 generic parameter: `NewSchema`
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:34:12
   |
34 |     pub fn remove_key<NewSchema: KeySchema>(self) -> RestrictedStringMap<NewSchema>
   |            ^^^^^^^^^^ ---------

error[E0277]: the trait bound `KeyCons<KeyNil, "k1">: KeySchema` is not satisfied
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:47:76
   |
47 |     let map: RestrictedStringMap<KeyCons<KeyNil, "k1">> = map.remove_key::<_, "k2">();
   |                                                               ----------   ^ the trait `KeySchema` is not implemented for `KeyCons<KeyNil, "k1">`
   |                                                               |
   |                                                               required by a bound introduced by this call
   |
   = help: the trait `KeySchema` is implemented for `KeyNil`
note: required by a bound in `RestrictedStringMap::<S>::remove_key`
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:34:34
   |
34 |     pub fn remove_key<NewSchema: KeySchema>(self) -> RestrictedStringMap<NewSchema>
   |                                  ^^^^^^^^^ required by this bound in `RestrictedStringMap::<S>::remove_key`

error[E0277]: the trait bound `(): KeySchema` is not satisfied
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:47:76
   |
47 |     let map: RestrictedStringMap<KeyCons<KeyNil, "k1">> = map.remove_key::<_, "k2">();
   |                                                               ----------   ^ the trait `KeySchema` is not implemented for `()`, which is required by `KeyCons<KeyNil, "k1">: SubsetExcept<KeyNil>`
   |                                                               |
   |                                                               required by a bound introduced by this call
   |
   = help: the trait `KeySchema` is implemented for `KeyNil`
note: required for `KeyCons<KeyNil, "k1">` to implement `SubsetExcept<KeyNil>`
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:14:53
   |
14 | impl<Schema, PossibleParent, const K: &'static str> SubsetExcept<PossibleParent, K> for Schema
   |                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^     ^^^^^^
...
17 |     (): KeySchema,
   |         --------- unsatisfied trait bound introduced here
note: required by a bound in `RestrictedStringMap::<S>::remove_key`
  --> /tmp/icemaker_global_tempdir.bEGplEUcAUNn/rustc_testrunner_tmpdir_reporting.f6LvrftWRmom/mvce.rs:38:20
   |
34 |     pub fn remove_key<NewSchema: KeySchema>(self) -> RestrictedStringMap<NewSchema>
   |            ---------- required by a bound in this associated function
...
38 |         NewSchema: SubsetExcept<S, K>,
   |                    ^^^^^^^^^^^^^^^^^^ required by this bound in `RestrictedStringMap::<S>::remove_key`

error: internal compiler error: compiler/rustc_infer/src/infer/at.rs:400:21: relating different kinds: {const error}: &'static str KeyNil

thread 'rustc' panicked at compiler/rustc_infer/src/infer/at.rs:400:21:
Box<dyn Any>
stack backtrace:
   0:     0x71096c8c7ab5 - std::backtrace_rs::backtrace::libunwind::trace::hf26b8e97f4d981a3
                               at /rustc/a77322c16f188402fa22a5e87100acce42433cbc/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x71096c8c7ab5 - std::backtrace_rs::backtrace::trace_unsynchronized::h257c3a9fcc68cb34
                               at /rustc/a77322c16f188402fa22a5e87100acce42433cbc/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x71096c8c7ab5 - std::sys_common::backtrace::_print_fmt::h78d592e526d576cc
                               at /rustc/a77322c16f188402fa22a5e87100acce42433cbc/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x71096c8c7ab5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h406a266f6476e993
                               at /rustc/a77322c16f188402fa22a5e87100acce42433cbc/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x71096c916cfb - core::fmt::rt::Argument::fmt::h7950f9cc4e18eb74
                               at /rustc/a77322c16f188402fa22a5e87100acce42433cbc/library/core/src/fmt/rt.rs:142:9
   5:     0x71096c916cfb - core::fmt::write::hf6d8222a297fe1b5
                               at /rustc/a77322c16f188402fa22a5e87100acce42433cbc/library/core/src/fmt/mod.rs:1153:17
   6:     0x71096c8bc69f - std::io::Write::write_fmt::h2e25e66707b8719c
                               at /rustc/a77322c16f188402fa22a5e87100acce42433cbc/library/std/src/io/mod.rs:1843:15
   7:     0x71096c8c788e - std::sys_common::backtrace::_print::h93052b2b7ae3e225
                               at /rustc/a77322c16f188402fa22a5e87100acce42433cbc/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x71096c8c788e - std::sys_common::backtrace::print::h2c3363fe806c95b9
                               at /rustc/a77322c16f188402fa22a5e87100acce42433cbc/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x71096c8ca2d9 - std::panicking::default_hook::{{closure}}::hccbad107bfb00663
  10:     0x71096c8ca043 - std::panicking::default_hook::h0629782f23910600
                               at /rustc/a77322c16f188402fa22a5e87100acce42433cbc/library/std/src/panicking.rs:291:9
  11:     0x71096920344f - std[cd169797441e4304]::panicking::update_hook::<alloc[80a8ff80e015276]::boxed::Box<rustc_driver_impl[4156c2df247de3fc]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x71096c8ca9dc - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hfd80129a92e7f542
                               at /rustc/a77322c16f188402fa22a5e87100acce42433cbc/library/alloc/src/boxed.rs:2032:9
  13:     0x71096c8ca9dc - std::panicking::rust_panic_with_hook::hbdb3c4b71c4fae93
                               at /rustc/a77322c16f188402fa22a5e87100acce42433cbc/library/std/src/panicking.rs:792:13
  14:     0x710969233224 - std[cd169797441e4304]::panicking::begin_panic::<rustc_errors[36548b9f9a9ea726]::ExplicitBug>::{closure#0}
  15:     0x710969230146 - std[cd169797441e4304]::sys_common::backtrace::__rust_end_short_backtrace::<std[cd169797441e4304]::panicking::begin_panic<rustc_errors[36548b9f9a9ea726]::ExplicitBug>::{closure#0}, !>
  16:     0x71096922fe26 - std[cd169797441e4304]::panicking::begin_panic::<rustc_errors[36548b9f9a9ea726]::ExplicitBug>
  17:     0x71096923c641 - <rustc_errors[36548b9f9a9ea726]::diagnostic::BugAbort as rustc_errors[36548b9f9a9ea726]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7109696cfd6c - rustc_middle[f32ad3853e76b525]::util::bug::opt_span_bug_fmt::<rustc_span[abf425ab4de01d9]::span_encoding::Span>::{closure#0}
  19:     0x7109696b32ca - rustc_middle[f32ad3853e76b525]::ty::context::tls::with_opt::<rustc_middle[f32ad3853e76b525]::util::bug::opt_span_bug_fmt<rustc_span[abf425ab4de01d9]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  20:     0x7109696b316b - rustc_middle[f32ad3853e76b525]::ty::context::tls::with_context_opt::<rustc_middle[f32ad3853e76b525]::ty::context::tls::with_opt<rustc_middle[f32ad3853e76b525]::util::bug::opt_span_bug_fmt<rustc_span[abf425ab4de01d9]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  21:     0x710967300350 - rustc_middle[f32ad3853e76b525]::util::bug::bug_fmt
  22:     0x7109694bdab7 - <rustc_middle[f32ad3853e76b525]::ty::generic_args::GenericArg as rustc_infer[d75b2a27552d986e]::infer::at::ToTrace>::to_trace
  23:     0x710969c50b76 - <rustc_infer[d75b2a27552d986e]::infer::at::At>::eq::<rustc_middle[f32ad3853e76b525]::ty::generic_args::GenericArg>
  24:     0x710969d4fdc7 - <rustc_infer[d75b2a27552d986e]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[d9dc339916816dbb]::traits::error_reporting::type_err_ctxt_ext::InferCtxtPrivExt>::report_similar_impl_candidates
  25:     0x710969d59ded - <rustc_infer[d75b2a27552d986e]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[d9dc339916816dbb]::traits::error_reporting::type_err_ctxt_ext::InferCtxtPrivExt>::try_to_add_help_message
  26:     0x710969d4b7c2 - <rustc_infer[d75b2a27552d986e]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[d9dc339916816dbb]::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_selection_error
  27:     0x710969d5c7f1 - <rustc_infer[d75b2a27552d986e]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[d9dc339916816dbb]::traits::error_reporting::type_err_ctxt_ext::InferCtxtPrivExt>::report_fulfillment_error
  28:     0x710969d46bb8 - <rustc_infer[d75b2a27552d986e]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[d9dc339916816dbb]::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_fulfillment_errors
  29:     0x71096ae44ac4 - <rustc_hir_typeck[312bf9d4ee85e4af]::fn_ctxt::FnCtxt>::type_inference_fallback
  30:     0x71096a817ba7 - rustc_hir_typeck[312bf9d4ee85e4af]::typeck
  31:     0x71096a817557 - rustc_query_impl[f27b006aa91c0ba0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f27b006aa91c0ba0]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f32ad3853e76b525]::query::erase::Erased<[u8; 8usize]>>
  32:     0x71096a8044f1 - rustc_query_system[e2bc6f1fc30f6df]::query::plumbing::try_execute_query::<rustc_query_impl[f27b006aa91c0ba0]::DynamicConfig<rustc_query_system[e2bc6f1fc30f6df]::query::caches::VecCache<rustc_span[abf425ab4de01d9]::def_id::LocalDefId, rustc_middle[f32ad3853e76b525]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[f27b006aa91c0ba0]::plumbing::QueryCtxt, false>
  33:     0x71096a80094c - rustc_query_impl[f27b006aa91c0ba0]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  34:     0x71096a80052b - <rustc_middle[f32ad3853e76b525]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[3e5cabd178036183]::check_crate::{closure#4}>::{closure#0}
  35:     0x71096a7ff1e1 - rustc_hir_analysis[3e5cabd178036183]::check_crate
  36:     0x71096aace36a - rustc_interface[bc155c77a5e962ed]::passes::analysis
  37:     0x71096aacded3 - rustc_query_impl[f27b006aa91c0ba0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f27b006aa91c0ba0]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f32ad3853e76b525]::query::erase::Erased<[u8; 1usize]>>
  38:     0x71096b412de5 - rustc_query_system[e2bc6f1fc30f6df]::query::plumbing::try_execute_query::<rustc_query_impl[f27b006aa91c0ba0]::DynamicConfig<rustc_query_system[e2bc6f1fc30f6df]::query::caches::SingleCache<rustc_middle[f32ad3853e76b525]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[f27b006aa91c0ba0]::plumbing::QueryCtxt, false>
  39:     0x71096b412b49 - rustc_query_impl[f27b006aa91c0ba0]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  40:     0x71096b2cb1d3 - rustc_interface[bc155c77a5e962ed]::interface::run_compiler::<core[620758cd80b91dd0]::result::Result<(), rustc_span[abf425ab4de01d9]::ErrorGuaranteed>, rustc_driver_impl[4156c2df247de3fc]::run_compiler::{closure#0}>::{closure#0}
  41:     0x71096b35ac19 - std[cd169797441e4304]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[bc155c77a5e962ed]::util::run_in_thread_with_globals<rustc_interface[bc155c77a5e962ed]::util::run_in_thread_pool_with_globals<rustc_interface[bc155c77a5e962ed]::interface::run_compiler<core[620758cd80b91dd0]::result::Result<(), rustc_span[abf425ab4de01d9]::ErrorGuaranteed>, rustc_driver_impl[4156c2df247de3fc]::run_compiler::{closure#0}>::{closure#0}, core[620758cd80b91dd0]::result::Result<(), rustc_span[abf425ab4de01d9]::ErrorGuaranteed>>::{closure#0}, core[620758cd80b91dd0]::result::Result<(), rustc_span[abf425ab4de01d9]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[620758cd80b91dd0]::result::Result<(), rustc_span[abf425ab4de01d9]::ErrorGuaranteed>>
  42:     0x71096b35aa27 - <<std[cd169797441e4304]::thread::Builder>::spawn_unchecked_<rustc_interface[bc155c77a5e962ed]::util::run_in_thread_with_globals<rustc_interface[bc155c77a5e962ed]::util::run_in_thread_pool_with_globals<rustc_interface[bc155c77a5e962ed]::interface::run_compiler<core[620758cd80b91dd0]::result::Result<(), rustc_span[abf425ab4de01d9]::ErrorGuaranteed>, rustc_driver_impl[4156c2df247de3fc]::run_compiler::{closure#0}>::{closure#0}, core[620758cd80b91dd0]::result::Result<(), rustc_span[abf425ab4de01d9]::ErrorGuaranteed>>::{closure#0}, core[620758cd80b91dd0]::result::Result<(), rustc_span[abf425ab4de01d9]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[620758cd80b91dd0]::result::Result<(), rustc_span[abf425ab4de01d9]::ErrorGuaranteed>>::{closure#1} as core[620758cd80b91dd0]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x71096c8d43fb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd0a22ba669218411
                               at /rustc/a77322c16f188402fa22a5e87100acce42433cbc/library/alloc/src/boxed.rs:2018:9
  44:     0x71096c8d43fb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hcc773386fb5423d0
                               at /rustc/a77322c16f188402fa22a5e87100acce42433cbc/library/alloc/src/boxed.rs:2018:9
  45:     0x71096c8d43fb - std::sys::pal::unix::thread::Thread::new::thread_start::hecd789c0696ca351
                               at /rustc/a77322c16f188402fa22a5e87100acce42433cbc/library/std/src/sys/pal/unix/thread.rs:108:17
  46:     0x7109660a955a - <unknown>
  47:     0x710966126a3c - <unknown>
  48:                0x0 - <unknown>

note: it seems that this compiler `1.79.0-nightly (a77322c16 2024-04-02)` is outdated, a newer nightly should have been released in the mean time
  |
  = note: please consider running `rustup update nightly` to update the nightly channel and check if this problem still persists
  = note: if the problem still persists, 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.79.0-nightly (a77322c16 2024-04-02) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z dump-mir-dir=dir

query stack during panic:
#0 [typeck] type-checking `foo`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 27 previous errors

Some errors have detailed explanations: E0107, E0207, E0277, E0308, E0392, E0412, E0425, E0601, E0747.
For more information about an error, try `rustc --explain E0107`.

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Apr 4, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 4, 2024
@matthiaskrgr
Copy link
Member Author

This bisects to #121154

@Luk-ESC
Copy link
Contributor

Luk-ESC commented Apr 4, 2024

Minimized further:

pub struct KeyHolder<const K: u8> {}

pub trait ContainsKey<const K: u8> {}

pub trait SubsetExcept<P> {}

impl<K> ContainsKey<K> for KeyHolder<K> {}

impl<P, T: ContainsKey<0>> SubsetExcept<P> for T {}

pub fn remove_key<K, S: SubsetExcept<K>>() -> S {
    loop {}
}

fn foo() {
    let map: KeyHolder<0> = remove_key::<_, _>();
}

@jieyouxu jieyouxu added S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue A-inference Area: Type inference and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 4, 2024
@cushionbadak
Copy link

Is #121134 related?

Current ICE-loc:

bug!("relating different kinds: {a:?} {b:?}")

Issue-121134's ICE-loc:

bug!("relating different kinds: {a:?} {b:?}")

@lqd
Copy link
Member

lqd commented Apr 5, 2024

This bisects to #121154

cc PR author @oli-obk

@oli-obk oli-obk self-assigned this Apr 9, 2024
@bors bors closed this as completed in 4aaa8f9 Apr 17, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 17, 2024
Rollup merge of rust-lang#123673 - oli-obk:sig_wfcheck_ice, r=jieyouxu,estebank

Don't ICE for kind mismatches during error rendering

fixes rust-lang#123457

also some test suite cleanups to make backtraces easier to read
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-inference Area: Type inference C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue 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