rust/tests/ui/regions/regions-infer-paramd-indirect.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
555 B
Rust
Raw Normal View History

// Check that we correctly infer that b and c must be region
// parameterized because they reference a which requires a region.
type A<'a> = &'a isize;
type B<'a> = Box<A<'a>>;
2013-03-07 03:09:17 +00:00
struct C<'a> {
f: Box<B<'a>>
2013-03-07 03:09:17 +00:00
}
trait SetF<'a> {
fn set_f_ok(&mut self, b: Box<B<'a>>);
fn set_f_bad(&mut self, b: Box<B>);
}
impl<'a> SetF<'a> for C<'a> {
fn set_f_ok(&mut self, b: Box<B<'a>>) {
self.f = b;
}
fn set_f_bad(&mut self, b: Box<B>) {
2014-12-06 02:12:25 +00:00
self.f = b;
2022-04-01 17:13:25 +00:00
//~^ ERROR lifetime may not live long enough
}
}
fn main() {}