Skip to content

Commit 20e3f49

Browse files
authored
Rollup merge of #145798 - compiler-errors:unnamed-lt-primary, r=lqd
Use unnamed lifetime spans as primary spans for `MISMATCHED_LIFETIME_SYNTAXES` Fixes rust-lang/rust#145772 This PR changes the primary span(s) of the `MISMATCHED_LIFETIME_SYNTAXES` to point to the *unnamed* lifetime spans in both the inputs and *outputs* of the function signature. As reported in rust-lang/rust#145772, this should make it so that IDEs highlight the spans of the actionable part of this lint, rather than just the (possibly named) input spans like they do today. This could be tweaked further perhaps, for example for `fn foo(_: T<'_>) -> T`, we don't need to highlight the elided lifetime if the actionable part is to change only the return type to `T<'_>`, but I think it's improvement on what's here today, so I think that should be follow-up since I think the logic might get a bit hairy. cc ```@shepmaster```
2 parents 8eca407 + fdde09b commit 20e3f49

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tests/ui/ptr_arg.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,10 @@ LL | fn barbar(_x: &mut Vec<u32>, y: &mut String) {
268268
| ^^^^^^^^^^^ help: change this to: `&mut str`
269269

270270
error: eliding a lifetime that's named elsewhere is confusing
271-
--> tests/ui/ptr_arg.rs:314:36
271+
--> tests/ui/ptr_arg.rs:314:56
272272
|
273273
LL | fn cow_good_ret_ty<'a>(input: &'a Cow<'a, str>) -> &str {
274-
| ^^ ^^ ---- the same lifetime is elided here
274+
| -- -- ^^^^ the same lifetime is elided here
275275
| | |
276276
| | the lifetime is named here
277277
| the lifetime is named here

0 commit comments

Comments
 (0)