rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.05k stars 12.69k forks source link

ICE: `None` in compiler/rustc_middle/src/ty/sty.rs #129209

Open matthiaskrgr opened 2 months ago

matthiaskrgr commented 2 months ago

auto-reduced (treereduce-rust):

impl<
        const N: usize = {
            const {
                static || {
                    let first = Foo([0; FOO_SIZE]);
                    yield;

                    yield;

                    yield;
                }
            }
        },
    > PartialEq<FixedI8<FRAC_RHS>> for True
{
}

original:

#![feature(generic_const_exprs)]

pub trait True {}

impl<const N: usize = { const {
    static || {
        let first = Foo([0; FOO_SIZE]);
        yield;
        let second = first;
        yield;
        let second = first;
        yield;
    }
} }> PartialEq<FixedI8<FRAC_RHS>> for v0<FRAC_LHS> where
    If<{}>: True
{
}
#![feature(generic_const_exprs)]

pub trait True {}

impl<const pointer_like_trait: usize = { const { InvariantRef::<'a>::NEW } }> PartialEq<FixedI8<FRAC_RHS>> for FixedI8<FRAC_LHS> where
    If<{}>: True {}

Version information

rustc 1.82.0-nightly (0f26ee4fd 2024-08-17)
binary: rustc
commit-hash: 0f26ee4fd95a1c046582dfb18892f520788e2c2c
commit-date: 2024-08-17
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0

Command: /home/matthias/.rustup/toolchains/master/bin/rustc

Program output

``` error[E0412]: cannot find type `FixedI8` in this scope --> /tmp/icemaker_global_tempdir.xxLsOJeDobON/rustc_testrunner_tmpdir_reporting.EW3ZNLfKk1Q3/mvce.rs:14:17 | 14 | > PartialEq> for True | ^^^^^^^ not found in this scope error[E0412]: cannot find type `FRAC_RHS` in this scope --> /tmp/icemaker_global_tempdir.xxLsOJeDobON/rustc_testrunner_tmpdir_reporting.EW3ZNLfKk1Q3/mvce.rs:14:25 | 14 | > PartialEq> for True | ^^^^^^^^ not found in this scope | help: you might be missing a type parameter | 13 | }, FRAC_RHS, | ++++++++++ error[E0412]: cannot find type `True` in this scope --> /tmp/icemaker_global_tempdir.xxLsOJeDobON/rustc_testrunner_tmpdir_reporting.EW3ZNLfKk1Q3/mvce.rs:14:40 | 14 | > PartialEq> for True | ^^^^ not found in this scope | help: you may want to use a bool value instead | 14 | > PartialEq> for true | ~~~~ error[E0425]: cannot find value `FOO_SIZE` in this scope --> /tmp/icemaker_global_tempdir.xxLsOJeDobON/rustc_testrunner_tmpdir_reporting.EW3ZNLfKk1Q3/mvce.rs:5:41 | 5 | let first = Foo([0; FOO_SIZE]); | ^^^^^^^^ not found in this scope error[E0658]: yield syntax is experimental --> /tmp/icemaker_global_tempdir.xxLsOJeDobON/rustc_testrunner_tmpdir_reporting.EW3ZNLfKk1Q3/mvce.rs:6:21 | 6 | yield; | ^^^^^ | = note: see issue #43122 for more information = help: add `#![feature(coroutines)]` to the crate attributes to enable = note: this compiler was built on 2024-08-17; consider upgrading it if it is out of date error[E0658]: yield syntax is experimental --> /tmp/icemaker_global_tempdir.xxLsOJeDobON/rustc_testrunner_tmpdir_reporting.EW3ZNLfKk1Q3/mvce.rs:8:21 | 8 | yield; | ^^^^^ | = note: see issue #43122 for more information = help: add `#![feature(coroutines)]` to the crate attributes to enable = note: this compiler was built on 2024-08-17; consider upgrading it if it is out of date error[E0658]: yield syntax is experimental --> /tmp/icemaker_global_tempdir.xxLsOJeDobON/rustc_testrunner_tmpdir_reporting.EW3ZNLfKk1Q3/mvce.rs:10:21 | 10 | yield; | ^^^^^ | = note: see issue #43122 for more information = help: add `#![feature(coroutines)]` to the crate attributes to enable = note: this compiler was built on 2024-08-17; consider upgrading it if it is out of date error[E0658]: yield syntax is experimental --> /tmp/icemaker_global_tempdir.xxLsOJeDobON/rustc_testrunner_tmpdir_reporting.EW3ZNLfKk1Q3/mvce.rs:6:21 | 6 | yield; | ^^^^^ | = note: see issue #43122 for more information = help: add `#![feature(coroutines)]` to the crate attributes to enable = note: this compiler was built on 2024-08-17; consider upgrading it if it is out of date error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks --> /tmp/icemaker_global_tempdir.xxLsOJeDobON/rustc_testrunner_tmpdir_reporting.EW3ZNLfKk1Q3/mvce.rs:6:21 | 6 | yield; | ^^^^^ | help: use `#[coroutine]` to make this closure a coroutine | 4 | #[coroutine] static || { | ++++++++++++ error[E0658]: yield syntax is experimental --> /tmp/icemaker_global_tempdir.xxLsOJeDobON/rustc_testrunner_tmpdir_reporting.EW3ZNLfKk1Q3/mvce.rs:8:21 | 8 | yield; | ^^^^^ | = note: see issue #43122 for more information = help: add `#![feature(coroutines)]` to the crate attributes to enable = note: this compiler was built on 2024-08-17; consider upgrading it if it is out of date error[E0658]: yield syntax is experimental --> /tmp/icemaker_global_tempdir.xxLsOJeDobON/rustc_testrunner_tmpdir_reporting.EW3ZNLfKk1Q3/mvce.rs:10:21 | 10 | yield; | ^^^^^ | = note: see issue #43122 for more information = help: add `#![feature(coroutines)]` to the crate attributes to enable = note: this compiler was built on 2024-08-17; consider upgrading it if it is out of date error[E0601]: `main` function not found in crate `mvce` --> /tmp/icemaker_global_tempdir.xxLsOJeDobON/rustc_testrunner_tmpdir_reporting.EW3ZNLfKk1Q3/mvce.rs:16:2 | 16 | } | ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.xxLsOJeDobON/rustc_testrunner_tmpdir_reporting.EW3ZNLfKk1Q3/mvce.rs` error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions --> /tmp/icemaker_global_tempdir.xxLsOJeDobON/rustc_testrunner_tmpdir_reporting.EW3ZNLfKk1Q3/mvce.rs:2:9 | 2 | / const N: usize = { 3 | | const { 4 | | static || { 5 | | let first = Foo([0; FOO_SIZE]); ... | 12 | | } 13 | | }, | |_________^ error[E0425]: cannot find function, tuple struct or tuple variant `Foo` in this scope --> /tmp/icemaker_global_tempdir.xxLsOJeDobON/rustc_testrunner_tmpdir_reporting.EW3ZNLfKk1Q3/mvce.rs:5:33 | 5 | let first = Foo([0; FOO_SIZE]); | ^^^ not found in this scope thread 'rustc' panicked at compiler/rustc_middle/src/ty/sty.rs:362:36: called `Option::unwrap()` on a `None` value stack backtrace: 0: 0x7b29de7c429d - ::fmt::hce35dec2bed7e8e1 1: 0x7b29df005297 - core::fmt::write::haaf8a728f3019c12 2: 0x7b29e02bbd91 - std::io::Write::write_fmt::hb0dc5188703aea0d 3: 0x7b29de7c697b - std::panicking::default_hook::{{closure}}::h35c501ae74c82675 4: 0x7b29de7c65ee - std::panicking::default_hook::hc1ddd62643c4c855 5: 0x7b29dd958729 - std[54b021f941472252]::panicking::update_hook::>::{closure#0} 6: 0x7b29de7c7297 - std::panicking::rust_panic_with_hook::h7960ad04eaeb646d 7: 0x7b29de7c6f23 - std::panicking::begin_panic_handler::{{closure}}::had964436d76b60a3 8: 0x7b29de7c4759 - std::sys::backtrace::__rust_end_short_backtrace::h287862de25ceaa43 9: 0x7b29de7c6c24 - rust_begin_unwind 10: 0x7b29db6b1253 - core::panicking::panic_fmt::hb93ba995a275cef9 11: 0x7b29db87fa9c - core::panicking::panic::he4e48426481834b3 12: 0x7b29dbd05839 - core::option::unwrap_failed::h850f2e87e5e16379 13: 0x7b29e0a8af3c - ::find_ty_from_env.cold 14: 0x7b29db67b97b - ::process_obligation 15: 0x7b29df008777 - >::process_obligations:: 16: 0x7b29df0cf344 - ::demand_coerce_diag 17: 0x7b29dfafeae0 - ::check_decl 18: 0x7b29dfafbd41 - ::check_block_with_expected 19: 0x7b29dfb02247 - ::check_expr_with_expectation_and_args 20: 0x7b29df243661 - rustc_hir_typeck[cd6451a3b3fe12c4]::check::check_fn 21: 0x7b29df985eea - ::check_expr_closure 22: 0x7b29dfb0614a - ::check_expr_with_expectation_and_args 23: 0x7b29dfafae56 - ::check_block_with_expected 24: 0x7b29dfb02247 - ::check_expr_with_expectation_and_args 25: 0x7b29dfb0a87f - ::check_expr_with_expectation_and_args 26: 0x7b29dfafae56 - ::check_block_with_expected 27: 0x7b29dfb02247 - ::check_expr_with_expectation_and_args 28: 0x7b29df7fe24b - rustc_hir_typeck[cd6451a3b3fe12c4]::typeck 29: 0x7b29df7fb975 - rustc_query_impl[69287ea093d06d1d]::plumbing::__rust_begin_short_backtrace::> 30: 0x7b29df2d4bf9 - rustc_query_system[1449707d44461b06]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[69287ea093d06d1d]::plumbing::QueryCtxt, false> 31: 0x7b29df2d3e15 - rustc_query_impl[69287ea093d06d1d]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace 32: 0x7b29df2420f5 - rustc_middle[10ec7aec7d9fdda3]::query::plumbing::query_get_at::>> 33: 0x7b29df7fcdb5 - rustc_hir_typeck[cd6451a3b3fe12c4]::typeck 34: 0x7b29df7fb975 - rustc_query_impl[69287ea093d06d1d]::plumbing::__rust_begin_short_backtrace::> 35: 0x7b29df2d4bf9 - rustc_query_system[1449707d44461b06]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[69287ea093d06d1d]::plumbing::QueryCtxt, false> 36: 0x7b29df2d3e15 - rustc_query_impl[69287ea093d06d1d]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace 37: 0x7b29df2d3a9b - ::par_body_owners::::{closure#0} 38: 0x7b29df2d17e4 - rustc_hir_analysis[c0d9d1e917b71b24]::check_crate 39: 0x7b29df784cbf - rustc_interface[f40e7651e6b02ea1]::passes::run_required_analyses 40: 0x7b29dfb5c49e - rustc_interface[f40e7651e6b02ea1]::passes::analysis 41: 0x7b29dfb5c471 - rustc_query_impl[69287ea093d06d1d]::plumbing::__rust_begin_short_backtrace::> 42: 0x7b29dff867ee - rustc_query_system[1449707d44461b06]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[69287ea093d06d1d]::plumbing::QueryCtxt, false> 43: 0x7b29dff8654f - rustc_query_impl[69287ea093d06d1d]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 44: 0x7b29dfdd38ea - rustc_interface[f40e7651e6b02ea1]::interface::run_compiler::, rustc_driver_impl[ec4d44b725e7aa11]::run_compiler::{closure#0}>::{closure#1} 45: 0x7b29dfdb3210 - std[54b021f941472252]::sys::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[ec4d44b725e7aa11]::run_compiler::{closure#0}>::{closure#1}, core[5070cb7ec77c977]::result::Result<(), rustc_span[a5a4c6b08f7cf6f]::ErrorGuaranteed>>::{closure#0}, core[5070cb7ec77c977]::result::Result<(), rustc_span[a5a4c6b08f7cf6f]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5070cb7ec77c977]::result::Result<(), rustc_span[a5a4c6b08f7cf6f]::ErrorGuaranteed>> 46: 0x7b29dfdb387a - <::spawn_unchecked_, rustc_driver_impl[ec4d44b725e7aa11]::run_compiler::{closure#0}>::{closure#1}, core[5070cb7ec77c977]::result::Result<(), rustc_span[a5a4c6b08f7cf6f]::ErrorGuaranteed>>::{closure#0}, core[5070cb7ec77c977]::result::Result<(), rustc_span[a5a4c6b08f7cf6f]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5070cb7ec77c977]::result::Result<(), rustc_span[a5a4c6b08f7cf6f]::ErrorGuaranteed>>::{closure#1} as core[5070cb7ec77c977]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 47: 0x7b29dfdb3beb - std::sys::pal::unix::thread::Thread::new::thread_start::he8fde62ed04f9a93 48: 0x7b29e152339d - 49: 0x7b29e15a849c - 50: 0x0 - error: 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: please make sure that you have updated to the latest nightly note: rustc 1.82.0-nightly (0f26ee4fd 2024-08-17) running on x86_64-unknown-linux-gnu query stack during panic: #0 [typeck] type-checking `::{constant#0}` #1 [typeck] type-checking `::{constant#0}::{constant#0}` end of query stack error: aborting due to 14 previous errors Some errors have detailed explanations: E0412, E0425, E0601, E0658. For more information about an error, try `rustc --explain E0412`. ```

@rustbot label +F-generic_const_exprs +F-generic_const_exprs

matthiaskrgr commented 2 months ago

smaller

impl<
        const N: usize = {
            static || {
                Foo([0; X]);
            }
        },
    > PartialEq for True
{
}
matthiaskrgr commented 2 months ago

also bisects to #125958