rust/tests/ui/self/elision
Jake Goulding 5530744318 Reword mismatched-lifetime-syntaxes text based on feedback
Key changes include:

- Removal of the word "syntax" from the lint message. More accurately,
  it could have been something like "syntax group" or "syntax
  category", but avoiding it completely is easier.
- The primary lint message now reflects exactly which mismatch is
  occurring, instead of trying to be general. A new `help` line is
  general across the mismatch kinds.
- Suggestions have been reduced to be more minimal, no longer also
  changing non-idiomatic but unrelated aspects.
- Suggestion text no longer mentions changes when those changes don't
  occur in that specific suggestion.
2025-07-14 09:52:58 -04:00
..
alias-async.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
alias.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
assoc-async.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
assoc.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
ignore-non-reference-lifetimes.rs Reword mismatched-lifetime-syntaxes text based on feedback 2025-07-14 09:52:58 -04:00
ignore-non-reference-lifetimes.stderr Reword mismatched-lifetime-syntaxes text based on feedback 2025-07-14 09:52:58 -04:00
lt-alias-async.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
lt-alias.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
lt-assoc-async.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
lt-assoc.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
lt-ref-self-async.fixed Replace elided_named_lifetimes with mismatched_lifetime_syntaxes 2025-06-04 10:40:04 -04:00
lt-ref-self-async.rs Replace elided_named_lifetimes with mismatched_lifetime_syntaxes 2025-06-04 10:40:04 -04:00
lt-ref-self-async.stderr Bless ui tests. 2024-10-04 23:38:41 +00:00
lt-ref-self.fixed Tweak suggested lifetimes to modify return type instead of &self receiver 2024-05-17 20:31:13 +00:00
lt-ref-self.rs Run rustfmt on modified tests 2024-05-17 20:31:13 +00:00
lt-ref-self.stderr Tweak suggested lifetimes to modify return type instead of &self receiver 2024-05-17 20:31:13 +00:00
lt-self-async.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
lt-self.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
lt-struct-async.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
lt-struct.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
multiple-ref-self-async.rs Do not elide if there's ambiguity in self lifetime. 2024-05-22 14:22:52 +00:00
multiple-ref-self-async.stderr Do not elide if there's ambiguity in self lifetime. 2024-05-22 14:22:52 +00:00
multiple-ref-self.rs Do not elide if there's ambiguity in self lifetime. 2024-05-22 14:22:52 +00:00
multiple-ref-self.stderr Do not elide if there's ambiguity in self lifetime. 2024-05-22 14:22:52 +00:00
nested-item.rs
nested-item.stderr
no-shadow-pin-self.rs Additional test due to Pin<&Self> discovery 2024-06-05 14:32:54 +00:00
no-shadow-pin-self.stderr Additional test due to Pin<&Self> discovery 2024-06-05 14:32:54 +00:00
README.md
ref-alias-async.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
ref-alias.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
ref-assoc-async.rs Ambiguous Self lifetimes: don't elide. 2024-05-22 14:22:52 +00:00
ref-assoc-async.stderr Bless ui tests. 2024-10-04 23:38:41 +00:00
ref-assoc.rs Ambiguous Self lifetimes: don't elide. 2024-05-22 14:22:52 +00:00
ref-assoc.stderr Ambiguous Self lifetimes: don't elide. 2024-05-22 14:22:52 +00:00
ref-mut-alias-async.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
ref-mut-alias.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
ref-mut-self-async.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
ref-mut-self-async.stderr Bless ui tests. 2024-10-04 23:38:41 +00:00
ref-mut-self.fixed Tweak suggested lifetimes to modify return type instead of &self receiver 2024-05-17 20:31:13 +00:00
ref-mut-self.rs Run rustfmt on modified tests 2024-05-17 20:31:13 +00:00
ref-mut-self.stderr Tweak suggested lifetimes to modify return type instead of &self receiver 2024-05-17 20:31:13 +00:00
ref-mut-struct-async.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
ref-mut-struct-async.stderr Bless ui tests. 2024-10-04 23:38:41 +00:00
ref-mut-struct.fixed Tweak suggested lifetimes to modify return type instead of &self receiver 2024-05-17 20:31:13 +00:00
ref-mut-struct.rs Run rustfmt on modified tests 2024-05-17 20:31:13 +00:00
ref-mut-struct.stderr Tweak suggested lifetimes to modify return type instead of &self receiver 2024-05-17 20:31:13 +00:00
ref-self-async.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
ref-self-async.stderr Bless ui tests. 2024-10-04 23:38:41 +00:00
ref-self-multi.rs Do not elide if there's ambiguity in self lifetime. 2024-05-22 14:22:52 +00:00
ref-self-multi.stderr Do not elide if there's ambiguity in self lifetime. 2024-05-22 14:22:52 +00:00
ref-self.fixed Ambiguous Self lifetimes: don't elide. 2024-05-22 14:22:52 +00:00
ref-self.rs Ambiguous Self lifetimes: don't elide. 2024-05-22 14:22:52 +00:00
ref-self.stderr Ambiguous Self lifetimes: don't elide. 2024-05-22 14:22:52 +00:00
ref-struct-async.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
ref-struct-async.stderr Bless ui tests. 2024-10-04 23:38:41 +00:00
ref-struct.fixed Tweak suggested lifetimes to modify return type instead of &self receiver 2024-05-17 20:31:13 +00:00
ref-struct.rs Run rustfmt on modified tests 2024-05-17 20:31:13 +00:00
ref-struct.stderr Tweak suggested lifetimes to modify return type instead of &self receiver 2024-05-17 20:31:13 +00:00
self-async.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
self.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
struct-async.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
struct.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00

Test cases intended to document behavior and try to exhaustively explore the combinations.

Confidence

These tests are not yet considered 100% normative, in that some aspects of the current behavior are not desirable. This is expressed in the "confidence" field in the following table. Values:

Confidence Interpretation
100% this will remain recommended behavior
75% unclear whether we will continue to accept this
50% this will likely be deprecated but remain valid
25% this could change in the future
0% this is definitely bogus and will likely change in the future in some way

Tests

Test file Self type Pattern Current elision behavior Confidence
self.rs Struct Self ignore self parameter 100%
struct.rs Struct Struct ignore self parameter 100%
alias.rs Struct Alias ignore self parameter 100%
ref-self.rs Struct &Self take lifetime from &Self 100%
ref-mut-self.rs Struct &mut Self take lifetime from &mut Self 100%
ref-struct.rs Struct &Struct take lifetime from &Self 50%
ref-mut-struct.rs Struct &mut Struct take lifetime from &mut Self 50%
ref-alias.rs Struct &Alias ignore Alias 0%
ref-mut-alias.rs Struct &mut Alias ignore Alias 0%
lt-self.rs Struct<'a> Self ignore Self (and hence 'a) 25%
lt-struct.rs Struct<'a> Self ignore Self (and hence 'a) 0%
lt-alias.rs Alias<'a> Self ignore Self (and hence 'a) 0%
lt-ref-self.rs Struct<'a> &Self take lifetime from &Self 75%

In each case, we test the following patterns:

  • self: XXX
  • self: Box<XXX>
  • self: Pin<XXX>
  • self: Box<Box<XXX>>
  • self: Box<Pin<XXX>>

In the non-reference cases, Pin causes errors so we substitute Rc.

async fn

For each of the tests above we also check that async fn behaves as an fn would. These tests are in files named *-async.rs.

Legends:

  • ✓ ⟹ Yes / Pass
  • X ⟹ No
  • α ⟹ lifetime mismatch
  • β ⟹ cannot infer an appropriate lifetime
  • γ ⟹ missing lifetime specifier
async file Pass? Conforms to fn? How does it diverge?
fnasync fn
self-async.rs N/A
struct-async.rs N/A
alias-async.rs N/A
assoc-async.rs N/A
ref-self-async.rs X N/A
ref-mut-self-async.rs X N/A
ref-struct-async.rs X N/A
ref-mut-struct-async.rs X N/A
ref-alias-async.rs N/A
ref-assoc-async.rs N/A
ref-mut-alias-async.rs N/A
lt-self-async.rs N/A
lt-struct-async.rs N/A
lt-alias-async.rs N/A
lt-assoc-async.rs N/A
lt-ref-self-async.rs X N/A