Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Borrow checker (move analysis) #2810

Merged
merged 5 commits into from
Oct 19, 2018

Conversation

artemmukhin
Copy link
Member

@artemmukhin artemmukhin commented Aug 30, 2018

  • Introduce DataFlowContext providing GEN and KILL sets and propagation;
  • Introduce initial part of borrow checker providing move analysis;
  • Add Use of moved value and Cannot move error messages to RsBorrowCheckerInspection;
  • Add DeriveCopyFix for such errors.

derivecopyfix2

@artemmukhin artemmukhin force-pushed the borrow-checker-move branch 6 times, most recently from 1725dd3 to 5534ade Compare September 3, 2018 14:17
@artemmukhin artemmukhin force-pushed the borrow-checker-move branch 7 times, most recently from b9edd14 to 1474182 Compare September 6, 2018 08:37
@artemmukhin artemmukhin force-pushed the borrow-checker-move branch 2 times, most recently from 638d722 to 61c13f4 Compare September 20, 2018 14:03
@mchernyavsky mchernyavsky assigned vlad20012 and unassigned vlad20012 Oct 8, 2018
src/main/kotlin/org/rust/lang/core/types/Extensions.kt Outdated Show resolved Hide resolved
src/main/kotlin/org/rust/lang/core/types/Extensions.kt Outdated Show resolved Hide resolved
src/main/kotlin/org/rust/lang/core/types/Extensions.kt Outdated Show resolved Hide resolved
val mutCat = lpKind.mutCategory

// Moving/assigning one union field automatically moves/assigns all its fields
union.namedFields
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fragment isn't covered by tests

}

pathAssignments.forEach { assignment ->
killMoves(assignment.path, assignment.element, Execution, dfcxMoves)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fragment isn't covered by tests

fields.mapNotNull { it.expr }.forEach { consumeExpr(it) }
if (withExpr == null) return

val withCmt = mc.processExpr(withExpr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fragment isn't covered by tests

val lpElement = extend.lpElement

if (lpElement is Interior.Field) {
if (baseLoanPath.ty.isAdtWithDestructor) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fragment isn't covered by tests

is Interior.Index -> cmt

is Downcast -> {
val base = category.cmt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fragment isn't covered by tests

@vlad20012
Copy link
Member

And maybe we can write more tests? And if so, we can move these tests to a separate file

@artemmukhin artemmukhin force-pushed the borrow-checker-move branch 2 times, most recently from 220a00d to b7006be Compare October 16, 2018 11:54
@artemmukhin artemmukhin changed the title WIP: Borrow checker (move analysis) Borrow checker (move analysis) Oct 16, 2018
@artemmukhin artemmukhin force-pushed the borrow-checker-move branch 4 times, most recently from fee8a2c to ed5611a Compare October 16, 2018 14:20
@artemmukhin artemmukhin force-pushed the borrow-checker-move branch 5 times, most recently from fdc117e to d0942fc Compare October 18, 2018 11:13
@artemmukhin artemmukhin force-pushed the borrow-checker-move branch 8 times, most recently from de12ed7 to a40061e Compare October 18, 2018 15:28
@vlad20012
Copy link
Member

I think we can merge it. Objections? No? Ok, let's go!
bors r+

@vlad20012
Copy link
Member

🤔 Looks like bors is crashed
bors r-

@artemmukhin
Copy link
Member Author

bors r-

@Undin
Copy link
Member

Undin commented Oct 19, 2018

Let's try again
bors r=vlad20012

bors bot added a commit that referenced this pull request Oct 19, 2018
2810: Borrow checker (move analysis) r=vlad20012 a=ortem

- Introduce `DataFlowContext` providing `GEN` and `KILL` sets and propagation;
- Introduce initial part of borrow checker providing move analysis;
- Add `Use of moved value` and `Cannot move` error messages to `RsBorrowCheckerInspection`;
- Add `DeriveCopyFix` for such errors.

![derivecopyfix2](https://user-images.githubusercontent.com/4854600/44843336-bf33bc00-ac50-11e8-9a5a-fac2193113f6.gif)


Co-authored-by: ortem <ortem00@gmail.com>
@bors
Copy link
Contributor

bors bot commented Oct 19, 2018

@bors bors bot merged commit cda38a2 into intellij-rust:master Oct 19, 2018
@farodin91 farodin91 mentioned this pull request Sep 4, 2020
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants