Skip to content

Commit

Permalink
add regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed Sep 26, 2024
1 parent a9dd08c commit f666aac
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 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() {}
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 f666aac

Please sign in to comment.