Repository navigation
reject Reborrow impls on types with &'static mut fields - #165006
paradoxicalguy wants to merge 1 commit into
Conversation
|
r? @fee1-dead rustbot has assigned @fee1-dead. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
|
oops |
566ba0a to
48aa1c8
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
What about: struct Thing<'a: 'static> {
field: &'a mut u8,
} |
48aa1c8 to
a04e708
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. |
|
the check now looks at the declared field type rather than the substituted one, so |
|
It gives a borrowcheck error when you actually try to use the |
|
:O, yes pushed: the impl is now rejected for |
a04e708 to
4f03448
Compare
|
In general, I don't think we should keep adding ad-hoc checks here without a solid plan for the end-state. This is an unstable feature, it's fine if there are rough edges. |
|
yeah i think i went nuts; been extending the check around individual cases without establishing the general rule first. +would you prefer keeping this pr scoped to the original literal i'd rather get the invariant right than keep extending an incomplete region-bound scan |
4f03448 to
25f3d21
Compare
25f3d21 to
80e4c80
Compare
|
pushed a simpler version of the fix. it now only checks for literal i also tested the all 125 reborrow UI tests pass, and tidy is clean. keeping this scoped to the original ICE for now rather than trying to handle every lifetime bound here. |
|
cc @fee1-dead |
|
☔ The latest upstream changes (presumably #165579) made this pull request unmergeable. Please resolve the merge conflicts by rebasing. |
fixes #164933
the
Reborrowimpl check accepted every&mutfield, so a type with a&'static mut Tfield passed coherence and then hit abug!in borrowck. this makes&'static mutfall through to theCopycheck, so the impl is rejected with a normal error instead of an ice.adds a ui test using the repro from the issue.
edit:
also updates
invalid-coerce-shared-static-mut-field: itsReborrowimpl is now rejected at the impl, so the test gains an E0277.