Skip to content

Handle const-checks for &mut outside of HasMutInterior#66654

Merged
bors merged 12 commits intorust-lang:masterfrom
ecstatic-morse:check-consts-ref
Dec 2, 2019
Merged

Handle const-checks for &mut outside of HasMutInterior#66654
bors merged 12 commits intorust-lang:masterfrom
ecstatic-morse:check-consts-ref

Conversation

@ecstatic-morse
Copy link
Copy Markdown
Contributor

@ecstatic-morse ecstatic-morse commented Nov 23, 2019

Addresses this comment.

Const-checking relied on HasMutInterior to forbid &mut in a const context. This was strange because all we needed to do was look for an Rvalue::Ref with a certain BorrowKind, whereas the Qualif traits are specifically meant to get the qualifs for a value. This PR removes that logic from HasMutInterior and moves it into check_consts::Validator.

As a result, we can now properly handle qualifications for statics, which had to be ignored previously since you can e.g. borrow a static Cell from another static. We also remove the derived_from_illegal_borrow logic, since it is no longer necessary; we give good errors for subsequent reborrows/borrows of illegal borrows.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-const_mut_refs `#![feature(const_mut_refs)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants