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: Unexpected type for 'Single' constructor #117100

Closed
matthiaskrgr opened this issue Oct 23, 2023 · 6 comments · Fixed by #116821
Closed

ICE: Unexpected type for 'Single' constructor #117100

matthiaskrgr opened this issue Oct 23, 2023 · 6 comments · Fixed by #116821
Labels
A-exhaustiveness-checking Relating to exhaustiveness / usefulness checking of patterns A-patterns Relating to patterns and pattern matching 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.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Oct 23, 2023

File: /tmp/icemaker/81DF126D24557409A8EFD18AB1CCB3D2E8119C89297C34BA28DE025833020886.rs

auto-reduced (treereduce-rust):

fn enum_upvar() {
    type T = impl Copy;
    let foo: T = Some((1u32, 2u32));
    let x = move || match foo {
        Foo => (),
        Some((a, b)) => (),
    };
}
original code

original:

#![feature(type_alias_impl_trait)]
// check-pass

fn main() {
    type T = impl Copy;
    let foo: T = Some((1u32, 2u32));
    match foo {
        None => (),
        Some((a, b)) => (),
    }
}

fn upvar() {
    #[derive(Copy, Clone)]
    struct Foo((u32, u32));

    type T = impl Copy;
    let foo: T = Foo((1u32, 2u32));
    let x = move || {
        let Foo((a, b)) = foo;
    };
}

fn enum_upvar() {
    type T = impl Copy;
    let foo: T = Some((1u32, 2u32));
    let x = move || {
        match foo {
            Foo => (),
            Some((a, b)) => (),
        }
    };
}

fn r#struct() {
    #[derive(Copy, Clone)]
    struct Foo((u32, u32));

    type U = impl Copy;
    let foo: U = Foo((1u32, 2u32));
    let Foo((a, b)) = foo;
}

mod only_pattern {
    type T = impl Copy;

    fn foo(foo: T) {
        let (mut x, mut y) = foo;
        x = 42;
        y = "foo";
    }

    type U = impl Copy;

    fn bar(bar: Option<U>) {
        match bar {
            Some((mut x, mut y)) => {
                x = 42;
                y = "foo";
            }
            None => {}
        }
    }
}

mod only_pattern_rpit {
    #[allow(unconditional_recursion)]
    fn foo(b: bool) -> impl Copy {
        let (mut x, mut y) = foo(false);
        x = 42;
        y = "foo";
        if b {
            panic!()
        } else {
            foo(true)
        }
    }

    fn bar(b: bool) -> Option<impl Copy> {
        if b {
            return None;
        }
        match bar(!b) {
            Some((mut x, mut y)) => {
                x = 42;
                y = "foo";
            }
            None => {}
        }
        None
    }
}

Version information

rustc 1.75.0-nightly (e2068cdb0 2023-10-23)
binary: rustc
commit-hash: e2068cdb0964ccbae614ab60cddeed7b24473cdd
commit-date: 2023-10-23
host: x86_64-unknown-linux-gnu
release: 1.75.0-nightly
LLVM version: 17.0.3

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(non_exhaustive_omitted_patterns_lint) -Wnon-exhaustive-omitted-patterns

Program output

error[E0658]: `impl Trait` in type aliases is unstable
 --> /tmp/icemaker_global_tempdir.XldkPeZXsiM8/rustc_testrunner_tmpdir_reporting.HnpgDO2rOy70/mvce.rs:2:14
  |
2 |     type T = impl Copy;
  |              ^^^^^^^^^
  |
  = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
  = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable

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

warning: unused variable: `x`
 --> /tmp/icemaker_global_tempdir.XldkPeZXsiM8/rustc_testrunner_tmpdir_reporting.HnpgDO2rOy70/mvce.rs:4:9
  |
4 |     let x = move || match foo {
  |         ^ help: if this is intentional, prefix it with an underscore: `_x`
  |
  = note: `#[warn(unused_variables)]` on by default

error: internal compiler error: compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs:688:22: Unexpected type for `Single` constructor: Alias(Opaque, AliasTy { args: [], def_id: DefId(0:6 ~ mvce[9309]::enum_upvar::T::{opaque#0}) })

thread 'rustc' panicked at /rustc/e2068cdb0964ccbae614ab60cddeed7b24473cdd/compiler/rustc_errors/src/lib.rs:1659:9:
Box<dyn Any>
stack backtrace:
   0:     0x7f623476917c - std::backtrace_rs::backtrace::libunwind::trace::h4bc45ce9b5e3ecb5
                               at /rustc/e2068cdb0964ccbae614ab60cddeed7b24473cdd/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f623476917c - std::backtrace_rs::backtrace::trace_unsynchronized::h77fef45dac28db31
                               at /rustc/e2068cdb0964ccbae614ab60cddeed7b24473cdd/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f623476917c - std::sys_common::backtrace::_print_fmt::h062a8512ed8cd5cc
                               at /rustc/e2068cdb0964ccbae614ab60cddeed7b24473cdd/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f623476917c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd074e811727bbea6
                               at /rustc/e2068cdb0964ccbae614ab60cddeed7b24473cdd/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f62347cb400 - core::fmt::rt::Argument::fmt::hc0fbbf578e30bc2c
                               at /rustc/e2068cdb0964ccbae614ab60cddeed7b24473cdd/library/core/src/fmt/rt.rs:142:9
   5:     0x7f62347cb400 - core::fmt::write::he36b68adc7e6be82
                               at /rustc/e2068cdb0964ccbae614ab60cddeed7b24473cdd/library/core/src/fmt/mod.rs:1117:17
   6:     0x7f623475d09f - std::io::Write::write_fmt::hf5123e49f0129c06
                               at /rustc/e2068cdb0964ccbae614ab60cddeed7b24473cdd/library/std/src/io/mod.rs:1762:15
   7:     0x7f6234768f64 - std::sys_common::backtrace::_print::h6da84f440ebc0da4
                               at /rustc/e2068cdb0964ccbae614ab60cddeed7b24473cdd/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f6234768f64 - std::sys_common::backtrace::print::hc890a71d29bf133e
                               at /rustc/e2068cdb0964ccbae614ab60cddeed7b24473cdd/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f623476bbf7 - std::panicking::default_hook::{{closure}}::h5007462eb02fe0f7
  10:     0x7f623476b95f - std::panicking::default_hook::h74cd236d286fc688
                               at /rustc/e2068cdb0964ccbae614ab60cddeed7b24473cdd/library/std/src/panicking.rs:292:9
  11:     0x7f62372af240 - std[2f4a0694a58cda61]::panicking::update_hook::<alloc[fcaa6962a6f8cc73]::boxed::Box<rustc_driver_impl[d38002856561e974]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f623476c338 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h3d000bb31fc13980
                               at /rustc/e2068cdb0964ccbae614ab60cddeed7b24473cdd/library/alloc/src/boxed.rs:2021:9
  13:     0x7f623476c338 - std::panicking::rust_panic_with_hook::hcafe47f43a083fd9
                               at /rustc/e2068cdb0964ccbae614ab60cddeed7b24473cdd/library/std/src/panicking.rs:735:13
  14:     0x7f6237673784 - std[2f4a0694a58cda61]::panicking::begin_panic::<rustc_errors[fe61904af5203354]::ExplicitBug>::{closure#0}
  15:     0x7f6237665d76 - std[2f4a0694a58cda61]::sys_common::backtrace::__rust_end_short_backtrace::<std[2f4a0694a58cda61]::panicking::begin_panic<rustc_errors[fe61904af5203354]::ExplicitBug>::{closure#0}, !>
  16:     0x7f6237656536 - std[2f4a0694a58cda61]::panicking::begin_panic::<rustc_errors[fe61904af5203354]::ExplicitBug>
  17:     0x7f623764d594 - <rustc_errors[fe61904af5203354]::HandlerInner>::bug::<alloc[fcaa6962a6f8cc73]::string::String>
  18:     0x7f623764d354 - <rustc_errors[fe61904af5203354]::Handler>::bug::<alloc[fcaa6962a6f8cc73]::string::String>
  19:     0x7f62376ece6d - rustc_middle[cdc9403fb0d2bf23]::util::bug::opt_span_bug_fmt::<rustc_span[b1c0d326828bdf7]::span_encoding::Span>::{closure#0}
  20:     0x7f62376d3e4a - rustc_middle[cdc9403fb0d2bf23]::ty::context::tls::with_opt::<rustc_middle[cdc9403fb0d2bf23]::util::bug::opt_span_bug_fmt<rustc_span[b1c0d326828bdf7]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f62376d3d08 - rustc_middle[cdc9403fb0d2bf23]::ty::context::tls::with_context_opt::<rustc_middle[cdc9403fb0d2bf23]::ty::context::tls::with_opt<rustc_middle[cdc9403fb0d2bf23]::util::bug::opt_span_bug_fmt<rustc_span[b1c0d326828bdf7]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f62357d5a50 - rustc_middle[cdc9403fb0d2bf23]::util::bug::bug_fmt
  23:     0x7f62399529b1 - <rustc_mir_build[b597ffe59bdba8da]::thir::pattern::deconstruct_pat::Constructor>::arity.cold.0
  24:     0x7f623775f0ba - rustc_mir_build[b597ffe59bdba8da]::thir::pattern::usefulness::collect_nonexhaustive_missing_variants
  25:     0x7f62386ff965 - rustc_mir_build[b597ffe59bdba8da]::thir::pattern::usefulness::compute_match_usefulness
  26:     0x7f62355e79c1 - <rustc_mir_build[b597ffe59bdba8da]::thir::pattern::check_match::MatchVisitor as rustc_middle[cdc9403fb0d2bf23]::thir::visit::Visitor>::visit_expr
  27:     0x7f62355e70a9 - <rustc_mir_build[b597ffe59bdba8da]::thir::pattern::check_match::MatchVisitor as rustc_middle[cdc9403fb0d2bf23]::thir::visit::Visitor>::visit_expr
  28:     0x7f62388d468a - rustc_mir_build[b597ffe59bdba8da]::thir::pattern::check_match::check_match
  29:     0x7f62388d4417 - rustc_query_impl[7a9350cb63c32305]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7a9350cb63c32305]::query_impl::check_match::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cdc9403fb0d2bf23]::query::erase::Erased<[u8; 1usize]>>
  30:     0x7f62388d3e2b - rustc_query_system[36043fee951be75c]::query::plumbing::try_execute_query::<rustc_query_impl[7a9350cb63c32305]::DynamicConfig<rustc_query_system[36043fee951be75c]::query::caches::VecCache<rustc_span[b1c0d326828bdf7]::def_id::LocalDefId, rustc_middle[cdc9403fb0d2bf23]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[7a9350cb63c32305]::plumbing::QueryCtxt, false>
  31:     0x7f62388d3bdd - rustc_query_impl[7a9350cb63c32305]::query_impl::check_match::get_query_non_incr::__rust_end_short_backtrace
  32:     0x7f62389ce39c - rustc_mir_build[b597ffe59bdba8da]::build::mir_built
  33:     0x7f62389ce1bb - rustc_query_impl[7a9350cb63c32305]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7a9350cb63c32305]::query_impl::mir_built::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cdc9403fb0d2bf23]::query::erase::Erased<[u8; 8usize]>>
  34:     0x7f623849a96c - rustc_query_system[36043fee951be75c]::query::plumbing::try_execute_query::<rustc_query_impl[7a9350cb63c32305]::DynamicConfig<rustc_query_system[36043fee951be75c]::query::caches::VecCache<rustc_span[b1c0d326828bdf7]::def_id::LocalDefId, rustc_middle[cdc9403fb0d2bf23]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[7a9350cb63c32305]::plumbing::QueryCtxt, false>
  35:     0x7f623849a350 - rustc_query_impl[7a9350cb63c32305]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7f623664cd2e - rustc_mir_transform[9daa006cdf909815]::check_unsafety::unsafety_check_result
  37:     0x7f623849a747 - rustc_query_impl[7a9350cb63c32305]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7a9350cb63c32305]::query_impl::unsafety_check_result::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cdc9403fb0d2bf23]::query::erase::Erased<[u8; 8usize]>>
  38:     0x7f623849a96c - rustc_query_system[36043fee951be75c]::query::plumbing::try_execute_query::<rustc_query_impl[7a9350cb63c32305]::DynamicConfig<rustc_query_system[36043fee951be75c]::query::caches::VecCache<rustc_span[b1c0d326828bdf7]::def_id::LocalDefId, rustc_middle[cdc9403fb0d2bf23]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[7a9350cb63c32305]::plumbing::QueryCtxt, false>
  39:     0x7f623849a410 - rustc_query_impl[7a9350cb63c32305]::query_impl::unsafety_check_result::get_query_non_incr::__rust_end_short_backtrace
  40:     0x7f62366500ce - rustc_mir_transform[9daa006cdf909815]::check_unsafety::unsafety_check_result
  41:     0x7f623849a747 - rustc_query_impl[7a9350cb63c32305]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7a9350cb63c32305]::query_impl::unsafety_check_result::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cdc9403fb0d2bf23]::query::erase::Erased<[u8; 8usize]>>
  42:     0x7f623849a96c - rustc_query_system[36043fee951be75c]::query::plumbing::try_execute_query::<rustc_query_impl[7a9350cb63c32305]::DynamicConfig<rustc_query_system[36043fee951be75c]::query::caches::VecCache<rustc_span[b1c0d326828bdf7]::def_id::LocalDefId, rustc_middle[cdc9403fb0d2bf23]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[7a9350cb63c32305]::plumbing::QueryCtxt, false>
  43:     0x7f623849a410 - rustc_query_impl[7a9350cb63c32305]::query_impl::unsafety_check_result::get_query_non_incr::__rust_end_short_backtrace
  44:     0x7f623849b45a - rustc_mir_transform[9daa006cdf909815]::mir_const
  45:     0x7f623849b3a7 - rustc_query_impl[7a9350cb63c32305]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7a9350cb63c32305]::query_impl::mir_const::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cdc9403fb0d2bf23]::query::erase::Erased<[u8; 8usize]>>
  46:     0x7f623849a96c - rustc_query_system[36043fee951be75c]::query::plumbing::try_execute_query::<rustc_query_impl[7a9350cb63c32305]::DynamicConfig<rustc_query_system[36043fee951be75c]::query::caches::VecCache<rustc_span[b1c0d326828bdf7]::def_id::LocalDefId, rustc_middle[cdc9403fb0d2bf23]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[7a9350cb63c32305]::plumbing::QueryCtxt, false>
  47:     0x7f623849a4d0 - rustc_query_impl[7a9350cb63c32305]::query_impl::mir_const::get_query_non_incr::__rust_end_short_backtrace
  48:     0x7f62368c6c73 - rustc_mir_transform[9daa006cdf909815]::mir_promoted
  49:     0x7f62388d4d92 - rustc_query_impl[7a9350cb63c32305]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7a9350cb63c32305]::query_impl::mir_promoted::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cdc9403fb0d2bf23]::query::erase::Erased<[u8; 16usize]>>
  50:     0x7f62388d4fea - rustc_query_system[36043fee951be75c]::query::plumbing::try_execute_query::<rustc_query_impl[7a9350cb63c32305]::DynamicConfig<rustc_query_system[36043fee951be75c]::query::caches::VecCache<rustc_span[b1c0d326828bdf7]::def_id::LocalDefId, rustc_middle[cdc9403fb0d2bf23]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[7a9350cb63c32305]::plumbing::QueryCtxt, false>
  51:     0x7f62388d4c93 - rustc_query_impl[7a9350cb63c32305]::query_impl::mir_promoted::get_query_non_incr::__rust_end_short_backtrace
  52:     0x7f6239185603 - rustc_borrowck[14a9d49ebe9cc411]::mir_borrowck
  53:     0x7f623918556f - rustc_query_impl[7a9350cb63c32305]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7a9350cb63c32305]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cdc9403fb0d2bf23]::query::erase::Erased<[u8; 8usize]>>
  54:     0x7f623849a96c - rustc_query_system[36043fee951be75c]::query::plumbing::try_execute_query::<rustc_query_impl[7a9350cb63c32305]::DynamicConfig<rustc_query_system[36043fee951be75c]::query::caches::VecCache<rustc_span[b1c0d326828bdf7]::def_id::LocalDefId, rustc_middle[cdc9403fb0d2bf23]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[7a9350cb63c32305]::plumbing::QueryCtxt, false>
  55:     0x7f623849a590 - rustc_query_impl[7a9350cb63c32305]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  56:     0x7f62373c72fa - <rustc_hir_analysis[4f5f2fc3d25550fe]::collect::type_of::opaque::TaitConstraintLocator>::check
  57:     0x7f62373b8050 - <rustc_hir_analysis[4f5f2fc3d25550fe]::collect::type_of::opaque::TaitConstraintLocator as rustc_hir[101d9aa3d11e5aaf]::intravisit::Visitor>::visit_item
  58:     0x7f6238e1396d - rustc_hir_analysis[4f5f2fc3d25550fe]::collect::type_of::type_of_opaque
  59:     0x7f6238e1315b - rustc_query_impl[7a9350cb63c32305]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7a9350cb63c32305]::query_impl::type_of_opaque::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cdc9403fb0d2bf23]::query::erase::Erased<[u8; 8usize]>>
  60:     0x7f6238461205 - rustc_query_system[36043fee951be75c]::query::plumbing::try_execute_query::<rustc_query_impl[7a9350cb63c32305]::DynamicConfig<rustc_query_system[36043fee951be75c]::query::caches::DefaultCache<rustc_span[b1c0d326828bdf7]::def_id::DefId, rustc_middle[cdc9403fb0d2bf23]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[7a9350cb63c32305]::plumbing::QueryCtxt, false>
  61:     0x7f62392ce3a2 - rustc_query_impl[7a9350cb63c32305]::query_impl::type_of_opaque::get_query_non_incr::__rust_end_short_backtrace
  62:     0x7f623851fdfb - rustc_middle[cdc9403fb0d2bf23]::query::plumbing::query_get_at::<rustc_query_system[36043fee951be75c]::query::caches::DefaultCache<rustc_span[b1c0d326828bdf7]::def_id::DefId, rustc_middle[cdc9403fb0d2bf23]::query::erase::Erased<[u8; 8usize]>>>
  63:     0x7f6238464149 - rustc_hir_analysis[4f5f2fc3d25550fe]::collect::type_of::type_of
  64:     0x7f6238461e69 - rustc_query_impl[7a9350cb63c32305]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7a9350cb63c32305]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cdc9403fb0d2bf23]::query::erase::Erased<[u8; 8usize]>>
  65:     0x7f6238461205 - rustc_query_system[36043fee951be75c]::query::plumbing::try_execute_query::<rustc_query_impl[7a9350cb63c32305]::DynamicConfig<rustc_query_system[36043fee951be75c]::query::caches::DefaultCache<rustc_span[b1c0d326828bdf7]::def_id::DefId, rustc_middle[cdc9403fb0d2bf23]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[7a9350cb63c32305]::plumbing::QueryCtxt, false>
  66:     0x7f6238460e2b - rustc_query_impl[7a9350cb63c32305]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
  67:     0x7f623851fdfb - rustc_middle[cdc9403fb0d2bf23]::query::plumbing::query_get_at::<rustc_query_system[36043fee951be75c]::query::caches::DefaultCache<rustc_span[b1c0d326828bdf7]::def_id::DefId, rustc_middle[cdc9403fb0d2bf23]::query::erase::Erased<[u8; 8usize]>>>
  68:     0x7f6238fcedeb - rustc_hir_analysis[4f5f2fc3d25550fe]::check::check::check_mod_item_types
  69:     0x7f6238fcd78d - rustc_query_impl[7a9350cb63c32305]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7a9350cb63c32305]::query_impl::check_mod_item_types::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cdc9403fb0d2bf23]::query::erase::Erased<[u8; 0usize]>>
  70:     0x7f6238a6ec08 - rustc_query_system[36043fee951be75c]::query::plumbing::try_execute_query::<rustc_query_impl[7a9350cb63c32305]::DynamicConfig<rustc_query_system[36043fee951be75c]::query::caches::DefaultCache<rustc_span[b1c0d326828bdf7]::def_id::LocalModDefId, rustc_middle[cdc9403fb0d2bf23]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[7a9350cb63c32305]::plumbing::QueryCtxt, false>
  71:     0x7f6238a6e59b - rustc_query_impl[7a9350cb63c32305]::query_impl::check_mod_item_types::get_query_non_incr::__rust_end_short_backtrace
  72:     0x7f62386c1ff5 - rustc_hir_analysis[4f5f2fc3d25550fe]::check_crate
  73:     0x7f6238a7111f - rustc_interface[1301374836cf4118]::passes::analysis
  74:     0x7f6238a70b21 - rustc_query_impl[7a9350cb63c32305]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7a9350cb63c32305]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cdc9403fb0d2bf23]::query::erase::Erased<[u8; 1usize]>>
  75:     0x7f6238ee3826 - rustc_query_system[36043fee951be75c]::query::plumbing::try_execute_query::<rustc_query_impl[7a9350cb63c32305]::DynamicConfig<rustc_query_system[36043fee951be75c]::query::caches::SingleCache<rustc_middle[cdc9403fb0d2bf23]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[7a9350cb63c32305]::plumbing::QueryCtxt, false>
  76:     0x7f6238ee3655 - rustc_query_impl[7a9350cb63c32305]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  77:     0x7f623912bfcd - std[2f4a0694a58cda61]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[1301374836cf4118]::util::run_in_thread_with_globals<rustc_interface[1301374836cf4118]::interface::run_compiler<core[5c6e87b24e6e70e4]::result::Result<(), rustc_span[b1c0d326828bdf7]::ErrorGuaranteed>, rustc_driver_impl[d38002856561e974]::run_compiler::{closure#1}>::{closure#0}, core[5c6e87b24e6e70e4]::result::Result<(), rustc_span[b1c0d326828bdf7]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5c6e87b24e6e70e4]::result::Result<(), rustc_span[b1c0d326828bdf7]::ErrorGuaranteed>>
  78:     0x7f623912b2b3 - <<std[2f4a0694a58cda61]::thread::Builder>::spawn_unchecked_<rustc_interface[1301374836cf4118]::util::run_in_thread_with_globals<rustc_interface[1301374836cf4118]::interface::run_compiler<core[5c6e87b24e6e70e4]::result::Result<(), rustc_span[b1c0d326828bdf7]::ErrorGuaranteed>, rustc_driver_impl[d38002856561e974]::run_compiler::{closure#1}>::{closure#0}, core[5c6e87b24e6e70e4]::result::Result<(), rustc_span[b1c0d326828bdf7]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5c6e87b24e6e70e4]::result::Result<(), rustc_span[b1c0d326828bdf7]::ErrorGuaranteed>>::{closure#1} as core[5c6e87b24e6e70e4]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  79:     0x7f6234777105 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h57e353e84f121ba4
                               at /rustc/e2068cdb0964ccbae614ab60cddeed7b24473cdd/library/alloc/src/boxed.rs:2007:9
  80:     0x7f6234777105 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h85e27837fb36d5ba
                               at /rustc/e2068cdb0964ccbae614ab60cddeed7b24473cdd/library/alloc/src/boxed.rs:2007:9
  81:     0x7f6234777105 - std::sys::unix::thread::Thread::new::thread_start::h7366c40575a243da
                               at /rustc/e2068cdb0964ccbae614ab60cddeed7b24473cdd/library/std/src/sys/unix/thread.rs:108:17
  82:     0x7f62345409eb - <unknown>
  83:     0x7f62345c47cc - <unknown>
  84:                0x0 - <unknown>

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.75.0-nightly (e2068cdb0 2023-10-23) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z crate-attr=feature(non_exhaustive_omitted_patterns_lint) -Z dump-mir-dir=dir

query stack during panic:
#0 [check_match] match-checking `enum_upvar::{closure#0}`
#1 [mir_built] building MIR for `enum_upvar::{closure#0}`
#2 [unsafety_check_result] unsafety-checking `enum_upvar::{closure#0}`
#3 [unsafety_check_result] unsafety-checking `enum_upvar`
#4 [mir_const] preparing `enum_upvar` for borrow checking
#5 [mir_promoted] promoting constants in MIR for `enum_upvar`
#6 [mir_borrowck] borrow-checking `enum_upvar`
#7 [type_of_opaque] computing type of opaque `enum_upvar::T::{opaque#0}`
#8 [type_of] computing type of `enum_upvar::T::{opaque#0}`
#9 [check_mod_item_types] checking item types in top-level module
#10 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors; 1 warning emitted

Some errors have detailed explanations: E0601, E0658.
For more information about an error, try `rustc --explain E0601`.

@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 Oct 23, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 23, 2023
@matthiaskrgr
Copy link
Member Author

cc @Nadrieril probably ^^

@Nadrieril
Copy link
Member

Hehe hi again! I know about this one, it'll get fixed by #116751, or by #116821 once I clean it up

@Nadrieril
Copy link
Member

Out of curiosity, how do you get these? Do you regularly run the whole rustc test suite with some lints turned on?

@matthiaskrgr
Copy link
Member Author

Do you regularly run the whole rustc test suite with some lints turned on?

I usually do that about daily 😉 :D
I also have like gigabytes of fuzzed code around https://github.com/matthiaskrgr/icemaker

@Nadrieril
Copy link
Member

Wow :D Stunning work

@Nilstrieb Nilstrieb added A-patterns Relating to patterns and pattern matching and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Oct 26, 2023
@Nadrieril
Copy link
Member

Nadrieril commented Oct 28, 2023

#116751 is merged with a mitigation that should fix this! I forgot to add a regression test so I'm not 100% sure x) #116821 is the one that should fix this whole class of issues for real; I'll add tests there.

@Nadrieril Nadrieril added the A-exhaustiveness-checking Relating to exhaustiveness / usefulness checking of patterns label Dec 1, 2023
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 22, 2023
…-errors

Exhaustiveness: reveal opaque types properly

Previously, exhaustiveness had no clear policy around opaque types. In this PR I propose the following policy: within the body of an item that defines the hidden type of some opaque type, exhaustiveness checking on a value of that opaque type is performed using the concrete hidden type inferred in this body.

I'm not sure how consistent this is with other operations allowed on opaque types; I believe this will require FCP.

From what I can tell, this doesn't change anything for non-empty types.

The observable changes are:
- when the real type is uninhabited, matches within the defining scopes can now rely on that for exhaustiveness, e.g.:

```rust
#[derive(Copy, Clone)]
enum Void {}
fn return_never_rpit(x: Void) -> impl Copy {
    if false {
        match return_never_rpit(x) {}
    }
    x
}
```
- this properly fixes ICEs like rust-lang#117100 that occurred because a same match could have some patterns where the type is revealed and some where it is not.

Bonus subtle point: if `x` is opaque, a match like `match x { ("", "") => {} ... }` will constrain its type ([playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=901d715330eac40339b4016ac566d6c3)). This is not the case for `match x {}`: this will not constain the type, and will only compile if something else constrains the type to be empty.

Fixes rust-lang#117100

r? `@oli-obk`

Edited for precision of the wording

[Included](rust-lang#116821 (comment)) in the FCP on this PR is this rule:

> Within the body of an item that defines the hidden type of some opaque type, exhaustiveness checking on a value of that opaque type is performed using the concrete hidden type inferred in this body.
@bors bors closed this as completed in c1fc1d1 Dec 22, 2023
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Dec 24, 2023
Exhaustiveness: reveal opaque types properly

Previously, exhaustiveness had no clear policy around opaque types. In this PR I propose the following policy: within the body of an item that defines the hidden type of some opaque type, exhaustiveness checking on a value of that opaque type is performed using the concrete hidden type inferred in this body.

I'm not sure how consistent this is with other operations allowed on opaque types; I believe this will require FCP.

From what I can tell, this doesn't change anything for non-empty types.

The observable changes are:
- when the real type is uninhabited, matches within the defining scopes can now rely on that for exhaustiveness, e.g.:

```rust
#[derive(Copy, Clone)]
enum Void {}
fn return_never_rpit(x: Void) -> impl Copy {
    if false {
        match return_never_rpit(x) {}
    }
    x
}
```
- this properly fixes ICEs like rust-lang/rust#117100 that occurred because a same match could have some patterns where the type is revealed and some where it is not.

Bonus subtle point: if `x` is opaque, a match like `match x { ("", "") => {} ... }` will constrain its type ([playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=901d715330eac40339b4016ac566d6c3)). This is not the case for `match x {}`: this will not constain the type, and will only compile if something else constrains the type to be empty.

Fixes rust-lang/rust#117100

r? `@oli-obk`

Edited for precision of the wording

[Included](rust-lang/rust#116821 (comment)) in the FCP on this PR is this rule:

> Within the body of an item that defines the hidden type of some opaque type, exhaustiveness checking on a value of that opaque type is performed using the concrete hidden type inferred in this body.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-exhaustiveness-checking Relating to exhaustiveness / usefulness checking of patterns A-patterns Relating to patterns and pattern matching 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants