Skip to content

Commit 1605276

Browse files
committedJan 25, 2020
Add some type-alias-impl-trait regression tests
Fixes #57611 Fixes #57807
1 parent e0bbe79 commit 1605276

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Regression test for issue #57611
2+
// Ensures that we don't ICE
3+
// FIXME: This should compile, but it currently doesn't
4+
5+
#![feature(trait_alias)]
6+
#![feature(type_alias_impl_trait)]
7+
8+
trait Foo {
9+
type Bar: Baz<Self, Self>;
10+
11+
fn bar(&self) -> Self::Bar;
12+
}
13+
14+
struct X;
15+
16+
impl Foo for X {
17+
type Bar = impl Baz<Self, Self>; //~ ERROR type mismatch in closure arguments
18+
//~^ ERROR type mismatch resolving
19+
20+
fn bar(&self) -> Self::Bar {
21+
|x| x
22+
}
23+
}
24+
25+
trait Baz<A, B> = Fn(&A) -> &B;
26+
27+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error[E0631]: type mismatch in closure arguments
2+
--> $DIR/issue-57611-trait-alias.rs:17:5
3+
|
4+
LL | type Bar = impl Baz<Self, Self>;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected signature of `for<'r> fn(&'r X) -> _`
6+
...
7+
LL | |x| x
8+
| ----- found signature of `fn(_) -> _`
9+
|
10+
= note: the return type of a function must have a statically known size
11+
12+
error[E0271]: type mismatch resolving `for<'r> <[closure@$DIR/issue-57611-trait-alias.rs:21:9: 21:14] as std::ops::FnOnce<(&'r X,)>>::Output == &'r X`
13+
--> $DIR/issue-57611-trait-alias.rs:17:5
14+
|
15+
LL | type Bar = impl Baz<Self, Self>;
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter, found concrete lifetime
17+
|
18+
= note: the return type of a function must have a statically known size
19+
20+
error: aborting due to 2 previous errors
21+
22+
Some errors have detailed explanations: E0271, E0631.
23+
For more information about an error, try `rustc --explain E0271`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Regression test for issue #57807 - ensure
2+
// that we properly unify associated types within
3+
// a type alias impl trait
4+
// check-pass
5+
#![feature(type_alias_impl_trait)]
6+
7+
trait Bar {
8+
type A;
9+
}
10+
11+
impl Bar for () {
12+
type A = ();
13+
}
14+
15+
trait Foo {
16+
type A;
17+
type B: Bar<A = Self::A>;
18+
19+
fn foo() -> Self::B;
20+
}
21+
22+
impl Foo for () {
23+
type A = ();
24+
type B = impl Bar<A = Self::A>;
25+
26+
fn foo() -> Self::B {
27+
()
28+
}
29+
}
30+
31+
fn main() {}

0 commit comments

Comments
 (0)