about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-07-17 10:41:47 +0200
committerGitHub <noreply@github.com>2025-07-17 10:41:47 +0200
commita6be68a6cafc85324216d208016241f4269db8dc (patch)
treebe287dcca51cf485a003f7e0129181c87a65c156
parent0e6649096fa5e23927fb216b6b314a9a6dc04f13 (diff)
parentff1ae2b994960b23eac9e7ce5275c0c5235a0c1d (diff)
downloadrust-a6be68a6cafc85324216d208016241f4269db8dc.tar.gz
rust-a6be68a6cafc85324216d208016241f4269db8dc.zip
Rollup merge of #143914 - shepmaster:mismatched-lifetime-syntaxes-rewording, r=traviscross,jieyouxu
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.

r? ``@jieyouxu``
-rw-r--r--tests/ui/ptr_arg.rs2
-rw-r--r--tests/ui/ptr_arg.stderr11
2 files changed, 7 insertions, 6 deletions
diff --git a/tests/ui/ptr_arg.rs b/tests/ui/ptr_arg.rs
index 65f3f05d6cb..578641e910d 100644
--- a/tests/ui/ptr_arg.rs
+++ b/tests/ui/ptr_arg.rs
@@ -312,7 +312,7 @@ mod issue_9218 {
 
     // Inferred to be `&'a str`, afaik.
     fn cow_good_ret_ty<'a>(input: &'a Cow<'a, str>) -> &str {
-        //~^ ERROR: lifetime flowing from input to output with different syntax
+        //~^ ERROR: eliding a lifetime that's named elsewhere is confusing
         todo!()
     }
 }
diff --git a/tests/ui/ptr_arg.stderr b/tests/ui/ptr_arg.stderr
index 600343754e1..fd9ceddfe11 100644
--- a/tests/ui/ptr_arg.stderr
+++ b/tests/ui/ptr_arg.stderr
@@ -231,18 +231,19 @@ error: writing `&String` instead of `&str` involves a new object where a slice w
 LL |     fn good(v1: &String, v2: &String) {
    |                              ^^^^^^^ help: change this to: `&str`
 
-error: lifetime flowing from input to output with different syntax can be confusing
+error: eliding a lifetime that's named elsewhere is confusing
   --> tests/ui/ptr_arg.rs:314:36
    |
 LL |     fn cow_good_ret_ty<'a>(input: &'a Cow<'a, str>) -> &str {
-   |                                    ^^     ^^           ---- the lifetime gets resolved as `'a`
+   |                                    ^^     ^^           ---- the same lifetime is elided here
    |                                    |      |
-   |                                    |      these lifetimes flow to the output
-   |                                    these lifetimes flow to the output
+   |                                    |      the lifetime is named here
+   |                                    the lifetime is named here
    |
+   = help: the same lifetime is referred to in inconsistent ways, making the signature confusing
    = note: `-D mismatched-lifetime-syntaxes` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(mismatched_lifetime_syntaxes)]`
-help: one option is to consistently use `'a`
+help: consistently use `'a`
    |
 LL |     fn cow_good_ret_ty<'a>(input: &'a Cow<'a, str>) -> &'a str {
    |                                                         ++