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

Various type and trans cleanups. #11252

Closed
wants to merge 3 commits into from
Closed

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Jan 1, 2014

No description provided.

@brson
Copy link
Contributor

brson commented Jan 2, 2014

Need someone who knows trans to review: @nikomatsakis @pcwalton ?

@nikomatsakis
Copy link
Contributor

I can review, but not until next week.

@eddyb
Copy link
Member Author

eddyb commented Jan 3, 2014

The last commit requires cleanup improvements (which @nikomatsakis said was working on), right now this example crashes with a double free:

// Because ~[u8], it's represented as a pointer to len, capacity and data,
// so it would be passed ByValue (datum-wise).
fn foo(x: ~[u8]) -> ~str {
    unsafe {
        // This call would move out of x, so the original cleanup
        // has to be revoked. but this isn't in the same scope as
        // the original, so only ByRef(ZeroMem) can be revoked
        // and that produces bloated code (which I wanted to avoid).
        ::std::unstable::intrinsics::transmute(x)
    }
}
fn main() {
    foo(~[]);
}

EDIT: I've delayed fixing that issue, see #11445 - the code for determining whether an alloca is (not) required is still there, but it's disabled.

@eddyb
Copy link
Member Author

eddyb commented Jan 10, 2014

From my own tests, it looks like librustc takes 20s (about 3%) less to compile and link (I assume most of that is caused by the removal of free_glue).

Store(bcx, tmp, alloc);
alloc
let needs_indirection = if slf.mode.is_by_value() {
// FIXME(eddyb) #11445 Always needs indirection because of cleanup.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer to just have commented out code or something here.

@pcwalton
Copy link
Contributor

This looks great modulo nits, thanks so much!

@bors bors closed this Jan 11, 2014
@eddyb eddyb deleted the ty-cleanup branch January 11, 2014 16:52
@nikomatsakis
Copy link
Contributor

For what it's worth, I read these changes over on the plane and was coming here to give them r+ as well, but I see that @huonw beat me to the punch. Thanks @eddyb. Now I just have to rebase my branch over these changes -- actually that doesn't look too bad.

@huonw
Copy link
Member

huonw commented Jan 12, 2014

(It was actually @pcwalton who r+'d it originally; there were just some minor things with the testsuite on the first few runs.)

@eddyb
Copy link
Member Author

eddyb commented Jan 13, 2014

@nikomatsakis so I won't forget: if an argument doesn't require drop, it doesn't need indirection, the current override is stronger than it needs to be. I hope it will be possible to remove the indirection even for types with drop in the future, at least in simple cases like my example above (which is the same as #11445).

@eddyb eddyb restored the ty-cleanup branch February 6, 2016 11:47
@eddyb eddyb deleted the ty-cleanup branch February 6, 2016 11:47
flip1995 pushed a commit to flip1995/rust that referenced this pull request Aug 11, 2023
[`unwrap_used`]: Do not lint unwrapping on `!` or never-like enums

Fixes rust-lang#11245

changelog: [`unwrap_used`]: Do not lint unwrapping on `!` or never-like enums
changelog: [`expect_used`]: Do not lint unwrapping on `!` or never-like enums
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants