]> git.lizzy.rs Git - rust.git/commit - src/tools/miri
Rollup merge of #80726 - lcnr:unsize-query, r=oli-obk
authorMara Bos <m-ou.se@m-ou.se>
Fri, 5 Feb 2021 11:25:52 +0000 (12:25 +0100)
committerGitHub <noreply@github.com>
Fri, 5 Feb 2021 11:25:52 +0000 (12:25 +0100)
commit676ff77fb7bd45aaa56ff636fdaee3a084c23c1f
tree4d6c2ec0130435a594a51f16a14d66c387c50356
parentdeec6a96d428d20250bfad2317c00fc67e4b70f0
parent031cce8cfc7fef922989e8b820da236ee17e016a
Rollup merge of #80726 - lcnr:unsize-query, r=oli-obk

relax adt unsizing requirements

Changes unsizing of structs in case the last struct field shares generic params with other adt fields which do not change.
This change is currently insta stable and changes the language, so it at least requires a lang fcp. I feel like the current state is fairly unintuitive.

An example for what's now allowed would be https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=6dd331d23f5c9ffc8c978175aae2e967
```rust
struct A<T, U: ?Sized>(T, B<T, U>); // previously ERR
// struct A<T, U: ?Sized>(T, B<[u32; 1], U>); // ok
struct B<T, U: ?Sized>(T, U);

fn main() {
    let x = A([0; 1], B([0; 1], [0; 1]));
    let y: &A<[u32; 1], [u32]> = &x;
    assert_eq!(y.1.1.len(), 1);
}
```