Skip to content

Normalize lazilly for sized #32844

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
wants to merge 3 commits into from

Conversation

nikomatsakis
Copy link
Contributor

This is a bit of a hack, but if we eagerly expand structural type obligations, we can resolve #31299.

r? @arielb1

It should never have been public. Call `skip_binder` instead and make
your intentions explicit. Where possible, I adopted `map_bound_ref`
and `map_bound` instead.
This avoids normalizing for structural types, which kind of gives us a
poor man's lazy normalization. It's enough to fix issue rust-lang#31299, anyway,
though you can still get false failures if you try hard enough.

Fixes rust-lang#31299.
Leverage the fact that wfcheck requires that all struct fields are of
sized type except the last, so we don't need to check that again.
@arielb1
Copy link
Contributor

arielb1 commented Apr 9, 2016

This does not handle newtyped pointers (Unique<T> etc.), right? I am not sure we want to land something like this.

ty::BoundCopy => ok_if(vec![element_ty]),
ty::BoundSized => ok_if(Vec::new()),
ty::BoundCopy => self.builtin_bound_ok_if(bound, vec![element_ty]),
ty::BoundSized => self.builtin_bound_ok_if(bound, vec![]),
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks a bit heavy.

@arielb1
Copy link
Contributor

arielb1 commented Apr 9, 2016

How does last-field-only not break our self-recursive struct checking?

struct Recursive {
    this: Recursive,
    last: u32
}

@nikomatsakis
Copy link
Contributor Author

@arielb1

How does last-field-only not break our self-recursive struct checking?

We have separate code that checks for this. It so happens that if we get a recursive Sized error, we will try to detect this case and print it nicely, but it's not the only place that checks for this condition iirc.

When I run that test I get:

/home/nmatsakis/tmp/x.rs:1:1: 4:2 error: recursive type `Recursive` has infinite size [E0072]
/home/nmatsakis/tmp/x.rs:1 struct Recursive {
/home/nmatsakis/tmp/x.rs:2     this: Recursive,
/home/nmatsakis/tmp/x.rs:3     last: u32
/home/nmatsakis/tmp/x.rs:4 }
/home/nmatsakis/tmp/x.rs:1:1: 4:2 help: run `rustc --explain E0072` to see a detailed explanation
/home/nmatsakis/tmp/x.rs:1:1: 4:2 help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Recursive` representable
error: aborting due to previous error

I can add a test case if you like.

@nikomatsakis
Copy link
Contributor Author

@arielb1

This does not handle newtyped pointers (Unique etc.), right? I am not sure we want to land something like this.

No, it doesn't, no structs. Why not land it? Just because it's hacky?

@nikomatsakis
Copy link
Contributor Author

Withdrawing this PR in favor of #33138, which is way better.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bogus error in beta and nightly: recursive type has infinite size
2 participants