Add a regression test for issue-52843

This commit is contained in:
Yuki Okushi 2020-10-09 18:31:48 +09:00
parent 9a74fb726e
commit 07627a3aa3
2 changed files with 29 additions and 0 deletions

View file

@ -0,0 +1,15 @@
#![feature(type_alias_impl_trait)]
type Foo<T> = impl Default;
//~^ ERROR: the trait bound `T: Default` is not satisfied
#[allow(unused)]
fn foo<T: Default>(t: T) -> Foo<T> {
t
}
struct NotDefault;
fn main() {
let _ = Foo::<NotDefault>::default();
}

View file

@ -0,0 +1,14 @@
error[E0277]: the trait bound `T: Default` is not satisfied
--> $DIR/issue-52843.rs:3:15
|
LL | type Foo<T> = impl Default;
| ^^^^^^^^^^^^ the trait `Default` is not implemented for `T`
|
help: consider restricting type parameter `T`
|
LL | type Foo<T: Default> = impl Default;
| ^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.