Skip to content

Commit 14ce42a

Browse files
committed
augment equal lifetimes test
1 parent afd6be7 commit 14ce42a

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

tests/ui/type-alias-impl-trait/equal-lifetime-params-not-ok.rs

+10
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,14 @@ mod mod3 {
2424
//~^ ERROR non-defining opaque type use in defining scope
2525
}
2626

27+
// This is similar to the previous cases in that 'a is equal to 'static,
28+
// which is is some sense an implicit parameter to `Opaque`.
29+
// For example, given a defining use `Opaque<'a> := &'a ()`,
30+
// it is ambiguous whether `Opaque<'a> := &'a ()` or `Opaque<'a> := &'static ()`
31+
mod mod4 {
32+
type Opaque<'a> = impl super::Trait<'a, 'a>;
33+
fn test<'a: 'static>() -> Opaque<'a> {}
34+
//~^ ERROR expected generic lifetime parameter, found `'static`
35+
}
36+
2737
fn main() {}

tests/ui/type-alias-impl-trait/equal-lifetime-params-not-ok.stderr

+10-1
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,14 @@ note: lifetime used multiple times
4646
LL | type Opaque<'a, 'b> = impl super::Trait<'a, 'b>;
4747
| ^^ ^^
4848

49-
error: aborting due to 4 previous errors
49+
error[E0792]: expected generic lifetime parameter, found `'static`
50+
--> $DIR/equal-lifetime-params-not-ok.rs:33:42
51+
|
52+
LL | type Opaque<'a> = impl super::Trait<'a, 'a>;
53+
| -- cannot use static lifetime; use a bound lifetime instead or remove the lifetime parameter from the opaque type
54+
LL | fn test<'a: 'static>() -> Opaque<'a> {}
55+
| ^^
56+
57+
error: aborting due to 5 previous errors
5058

59+
For more information about this error, try `rustc --explain E0792`.

0 commit comments

Comments
 (0)