diff options
| author | lcnr <rust@lcnr.de> | 2025-09-30 12:02:43 +0200 |
|---|---|---|
| committer | lcnr <rust@lcnr.de> | 2025-09-30 12:02:43 +0200 |
| commit | 5139facb365c40e5b0ddedf221cd62347a2a4504 (patch) | |
| tree | 3fc1437eeb6e63ebaf45d983abac0b1d8c13b814 /tests/ui/traits | |
| parent | a2db9280539229a3b8a084a09886670a57bc7e9c (diff) | |
| download | rust-5139facb365c40e5b0ddedf221cd62347a2a4504.tar.gz rust-5139facb365c40e5b0ddedf221cd62347a2a4504.zip | |
add tests
Diffstat (limited to 'tests/ui/traits')
| -rw-r--r-- | tests/ui/traits/next-solver/forced-ambiguity-typenum-ice.rs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/ui/traits/next-solver/forced-ambiguity-typenum-ice.rs b/tests/ui/traits/next-solver/forced-ambiguity-typenum-ice.rs new file mode 100644 index 00000000000..679d6b1fb16 --- /dev/null +++ b/tests/ui/traits/next-solver/forced-ambiguity-typenum-ice.rs @@ -0,0 +1,60 @@ +//@ compile-flags: -Znext-solver +//@ check-pass + +// Regression test for trait-system-refactor-initiative#105. We previously encountered +// an ICE in typenum as `forced_ambiguity` failed. While this test no longer causes +// `forced_ambiguity` to error, we still want to use it as a regression test. + +pub struct UInt<U, B> { + _msb: U, + _lsb: B, +} +pub struct B1; +pub trait Sub<Rhs> { + type Output; +} +impl<U, B> Sub<B1> for UInt<UInt<U, B>, B1> { + type Output = (); +} +impl<U> Sub<B1> for UInt<U, ()> +where + U: Sub<B1>, + U::Output: Send, +{ + type Output = (); +} + +pub trait Op<N, R, I> { + fn op(&self) { + unimplemented!() + } +} +trait OpIf<N, R, I> {} + +impl<N, Ur, Br, I> Op<N, UInt<Ur, Br>, I> for () +where + N: Sub<I>, + (): OpIf<N, UInt<UInt<Ur, Br>, N::Output>, I>, +{ +} +impl<N, R, Ui, Bi> OpIf<N, R, UInt<Ui, Bi>> for () +where + UInt<Ui, Bi>: Sub<B1>, + (): Op<N, R, <UInt<Ui, Bi> as Sub<B1>>::Output>, +{ +} +impl<N, R> OpIf<N, R, ()> for () where R: Sub<N> {} + +pub trait Compute { + type Output; +} + +pub fn repro<Ul, Bl>() +where + UInt<Ul, Bl>: Compute, + <UInt<Ul, Bl> as Compute>::Output: Sub<B1>, + (): Op<UInt<(), Bl>, (), ()>, +{ + ().op(); +} +fn main() {} |
