Skip to content

Commit 7c81234

Browse files
committed
add additional tests
1 parent 6d56d61 commit 7c81234

4 files changed

+75
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//@ revisions: current next
2+
//@ ignore-compare-mode-next-solver (explicit revisions)
3+
//@[next] compile-flags: -Znext-solver
4+
//@ check-pass
5+
6+
trait Foo {}
7+
fn needs_foo<T>(_: T)
8+
where
9+
Wrap<T>: Foo,
10+
{
11+
}
12+
13+
struct Wrap<T>(T);
14+
impl<T> Foo for Wrap<T> where T: for<'a> Fn(&'a i32) {}
15+
16+
fn main() {
17+
needs_foo(|x| {
18+
x.to_string();
19+
});
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: implementation of `Foo` is not general enough
2+
--> $DIR/obligation-with-leaking-placeholders.rs:18:5
3+
|
4+
LL | / needs_foo(|x| {
5+
LL | |
6+
LL | |
7+
LL | | x.to_string();
8+
LL | | });
9+
| |______^ implementation of `Foo` is not general enough
10+
|
11+
= note: `Wrap<{closure@$DIR/obligation-with-leaking-placeholders.rs:18:15: 18:18}>` must implement `Foo<'0>`, for any lifetime `'0`...
12+
= note: ...but it actually implements `Foo<'1>`, for some specific lifetime `'1`
13+
14+
error: aborting due to 1 previous error
15+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0282]: type annotations needed
2+
--> $DIR/obligation-with-leaking-placeholders.rs:18:16
3+
|
4+
LL | needs_foo(|x| {
5+
| ^
6+
...
7+
LL | x.to_string();
8+
| - type must be known at this point
9+
|
10+
help: consider giving this closure parameter an explicit type
11+
|
12+
LL | needs_foo(|x: /* Type */| {
13+
| ++++++++++++
14+
15+
error: aborting due to 1 previous error
16+
17+
For more information about this error, try `rustc --explain E0282`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//@ revisions: current next
2+
//@ ignore-compare-mode-next-solver (explicit revisions)
3+
//@[next] compile-flags: -Znext-solver
4+
5+
// See #124385 for more details.
6+
7+
trait Foo<'a> {}
8+
fn needs_foo<T>(_: T)
9+
where
10+
for<'a> Wrap<T>: Foo<'a>,
11+
{
12+
}
13+
14+
struct Wrap<T>(T);
15+
impl<'a, T> Foo<'a> for Wrap<T> where T: Fn(&'a i32) {}
16+
17+
fn main() {
18+
needs_foo(|x| {
19+
//[current]~^ implementation of `Foo` is not general enough
20+
//[next]~^^ ERROR type annotations needed
21+
x.to_string();
22+
});
23+
}

0 commit comments

Comments
 (0)