mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 06:51:58 +00:00
33 lines
470 B
Rust
33 lines
470 B
Rust
// check-pass
|
|
|
|
trait Base<'f> {
|
|
type Assoc;
|
|
|
|
fn do_something(&self);
|
|
}
|
|
|
|
trait ForAnyLifetime: for<'f> Base<'f> {}
|
|
|
|
impl<T> ForAnyLifetime for T where T: for<'f> Base<'f> {}
|
|
|
|
trait CanBeDynamic: ForAnyLifetime + for<'f> Base<'f, Assoc = ()> {}
|
|
|
|
fn foo(a: &dyn CanBeDynamic) {
|
|
a.do_something();
|
|
}
|
|
|
|
struct S;
|
|
|
|
impl<'a> Base<'a> for S {
|
|
type Assoc = ();
|
|
|
|
fn do_something(&self) {}
|
|
}
|
|
|
|
impl CanBeDynamic for S {}
|
|
|
|
fn main() {
|
|
let s = S;
|
|
foo(&s);
|
|
}
|