Skip to content

Commit a6be68a

Browse files
authored
Rollup merge of rust-lang#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``
2 parents 0e66490 + ff1ae2b commit a6be68a

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

tests/ui/ptr_arg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ mod issue_9218 {
312312

313313
// Inferred to be `&'a str`, afaik.
314314
fn cow_good_ret_ty<'a>(input: &'a Cow<'a, str>) -> &str {
315-
//~^ ERROR: lifetime flowing from input to output with different syntax
315+
//~^ ERROR: eliding a lifetime that's named elsewhere is confusing
316316
todo!()
317317
}
318318
}

tests/ui/ptr_arg.stderr

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,18 +231,19 @@ error: writing `&String` instead of `&str` involves a new object where a slice w
231231
LL | fn good(v1: &String, v2: &String) {
232232
| ^^^^^^^ help: change this to: `&str`
233233

234-
error: lifetime flowing from input to output with different syntax can be confusing
234+
error: eliding a lifetime that's named elsewhere is confusing
235235
--> tests/ui/ptr_arg.rs:314:36
236236
|
237237
LL | fn cow_good_ret_ty<'a>(input: &'a Cow<'a, str>) -> &str {
238-
| ^^ ^^ ---- the lifetime gets resolved as `'a`
238+
| ^^ ^^ ---- the same lifetime is elided here
239239
| | |
240-
| | these lifetimes flow to the output
241-
| these lifetimes flow to the output
240+
| | the lifetime is named here
241+
| the lifetime is named here
242242
|
243+
= help: the same lifetime is referred to in inconsistent ways, making the signature confusing
243244
= note: `-D mismatched-lifetime-syntaxes` implied by `-D warnings`
244245
= help: to override `-D warnings` add `#[allow(mismatched_lifetime_syntaxes)]`
245-
help: one option is to consistently use `'a`
246+
help: consistently use `'a`
246247
|
247248
LL | fn cow_good_ret_ty<'a>(input: &'a Cow<'a, str>) -> &'a str {
248249
| ++

0 commit comments

Comments
 (0)