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

Comments

@pnkfelix
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

This comment has been minimized.

Show comment
Hide comment
@pnkfelix

pnkfelix Sep 26, 2017

Member

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
Member

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
@KiChjang

This comment has been minimized.

Show comment
Hide comment
@KiChjang

KiChjang Sep 28, 2017

Member

I'm interested in tackling this.

Member

KiChjang commented Sep 28, 2017

I'm interested in tackling this.

@arielb1

This comment has been minimized.

Show comment
Hide comment
@arielb1

arielb1 Oct 2, 2017

Contributor

@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.

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

This comment has been minimized.

Show comment
Hide comment
@KiChjang

KiChjang Oct 9, 2017

Member

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

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 Nov 25, 2017

MIR borrowck: implement union-and-array-compatible semantics
Fixes rust-lang#44831.
Fixes rust-lang#44834.
Fixes rust-lang#45537.
Fixes rust-lang#45696 (by implementing DerefPure, which is what we want going
forward).

arielb1 added a commit to arielb1/rust that referenced this issue Nov 27, 2017

MIR borrowck: implement union-and-array-compatible semantics
Fixes rust-lang#44831.
Fixes rust-lang#44834.
Fixes rust-lang#45537.
Fixes rust-lang#45696 (by implementing DerefPure, which is what we want going
forward).

arielb1 added a commit to arielb1/rust that referenced this issue Nov 30, 2017

MIR borrowck: implement union-and-array-compatible semantics
Fixes rust-lang#44831.
Fixes rust-lang#44834.
Fixes rust-lang#45537.
Fixes rust-lang#45696 (by implementing DerefPure, which is what we want going
forward).

arielb1 added a commit to arielb1/rust that referenced this issue Nov 30, 2017

MIR borrowck: implement union-and-array-compatible semantics
Fixes rust-lang#44831.
Fixes rust-lang#44834.
Fixes rust-lang#45537.
Fixes rust-lang#45696 (by implementing DerefPure, which is what we want going
forward).

arielb1 added a commit to arielb1/rust that referenced this issue Dec 3, 2017

MIR borrowck: implement union-and-array-compatible semantics
Fixes rust-lang#44831.
Fixes rust-lang#44834.
Fixes rust-lang#45537.
Fixes rust-lang#45696 (by implementing DerefPure, which is what we want going
forward).

arielb1 added a commit to arielb1/rust that referenced this issue Dec 3, 2017

MIR borrowck: implement union-and-array-compatible semantics
Fixes rust-lang#44831.
Fixes rust-lang#44834.
Fixes rust-lang#45537.
Fixes rust-lang#45696 (by implementing DerefPure, which is what we want going
forward).

arielb1 added a commit to arielb1/rust that referenced this issue Dec 5, 2017

MIR borrowck: implement union-and-array-compatible semantics
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).

arielb1 added a commit to arielb1/rust that referenced this issue Dec 6, 2017

MIR borrowck: implement union-and-array-compatible semantics
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

Auto merge of #46268 - arielb1:union-borrow, r=nikomatsakis
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

@bors bors closed this in #46268 Dec 6, 2017

@Phlosioneer

This comment has been minimized.

Show comment
Hide comment
@Phlosioneer

Phlosioneer Mar 25, 2018

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?

Contributor

Phlosioneer commented Mar 25, 2018

@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

This comment has been minimized.

Show comment
Hide comment
@arielb1

arielb1 Mar 31, 2018

Contributor

@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 :-).

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

Unignore borrowck test
Unignores a test that has been fixed.

See rust-lang#44831
@Phlosioneer

This comment has been minimized.

Show comment
Hide comment
@Phlosioneer

Phlosioneer Apr 1, 2018

Contributor

Submitted a PR. Thanks!

Contributor

Phlosioneer commented Apr 1, 2018

Submitted a PR. Thanks!

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

Auto merge of #49547 - Phlosioneer:44831-borrowck-remove-ignore, r=ar…
…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

Rollup merge of rust-lang#49547 - Phlosioneer:44831-borrowck-remove-i…
…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