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

Nullable field optimization does the Wrong Thing when faced with associated types #27532

Closed
arielb1 opened this issue Aug 5, 2015 · 3 comments
Assignees

Comments

@arielb1
Copy link
Contributor

arielb1 commented Aug 5, 2015

STR

use std::mem;
trait Mirror { type Image; }
impl<T> Mirror for T { type Image = T; }
struct S1<T>(<T as Mirror>::Image);
struct S2<T>(T);

fn main() {
    println!("with: {}", mem::size_of::<Option<S1<&u8>>>());
    println!("without: {}", mem::size_of::<Option<S2<&u8>>>());
}

Expected Result

Nullable field optimization should be triggered in both cases

Result

with: 8
without: 16
@jonas-schievink
Copy link
Contributor

I think you swapped the results by accident

@eefriedman
Copy link
Contributor

It looks like the issue is just a couple missing calls to monomorphize::normalize_associated_type; I'm working on a fix.

@arielb1
Copy link
Contributor Author

arielb1 commented Aug 5, 2015

I will fix this with my ADTDef patch (coming real soon now) - I should have made that clearer.

@arielb1 arielb1 self-assigned this Aug 5, 2015
@arielb1 arielb1 closed this as completed in c533f96 Aug 7, 2015
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

No branches or pull requests

3 participants