Increase accuracy of lifetime bound on trait object impl suggestion
This commit is contained in:
parent
6513148c14
commit
4e08bab87d
18 changed files with 321 additions and 114 deletions
|
@ -9,10 +9,12 @@ mod foo {
|
|||
trait MyTrait {
|
||||
fn use_self(&self) -> &();
|
||||
}
|
||||
trait Irrelevant {}
|
||||
|
||||
impl MyTrait for dyn ObjectTrait {
|
||||
fn use_self(&self) -> &() { panic!() }
|
||||
}
|
||||
impl Irrelevant for dyn ObjectTrait {}
|
||||
|
||||
fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
|
||||
val.use_self() //~ ERROR cannot infer an appropriate lifetime
|
||||
|
@ -24,14 +26,48 @@ mod bar {
|
|||
trait MyTrait {
|
||||
fn use_self(&self) -> &();
|
||||
}
|
||||
trait Irrelevant {}
|
||||
|
||||
impl MyTrait for dyn ObjectTrait {
|
||||
fn use_self(&self) -> &() { panic!() }
|
||||
}
|
||||
impl Irrelevant for dyn ObjectTrait {}
|
||||
|
||||
fn use_it<'a>(val: &'a dyn ObjectTrait) -> &'a () {
|
||||
val.use_self() //~ ERROR cannot infer an appropriate lifetime
|
||||
}
|
||||
}
|
||||
|
||||
mod baz {
|
||||
trait ObjectTrait {}
|
||||
trait MyTrait {
|
||||
fn use_self(&self) -> &();
|
||||
}
|
||||
trait Irrelevant {}
|
||||
|
||||
impl MyTrait for Box<dyn ObjectTrait> {
|
||||
fn use_self(&self) -> &() { panic!() }
|
||||
}
|
||||
impl Irrelevant for Box<dyn ObjectTrait> {}
|
||||
|
||||
fn use_it<'a>(val: &'a Box<dyn ObjectTrait + 'a>) -> &'a () {
|
||||
val.use_self() //~ ERROR cannot infer an appropriate lifetime
|
||||
}
|
||||
}
|
||||
|
||||
mod bat {
|
||||
trait OtherTrait<'a> {}
|
||||
impl<'a> OtherTrait<'a> for &'a () {}
|
||||
|
||||
trait ObjectTrait {}
|
||||
|
||||
impl dyn ObjectTrait {
|
||||
fn use_self(&self) -> &() { panic!() }
|
||||
}
|
||||
|
||||
fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
|
||||
val.use_self() //~ ERROR cannot infer an appropriate lifetime
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue