// 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() {}
Code
(hand-reduced)
(original, 190+ lines)
Meta
rustc --version --verbose:Error output
Command:
rustcBacktrace
Notes
rustc_hir_analysis/src/impl_wf_check/min_specialization.rs L417rust/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs
Lines 413 to 417 in b5b1356
min_specializationfeature.