-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Conversation
Need someone who knows trans to review: @nikomatsakis @pcwalton ? |
I can review, but not until next week. |
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. |
From my own tests, it looks like |
Store(bcx, tmp, alloc); | ||
alloc | ||
let needs_indirection = if slf.mode.is_by_value() { | ||
// FIXME(eddyb) #11445 Always needs indirection because of cleanup. |
There was a problem hiding this comment.
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.
This looks great modulo nits, thanks so much! |
(It was actually @pcwalton who r+'d it originally; there were just some minor things with the testsuite on the first few runs.) |
@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). |
[`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
No description provided.