Open cushionbadak opened 3 weeks ago
This is quite old, and has been ICEing since the nightly where #68970 introduced min_specialization
.
Looks like a duplicate of https://github.com/rust-lang/rust/issues/102252
Both this report and issue #102252 point to the same ICE location. However, the trigger in #102252 relies on #![feature(rustc_attrs)]
, while this issue does not use internal features. Therefore I believe this could be considered as a separate issue.
Code
(hand-reduced)
(original, 190+ lines)
```Rust // Because of #109628, when we compute the implied bounds from `Foo`,
// 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 Trait for T {
type Ty<'a> = () where Self: 'a;
}
struct Foo(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>) {}
//[fail]~^ ERROR `::Ty2<'lt>` does not fulfill the required lifetime
}
mod pass {
use super::*;
// implied_bound: 'static: placeholder('x).
// don't ice.
fn test_lifetime(_: 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(_: Foo>) {
None::<&'static T::Ty2<'_>>;
}
}
fn main() {}
//@ check-pass
trait Data {
type Elem;
}
impl> Data for ArrayBase
{ type Elem = F; } struct DatasetIter<'a, R: Data> { data: &'a R::Elem, } pub struct ArrayBase{ data: S, } trait Trait { type Item; fn next() -> Option;
}
impl<'a, D: Data> Trait for DatasetIter<'a, ArrayBase> {
type Item = ();
fn next() -> Option {
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{ 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,
}
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
struct 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,
}
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
struct A {
A: A,
}
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
struct A(B)
where
A: D< continue >;
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
enum 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 },
}
} >;
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
enum A {
A(
),
A { A: A },
}
};
macro A() {
#[derive(CartialEq, Eq, PartialOrd, Ord, Debug, Default, Hash)]
struct Y(B)
where
B: From;
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
enum Z {
C(C),
B { C: C },
}
}
A!();
fn A() {}
```
Meta
rustc --version --verbose
:Error output
Command:
rustc
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::>, ()>
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: >::enter::, rustc_driver_impl::run_compiler::{closure#0}::{closure#1}::{closure#3}>
11: rustc_interface::interface::run_compiler::, 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 `` 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
rustc_hir_analysis/src/impl_wf_check/min_specialization.rs L417
https://github.com/rust-lang/rust/blob/b5b13568fb5da4ac988bde370008d6134d3dfe6c/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs#L413-L417min_specialization
feature.