diff options
| author | kennytm <kennytm@gmail.com> | 2019-02-20 01:13:33 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2019-02-20 11:59:02 +0800 |
| commit | fd18e3f35ee217cee03c421382468c6ac60a0080 (patch) | |
| tree | 511f89c1d6ccf965c048b05a3349e3f327f2e8c9 | |
| parent | 717aa461782c794c4202c81cdb5a552ee10aa13c (diff) | |
| parent | ee948d99815b73359214f28a8f1eb69f3091a026 (diff) | |
| download | rust-fd18e3f35ee217cee03c421382468c6ac60a0080.tar.gz rust-fd18e3f35ee217cee03c421382468c6ac60a0080.zip | |
Rollup merge of #58545 - emlai:regression-test-for-39448, r=Centril
Add regression test for a specialization-related ICE (#39448) Closes #39448. This is my first time contributing, I hope I got everything right. :)
| -rw-r--r-- | src/test/ui/specialization/issue-39448.rs | 50 | ||||
| -rw-r--r-- | src/test/ui/specialization/issue-39448.stderr | 12 |
2 files changed, 62 insertions, 0 deletions
diff --git a/src/test/ui/specialization/issue-39448.rs b/src/test/ui/specialization/issue-39448.rs new file mode 100644 index 00000000000..8ac6d8e9311 --- /dev/null +++ b/src/test/ui/specialization/issue-39448.rs @@ -0,0 +1,50 @@ +#![feature(specialization)] + +// Regression test for a specialization-related ICE (#39448). + +trait A: Sized { + fn foo(self, _: Self) -> Self { + self + } +} + +impl A for u8 {} +impl A for u16 {} + +impl FromA<u8> for u16 { + fn from(x: u8) -> u16 { + x as u16 + } +} + +trait FromA<T> { + fn from(T) -> Self; +} + +impl<T: A, U: A + FromA<T>> FromA<T> for U { + default fn from(x: T) -> Self { + ToA::to(x) + } +} + +trait ToA<T> { + fn to(self) -> T; +} + +impl<T, U> ToA<U> for T +where + U: FromA<T>, +{ + fn to(self) -> U { + U::from(self) + } +} + +#[allow(dead_code)] +fn foo<T: A, U: A>(x: T, y: U) -> U { + x.foo(y.to()).to() //~ ERROR overflow evaluating the requirement +} + +fn main() { + let z = foo(8u8, 1u16); +} diff --git a/src/test/ui/specialization/issue-39448.stderr b/src/test/ui/specialization/issue-39448.stderr new file mode 100644 index 00000000000..0b0fd2c4af5 --- /dev/null +++ b/src/test/ui/specialization/issue-39448.stderr @@ -0,0 +1,12 @@ +error[E0275]: overflow evaluating the requirement `T: FromA<U>` + --> $DIR/issue-39448.rs:45:13 + | +LL | x.foo(y.to()).to() //~ ERROR overflow evaluating the requirement + | ^^ + | + = note: required because of the requirements on the impl of `FromA<U>` for `T` + = note: required because of the requirements on the impl of `ToA<T>` for `U` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. |
