rust/src/test/ui/self
Yuki Okushi 76c1454d27
Rollup merge of #67595 - ohadravid:impl-trait-does-not-live-long-enough, r=estebank
Suggest adding a lifetime constraint for opaque type

Fixes #67577, where code like this:

```
struct List {
  data: Vec<String>,
}
impl List {
  fn started_with<'a>(&'a self, prefix: &'a str) -> impl Iterator<Item=&'a str> {
    self.data.iter().filter(|s| s.starts_with(prefix)).map(|s| s.as_ref())
  }
}
```

will show this error:
```
   Compiling playground v0.0.1 (/playground)
error[E0597]: `prefix` does not live long enough
 --> src/lib.rs:6:47
  |
5 |   fn started_with<'a>(&'a self, prefix: &'a str) -> impl Iterator<Item=&'a str> {
  |                   -- lifetime `'a` defined here     --------------------------- opaque type requires that `prefix` is borrowed for `'a`
...
```

but without suggesting the lovely `help: you can add a constraint..`.

r? @estebank
2020-01-03 17:56:21 +09:00
..
auxiliary Move run-pass/self/* to ui/self 2019-05-19 22:17:12 +09:00
elision remove get_named_span 2019-11-29 11:07:06 -06:00
arbitrary-self-types-not-object-safe.curr.stderr Stabilize nested self receivers 2019-11-26 13:35:33 -08:00
arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr Stabilize nested self receivers 2019-11-26 13:35:33 -08:00
arbitrary-self-types-not-object-safe.rs Stabilize nested self receivers 2019-11-26 13:35:33 -08:00
arbitrary-self-types-not-object-safe.stderr Stabilize nested self receivers 2019-11-26 13:35:33 -08:00
arbitrary_self_types_nested.rs Stabilize nested self receivers 2019-11-26 13:35:33 -08:00
arbitrary_self_types_pin_lifetime-async.rs Remove async_await gates from tests. 2019-08-20 03:08:42 +02:00
arbitrary_self_types_pin_lifetime.rs Add main functions and check-pass annotations 2019-07-27 12:28:05 +09:00
arbitrary_self_types_pin_lifetime_impl_trait-async.nll.stderr Change wording for lifetime suggestion for opaque types from constraint to bound 2019-12-31 12:13:35 +01:00
arbitrary_self_types_pin_lifetime_impl_trait-async.rs Remove async_await gates from tests. 2019-08-20 03:08:42 +02:00
arbitrary_self_types_pin_lifetime_impl_trait-async.stderr update suggestion ui test 2019-11-13 00:38:37 +08:00
arbitrary_self_types_pin_lifetime_impl_trait.nll.stderr Change wording for lifetime suggestion for opaque types from constraint to bound 2019-12-31 12:13:35 +01:00
arbitrary_self_types_pin_lifetime_impl_trait.rs Allow lifetime elision in Pin<&(mut) Self> 2019-07-27 12:28:02 +09:00
arbitrary_self_types_pin_lifetime_impl_trait.stderr Change wording for lifetime suggestion for opaque types from constraint to bound 2019-12-31 12:13:35 +01:00
arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr remove get_named_span 2019-11-29 11:07:06 -06:00
arbitrary_self_types_pin_lifetime_mismatch-async.rs Remove async_await gates from tests. 2019-08-20 03:08:42 +02:00
arbitrary_self_types_pin_lifetime_mismatch-async.stderr Update ui tests 2019-11-07 13:02:34 +01:00
arbitrary_self_types_pin_lifetime_mismatch.nll.stderr arbitrary_self_types lifetime elision: --bless --compare-mode=nll 2019-07-27 12:35:05 +09:00
arbitrary_self_types_pin_lifetime_mismatch.rs Remove query for .pin_type() 2019-07-27 12:28:03 +09:00
arbitrary_self_types_pin_lifetime_mismatch.stderr Update ui tests 2019-11-07 13:02:34 +01:00
arbitrary_self_types_pointers_and_wrappers.rs Move arbitrary_self_types's tests into ui/self 2019-05-19 12:31:08 +09:00
arbitrary_self_types_raw_pointer_struct.rs Move arbitrary_self_types's tests into ui/self 2019-05-19 12:31:08 +09:00
arbitrary_self_types_raw_pointer_trait.rs Update ui test suite to use dyn 2019-05-29 00:57:31 -04:00
arbitrary_self_types_silly.rs Move arbitrary_self_types's tests into ui/self 2019-05-19 12:31:08 +09:00
arbitrary_self_types_stdlib_pointers.rs Move arbitrary_self_types's tests into ui/self 2019-05-19 12:31:08 +09:00
arbitrary_self_types_struct.rs Stabilize nested self receivers 2019-11-26 13:35:33 -08:00
arbitrary_self_types_trait.rs Stabilize nested self receivers 2019-11-26 13:35:33 -08:00
arbitrary_self_types_unsized_struct.rs Stabilize nested self receivers 2019-11-26 13:35:33 -08:00
builtin-superkinds-self-type.rs Move run-pass/self/* to ui/self 2019-05-19 22:17:12 +09:00
by-value-self-in-mut-slot.rs Move run-pass/self/* to ui/self 2019-05-19 22:17:12 +09:00
explicit-self-closures.rs Migrate compile-pass annotations to build-pass 2019-07-03 06:30:28 +09:00
explicit-self-generic.rs Move run-pass/self/* to ui/self 2019-05-19 22:17:12 +09:00
explicit-self-objects-uniq.rs Update ui test suite to use dyn 2019-05-29 00:57:31 -04:00
explicit-self.rs Move run-pass/self/* to ui/self 2019-05-19 22:17:12 +09:00
explicit_self_xcrate_exe.rs Move run-pass/self/* to ui/self 2019-05-19 22:17:12 +09:00
move-self.rs Move run-pass/self/* to ui/self 2019-05-19 22:17:12 +09:00
object-safety-sized-self-by-value-self.rs Update ui test suite to use dyn 2019-05-29 00:57:31 -04:00
object-safety-sized-self-generic-method.rs Update ui test suite to use dyn 2019-05-29 00:57:31 -04:00
object-safety-sized-self-return-Self.rs Update ui test suite to use dyn 2019-05-29 00:57:31 -04:00
point-at-arbitrary-self-type-method.rs Account for arbitrary self types in E0599 2019-09-01 02:22:42 -07:00
point-at-arbitrary-self-type-method.stderr Give method not found a primary span label 2019-09-08 18:27:02 -07:00
point-at-arbitrary-self-type-trait-method.rs Account for arbitrary self types in E0599 2019-09-01 02:22:42 -07:00
point-at-arbitrary-self-type-trait-method.stderr Give method not found a primary span label 2019-09-08 18:27:02 -07:00
self-impl-2.rs Move run-pass/self/* to ui/self 2019-05-19 22:17:12 +09:00
self-impl.rs Remove licenses 2018-12-25 21:08:33 -07:00
self-impl.stderr Remove licenses 2018-12-25 21:08:33 -07:00
self-in-mut-slot-default-method.rs Move run-pass/self/* to ui/self 2019-05-19 22:17:12 +09:00
self-in-mut-slot-immediate-value.rs Move run-pass/self/* to ui/self 2019-05-19 22:17:12 +09:00
self-in-typedefs.rs Remove most uses of allow(unions_with_drop_fields) in tests 2019-10-11 10:43:54 +02:00
self-infer.rs Remove licenses 2018-12-25 21:08:33 -07:00
self-infer.stderr Account for all item kinds when collecting and gateing _ in item defs 2019-12-29 19:16:15 -08:00
self-re-assign.rs Move run-pass/self/* to ui/self 2019-05-19 22:17:12 +09:00
self-shadowing-import.rs Move run-pass/self/* to ui/self 2019-05-19 22:17:12 +09:00
self-type-param.rs Migrate compile-pass annotations to build-pass 2019-07-03 06:30:28 +09:00
self-vs-path-ambiguity.rs Remove licenses 2018-12-25 21:08:33 -07:00
self-vs-path-ambiguity.stderr parser: recover on &'lifetime mut $pat. 2019-12-13 02:36:25 +01:00
self_lifetime-async.rs Remove async_await gates from tests. 2019-08-20 03:08:42 +02:00
self_lifetime.rs Minor clean up 2019-07-27 12:28:06 +09:00
self_type_keyword-2.rs Point at local similarly named element and tweak references to variants 2019-10-27 11:50:43 -07:00
self_type_keyword-2.stderr Point at local similarly named element and tweak references to variants 2019-10-27 11:50:43 -07:00
self_type_keyword.rs Point at local similarly named element and tweak references to variants 2019-10-27 11:50:43 -07:00
self_type_keyword.stderr Point at local similarly named element and tweak references to variants 2019-10-27 11:50:43 -07:00
string-self-append.rs Move run-pass/self/* to ui/self 2019-05-19 22:17:12 +09:00
suggest-self.rs Remove double trailing newlines 2019-04-22 16:57:01 +01:00
suggest-self.stderr Remove licenses 2018-12-25 21:08:33 -07:00
ufcs-explicit-self.rs Move run-pass/self/* to ui/self 2019-05-19 22:17:12 +09:00
uniq-self-in-mut-slot.rs Move run-pass/self/* to ui/self 2019-05-19 22:17:12 +09:00
where-for-self.rs Move run-pass/self/* to ui/self 2019-05-19 22:17:12 +09:00