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

Remove the old AST-based backend from rustc_trans. #35764

Merged
merged 4 commits into from Aug 25, 2016
Merged

Conversation

@eddyb
Copy link
Member

eddyb commented Aug 17, 2016

Starting with Rust 1.13, --disable-orbit , -Z orbit=off and #[rustc_no_mir] have been removed.
Only the new MIR backend is left in the compiler, and only early const_eval uses ASTs from other crates.

Filling drop (previously "zeroing drop"), #[unsafe_no_drop_flag] and associated unstable APIs are gone.
Implementing Drop doesn't add a flag anymore to the type, all of the dynamic drop is function local.
This is a [breaking-change], please use Option::None and/or mem::forget if you are unsure about your ability to prevent/control the drop of a value. In the future, union will be usable in some such cases.

NOTE: DO NOT MERGE before we get the new beta as the stage0, there's some cruft to remove.

All of this will massively simplify any efforts to implement (and as such it blocks) features such as unions, safe use of #[packed] or new type layout optimizations, not to mention many other experiments.

@rust-highfive
Copy link
Collaborator

rust-highfive commented Aug 17, 2016

r? @nrc

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton
Copy link
Member

alexcrichton commented Aug 17, 2016

Dat diff.

@retep998
Copy link
Member

retep998 commented Aug 17, 2016

Praise be, the world will no longer be blocked on MIR, and development of new features can finally take place!

@nrc
Copy link
Member

nrc commented Aug 17, 2016

Much as I'd love to r+ this, r? @nikomatsakis

fn dtor_to_init_u8(dtor: bool) -> u8 {
if dtor { 1 } else { 0 }
}

pub trait GetDtorType<'tcx> { fn dtor_type(self) -> Ty<'tcx>; }

This comment has been minimized.

Copy link
@jld

jld Aug 18, 2016

Contributor

It looks like this trait can also be deleted?

@bors
Copy link
Contributor

bors commented Aug 18, 2016

The latest upstream changes (presumably #35684) made this pull request unmergeable. Please resolve the merge conflicts.

@eddyb
Copy link
Member Author

eddyb commented Aug 18, 2016

FWIW, this appears to fix #35408 locally, possibly due to P::map not using memset with 0x1d to prevent drop on panic, allowing LLVM to optimize the moves in the AST folder better.


// see comments above for why this check is here
if thin as usize == mem::POST_DROP_USIZE {
return;
#[cfg(stage0)] {

This comment has been minimized.

Copy link
@nikomatsakis

nikomatsakis Aug 19, 2016

Contributor

this is nifty

/// Rust moves to non-zeroing dynamic drop (and thus removes the
/// embedded drop flags that are being established by this
/// intrinsic).
pub fn init_dropped<T>() -> T;

This comment has been minimized.

Copy link
@nikomatsakis

nikomatsakis Aug 19, 2016

Contributor

buh-bye 👋

#[allow(missing_docs)]
pub const POST_DROP_USIZE: usize = POST_DROP_U16 as usize;
#[cfg(target_pointer_width = "32")]
// TODO HACK FIXME(eddyb) !!! Remove POST_DROP_* after beta branches off.

This comment has been minimized.

Copy link
@nikomatsakis

nikomatsakis Aug 19, 2016

Contributor

I'm confused --- what makes this a hack?

This comment has been minimized.

Copy link
@eddyb

eddyb Aug 19, 2016

Author Member

That's just an anti-tidy marker so we remove that stuff before merging. Which is why we need to update the stage0 first.

value: Int(I8),
non_zero: false
})).into_iter(), ty)?;
}

This comment has been minimized.

Copy link
@nikomatsakis

nikomatsakis Aug 19, 2016

Contributor

🐊 tears

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Aug 23, 2016

@bors r+

@bors
Copy link
Contributor

bors commented Aug 23, 2016

📌 Commit 9a9cd63 has been approved by nikomatsakis

eddyb added a commit to eddyb/rust that referenced this pull request Aug 23, 2016
Remove the old AST-based backend from rustc_trans.

Starting with Rust 1.13, `--disable-orbit` , `-Z orbit=off` and `#[rustc_no_mir]` have been removed.
Only the new MIR backend is left in the compiler, and only early const_eval uses ASTs from other crates.

Filling drop (previously "zeroing drop"), `#[unsafe_no_drop_flag]` and associated unstable APIs are gone.
Implementing `Drop` doesn't add a flag anymore to the type, all of the dynamic drop is function local.
This is a [breaking-change], please use `Option::None` and/or `mem::forget` if you are unsure about your ability to prevent/control the drop of a value. In the future, `union` will be usable in some such cases.

**NOTE**: DO NOT MERGE before we get the new beta as the stage0, there's some cruft to remove.

All of this will massively simplify any efforts to implement (and as such it blocks) features such as `union`s, safe use of `#[packed]` or new type layout optimizations, not to mention many other experiments.
@bors
Copy link
Contributor

bors commented Aug 24, 2016

💔 Test failed - auto-mac-cross-ios-opt

@eddyb
Copy link
Member Author

eddyb commented Aug 24, 2016

@bors retry

@bors
Copy link
Contributor

bors commented Aug 24, 2016

Testing commit 25cf800 with merge e9bc1ba...

bors added a commit that referenced this pull request Aug 24, 2016
Remove the old AST-based backend from rustc_trans.

Starting with Rust 1.13, `--disable-orbit` , `-Z orbit=off` and `#[rustc_no_mir]` have been removed.
Only the new MIR backend is left in the compiler, and only early const_eval uses ASTs from other crates.

Filling drop (previously "zeroing drop"), `#[unsafe_no_drop_flag]` and associated unstable APIs are gone.
Implementing `Drop` doesn't add a flag anymore to the type, all of the dynamic drop is function local.
This is a [breaking-change], please use `Option::None` and/or `mem::forget` if you are unsure about your ability to prevent/control the drop of a value. In the future, `union` will be usable in some such cases.

**NOTE**: DO NOT MERGE before we get the new beta as the stage0, there's some cruft to remove.

All of this will massively simplify any efforts to implement (and as such it blocks) features such as `union`s, safe use of `#[packed]` or new type layout optimizations, not to mention many other experiments.
@bors bors merged commit 25cf800 into rust-lang:master Aug 25, 2016
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@eddyb eddyb deleted the eddyb:byegone branch Aug 25, 2016
jseyfried added a commit to jseyfried/rust that referenced this pull request Aug 28, 2016
Implement untagged unions (RFC 1444)

cc rust-lang#32836

Notes:
- The RFC doesn't talk about `#[packed]` unions, this implementation supports them, packing changes union's alignment to 1 and removes trailing padding.
- The RFC doesn't talk about dynamically sized unions, this implementation doesn't support them and rejects them during wf-checking (similarly, dynamically sized enums are not supported as well).
- The lint for drop fields in unions can't work precisely before monomorphization, so it works pessimistically - non-`Copy` generic fields are reported, types not implementing `Drop` directly, but having non-trivial drop code are reported.

    ```
    struct S(String); // Doesn't implement `Drop`
    union U<T> {
        a: S, // Reported
        b: T, // Reported
    }
    ```

- rust-lang#35764 was indeed helpful and landed timely, I didn't have to implement internal drop flags for unions.
- Unions are not permitted in constant patterns, because matching on union fields is unsafe, I didn't want unsafety checker to dig into all constants to uncover this possible unsafety.
- The RFC doesn't talk about `#[derive]`, generally trait impls cannot be derived for unions, but some of them can. I implemented only `#[derive(Copy)]` so far. In theory shallow `#[derive(Clone)]` can be derived as well if all union fields are `Copy`, I left it for later though, it requires changing how `Clone` impls are generated.
- Moving union fields is implemented as per rust-lang#32836 (comment).
- Testing strategy: union specific behavior is tested, sometimes very basically (e.g. debuginfo), behavior common for all ADTs (e.g. something like coherence
checks) is not generally tested.
bors added a commit that referenced this pull request Sep 2, 2016
Implement untagged unions (RFC 1444)

cc #32836

Notes:
- The RFC doesn't talk about `#[packed]` unions, this implementation supports them, packing changes union's alignment to 1 and removes trailing padding.
- The RFC doesn't talk about dynamically sized unions, this implementation doesn't support them and rejects them during wf-checking (similarly, dynamically sized enums are not supported as well).
- The lint for drop fields in unions can't work precisely before monomorphization, so it works pessimistically - non-`Copy` generic fields are reported, types not implementing `Drop` directly, but having non-trivial drop code are reported.

    ```
    struct S(String); // Doesn't implement `Drop`
    union U<T> {
        a: S, // Reported
        b: T, // Reported
    }
    ```

- #35764 was indeed helpful and landed timely, I didn't have to implement internal drop flags for unions.
- Unions are not permitted in constant patterns, because matching on union fields is unsafe, I didn't want unsafety checker to dig into all constants to uncover this possible unsafety.
- The RFC doesn't talk about `#[derive]`, generally trait impls cannot be derived for unions, but some of them can. I implemented only `#[derive(Copy)]` so far. In theory shallow `#[derive(Clone)]` can be derived as well if all union fields are `Copy`, I left it for later though, it requires changing how `Clone` impls are generated.
- Moving union fields is implemented as per #32836 (comment).
- Testing strategy: union specific behavior is tested, sometimes very basically (e.g. debuginfo), behavior common for all ADTs (e.g. something like coherence
checks) is not generally tested.

r? @eddyb
bors added a commit that referenced this pull request Sep 2, 2016
Implement untagged unions (RFC 1444)

cc #32836

Notes:
- The RFC doesn't talk about `#[packed]` unions, this implementation supports them, packing changes union's alignment to 1 and removes trailing padding.
- The RFC doesn't talk about dynamically sized unions, this implementation doesn't support them and rejects them during wf-checking (similarly, dynamically sized enums are not supported as well).
- The lint for drop fields in unions can't work precisely before monomorphization, so it works pessimistically - non-`Copy` generic fields are reported, types not implementing `Drop` directly, but having non-trivial drop code are reported.

    ```
    struct S(String); // Doesn't implement `Drop`
    union U<T> {
        a: S, // Reported
        b: T, // Reported
    }
    ```

- #35764 was indeed helpful and landed timely, I didn't have to implement internal drop flags for unions.
- Unions are not permitted in constant patterns, because matching on union fields is unsafe, I didn't want unsafety checker to dig into all constants to uncover this possible unsafety.
- The RFC doesn't talk about `#[derive]`, generally trait impls cannot be derived for unions, but some of them can. I implemented only `#[derive(Copy)]` so far. In theory shallow `#[derive(Clone)]` can be derived as well if all union fields are `Copy`, I left it for later though, it requires changing how `Clone` impls are generated.
- Moving union fields is implemented as per #32836 (comment).
- Testing strategy: union specific behavior is tested, sometimes very basically (e.g. debuginfo), behavior common for all ADTs (e.g. something like coherence
checks) is not generally tested.

r? @eddyb
bors added a commit that referenced this pull request Sep 2, 2016
Implement untagged unions (RFC 1444)

cc #32836

Notes:
- The RFC doesn't talk about `#[packed]` unions, this implementation supports them, packing changes union's alignment to 1 and removes trailing padding.
- The RFC doesn't talk about dynamically sized unions, this implementation doesn't support them and rejects them during wf-checking (similarly, dynamically sized enums are not supported as well).
- The lint for drop fields in unions can't work precisely before monomorphization, so it works pessimistically - non-`Copy` generic fields are reported, types not implementing `Drop` directly, but having non-trivial drop code are reported.

    ```
    struct S(String); // Doesn't implement `Drop`
    union U<T> {
        a: S, // Reported
        b: T, // Reported
    }
    ```

- #35764 was indeed helpful and landed timely, I didn't have to implement internal drop flags for unions.
- Unions are not permitted in constant patterns, because matching on union fields is unsafe, I didn't want unsafety checker to dig into all constants to uncover this possible unsafety.
- The RFC doesn't talk about `#[derive]`, generally trait impls cannot be derived for unions, but some of them can. I implemented only `#[derive(Copy)]` so far. In theory shallow `#[derive(Clone)]` can be derived as well if all union fields are `Copy`, I left it for later though, it requires changing how `Clone` impls are generated.
- Moving union fields is implemented as per #32836 (comment).
- Testing strategy: union specific behavior is tested, sometimes very basically (e.g. debuginfo), behavior common for all ADTs (e.g. something like coherence
checks) is not generally tested.

r? @eddyb
bors added a commit that referenced this pull request Sep 2, 2016
Implement untagged unions (RFC 1444)

cc #32836

Notes:
- The RFC doesn't talk about `#[packed]` unions, this implementation supports them, packing changes union's alignment to 1 and removes trailing padding.
- The RFC doesn't talk about dynamically sized unions, this implementation doesn't support them and rejects them during wf-checking (similarly, dynamically sized enums are not supported as well).
- The lint for drop fields in unions can't work precisely before monomorphization, so it works pessimistically - non-`Copy` generic fields are reported, types not implementing `Drop` directly, but having non-trivial drop code are reported.

    ```
    struct S(String); // Doesn't implement `Drop`
    union U<T> {
        a: S, // Reported
        b: T, // Reported
    }
    ```

- #35764 was indeed helpful and landed timely, I didn't have to implement internal drop flags for unions.
- Unions are not permitted in constant patterns, because matching on union fields is unsafe, I didn't want unsafety checker to dig into all constants to uncover this possible unsafety.
- The RFC doesn't talk about `#[derive]`, generally trait impls cannot be derived for unions, but some of them can. I implemented only `#[derive(Copy)]` so far. In theory shallow `#[derive(Clone)]` can be derived as well if all union fields are `Copy`, I left it for later though, it requires changing how `Clone` impls are generated.
- Moving union fields is implemented as per #32836 (comment).
- Testing strategy: union specific behavior is tested, sometimes very basically (e.g. debuginfo), behavior common for all ADTs (e.g. something like coherence
checks) is not generally tested.

r? @eddyb
bors added a commit that referenced this pull request Sep 3, 2016
Implement untagged unions (RFC 1444)

cc #32836

Notes:
- The RFC doesn't talk about `#[packed]` unions, this implementation supports them, packing changes union's alignment to 1 and removes trailing padding.
- The RFC doesn't talk about dynamically sized unions, this implementation doesn't support them and rejects them during wf-checking (similarly, dynamically sized enums are not supported as well).
- The lint for drop fields in unions can't work precisely before monomorphization, so it works pessimistically - non-`Copy` generic fields are reported, types not implementing `Drop` directly, but having non-trivial drop code are reported.

    ```
    struct S(String); // Doesn't implement `Drop`
    union U<T> {
        a: S, // Reported
        b: T, // Reported
    }
    ```

- #35764 was indeed helpful and landed timely, I didn't have to implement internal drop flags for unions.
- Unions are not permitted in constant patterns, because matching on union fields is unsafe, I didn't want unsafety checker to dig into all constants to uncover this possible unsafety.
- The RFC doesn't talk about `#[derive]`, generally trait impls cannot be derived for unions, but some of them can. I implemented only `#[derive(Copy)]` so far. In theory shallow `#[derive(Clone)]` can be derived as well if all union fields are `Copy`, I left it for later though, it requires changing how `Clone` impls are generated.
- Moving union fields is implemented as per #32836 (comment).
- Testing strategy: union specific behavior is tested, sometimes very basically (e.g. debuginfo), behavior common for all ADTs (e.g. something like coherence
checks) is not generally tested.

r? @eddyb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

8 participants
You can’t perform that action at this time.