rust/tests/ui/nll
bors fec98b3bbc Auto merge of #125468 - BoxyUwU:remove_defid_from_regionparam, r=compiler-errors
Remove `DefId` from `EarlyParamRegion`

Currently we represent usages of `Region` parameters via the `ReEarlyParam` or `ReLateParam` variants. The `ReEarlyParam` is effectively equivalent to `TyKind::Param` and `ConstKind::Param` (i.e. it stores a `Symbol` and a `u32` index) however it also stores a `DefId` for the definition of the lifetime parameter.

This was used in roughly two places:
- Borrowck diagnostics instead of threading the appropriate `body_id` down to relevant locations. Interestingly there were already some places that had to pass down a `DefId` manually.
- Some opaque type checking logic was using the `DefId` field to track captured lifetimes

I've split this PR up into a commit for generate rote changes to diagnostics code to pass around a `DefId` manually everywhere, and another commit for the opaque type related changes which likely require more careful review as they might change the semantics of lints/errors.

Instead of manually passing the `DefId` around everywhere I previously tried to bundle it in with `TypeErrCtxt` but ran into issues with some call sites of `infcx.err_ctxt` being unable to provide a `DefId`, particularly places involved with trait solving and normalization. It might be worth investigating adding some new wrapper type to pass this around everywhere but I think this might be acceptable for now.

This pr also has the effect of reducing the size of `EarlyParamRegion` from 16 bytes -> 8 bytes. I wouldn't expect this to have any direct performance improvement however, other variants of `RegionKind` over `8` bytes are all because they contain a `BoundRegionKind` which is, as far as I know, mostly there for diagnostics. If we're ever able to remove this it would shrink the `RegionKind` type from `24` bytes to `12` (and with clever bit packing we might be able to get it to `8` bytes). I am curious what the performance impact would be of removing interning of `Region`'s if we ever manage to shrink `RegionKind` that much.

Sidenote: by removing the `DefId` the `Debug` output for `Region` has gotten significantly nicer. As an example see this opaque type debug print before vs after this PR:
`Opaque(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::{opaque#0}), [DefId(0:9 ~ impl_trait_captures[aeb9]::foo::'a)_'a/#0, T, DefId(0:9 ~ impl_trait_captures[aeb9]::foo::'a)_'a/#0])`
`Opaque(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::{opaque#0}), ['a/#0, T, 'a/#0])`

r? `@compiler-errors` (I would like someone who understands the opaque type setup to atleast review the type system commit, but the rest is likely reviewable by anyone)
2024-05-27 06:36:57 +00:00
..
closure-requirements Modify find_expr from Span to better account for closures 2024-04-24 22:21:13 +00:00
member-constraints
polonius Modify find_expr from Span to better account for closures 2024-04-24 22:21:13 +00:00
relate_tys
ty-outlives Remove DefId from EarlyParamRegion (tedium/diagnostics) 2024-05-24 18:06:53 +01:00
user-annotations Modify find_expr from Span to better account for closures 2024-04-24 22:21:13 +00:00
assign-while-to-immutable.rs
borrow-use-issue-46875.rs
borrowck-thread-local-static-mut-borrow-outlives-fn.rs
borrowck-thread-local-static-mut-borrow-outlives-fn.stderr
borrowed-local-error.rs
borrowed-local-error.stderr
borrowed-match-issue-45045.rs
borrowed-match-issue-45045.stderr
borrowed-referent-issue-38899.rs
borrowed-referent-issue-38899.stderr
borrowed-temporary-error.rs
borrowed-temporary-error.stderr
borrowed-universal-error-2.rs
borrowed-universal-error-2.stderr
borrowed-universal-error.rs
borrowed-universal-error.stderr
cannot-move-block-spans.rs
cannot-move-block-spans.stderr More move error suggestions to clone 2024-04-11 16:41:41 +00:00
capture-mut-ref.fixed
capture-mut-ref.rs
capture-mut-ref.stderr
capture-ref-in-struct.rs
capture-ref-in-struct.stderr
check-normalized-sig-for-wf.rs
check-normalized-sig-for-wf.stderr
closure-access-spans.rs
closure-access-spans.stderr Fix accuracy of T: Clone check in suggestion 2024-04-11 16:41:41 +00:00
closure-borrow-spans.rs
closure-borrow-spans.stderr Modify find_expr from Span to better account for closures 2024-04-24 22:21:13 +00:00
closure-captures.rs
closure-captures.stderr
closure-malformed-projection-input-issue-102800.rs
closure-malformed-projection-input-issue-102800.stderr
closure-move-spans.fixed Better account for more cases involving closures 2024-04-12 04:46:31 +00:00
closure-move-spans.rs Better account for more cases involving closures 2024-04-12 04:46:31 +00:00
closure-move-spans.stderr Better account for more cases involving closures 2024-04-12 04:46:31 +00:00
closure-use-spans.rs
closure-use-spans.stderr
closures-in-loops.rs
closures-in-loops.stderr Better account for more cases involving closures 2024-04-12 04:46:31 +00:00
constant-thread-locals-issue-47053.rs
constant-thread-locals-issue-47053.stderr
constant.rs
continue-after-missing-main.rs
continue-after-missing-main.stderr
coroutine-distinct-lifetime.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
coroutine-upvar-mutability.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
coroutine-upvar-mutability.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
decl-macro-illegal-copy.rs
decl-macro-illegal-copy.stderr
do-not-ignore-lifetime-bounds-in-copy-proj.rs
do-not-ignore-lifetime-bounds-in-copy-proj.stderr
do-not-ignore-lifetime-bounds-in-copy.rs
do-not-ignore-lifetime-bounds-in-copy.stderr
dont-print-desugared.rs
dont-print-desugared.stderr
drop-may-dangle.rs
drop-no-may-dangle.rs
drop-no-may-dangle.stderr
empty-type-predicate-2.rs
empty-type-predicate.rs
enum-drop-access.rs
enum-drop-access.stderr
extra-unused-mut.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
get_default.polonius.stderr
get_default.rs
get_default.stderr
guarantor-issue-46974.rs
guarantor-issue-46974.stderr
ice-106874.rs address review feedback 2024-03-23 16:14:42 +01:00
ice-106874.stderr add test for #106874 ICE BoundUniversalRegionError 2024-03-23 12:50:21 +01:00
issue-16223.rs
issue-21114-ebfull.rs
issue-21114-kixunil.rs
issue-21232-partial-init-and-erroneous-use.rs
issue-21232-partial-init-and-erroneous-use.stderr
issue-21232-partial-init-and-use.rs
issue-21232-partial-init-and-use.stderr Mention when type parameter could be Clone 2024-04-24 22:21:15 +00:00
issue-22323-temp-destruction.rs
issue-24535-allow-mutable-borrow-in-match-guard.rs
issue-27282-move-match-input-into-guard.rs
issue-27282-move-match-input-into-guard.stderr Better account for more cases involving closures 2024-04-12 04:46:31 +00:00
issue-27282-move-ref-mut-into-guard.fixed Modify find_expr from Span to better account for closures 2024-04-24 22:21:13 +00:00
issue-27282-move-ref-mut-into-guard.rs Modify find_expr from Span to better account for closures 2024-04-24 22:21:13 +00:00
issue-27282-move-ref-mut-into-guard.stderr Modify find_expr from Span to better account for closures 2024-04-24 22:21:13 +00:00
issue-27282-mutate-before-diverging-arm-1.rs
issue-27282-mutate-before-diverging-arm-1.stderr
issue-27282-mutate-before-diverging-arm-2.rs
issue-27282-mutate-before-diverging-arm-2.stderr
issue-27282-mutate-before-diverging-arm-3.rs
issue-27282-mutate-before-diverging-arm-3.stderr
issue-27282-mutation-in-guard.rs
issue-27282-mutation-in-guard.stderr Modify find_expr from Span to better account for closures 2024-04-24 22:21:13 +00:00
issue-27282-reborrow-ref-mut-in-guard.rs
issue-27282-reborrow-ref-mut-in-guard.stderr
issue-27583.rs
issue-27868.rs
issue-27868.stderr
issue-30104.rs
issue-30438-a.rs
issue-30438-a.stderr
issue-30438-b.rs
issue-30438-b.stderr
issue-30438-c.rs
issue-30438-c.stderr
issue-31567.rs
issue-31567.stderr
issue-32382-index-assoc-type-with-lifetime.rs
issue-40510-1.rs Move tests 2024-04-07 17:38:07 -03:00
issue-40510-1.stderr Move tests 2024-04-07 17:38:07 -03:00
issue-40510-2.rs Move tests 2024-04-07 17:38:07 -03:00
issue-40510-3.rs Move tests 2024-04-07 17:38:07 -03:00
issue-40510-3.stderr Move tests 2024-04-07 17:38:07 -03:00
issue-40510-4.rs Move tests 2024-04-07 17:38:07 -03:00
issue-42574-diagnostic-in-nested-closure.rs
issue-42574-diagnostic-in-nested-closure.stderr Modify find_expr from Span to better account for closures 2024-04-24 22:21:13 +00:00
issue-43058.rs
issue-45157.rs
issue-45157.stderr
issue-45696-long-live-borrows-in-boxes.rs
issue-45696-no-variant-box-recur.rs
issue-45696-scribble-on-boxed-borrow.rs
issue-45696-scribble-on-boxed-borrow.stderr
issue-46023.rs
issue-46023.stderr
issue-46036.rs
issue-46036.stderr
issue-46589.rs
issue-46589.stderr
issue-47022.rs
issue-47153-generic-const.rs
issue-47388.rs
issue-47388.stderr
issue-47470.rs
issue-47470.stderr
issue-47589.rs
issue-48070.rs
issue-48179.rs
issue-48238.rs
issue-48238.stderr
issue-48623-closure.rs
issue-48623-coroutine.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-48623-coroutine.stderr Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-48697.rs
issue-48697.stderr
issue-48803.rs
issue-48803.stderr
issue-50343.rs
issue-50461-used-mut-from-moves.rs
issue-50716-1.rs
issue-50716.rs
issue-50716.stderr
issue-51191.rs
issue-51191.stderr
issue-51244.rs
issue-51244.stderr
issue-51268.rs
issue-51268.stderr
issue-51345-2.rs
issue-51351.rs
issue-51512.rs
issue-51512.stderr
issue-51770.rs
issue-52057.rs
issue-52059-report-when-borrow-and-drop-conflict.rs
issue-52059-report-when-borrow-and-drop-conflict.stderr Fix accuracy of T: Clone check in suggestion 2024-04-11 16:41:41 +00:00
issue-52078.rs
issue-52086.rs
issue-52086.stderr Suggest .clone() in some move errors 2024-04-11 16:41:41 +00:00
issue-52113.rs
issue-52113.stderr
issue-52213.rs
issue-52213.stderr
issue-52533-1.rs
issue-52533-1.stderr
issue-52534-1.rs
issue-52534-1.stderr
issue-52534-2.rs
issue-52534-2.stderr
issue-52534.rs
issue-52534.stderr
issue-52663-span-decl-captured-variable.rs
issue-52663-span-decl-captured-variable.stderr Suggest .clone() in some move errors 2024-04-11 16:41:41 +00:00
issue-52663-trait-object.rs
issue-52663-trait-object.stderr
issue-52669.rs
issue-52669.stderr
issue-52742.rs
issue-52742.stderr
issue-52992.rs
issue-53040.rs
issue-53040.stderr
issue-53119.rs
issue-53123-raw-pointer-cast.rs
issue-53570.rs
issue-53773.rs
issue-53773.stderr
issue-53807.rs
issue-53807.stderr
issue-54189.rs Bless test fallout (duplicate diagnostics) 2024-03-20 13:00:34 -04:00
issue-54189.stderr Bless test fallout (duplicate diagnostics) 2024-03-20 13:00:34 -04:00
issue-54302-cases.rs
issue-54302-cases.stderr
issue-54302.rs
issue-54302.stderr
issue-54382-use-span-of-tail-of-block.rs
issue-54382-use-span-of-tail-of-block.stderr
issue-54556-niconii.rs
issue-54556-niconii.stderr
issue-54556-stephaneyfx.rs
issue-54556-stephaneyfx.stderr
issue-54556-temps-in-tail-diagnostic.rs
issue-54556-temps-in-tail-diagnostic.stderr
issue-54556-used-vs-unused-tails.rs
issue-54556-used-vs-unused-tails.stderr
issue-54556-wrap-it-up.rs
issue-54556-wrap-it-up.stderr
issue-54779-anon-static-lifetime.rs
issue-54779-anon-static-lifetime.stderr
issue-54943-3.rs
issue-54943.rs
issue-54943.stderr
issue-55288.rs
issue-55344.rs
issue-55394.rs
issue-55394.stderr
issue-55401.rs
issue-55401.stderr
issue-55511.rs remove IndirectStructuralMatch lint, emit the usual hard error instead 2024-05-03 15:56:59 +02:00
issue-55511.stderr remove IndirectStructuralMatch lint, emit the usual hard error instead 2024-05-03 15:56:59 +02:00
issue-55651.rs
issue-55825-const-fn.rs
issue-55850.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-55850.stderr
issue-57100.rs
issue-57100.stderr
issue-57265-return-type-wf-check.rs
issue-57265-return-type-wf-check.stderr
issue-57280-1-flipped.rs
issue-57280-1-flipped.stderr
issue-57280-1.rs
issue-57280.rs
issue-57362-1.rs Move some tests 2024-04-21 15:43:43 -03:00
issue-57362-1.stderr Move some tests 2024-04-21 15:43:43 -03:00
issue-57362-2.rs Normalize xform_ret_ty after constrained 2024-04-21 20:10:12 -04:00
issue-57362-2.stderr Normalize xform_ret_ty after constrained 2024-04-21 20:10:12 -04:00
issue-57642-higher-ranked-subtype.rs Use fulfillment, not evaluate, during method probe 2024-04-21 20:10:12 -04:00
issue-57642-higher-ranked-subtype.stderr Use fulfillment, not evaluate, during method probe 2024-04-21 20:10:12 -04:00
issue-57843.rs
issue-57843.stderr
issue-57960.rs
issue-57989.rs
issue-57989.stderr
issue-58053.rs
issue-58053.stderr
issue-58299.rs
issue-58299.stderr
issue-61311-normalize.rs
issue-61320-normalize.rs
issue-61424.fixed
issue-61424.rs
issue-61424.stderr
issue-62007-assign-const-index.rs
issue-62007-assign-const-index.stderr
issue-62007-assign-differing-fields.rs
issue-62007-assign-differing-fields.stderr
issue-63154-normalize.rs
issue-67007-escaping-data.rs
issue-67007-escaping-data.stderr
issue-68550.rs
issue-68550.stderr
issue-69114-static-mut-ty.rs
issue-69114-static-mut-ty.stderr
issue-69114-static-ty.rs
issue-69114-static-ty.stderr
issue-73159-rpit-static.rs
issue-73159-rpit-static.stderr
issue-75777.rs
issue-75777.stderr
issue-78561.rs
issue-95272.rs
issue-95272.stderr
issue-97997.rs
issue-97997.stderr
issue-98170.rs
issue-98170.stderr
issue-98589-closures-relate-named-regions.rs
issue-98589-closures-relate-named-regions.stderr
issue-98693.rs
issue-98693.stderr
issue-112604-closure-output-normalize.rs
lint-no-err.rs
loan_ends_mid_block_pair.rs
loan_ends_mid_block_pair.stderr
loan_ends_mid_block_vec.rs
loan_ends_mid_block_vec.stderr
local-outlives-static-via-hrtb.rs
local-outlives-static-via-hrtb.stderr
lub-if.rs
lub-if.stderr
lub-match.rs
lub-match.stderr
match-cfg-fake-edges2.rs Add tests 2024-04-03 21:02:47 +02:00
match-cfg-fake-edges2.stderr Add tests 2024-04-03 21:02:47 +02:00
match-cfg-fake-edges.rs Add if let tests 2024-04-03 23:16:27 +02:00
match-cfg-fake-edges.stderr Handle more cases of value suggestions 2024-04-10 20:36:14 +00:00
match-guards-always-borrow.fixed Modify find_expr from Span to better account for closures 2024-04-24 22:21:13 +00:00
match-guards-always-borrow.rs Modify find_expr from Span to better account for closures 2024-04-24 22:21:13 +00:00
match-guards-always-borrow.stderr Modify find_expr from Span to better account for closures 2024-04-24 22:21:13 +00:00
match-guards-partially-borrow.rs
match-guards-partially-borrow.stderr
match-on-borrowed.rs
match-on-borrowed.stderr Use /* value */ as a placeholder 2024-04-15 21:36:52 -04:00
maybe-initialized-drop-implicit-fragment-drop.rs
maybe-initialized-drop-implicit-fragment-drop.stderr
maybe-initialized-drop-uninitialized.rs
maybe-initialized-drop-with-fragment.rs
maybe-initialized-drop-with-fragment.stderr
maybe-initialized-drop-with-uninitialized-fragments.rs
maybe-initialized-drop-with-uninitialized-fragments.stderr
maybe-initialized-drop.rs
maybe-initialized-drop.stderr
mir_check_cast_closure.rs
mir_check_cast_closure.stderr
mir_check_cast_reify.rs
mir_check_cast_reify.stderr
mir_check_cast_unsafe_fn.rs
mir_check_cast_unsafe_fn.stderr
mir_check_cast_unsize.rs
mir_check_cast_unsize.stderr
missing-universe-cause-issue-114907.rs eagerly instantiate binders to avoid relying on sub 2024-03-14 17:19:40 +01:00
missing-universe-cause-issue-114907.stderr eagerly instantiate binders to avoid relying on sub 2024-03-14 17:19:40 +01:00
move-errors.rs
move-errors.stderr Mention when type parameter could be Clone 2024-04-24 22:21:15 +00:00
move-subpaths-moves-root.rs
move-subpaths-moves-root.stderr
mutating_references.rs
normalization-bounds-error.rs
normalization-bounds-error.stderr
normalization-bounds.rs
outlives-suggestion-more.rs
outlives-suggestion-more.stderr
outlives-suggestion-simple.polonius.stderr
outlives-suggestion-simple.rs
outlives-suggestion-simple.stderr
process_or_insert_default.rs
projection-return.rs
promotable-mutable-zst-doesnt-conflict.rs
promoted-bounds.rs
promoted-bounds.stderr
promoted-closure-pair.rs
promoted-closure-pair.stderr
promoted-liveness.rs
rc-loop.rs
ref-suggestion.rs
ref-suggestion.stderr
reference-carried-through-struct-field.rs
reference-carried-through-struct-field.stderr
region-ends-after-if-condition.rs
region-ends-after-if-condition.stderr
return_from_loop.rs
return_from_loop.stderr
return-ref-mut-issue-46557.rs
return-ref-mut-issue-46557.stderr
self-assign-ref-mut.rs
snocat-regression.rs
snocat-regression.stderr
trait-associated-constant.rs
trait-associated-constant.stderr
type-alias-free-regions.rs
type-alias-free-regions.stderr
type-check-pointer-coercions.rs
type-check-pointer-coercions.stderr
type-check-pointer-comparisons.rs
type-check-pointer-comparisons.stderr
type-test-universe.rs
type-test-universe.stderr
unexpected-inference-var-ice-116599.rs add test for #116599 2024-03-24 10:05:27 +01:00
unused-mut-issue-50343.fixed
unused-mut-issue-50343.rs
unused-mut-issue-50343.stderr
vimwiki-core-regression.rs
where_clauses_in_functions.rs
where_clauses_in_functions.stderr
where_clauses_in_structs.rs
where_clauses_in_structs.stderr