Skip to content

Commit

Permalink
augment equal lifetimes test
Browse files Browse the repository at this point in the history
  • Loading branch information
aliemjay committed Oct 19, 2023
1 parent afd6be7 commit 14ce42a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
10 changes: 10 additions & 0 deletions tests/ui/type-alias-impl-trait/equal-lifetime-params-not-ok.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,14 @@ mod mod3 {
//~^ ERROR non-defining opaque type use in defining scope
}

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

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,14 @@ note: lifetime used multiple times
LL | type Opaque<'a, 'b> = impl super::Trait<'a, 'b>;
| ^^ ^^

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

error: aborting due to 5 previous errors

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

0 comments on commit 14ce42a

Please sign in to comment.