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

@eddyb eddyb added the relnotes Marks issues that should be documented in the release notes of the next release. label Aug 17, 2016
@rust-highfive
Copy link
Collaborator

r? @nrc

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

@alexcrichton
Copy link
Member

Dat diff.

@retep998
Copy link
Member

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>; }
Copy link
Contributor

Choose a reason for hiding this comment

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

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)] {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is nifty

@nikomatsakis
Copy link
Contributor

@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
Copy link
Contributor

bors commented Aug 25, 2016

@bors bors merged commit 25cf800 into rust-lang:master Aug 25, 2016
@eddyb eddyb deleted the byegone branch August 25, 2016 01:45
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
Labels
relnotes Marks issues that should be documented in the release notes of the next release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants