Skip to content

Commit ac41056

Browse files
authored
Rollup merge of rust-lang#86248 - JohnTitor:issue-85113, r=Mark-Simulacrum
Add a regression test for issue-85113 Fixed by rust-lang#86118, closes rust-lang#85113
2 parents 3ee78b3 + c09b699 commit ac41056

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#![feature(min_type_alias_impl_trait)]
2+
#![feature(impl_trait_in_bindings)]
3+
#![allow(incomplete_features)]
4+
5+
type OpaqueOutputImpl<'a> = impl Output<'a> + 'a;
6+
//~^ ERROR: hidden type for `impl Trait` captures lifetime that does not appear in bounds
7+
//~| ERROR: the type `&'<empty> str` does not fulfill the required lifetime
8+
//~| ERROR: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
9+
10+
trait Output<'a> {}
11+
12+
impl<'a> Output<'a> for &'a str {}
13+
14+
fn cool_fn<'a>(arg: &'a str) -> OpaqueOutputImpl<'a> {
15+
let out: OpaqueOutputImpl<'a> = arg;
16+
arg
17+
}
18+
19+
fn main() {
20+
let s = String::from("wassup");
21+
cool_fn(&s);
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
2+
--> $DIR/issue-85113.rs:5:29
3+
|
4+
LL | type OpaqueOutputImpl<'a> = impl Output<'a> + 'a;
5+
| ^^^^^^^^^^^^^^^^^^^^
6+
|
7+
note: hidden type `&'<empty> str` captures lifetime smaller than the function body
8+
--> $DIR/issue-85113.rs:5:29
9+
|
10+
LL | type OpaqueOutputImpl<'a> = impl Output<'a> + 'a;
11+
| ^^^^^^^^^^^^^^^^^^^^
12+
13+
error[E0477]: the type `&'<empty> str` does not fulfill the required lifetime
14+
--> $DIR/issue-85113.rs:5:29
15+
|
16+
LL | type OpaqueOutputImpl<'a> = impl Output<'a> + 'a;
17+
| ^^^^^^^^^^^^^^^^^^^^
18+
|
19+
note: type must outlive the lifetime `'a` as defined on the item at 5:23
20+
--> $DIR/issue-85113.rs:5:23
21+
|
22+
LL | type OpaqueOutputImpl<'a> = impl Output<'a> + 'a;
23+
| ^^
24+
25+
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
26+
--> $DIR/issue-85113.rs:5:29
27+
|
28+
LL | type OpaqueOutputImpl<'a> = impl Output<'a> + 'a;
29+
| ^^^^^^^^^^^^^^^^^^^^
30+
|
31+
= note: first, the lifetime cannot outlive the empty lifetime...
32+
note: ...but the lifetime must also be valid for the lifetime `'a` as defined on the item at 5:23...
33+
--> $DIR/issue-85113.rs:5:23
34+
|
35+
LL | type OpaqueOutputImpl<'a> = impl Output<'a> + 'a;
36+
| ^^
37+
note: ...so that the types are compatible
38+
--> $DIR/issue-85113.rs:5:29
39+
|
40+
LL | type OpaqueOutputImpl<'a> = impl Output<'a> + 'a;
41+
| ^^^^^^^^^^^^^^^^^^^^
42+
= note: expected `Output<'a>`
43+
found `Output<'_>`
44+
45+
error: aborting due to 3 previous errors
46+
47+
Some errors have detailed explanations: E0477, E0495, E0700.
48+
For more information about an error, try `rustc --explain E0477`.

0 commit comments

Comments
 (0)