-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// We must not allow this with our current setup as `T` | ||
// is mentioned both in the tail of `Foo` and by another | ||
// field. | ||
struct Foo<T: ?Sized>(Box<T>, T); | ||
|
||
fn main() { | ||
let x: Foo<[u8; 1]> = Foo(Box::new([2]), [3]); | ||
let y: &Foo<[u8]> = &x; //~ ERROR mismatched types | ||
assert_eq!(y.0.len(), 1); | ||
} |
14 changes: 14 additions & 0 deletions
14
src/test/ui/unsized/param-mentioned-by-different-field.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/param-mentioned-by-different-field.rs:8:25 | ||
| | ||
LL | let y: &Foo<[u8]> = &x; | ||
| ---------- ^^ expected slice `[u8]`, found array `[u8; 1]` | ||
| | | ||
| expected due to this | ||
| | ||
= note: expected reference `&Foo<[u8]>` | ||
found reference `&Foo<[u8; 1]>` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |