rust/tests/ui/self
Esteban Küber 9f730e92f2 Suggest setting lifetime in borrowck error involving types with elided lifetimes
```
error: lifetime may not live long enough
  --> $DIR/ex3-both-anon-regions-both-are-structs-2.rs:7:5
   |
LL | fn foo(mut x: Ref, y: Ref) {
   |        -----       - has type `Ref<'_, '1>`
   |        |
   |        has type `Ref<'_, '2>`
LL |     x.b = y.b;
   |     ^^^^^^^^^ assignment requires that `'1` must outlive `'2`
   |
help: consider introducing a named lifetime parameter
   |
LL | fn foo<'a>(mut x: Ref<'a, 'a>, y: Ref<'a, 'a>) {
   |       ++++           ++++++++        ++++++++
```

As can be seen above, it currently doesn't try to compare the `ty::Ty` lifetimes that diverged vs the `hir::Ty` to correctly suggest the following

```
help: consider introducing a named lifetime parameter
   |
LL | fn foo<'a>(mut x: Ref<'_, 'a>, y: Ref<'_, 'a>) {
   |       ++++           ++++++++        ++++++++
```

but I believe this to still be an improvement over the status quo.

CC #40990.
2024-05-17 20:31:13 +00:00
..
auxiliary
elision [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
arbitrary_self_type_mut_difference.rs
arbitrary_self_type_mut_difference.stderr Deduplicate some logic and reword output 2024-02-22 18:05:28 +00:00
arbitrary_self_types_needing_box_or_arc_wrapping.fixed [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
arbitrary_self_types_needing_box_or_arc_wrapping.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
arbitrary_self_types_needing_box_or_arc_wrapping.stderr
arbitrary_self_types_needing_mut_pin.fixed [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
arbitrary_self_types_needing_mut_pin.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
arbitrary_self_types_needing_mut_pin.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
arbitrary_self_types_nested.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
arbitrary_self_types_pin_lifetime_impl_trait-async.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
arbitrary_self_types_pin_lifetime_impl_trait-async.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
arbitrary_self_types_pin_lifetime_impl_trait.rs
arbitrary_self_types_pin_lifetime_impl_trait.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
arbitrary_self_types_pin_lifetime_mismatch-async.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
arbitrary_self_types_pin_lifetime_mismatch-async.stderr Suggest setting lifetime in borrowck error involving types with elided lifetimes 2024-05-17 20:31:13 +00:00
arbitrary_self_types_pin_lifetime_mismatch.rs
arbitrary_self_types_pin_lifetime_mismatch.stderr Suggest setting lifetime in borrowck error involving types with elided lifetimes 2024-05-17 20:31:13 +00:00
arbitrary_self_types_pin_lifetime-async.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
arbitrary_self_types_pin_lifetime.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
arbitrary_self_types_pin_needing_borrow.rs
arbitrary_self_types_pin_needing_borrow.stderr update ui tests 2024-01-07 08:56:20 -08:00
arbitrary_self_types_pointers_and_wrappers.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
arbitrary_self_types_raw_pointer_struct.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
arbitrary_self_types_raw_pointer_trait.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
arbitrary_self_types_silly.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
arbitrary_self_types_stdlib_pointers.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
arbitrary_self_types_struct.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
arbitrary_self_types_trait.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
arbitrary_self_types_unsized_struct.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
arbitrary-self-from-method-substs.default.stderr Continue compilation after check_mod_type_wf errors 2024-02-14 11:00:30 +00:00
arbitrary-self-from-method-substs.feature.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
arbitrary-self-from-method-substs.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
arbitrary-self-opaque.rs Replace item names containing an error code with something more meaningful 2024-04-30 22:27:19 +02:00
arbitrary-self-opaque.stderr Replace item names containing an error code with something more meaningful 2024-04-30 22:27:19 +02:00
arbitrary-self-types-not-object-safe.curr.stderr On object safety error, mention new enum as alternative 2023-10-29 23:55:46 +00:00
arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
arbitrary-self-types-not-object-safe.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
builtin-superkinds-self-type.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
by-value-self-in-mut-slot.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
class-missing-self.rs
class-missing-self.stderr When suggesting self.x for S { x }, use S { x: self.x } 2023-09-25 15:56:36 +00:00
explicit_self_xcrate_exe.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
explicit-self-closures.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
explicit-self-generic.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
explicit-self-objects-uniq.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
explicit-self.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-61882-2.rs
issue-61882-2.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-61882.rs
issue-61882.stderr
move-self.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
object-safety-sized-self-by-value-self.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
object-safety-sized-self-generic-method.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
object-safety-sized-self-return-Self.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
objects-owned-object-owned-method.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
point-at-arbitrary-self-type-method.rs
point-at-arbitrary-self-type-method.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
point-at-arbitrary-self-type-trait-method.rs
point-at-arbitrary-self-type-trait-method.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
self_lifetime-async.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
self_lifetime.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
self_type_keyword-2.rs
self_type_keyword-2.stderr
self_type_keyword.rs Avoid a track_errors by bubbling up most errors from check_well_formed 2023-10-20 08:46:27 +00:00
self_type_keyword.stderr Improve the diagnostics for unused generic parameters 2024-02-01 16:18:03 +01:00
self-ctor-nongeneric.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
self-impl-2.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
self-impl.rs
self-impl.stderr Unify suggestion wording 2023-10-17 17:33:55 +00:00
self-in-mut-slot-default-method.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
self-in-mut-slot-immediate-value.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
self-in-typedefs.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
self-infer.rs
self-infer.stderr
self-re-assign.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
self-shadowing-import.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
self-type-param.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
self-vs-path-ambiguity.rs
self-vs-path-ambiguity.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
string-self-append.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
suggest-self-2.rs
suggest-self-2.stderr
suggest-self.rs
suggest-self.stderr
ufcs-explicit-self.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
uniq-self-in-mut-slot.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
where-for-self.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00