Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed Oct 1, 2024
1 parent db4a25e commit fb2914e
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//@ check-pass
//@ revisions: ai ia ii
//@ compile-flags: -Znext-solver=coherence

// Regression test for nalgebra hang <https://github.com/rust-lang/rust/issues/130056>.

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

type Id<T: ?Sized> = T;
trait NotImplemented {}

struct W<'a, T: ?Sized, U: ?Sized>(&'a (), *const T, *const U);
trait Trait {
type Assoc: ?Sized;
}
impl<'a, T: ?Sized + Trait> Trait for W<'a, T, T> {
#[cfg(ai)]
type Assoc = W<'a, T::Assoc, Id<T::Assoc>>;
#[cfg(ia)]
type Assoc = W<'a, Id<T::Assoc>, T::Assoc>;
#[cfg(ii)]
type Assoc = W<'a, Id<T::Assoc>, Id<T::Assoc>>;
}

trait Overlap<T: ?Sized> {}
impl<'a, T: ?Sized> Overlap<T> for W<'a, T, T> {}
impl<T: ?Sized + Trait + NotImplemented> Overlap<T::Assoc> for T {}

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//@ check-pass
//@ revisions: current next
//[next]@ compile-flags: -Znext-solver
//@ revisions: ai_current ai_next ia_current ia_next ii_current ii_next
//@[ai_next] compile-flags: -Znext-solver
//@[ia_next] compile-flags: -Znext-solver
//@[ii_next] compile-flags: -Znext-solver

// Regression test for nalgebra hang <https://github.com/rust-lang/rust/issues/130056>.

Expand All @@ -15,7 +17,12 @@ trait Trait {
type Assoc: ?Sized;
}
impl<T: ?Sized + Trait> Trait for W<T, T> {
#[cfg(any(ai_current, ai_next))]
type Assoc = W<T::Assoc, Id<T::Assoc>>;
#[cfg(any(ia_current, ia_next))]
type Assoc = W<Id<T::Assoc>, T::Assoc>;
#[cfg(any(ii_current, ii_next))]
type Assoc = W<Id<T::Assoc>, Id<T::Assoc>>;
}

trait Overlap<T: ?Sized> {}
Expand Down
35 changes: 35 additions & 0 deletions tests/ui/traits/next-solver/overflow/nalgebra-hang.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//@ check-pass
//@ revisions: current next
//@[next] compile-flags: -Znext-solver

// Regression test for nalgebra hang from
// https://github.com/rust-lang/rust/pull/130654#issuecomment-2365465354
trait HasAlias {}

struct Dummy;
trait DummyTrait {
type DummyType<T: HasAlias>;
}
impl DummyTrait for Dummy {
type DummyType<T: HasAlias> = T;
}
type AliasOf<T> = <Dummy as DummyTrait>::DummyType<T>;

struct Matrix<T, S>(T, S);
type OMatrix<T> = Matrix<T, AliasOf<T>>;

impl<T: HasAlias> HasAlias for OMatrix<T> {}

trait SimdValue {
type Element;
}
impl<T: HasAlias + SimdValue<Element: HasAlias>> SimdValue for OMatrix<T> {
type Element = OMatrix<T::Element>;
}

trait Unimplemented {}
pub trait MyFrom<T> {}
impl<T: Unimplemented> MyFrom<T> for T {}
impl<T: SimdValue<Element: HasAlias>> MyFrom<T> for OMatrix<T::Element> {}

fn main() {}

0 comments on commit fb2914e

Please sign in to comment.