Skip to content

NLL Diagnostic Review 3: Missing errors for borrows of union fields #55675

@davidtwco

Description

@davidtwco
Member

@pnkfelix's review comments:

ui/union/union-borrow-move-parent-sibling.nll.stderr has 3 errors when AST-borrowck reports 6 errors. Double-check.

Activity

self-assigned this
on Nov 4, 2018
added
A-NLLArea: Non-lexical lifetimes (NLL)
NLL-diagnosticsWorking towards the "diagnostic parity" goal
NLL-soundWorking towards the "invalid code does not compile" goal
on Nov 4, 2018
davidtwco

davidtwco commented on Nov 4, 2018

@davidtwco
MemberAuthor

I've looked into this some - NLL misses three errors, all of the form cannot borrow `u.y` as immutable because `u.x` is also borrowed as mutable.

In each of the three cases, there is a mutable borrow of some field of the union and then a shared borrow of some other field immediately following. The issue seems to be that the mutable borrow is killed straight away as it isn't used later - therefore not causing a conflict with the shared borrow.

I'm inclined to think that this is fine - and that NLL is correct in having less errors here. However, we might want to update the test to use the first mutable borrow for each case in order to make the error happen and demonstrate the diagnostic - if this is the case, I've got a branch here that we can open a PR for that will update the test.

cc @nikomatsakis @pnkfelix

pnkfelix

pnkfelix commented on Nov 5, 2018

@pnkfelix
Member

I'm inclined to agree that this is an instance where the test was not robust and that we need to add uses of those first mutable borrows.

davidtwco

davidtwco commented on Nov 5, 2018

@davidtwco
MemberAuthor

I've submitted a PR (#55696) that makes the test more robust.

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

Metadata

Metadata

Assignees

Labels

A-NLLArea: Non-lexical lifetimes (NLL)NLL-diagnosticsWorking towards the "diagnostic parity" goalNLL-soundWorking towards the "invalid code does not compile" goal

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @pnkfelix@davidtwco

    Issue actions

      NLL Diagnostic Review 3: Missing errors for borrows of union fields · Issue #55675 · rust-lang/rust