Repository navigation
suggest named lifetimes instead of '_ in use<...> for E0700 - #163684
Conversation
40cda7b to
e36e829
Compare
This comment has been minimized.
This comment has been minimized.
|
any updates? |
This comment has been minimized.
This comment has been minimized.
records current behaviour. for an anonymous lifetime the suggestion renders use<'_>, which resolves to the first elided lifetime in the signature. two of the cases here still fail after applying it, and one stops resolving entirely and reports a missing lifetime specifier on top of the original error.
for an anonymous lifetime the suggestion rendered use<'_>, which resolves to the first elided lifetime in the signature. with several of them it either captured the wrong one or stopped resolving and reported a missing lifetime specifier on top of the original error. when the hidden type captures more than one anonymous lifetime the suggestion now names them in the signature and lists those names in the bound. a signature with a single elided lifetime keeps the shorter use<'_> form. fixes rust-lang#132199
suggest_name_regions names several regions against one set of used names and adds the new generic parameters once, and suggest_name_region now delegates to it
e36e829 to
81b952e
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
sorry, was prepping for eurorust and then doing some travelling, reviews responsiveness should be back to my usual normal |
| emit_msg_span(err, prefix, description, span, suffix); | ||
| } | ||
|
|
||
| fn suggest_name_regions<'tcx>( |
There was a problem hiding this comment.
it's fine now, but for future contribs, please perform such movements in their own commit without also doing other changes in the same commit. This way it's easier to review as I don't also have to look out for behaviour changes in the code we're reusing
There was a problem hiding this comment.
sure ill keep that in mind and thanks for the review!
no problem and sry if the ping bothered you. hope you had fun in eurorust! |
…-use-bound, r=oli-obk suggest named lifetimes instead of `'_` in `use<...>` for E0700 when a signature has more than one elided lifetime, the suggested `use<'_>` captures only the first in a case like `fn f(_a: &u8, b: &T) -> impl Sized` it stops resolving entirely and adds `error[E0106]` on top of the original error all at `MachineApplicable`. when the hidden type captures more than one anonymous lifetime the suggestion now names them in the signature and lists those names in the bound which is the desired output from the issue. a signature with a single elided lifetime keeps the shorter `use<'_>`. this reuses the three-part shape `AddPreciseCapturingAndParams` already emits for argument-position `impl Trait` in the same function. note. the argument-position `impl Trait` path in `AddPreciseCapturingAndParams` has the same defect when the signature also has elided reference lifetimes: `fn f(_a: impl Sized, x: &u8, y: &u8) -> impl Sized` still suggests `use<'_, T>` which produces `E0106` plus the original `E0700`. it is `MaybeIncorrect` so rustfix does not apply it but the suggestion misleads. ill follow up on that. the new test is `//@ run-rustfix` with a `.fixed` file that compiles which also let `tests/ui/lifetimes/issue-105227.rs` drop its `FIXME(precise_capturing): Add rustfix here after dealing w/ elided lifetimes`. fixes rust-lang#132199 r? @oli-obk
Rollup of 9 pull requests Successful merges: - #164792 (rustc_codegen_cranelift subtree update) - #163799 (std: keep value of `local_pointer!` until `thread_cleanup` is run) - #164781 (Bump dist-x86_64-illumos to Ubuntu 22.04) - #160902 (borrowck dataflow: respect borrow shallowness when killing borrows that conflict with assignments) - #163684 (suggest named lifetimes instead of `'_` in `use<...>` for E0700) - #164167 (Account for `use foo as bar;` on resolution error suggestions) - #164438 (Make async drop shim proxy pinned) - #164528 (Complete the various renamings of terms belonging to feature `checked_type_aliases`) - #164796 (miri: fix ICE when caller signature is c-variadic but callee is not)
Rollup merge of #163684 - Albab-Hasan:name-anon-lifetimes-in-use-bound, r=oli-obk suggest named lifetimes instead of `'_` in `use<...>` for E0700 when a signature has more than one elided lifetime, the suggested `use<'_>` captures only the first in a case like `fn f(_a: &u8, b: &T) -> impl Sized` it stops resolving entirely and adds `error[E0106]` on top of the original error all at `MachineApplicable`. when the hidden type captures more than one anonymous lifetime the suggestion now names them in the signature and lists those names in the bound which is the desired output from the issue. a signature with a single elided lifetime keeps the shorter `use<'_>`. this reuses the three-part shape `AddPreciseCapturingAndParams` already emits for argument-position `impl Trait` in the same function. note. the argument-position `impl Trait` path in `AddPreciseCapturingAndParams` has the same defect when the signature also has elided reference lifetimes: `fn f(_a: impl Sized, x: &u8, y: &u8) -> impl Sized` still suggests `use<'_, T>` which produces `E0106` plus the original `E0700`. it is `MaybeIncorrect` so rustfix does not apply it but the suggestion misleads. ill follow up on that. the new test is `//@ run-rustfix` with a `.fixed` file that compiles which also let `tests/ui/lifetimes/issue-105227.rs` drop its `FIXME(precise_capturing): Add rustfix here after dealing w/ elided lifetimes`. fixes #132199 r? @oli-obk
when a signature has more than one elided lifetime, the suggested
use<'_>captures only the first in a case likefn f(_a: &u8, b: &T) -> impl Sizedit stops resolving entirely and addserror[E0106]on top of the original error all atMachineApplicable.when the hidden type captures more than one anonymous lifetime the suggestion now names them in the signature and lists those names in the bound which is the desired output from the issue. a signature with a single elided lifetime keeps the shorter
use<'_>. this reuses the three-part shapeAddPreciseCapturingAndParamsalready emits for argument-positionimpl Traitin the same function.note. the argument-position
impl Traitpath inAddPreciseCapturingAndParamshas the same defect when the signature also has elided reference lifetimes:fn f(_a: impl Sized, x: &u8, y: &u8) -> impl Sizedstill suggestsuse<'_, T>which producesE0106plus the originalE0700. it isMaybeIncorrectso rustfix does not apply it but the suggestion misleads. ill follow up on that.the new test is
//@ run-rustfixwith a.fixedfile that compiles which also lettests/ui/lifetimes/issue-105227.rsdrop itsFIXME(precise_capturing): Add rustfix here after dealing w/ elided lifetimes.fixes #132199
r? @oli-obk