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

[WIP] Implement DST coercions. #23785

Closed
wants to merge 12 commits into from
Closed

[WIP] Implement DST coercions. #23785

wants to merge 12 commits into from

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Mar 27, 2015

This implements the new opt-in coercion mechanism from rust-lang/rfcs#982.

The first 7 commits are refactoring, then a partial fix for #23785, Unsize, CoerceUnsized, intrinsics and Rc support, each with its own commit.
Only the last two actually affect stable APIs and they may be taken out to speed out merging the core changes (or just the refactoring).

TODO:

  • fix expected errors in compile-fail tests after move to CoerceUnsized (errors related to region inference are somewhat different) and a couple of LLVM assertions
  • maybe have is_null implemented on pointers to unsized types
  • repeat the Rc changes for Arc
  • add new tests for Unsize and CoerceUnsized - there's so much to do here, I'm considering centralizing testing for DST, but then again... const-polymorphic-paths used to be an experiment in DRY testing of many combinations and it ended up really weird, with all that macro abuse 😞

r? @nikomatsakis or @nrc
f? @pcwalton

@nrc nrc assigned nrc and unassigned nikomatsakis Apr 9, 2015
@nrc nrc closed this Apr 20, 2015
@nrc
Copy link
Member

nrc commented Apr 20, 2015

See #24619 for the rebased and finished off version.

@eddyb eddyb deleted the dst branch March 8, 2017 19:33
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Mar 10, 2017
…r=nikomatsakis

Disallow subtyping between T and U in T: Unsize<U>.

Because `&mut T` can be coerced to `&mut U`, `T` and `U` must be unified invariantly. Fixes rust-lang#40288.
E.g. coercing `&mut [&'a X; N]` to `&mut [&'b X]` must require `'a` be equal to `'b`, otherwise you can convert between `&'a X` and `&'b X` (in either direction), potentially unsoundly lengthening lifetimes.

Subtyping here was introduced with `Unsize` in rust-lang#24619 (landed in 1.1, original PR is rust-lang#23785).
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Mar 10, 2017
…r=nikomatsakis

Disallow subtyping between T and U in T: Unsize<U>.

Because `&mut T` can be coerced to `&mut U`, `T` and `U` must be unified invariantly. Fixes rust-lang#40288.
E.g. coercing `&mut [&'a X; N]` to `&mut [&'b X]` must require `'a` be equal to `'b`, otherwise you can convert between `&'a X` and `&'b X` (in either direction), potentially unsoundly lengthening lifetimes.

Subtyping here was introduced with `Unsize` in rust-lang#24619 (landed in 1.1, original PR is rust-lang#23785).
arielb1 pushed a commit to arielb1/rust that referenced this pull request Mar 10, 2017
…r=nikomatsakis

Disallow subtyping between T and U in T: Unsize<U>.

Because `&mut T` can be coerced to `&mut U`, `T` and `U` must be unified invariantly. Fixes rust-lang#40288.
E.g. coercing `&mut [&'a X; N]` to `&mut [&'b X]` must require `'a` be equal to `'b`, otherwise you can convert between `&'a X` and `&'b X` (in either direction), potentially unsoundly lengthening lifetimes.

Subtyping here was introduced with `Unsize` in rust-lang#24619 (landed in 1.1, original PR is rust-lang#23785).
arielb1 pushed a commit to arielb1/rust that referenced this pull request Mar 10, 2017
…r=nikomatsakis

Disallow subtyping between T and U in T: Unsize<U>.

Because `&mut T` can be coerced to `&mut U`, `T` and `U` must be unified invariantly. Fixes rust-lang#40288.
E.g. coercing `&mut [&'a X; N]` to `&mut [&'b X]` must require `'a` be equal to `'b`, otherwise you can convert between `&'a X` and `&'b X` (in either direction), potentially unsoundly lengthening lifetimes.

Subtyping here was introduced with `Unsize` in rust-lang#24619 (landed in 1.1, original PR is rust-lang#23785).
arielb1 pushed a commit to arielb1/rust that referenced this pull request Mar 10, 2017
…r=nikomatsakis

Disallow subtyping between T and U in T: Unsize<U>.

Because `&mut T` can be coerced to `&mut U`, `T` and `U` must be unified invariantly. Fixes rust-lang#40288.
E.g. coercing `&mut [&'a X; N]` to `&mut [&'b X]` must require `'a` be equal to `'b`, otherwise you can convert between `&'a X` and `&'b X` (in either direction), potentially unsoundly lengthening lifetimes.

Subtyping here was introduced with `Unsize` in rust-lang#24619 (landed in 1.1, original PR is rust-lang#23785).
arielb1 pushed a commit to arielb1/rust that referenced this pull request Mar 11, 2017
…r=nikomatsakis

Disallow subtyping between T and U in T: Unsize<U>.

Because `&mut T` can be coerced to `&mut U`, `T` and `U` must be unified invariantly. Fixes rust-lang#40288.
E.g. coercing `&mut [&'a X; N]` to `&mut [&'b X]` must require `'a` be equal to `'b`, otherwise you can convert between `&'a X` and `&'b X` (in either direction), potentially unsoundly lengthening lifetimes.

Subtyping here was introduced with `Unsize` in rust-lang#24619 (landed in 1.1, original PR is rust-lang#23785).
arielb1 pushed a commit to arielb1/rust that referenced this pull request Mar 11, 2017
…r=nikomatsakis

Disallow subtyping between T and U in T: Unsize<U>.

Because `&mut T` can be coerced to `&mut U`, `T` and `U` must be unified invariantly. Fixes rust-lang#40288.
E.g. coercing `&mut [&'a X; N]` to `&mut [&'b X]` must require `'a` be equal to `'b`, otherwise you can convert between `&'a X` and `&'b X` (in either direction), potentially unsoundly lengthening lifetimes.

Subtyping here was introduced with `Unsize` in rust-lang#24619 (landed in 1.1, original PR is rust-lang#23785).
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.

3 participants