Open
Description
Code
(hand-reduced)
#![feature(min_specialization)]
trait Trait {}
impl<T> Trait for T {}
trait Data {
type Elem;
}
struct DatasetIter<'a, R: Data> {
data: &'a R::Elem,
}
pub struct ArrayBase {}
impl<'a> Trait for DatasetIter<'a, ArrayBase> {}
fn main() {}
(original, 190+ lines)
// Because of #109628, when we compute the implied bounds from `Foo<X>`,
// we incorrectly get `X: placeholder('x)`.
// Make sure we ignore these bogus bounds and not use them for anything useful.
//
//@ revisions: fail pass
//@ [fail] check-fail
//@ [pass] check-pass
trait Trait {
type Ty<'a> where Self: 'a;
}
impl<T> Trait for T {
type Ty<'a> = () where Self: 'a;
}
struct Foo<T: Trait>(T)
where
for<'x> T::Ty<'x>: Sized;
trait AnotherTrait {
type Ty2<'a>: 'a;
}
#[cfg(fail)]
mod fail {
use super::*;
// implied_bound: `'lt: placeholder('x)`.
// don't use the bound to prove `'lt: 'static`.
fn test_lifetime<'lt, T: Trait>(_: Foo<&'lt u8>) {}
//[fail]~^ ERROR `&'lt u8` does not fulfill the required lifetime
// implied bound: `T::Ty2<'lt>: placeholder('x)`.
// don't use the bound to prove `T::Ty2<'lt>: 'static`.
fn test_alias<'lt, T: AnotherTrait>(_: Foo<T::Ty2::<'lt>>) {}
//[fail]~^ ERROR `<T as AnotherTrait>::Ty2<'lt>` does not fulfill the required lifetime
}
mod pass {
use super::*;
// implied_bound: 'static: placeholder('x).
// don't ice.
fn test_lifetime<T: Trait>(_: Foo<&'static u8>) {}
// implied bound: T::Ty2<'static>: placeholder('x).
// don't add the bound to the environment,
// otherwise we would fail to infer a value for `'_`.
fn test_alias<T: AnotherTrait>(_: Foo<T::Ty2::<'static>>) {
None::<&'static T::Ty2<'_>>;
}
}
fn main() {}
//@ check-pass
trait Data {
type Elem;
}
impl<F, S: Data<Elem = F>> Data for ArrayBase<S> {
type Elem = F;
}
struct DatasetIter<'a, R: Data> {
data: &'a R::Elem,
}
pub struct ArrayBase<S> {
data: S,
}
trait Trait {
type Item;
fn next() -> Option<Self::Item>;
}
impl<'a, D: Data> Trait for DatasetIter<'a, ArrayBase<D>> {
type Item = ();
fn next() -> Option<Self::Item> {
None
}
}
fn main() {}
// Make sure that built-in derives don't rely on the user not declaring certain
// names to work properlDebug, Hash)]
enum A<A> {
A(A),
A{ C C: },
}
// Make sure that we aren't using `self::` in paths, since it doesn't work in
// non-module scopes.
const A: () = {
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
enum A { A, }
#[repr(i16)]
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
enum A { A(A), A{ C C: } }
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Default, Hash)]
struct A<A> {
A: A,
}
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
struct A<A: A>(B)
where
A: A< {
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
enum A { A(A), }
#[repr(i16)]
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
enum A { A, A{ C C: } }
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Default, Hash)]
struct A<A> {
A: A,
}
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
struct A<A: A< {
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
enum A { A(A), }
#[repr(i16)]
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
enum A { A, A{ C C: } }
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Default, Hash)]
struct A<A> {
A: A,
}
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
struct A<A: Foo>(B)
where
A: D< continue >;
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
enum A<A> {
A(
),
A { A: A },
}
} >>(B)
where
A: A< continue >;
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
enum A<A> {
A(
),
A { A: A },
}
} >;
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
enum A<A> {
A(
),
A { A: A },
}
};
macro A() {
#[derive(CartialEq, Eq, PartialOrd, Ord, Debug, Default, Hash)]
struct Y<B>(B)
where
B: From<B>;
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
enum Z<C> {
C(C),
B { C: C },
}
}
A!();
fn A() {}
Meta
rustc --version --verbose
:
rustc 1.81.0-nightly (b5b13568f 2024-06-10)
binary: rustc
commit-hash: b5b13568fb5da4ac988bde370008d6134d3dfe6c
commit-date: 2024-06-10
host: x86_64-apple-darwin
release: 1.81.0-nightly
LLVM version: 18.1.7
Error output
Command: rustc
error: specialization impl does not specialize any associated items
--> r_min_spec_9BA0891CC.rs:17:1
|
17 | impl<'a> Trait for DatasetIter<'a, ArrayBase> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: impl is a specialization of this impl
--> r_min_spec_9BA0891CC.rs:5:1
|
5 | impl<T> Trait for T {}
| ^^^^^^^^^^^^^^^^^^^
Backtrace
thread 'rustc' panicked at compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs:417:9:
assertion failed: !obligations.has_infer()
stack backtrace:
0: _rust_begin_unwind
1: core::panicking::panic_fmt
2: core::panicking::panic
3: rustc_hir_analysis::impl_wf_check::min_specialization::check_always_applicable
4: rustc_hir_analysis::check::wfcheck::check_well_formed
[... omitted 1 frame ...]
5: rustc_middle::query::plumbing::query_ensure_error_guaranteed::<rustc_query_system::query::caches::VecCache<rustc_hir::hir_id::OwnerId, rustc_middle::query::erase::Erased<[u8; 1]>>, ()>
6: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
[... omitted 1 frame ...]
7: rustc_hir_analysis::check_crate
8: rustc_interface::passes::run_required_analyses
9: rustc_interface::passes::analysis
[... omitted 1 frame ...]
10: <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}>
11: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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: please attach the file at `/Volumes/T7/workspace/240607_100chaos_tree_combine_typ/icefiles/rustc-ice-2024-06-11T11_20_55-64291.txt` to your bug report
query stack during panic:
#0 [check_well_formed] checking that `<impl at r_min_spec_9BA0891CC.rs:17:1: 17:46>` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 1 previous error
Notes
- ICE location:
rustc_hir_analysis/src/impl_wf_check/min_specialization.rs L417
rust/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs
Lines 413 to 417 in b5b1356
- I cannot find an F-label for
min_specialization
feature.
Metadata
Metadata
Assignees
Labels
Category: This is a bug.`#![feature(min_specialization)]`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Status: This bug is tracked inside the repo by a `known-bug` test.Status: A Minimal Complete and Verifiable Example has been found for this issueRelevant to the compiler team, which will review and decide on the PR/issue.This issue requires a nightly compiler in some way.