Rollup merge of #73783 - estebank:impl-dyn-trait-static-lifetime, r=nikomatsakis

Detect when `'static` obligation might come from an `impl`

Partly address #71341.
This commit is contained in:
Manish Goregaokar 2020-07-22 16:34:36 -07:00 committed by GitHub
commit fe9babbaed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
60 changed files with 1308 additions and 446 deletions

View file

@ -1,8 +1,7 @@
use std::any::Any;
fn foo<T: Any>(value: &T) -> Box<dyn Any> {
Box::new(value) as Box<dyn Any>
//~^ ERROR cannot infer an appropriate lifetime
Box::new(value) as Box<dyn Any> //~ ERROR E0759
}
fn main() {

View file

@ -1,4 +1,4 @@
error[E0759]: cannot infer an appropriate lifetime
error[E0759]: `value` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
--> $DIR/issue-16922.rs:4:14
|
LL | fn foo<T: Any>(value: &T) -> Box<dyn Any> {