]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #40319 - eddyb:it's-"unsize"-not-"unsound", r=nikomatsakis
authorAriel Ben-Yehuda <arielb1@mail.tau.ac.il>
Sat, 11 Mar 2017 19:57:42 +0000 (21:57 +0200)
committerGitHub <noreply@github.com>
Sat, 11 Mar 2017 19:57:42 +0000 (21:57 +0200)
commitc886815e949cefa9398b6c9c57a7126e743fe8eb
tree6ced918a44754b28dfbe7a3d03f22d2d97021b29
parentb49036c7d016f1fdf99bec9b398f7f6c052d5464
parentcfb41aedd3a5e21c169a0a91dfd600e8e370d291
Rollup merge of #40319 - eddyb:it's-"unsize"-not-"unsound", 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 #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 #24619 (landed in 1.1, original PR is #23785).