diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2024-01-14 20:17:23 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-14 20:17:23 +0100 |
| commit | 8914ca722c29f533335ec4167a8a30658ae8d914 (patch) | |
| tree | b4ea4463e05dae080fdff88f2d3eb131d767ea0b /tests/rustdoc-ui | |
| parent | 273035458dc24e2babbb4708dbb870243742566e (diff) | |
| parent | a704e21c3f2ee1c9215bd088d2880c8e396eacca (diff) | |
| download | rust-8914ca722c29f533335ec4167a8a30658ae8d914.tar.gz rust-8914ca722c29f533335ec4167a8a30658ae8d914.zip | |
Rollup merge of #119561 - notriddle:master, r=fmease
rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 5) Follow up * https://github.com/rust-lang/rust/pull/116214 * https://github.com/rust-lang/rust/pull/116432 * https://github.com/rust-lang/rust/pull/116824 * https://github.com/rust-lang/rust/pull/118105
Diffstat (limited to 'tests/rustdoc-ui')
| -rw-r--r-- | tests/rustdoc-ui/ice-blanket-impl-52873.rs | 175 | ||||
| -rw-r--r-- | tests/rustdoc-ui/ice-blanket-impl-selection-55001.rs | 35 |
2 files changed, 210 insertions, 0 deletions
diff --git a/tests/rustdoc-ui/ice-blanket-impl-52873.rs b/tests/rustdoc-ui/ice-blanket-impl-52873.rs new file mode 100644 index 00000000000..2520957bd00 --- /dev/null +++ b/tests/rustdoc-ui/ice-blanket-impl-52873.rs @@ -0,0 +1,175 @@ +// check-pass +// https://github.com/rust-lang/rust/issues/52873 +#![crate_name="foo"] + +// Regression test for #52873. We used to ICE due to unexpected +// overflows when checking for "blanket impl inclusion". + +use std::marker::PhantomData; +use std::cmp::Ordering; +use std::ops::{Add, Mul}; + +pub type True = B1; +pub type False = B0; +pub type U0 = UTerm; +pub type U1 = UInt<UTerm, B1>; + +pub trait NonZero {} + +pub trait Bit { +} + +pub trait Unsigned { +} + +#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)] +pub struct B0; + +impl B0 { + #[inline] + pub fn new() -> B0 { + B0 + } +} + +#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)] +pub struct B1; + +impl B1 { + #[inline] + pub fn new() -> B1 { + B1 + } +} + +impl Bit for B0 { +} + +impl Bit for B1 { +} + +impl NonZero for B1 {} + +pub trait PrivatePow<Y, N> { + type Output; +} +pub type PrivatePowOut<A, Y, N> = <A as PrivatePow<Y, N>>::Output; + +pub type Add1<A> = <A as Add<::B1>>::Output; +pub type Prod<A, B> = <A as Mul<B>>::Output; +pub type Square<A> = <A as Mul>::Output; +pub type Sum<A, B> = <A as Add<B>>::Output; + +#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)] +pub struct UTerm; + +impl UTerm { + #[inline] + pub fn new() -> UTerm { + UTerm + } +} + +impl Unsigned for UTerm { +} + +#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)] +pub struct UInt<U, B> { + _marker: PhantomData<(U, B)>, +} + +impl<U: Unsigned, B: Bit> UInt<U, B> { + #[inline] + pub fn new() -> UInt<U, B> { + UInt { + _marker: PhantomData, + } + } +} + +impl<U: Unsigned, B: Bit> Unsigned for UInt<U, B> { +} + +impl<U: Unsigned, B: Bit> NonZero for UInt<U, B> {} + +impl Add<B0> for UTerm { + type Output = UTerm; + fn add(self, _: B0) -> Self::Output { + UTerm + } +} + +impl<U: Unsigned, B: Bit> Add<B0> for UInt<U, B> { + type Output = UInt<U, B>; + fn add(self, _: B0) -> Self::Output { + UInt::new() + } +} + +impl<U: Unsigned> Add<U> for UTerm { + type Output = U; + fn add(self, _: U) -> Self::Output { + unimplemented!() + } +} + +impl<U: Unsigned, B: Bit> Mul<B0> for UInt<U, B> { + type Output = UTerm; + fn mul(self, _: B0) -> Self::Output { + UTerm + } +} + +impl<U: Unsigned, B: Bit> Mul<B1> for UInt<U, B> { + type Output = UInt<U, B>; + fn mul(self, _: B1) -> Self::Output { + UInt::new() + } +} + +impl<U: Unsigned> Mul<U> for UTerm { + type Output = UTerm; + fn mul(self, _: U) -> Self::Output { + UTerm + } +} + +impl<Ul: Unsigned, B: Bit, Ur: Unsigned> Mul<UInt<Ur, B>> for UInt<Ul, B0> +where + Ul: Mul<UInt<Ur, B>>, +{ + type Output = UInt<Prod<Ul, UInt<Ur, B>>, B0>; + fn mul(self, _: UInt<Ur, B>) -> Self::Output { + unimplemented!() + } +} + +pub trait Pow<Exp> { + type Output; +} + +impl<X: Unsigned, N: Unsigned> Pow<N> for X +where + X: PrivatePow<U1, N>, +{ + type Output = PrivatePowOut<X, U1, N>; +} + +impl<Y: Unsigned, X: Unsigned> PrivatePow<Y, U0> for X { + type Output = Y; +} + +impl<Y: Unsigned, X: Unsigned> PrivatePow<Y, U1> for X +where + X: Mul<Y>, +{ + type Output = Prod<X, Y>; +} + +impl<Y: Unsigned, U: Unsigned, B: Bit, X: Unsigned> PrivatePow<Y, UInt<UInt<U, B>, B0>> for X +where + X: Mul, + Square<X>: PrivatePow<Y, UInt<U, B>>, +{ + type Output = PrivatePowOut<Square<X>, Y, UInt<U, B>>; +} diff --git a/tests/rustdoc-ui/ice-blanket-impl-selection-55001.rs b/tests/rustdoc-ui/ice-blanket-impl-selection-55001.rs new file mode 100644 index 00000000000..babcb3dda14 --- /dev/null +++ b/tests/rustdoc-ui/ice-blanket-impl-selection-55001.rs @@ -0,0 +1,35 @@ +// check-pass +// https://github.com/rust-lang/rust/issues/55001 +#![crate_name="foo"] + +// Regression test for issue #55001. Previously, we would incorrectly +// cache certain trait selection results when checking for blanket impls, +// resulting in an ICE when we tried to confirm the cached ParamCandidate +// against an obligation. + +pub struct DefaultAllocator; +pub struct Standard; +pub struct Inner; + +pub trait Rand {} + +pub trait Distribution<T> {} +pub trait Allocator<N> {} + +impl<T> Rand for T where Standard: Distribution<T> {} + +impl<A> Distribution<Point<A>> for Standard +where +DefaultAllocator: Allocator<A>, +Standard: Distribution<A> {} + +impl Distribution<Inner> for Standard {} + + +pub struct Point<N> +where DefaultAllocator: Allocator<N> +{ + field: N +} + +fn main() {} |
