Skip to content

Commit d79bd79

Browse files
committed
Add regression test
1 parent 4bdf8d2 commit d79bd79

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#![feature(type_alias_impl_trait)]
2+
trait Trait<'a> {
3+
type Out<U>;
4+
}
5+
6+
impl<'a, T> Trait<'a> for T {
7+
type Out<U> = T;
8+
}
9+
10+
type Foo = impl Sized;
11+
//~^ ERROR: unconstrained opaque type
12+
13+
fn weird_bound<X>(x: &<X as Trait<'static>>::Out<Foo>) -> X
14+
//~^ ERROR: item does not constrain
15+
where
16+
for<'a> X: Trait<'a>,
17+
for<'a> <X as Trait<'a>>::Out<()>: Copy,
18+
{
19+
let x = *x; //~ ERROR: cannot move out of `*x`
20+
todo!();
21+
}
22+
23+
fn main() {
24+
let _: () = weird_bound(&());
25+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
error: item does not constrain `Foo::{opaque#0}`, but has it in its signature
2+
--> $DIR/bind-hidden-type-in-projection-matching.rs:13:4
3+
|
4+
LL | fn weird_bound<X>(x: &<X as Trait<'static>>::Out<Foo>) -> X
5+
| ^^^^^^^^^^^
6+
|
7+
= note: consider moving the opaque type's declaration and defining uses into a separate module
8+
note: this opaque type is in the signature
9+
--> $DIR/bind-hidden-type-in-projection-matching.rs:10:12
10+
|
11+
LL | type Foo = impl Sized;
12+
| ^^^^^^^^^^
13+
14+
error: unconstrained opaque type
15+
--> $DIR/bind-hidden-type-in-projection-matching.rs:10:12
16+
|
17+
LL | type Foo = impl Sized;
18+
| ^^^^^^^^^^
19+
|
20+
= note: `Foo` must be used in combination with a concrete type within the same module
21+
22+
error[E0507]: cannot move out of `*x` which is behind a shared reference
23+
--> $DIR/bind-hidden-type-in-projection-matching.rs:19:13
24+
|
25+
LL | let x = *x;
26+
| ^^ move occurs because `*x` has type `<X as Trait<'_>>::Out<Foo>`, which does not implement the `Copy` trait
27+
|
28+
help: consider removing the dereference here
29+
|
30+
LL - let x = *x;
31+
LL + let x = x;
32+
|
33+
34+
error: aborting due to 3 previous errors
35+
36+
For more information about this error, try `rustc --explain E0507`.

0 commit comments

Comments
 (0)