diff options
| author | David Wood <david.wood2@arm.com> | 2025-06-27 16:46:29 +0000 |
|---|---|---|
| committer | David Wood <david.wood2@arm.com> | 2025-06-27 17:01:47 +0000 |
| commit | 2057423506ea08f35d05f067a2ffe73579afac12 (patch) | |
| tree | 4762727739f4a70152dda8e6a099310f9f8028f7 /tests | |
| parent | 13c46fd0b089360922a557d8e18a63a2c41dfbeb (diff) | |
| download | rust-2057423506ea08f35d05f067a2ffe73579afac12.tar.gz rust-2057423506ea08f35d05f067a2ffe73579afac12.zip | |
hir_analysis: prohibit `dyn PointeeSized`
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/sized-hierarchy/reject-dyn-pointeesized.rs | 16 | ||||
| -rw-r--r-- | tests/ui/sized-hierarchy/reject-dyn-pointeesized.stderr | 14 |
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/ui/sized-hierarchy/reject-dyn-pointeesized.rs b/tests/ui/sized-hierarchy/reject-dyn-pointeesized.rs new file mode 100644 index 00000000000..ece1702679d --- /dev/null +++ b/tests/ui/sized-hierarchy/reject-dyn-pointeesized.rs @@ -0,0 +1,16 @@ +#![feature(sized_hierarchy)] + +use std::marker::PointeeSized; + +type Foo = dyn PointeeSized; +//~^ ERROR `PointeeSized` cannot be used with trait objects + +fn foo(f: &Foo) {} + +fn main() { + foo(&()); + + let x = main; + let y: Box<dyn PointeeSized> = x; +//~^ ERROR `PointeeSized` cannot be used with trait objects +} diff --git a/tests/ui/sized-hierarchy/reject-dyn-pointeesized.stderr b/tests/ui/sized-hierarchy/reject-dyn-pointeesized.stderr new file mode 100644 index 00000000000..a833c6952fd --- /dev/null +++ b/tests/ui/sized-hierarchy/reject-dyn-pointeesized.stderr @@ -0,0 +1,14 @@ +error: `PointeeSized` cannot be used with trait objects + --> $DIR/reject-dyn-pointeesized.rs:5:12 + | +LL | type Foo = dyn PointeeSized; + | ^^^^^^^^^^^^^^^^ + +error: `PointeeSized` cannot be used with trait objects + --> $DIR/reject-dyn-pointeesized.rs:14:16 + | +LL | let y: Box<dyn PointeeSized> = x; + | ^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + |
