Skip to content

Commit b2aeb1f

Browse files
authored
Rollup merge of #88357 - lcnr:stabilize-relaxed_struct_unsize, r=Mark-Simulacrum
add unsized coercion test we had no tests in our test suite for this case
2 parents 191ca73 + bee13d1 commit b2aeb1f

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// We must not allow this with our current setup as `T`
2+
// is mentioned both in the tail of `Foo` and by another
3+
// field.
4+
struct Foo<T: ?Sized>(Box<T>, T);
5+
6+
fn main() {
7+
let x: Foo<[u8; 1]> = Foo(Box::new([2]), [3]);
8+
let y: &Foo<[u8]> = &x; //~ ERROR mismatched types
9+
assert_eq!(y.0.len(), 1);
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/param-mentioned-by-different-field.rs:8:25
3+
|
4+
LL | let y: &Foo<[u8]> = &x;
5+
| ---------- ^^ expected slice `[u8]`, found array `[u8; 1]`
6+
| |
7+
| expected due to this
8+
|
9+
= note: expected reference `&Foo<[u8]>`
10+
found reference `&Foo<[u8; 1]>`
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)