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

MIR-borrowck: Add support for union types #44831

Closed
pnkfelix opened this issue Sep 25, 2017 · 7 comments
Closed

MIR-borrowck: Add support for union types #44831

pnkfelix opened this issue Sep 25, 2017 · 7 comments
Assignees
Labels
A-borrow-checker Area: The borrow checker C-enhancement Category: An issue proposing an enhancement or a PR with one. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Milestone

Comments

@pnkfelix
Copy link
Member

pnkfelix commented Sep 25, 2017

The MIR-borrowck prototype code left out support for union. Luckily we have test cases that illustrate the omission.

  • You can see list of such tests in the discrepancy spreadsheet.
  • But for ease of reference, I am also transcribing that list into the first comment on this issue.

So the next step is to incorporate support for union into librustc_mir/borrow_check.rs.

@pnkfelix pnkfelix added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-compiler-nll E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Sep 26, 2017
@pnkfelix
Copy link
Member Author

pnkfelix commented Sep 26, 2017

Transcription of relevant tests according to the discrepancy spreadsheet. (caveat: data is based on out-of-date pnkfelix/mir-borrowck4 branch)

tests failing because union support is missing from MIR-borrowck ...
borrowck-union-borrow-nested.rs
borrowck-union-borrow.rs
borrowck-union-uninitialized.rs

@TimNN TimNN added A-borrow-checker Area: The borrow checker C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Sep 27, 2017
@KiChjang
Copy link
Member

I'm interested in tackling this.

@arielb1
Copy link
Contributor

arielb1 commented Oct 2, 2017

@KiChjang

So I think a useful first step would be to integrate the spec for borrowing unions here:
https://github.com/rust-lang/rfcs/blob/master/text/1444-union.md#borrowing-union-fields

into the main borrowck spec (yes I know it's called "nll", but it also applies to MIR borrowck) - preferably as a PR against rust-lang/rfcs:
https://github.com/rust-lang/rfcs/blob/master/text/2094-nll.md#borrow-checker-phase-2-reporting-errors

From that, we should be able to see what changes need to be done to the borrow-checker implementation and do them.

@KiChjang
Copy link
Member

KiChjang commented Oct 9, 2017

PR to make changes to the RFC: rust-lang/rfcs#2174

@arielb1 arielb1 added this to the NLL prototype milestone Nov 15, 2017
arielb1 added a commit to arielb1/rust that referenced this issue Dec 6, 2017
Fixes rust-lang#44831.
Fixes rust-lang#44834.
Fixes rust-lang#45537.
Fixes rust-lang#45696 (by implementing DerefPure semantics, which is what we want
going forward).
bors added a commit that referenced this issue Dec 6, 2017
MIR borrowck: implement union-and-array-compatible semantics

Fixes #44831.
Fixes #44834.
Fixes #45537.
Fixes #45696 (by implementing DerefPure semantics, which is what we want going forward).

r? @nikomatsakis
@Phlosioneer
Copy link
Contributor

@arielb1 You left a note when ignoring this test:

// ignore-test will be fixed later
// revisions: ast mir
//[mir]compile-flags: -Z borrowck=mir
#![feature(thread_local)]
#[thread_local]
static FOO: u8 = 3;
fn assert_static(_t: &'static u8) {}
fn main() {
assert_static(&FOO); //[ast]~ ERROR [E0597]
//[mir]~^ ERROR [E0597]
}

When / under what conditions will this be fixed? Can we make an issue to track it or a more descriptive comment, so future issue triage knows what's going on?

@arielb1
Copy link
Contributor

arielb1 commented Mar 31, 2018

@Phlosioneer

The bug that forced the test to be ignored had been fixed, but I forgot to un-ignore the test. Feel free to un-ignore it yourself :-).

Phlosioneer added a commit to Phlosioneer/rust that referenced this issue Apr 1, 2018
Unignores a test that has been fixed.

See rust-lang#44831
@Phlosioneer
Copy link
Contributor

Phlosioneer commented Apr 1, 2018

Submitted a PR. Thanks!

bors added a commit that referenced this issue Apr 1, 2018
…ielb1

Unignore borrowck test

Unignores a test that has been fixed.

See #44831
kennytm added a commit to kennytm/rust that referenced this issue Apr 4, 2018
…gnore, r=arielb1

Unignore borrowck test

Unignores a test that has been fixed.

See rust-lang#44831
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-borrow-checker Area: The borrow checker C-enhancement Category: An issue proposing an enhancement or a PR with one. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants