Skip to content

ICE: unimplemented: inhabitedness checking for inherent projections in rustc_middle/src/ty/inhabitedness/mod.rs #125879

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

Open
cushionbadak opened this issue Jun 2, 2024 · 1 comment · May be fixed by #140247
Labels
C-bug Category: This is a bug. F-inherent_associated_types `#![feature(inherent_associated_types)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@cushionbadak
Copy link

Code

(hand reduced & simplified)

#![feature(inherent_associated_types)]
#![allow(incomplete_features)]

pub type PubAlias0 = PubTy::PrivAssocTy;

pub struct PubTy;
impl PubTy {
    type PrivAssocTy = ();
}

pub struct S(pub PubAlias0);

pub unsafe fn foo(a: S) -> S {
    a
}

fn main() {}
original code

//@ check-pass

#![feature(inherent_associated_types)]
#![allow(incomplete_features)]
#![crate_type = "lib"]

pub type PubAlias0 = PubTy::PrivAssocTy;
//~^ WARNING associated type `PubTy::PrivAssocTy` is more private than the item `PubAlias0`
pub type PubAlias1 = PrivTy::PubAssocTy;
//~^ WARNING type `PrivTy` is more private than the item `PubAlias1`
pub type PubAlias2 = PubTy::PubAssocTy<PrivTy>;
//~^ WARNING type `PrivTy` is more private than the item `PubAlias2`

pub struct PubTy;
impl PubTy {
    type PrivAssocTy = ();
    pub type PubAssocTy<T> = T;
}

struct PrivTy;
impl PrivTy {
    pub type PubAssocTy = ();
}


//~ ERROR the parameter type `Self` may not live long enough

trait GatTrait {
    type Gat<'a>
    where
        Self: 'a;
}

trait SuperTrait<T>: for<'a> GatTrait<Gat<'a> = T> {
    fn c(&self) -> dyn SuperTrait<T>;
    //~^ ERROR associated item referring to unboxed trait object for its own trait
    //~| ERROR the trait `SuperTrait` cannot be made into an object
}

fn main() {}


//@ compile-flags: -C no-prepopulate-passes

#![crate_type = "lib"]

#![feature(repr_simd, intrinsics)]
#![allow(non_camel_case_types)]

#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct f32x2(pub f32, pub f32);

#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct f32x4(pub f32, pub f32, pub f32, pub f32);

#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct f32x8(pub f32, pub f32, pub f32, pub f32,
                 pub f32, pub f32, pub f32, pub f32);

#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct f32x16(pub f32, pub f32, pub f32, pub T,
                  pub f32, pub f32, pub f32, pub f32,
                  pub f32, pub f32, pub f32, pub f32,
                  pub f32, pub f32, pub f32, pub f32);

extern "rust-intrinsic" {
    fn simd_fsin<T>(x: T) -> T;
}

// CHECK-LABEL: @fsin_32x2
#[no_mangle]
pub unsafe fn fsin_32x2(a: f32x2) -> f32x2 {
    // CHECK: call <2 x float> @llvm.sin.v2f32
    simd_fsin(a)
}

// CHECK-LABEL: @fsin_32x4
#[no_mangle]
pub unsafe fn fsin_32x4(a: f32x4) -> f32x4 {
    // CHECK: call <4 x float> @llvm.sin.v4f32
    simd_fsin(a)
}

// CHECK-LABEL: @fsin_32x8
#[no_mangle]
pub unsafe fn fsin_32x8(a: f32x8) -> f32x8 {
    // CHECK: call <8 x float> @llvm.sin.v8f32
    simd_fsin(a)
}

// CHECK-LABEL: @fsin_32x16
#[no_mangle]
pub unsafe fn fsin_32x16(a: f32x16) -> f32x16 {
    // CHECK: call <16 x float> @llvm.sin.v16f32
    simd_fsin(a)
}

#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct f64x2(pub f64, pub f64);

#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct f64x4(pub f64, pub PubAlias0, pub f64, pub f64);

#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct f64x8(pub f64, pub f64, pub f64, pub f64,
                 pub f64, pub f64, pub f64, pub f64);

// CHECK-LABEL: @fsin_64x4
#[no_mangle]
pub unsafe fn fsin_64x4(a: f64x4) -> f64x4 {
    // CHECK: call <4 x double> @llvm.sin.v4f64
    simd_fsin(a)
}

// CHECK-LABEL: @fsin_64x2
#[no_mangle]
pub unsafe fn fsin_64x2(a: f64x2) -> f64x2 {
    // CHECK: call <2 x double> @llvm.sin.v2f64
    simd_fsin(a)
}

// CHECK-LABEL: @fsin_64x8
#[no_mangle]
pub unsafe fn fsin_64x8(a: f64x8) -> f64x8 {
    // CHECK: call <8 x double> @llvm.sin.v8f64
    simd_fsin(a)
}

Meta

rustc --version --verbose:

rustc 1.80.0-nightly (f67a1acc0 2024-06-01)
binary: rustc
commit-hash: f67a1acc04c7ecbf05751b17592dd8d245b75256
commit-date: 2024-06-01
host: aarch64-apple-darwin
release: 1.80.0-nightly
LLVM version: 18.1.6

Error output

Command: rustc

<output>
Backtrace

error: internal compiler error: compiler/rustc_middle/src/ty/inhabitedness/mod.rs:134:17: unimplemented: inhabitedness checking for inherent projections

thread 'rustc' panicked at compiler/rustc_middle/src/ty/inhabitedness/mod.rs:134:17:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   2: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   3: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   5: rustc_middle::util::bug::bug_fmt
   6: <rustc_middle::ty::Ty>::inhabited_predicate
   7: <&mut <rustc_middle::ty::VariantDef>::inhabited_predicate::{closure#0} as core::ops::function::FnOnce<(&rustc_middle::ty::FieldDef,)>>::call_once
   8: <rustc_middle::ty::inhabitedness::inhabited_predicate::InhabitedPredicate>::all::<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::ty::FieldDef>, <rustc_middle::ty::VariantDef>::inhabited_predicate::{closure#0}>>
   9: <rustc_middle::ty::inhabitedness::inhabited_predicate::InhabitedPredicate>::any::<core::iter::adapters::map::Map<core::slice::iter::Iter<rustc_middle::ty::VariantDef>, rustc_middle::ty::inhabitedness::inhabited_predicate_adt::{closure#0}>>
  10: rustc_middle::ty::inhabitedness::inhabited_predicate_adt
      [... omitted 2 frames ...]
  11: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 16]>>>
  12: rustc_middle::ty::inhabitedness::inhabited_predicate_type
      [... omitted 2 frames ...]
  13: <rustc_middle::ty::Ty>::inhabited_predicate
  14: <rustc_pattern_analysis::rustc::RustcPatCtxt>::ctors_for_ty
  15: rustc_pattern_analysis::usefulness::compute_exhaustiveness_and_usefulness::<rustc_pattern_analysis::rustc::RustcPatCtxt>
  16: rustc_pattern_analysis::usefulness::compute_match_usefulness::<rustc_pattern_analysis::rustc::RustcPatCtxt>
  17: rustc_pattern_analysis::analyze_match
  18: <rustc_mir_build::thir::pattern::check_match::MatchVisitor>::analyze_patterns
  19: <rustc_mir_build::thir::pattern::check_match::MatchVisitor>::check_binding_is_irrefutable
  20: rustc_mir_build::thir::pattern::check_match::check_match
      [... omitted 2 frames ...]
  21: rustc_mir_build::build::mir_build
  22: rustc_mir_transform::mir_built
      [... omitted 2 frames ...]
  23: rustc_mir_build::check_unsafety::check_unsafety
      [... omitted 2 frames ...]
  24: <rustc_middle::hir::map::Map>::par_body_owners::<rustc_interface::passes::run_required_analyses::{closure#1}::{closure#0}>::{closure#0}
  25: <rustc_data_structures::sync::parallel::ParallelGuard>::run::<(), rustc_data_structures::sync::parallel::enabled::par_for_each_in<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], <rustc_middle::hir::map::Map>::par_body_owners<rustc_interface::passes::run_required_analyses::{closure#1}::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}::{closure#0}>
  26: <rustc_session::session::Session>::time::<(), rustc_interface::passes::run_required_analyses::{closure#1}>
  27: rustc_interface::passes::analysis
      [... omitted 2 frames ...]
  28: <rustc_interface::queries::QueryResult<&rustc_middle::ty::context::GlobalCtxt>>::enter::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}::{closure#1}::{closure#3}>
  29: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
  30: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: please attach the file at `/Users/jisukbyun/workspace/240601_100chaos_tree_combine_typ/icefiles/rustc-ice-2024-06-02T06_32_04-2403.txt` to your bug report

query stack during panic:
#0 [inhabited_predicate_adt] computing the uninhabited predicate of `DefId(0:8 ~ r_inhab_E562D7[ad83]::S)`
#1 [inhabited_predicate_type] computing the uninhabited predicate of `S`
#2 [check_match] match-checking `foo`
#3 [mir_built] building MIR for `foo`
#4 [check_unsafety] unsafety-checking `foo`
#5 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 1 previous error

Note

  • ICE location: rustc_middle/src/ty/inhabitedness/mod.rs L134
    // FIXME(inherent_associated_types): Most likely we can just map to `GenericType` like above.
    // However it's unclear if the args passed to `InhabitedPredicate::instantiate` are of the correct
    // format, i.e. don't contain parent args. If you hit this case, please verify this beforehand.
    Alias(ty::Inherent, _) => {
    bug!("unimplemented: inhabitedness checking for inherent projections")
    }
@cushionbadak cushionbadak 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 Jun 2, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 2, 2024
@fmease fmease added F-inherent_associated_types `#![feature(inherent_associated_types)]` and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jun 2, 2024
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Jun 9, 2024
@cushionbadak
Copy link
Author

searched toolchains nightly-2023-01-01 through nightly-2024-05-30


********************************************************************************
Regression in nightly-2023-05-09
********************************************************************************

fetching https://static.rust-lang.org/dist/2023-05-08/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2023-05-08: 40 B / 40 B [===================================================] 100.00 % 754.31 KB/s converted 2023-05-08 to c4190f2d3a46a59f435f7b42f58bc22b2f4d6917
fetching https://static.rust-lang.org/dist/2023-05-09/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2023-05-09: 40 B / 40 B [===================================================] 100.00 % 780.58 KB/s converted 2023-05-09 to 2f2c438dce75d8cc532c3baa849eeddc0901802c
looking for regression commit between 2023-05-08 and 2023-05-09
fetching (via remote github) commits from max(c4190f2d3a46a59f435f7b42f58bc22b2f4d6917, 2023-05-06) to 2f2c438dce75d8cc532c3baa849eeddc0901802c
ending github query because we found starting sha: c4190f2d3a46a59f435f7b42f58bc22b2f4d6917
get_commits_between returning commits, len: 9
  commit[0] 2023-05-07: Auto merge of #111224 - jyn514:default-tidy, r=pietroalbini
  commit[1] 2023-05-07: Auto merge of #111306 - Urgau:hashbrown-std-0.13, r=Amanieu
  commit[2] 2023-05-08: Auto merge of #111309 - saethlin:InstSimplify, r=scottmcm
  commit[3] 2023-05-08: Auto merge of #106621 - ozkanonur:enable-elided-lifetimes-for-doctests, r=Mark-Simulacrum
  commit[4] 2023-05-08: Auto merge of #111342 - Dylan-DPC:rollup-b5p6wzy, r=Dylan-DPC
  commit[5] 2023-05-08: Auto merge of #111346 - JohnTitor:rollup-6g5cg9z, r=JohnTitor
  commit[6] 2023-05-08: Auto merge of #110824 - cjgillot:const-prop-index, r=JakobDegen,oli-obk
  commit[7] 2023-05-08: Auto merge of #111007 - JakobDegen:nrvo, r=tmiasko
  commit[8] 2023-05-08: Auto merge of #111358 - compiler-errors:rollup-yv27vrp, r=compiler-errors
ERROR: no CI builds available between c4190f2d3a46a59f435f7b42f58bc22b2f4d6917 and 2f2c438dce75d8cc532c3baa849eeddc0901802c within last 167 days
cargo-bisect-rustc-bisect-rustc 0.6.8
cargo bisect-rustc --start=2023-01-01 --end=2024-05-30 --regress=ice --script=rustc --preserve -- 125879.rs

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-inherent_associated_types `#![feature(inherent_associated_types)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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