about summary refs log tree commit diff
path: root/tests/ui/sized
diff options
context:
space:
mode:
authorKivooeo <Kivooeo123@gmail.com>2025-07-01 19:28:14 +0500
committerKivooeo <Kivooeo123@gmail.com>2025-07-01 19:28:14 +0500
commit1549585f26881927ea8305e0724d2d1f1dc45ade (patch)
tree4ee5910334298af44557acbac0d8fa0ad0069297 /tests/ui/sized
parentf46ce66fcc3d6058f90ac5bf0930f940f1e7b0ca (diff)
downloadrust-1549585f26881927ea8305e0724d2d1f1dc45ade.tar.gz
rust-1549585f26881927ea8305e0724d2d1f1dc45ade.zip
moved tests
Diffstat (limited to 'tests/ui/sized')
-rw-r--r--tests/ui/sized/recursive-type-infinite-size.rs7
-rw-r--r--tests/ui/sized/recursive-type-infinite-size.stderr19
-rw-r--r--tests/ui/sized/sized-box-unsized-content.rs10
-rw-r--r--tests/ui/sized/sized-reference-to-unsized.rs9
4 files changed, 45 insertions, 0 deletions
diff --git a/tests/ui/sized/recursive-type-infinite-size.rs b/tests/ui/sized/recursive-type-infinite-size.rs
new file mode 100644
index 00000000000..766a5fa0de3
--- /dev/null
+++ b/tests/ui/sized/recursive-type-infinite-size.rs
@@ -0,0 +1,7 @@
+struct Baz { q: Option<Foo> }
+//~^ ERROR recursive types `Baz` and `Foo` have infinite size
+struct Foo { q: Option<Baz> }
+
+impl Foo { fn bar(&self) {} }
+
+fn main() {}
diff --git a/tests/ui/sized/recursive-type-infinite-size.stderr b/tests/ui/sized/recursive-type-infinite-size.stderr
new file mode 100644
index 00000000000..21e54c12fed
--- /dev/null
+++ b/tests/ui/sized/recursive-type-infinite-size.stderr
@@ -0,0 +1,19 @@
+error[E0072]: recursive types `Baz` and `Foo` have infinite size
+  --> $DIR/sized-cycle-note.rs:1:1
+   |
+LL | struct Baz { q: Option<Foo> }
+   | ^^^^^^^^^^             --- recursive without indirection
+LL |
+LL | struct Foo { q: Option<Baz> }
+   | ^^^^^^^^^^             --- recursive without indirection
+   |
+help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
+   |
+LL ~ struct Baz { q: Option<Box<Foo>> }
+LL |
+LL ~ struct Foo { q: Option<Box<Baz>> }
+   |
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0072`.
diff --git a/tests/ui/sized/sized-box-unsized-content.rs b/tests/ui/sized/sized-box-unsized-content.rs
new file mode 100644
index 00000000000..b35c0f91abd
--- /dev/null
+++ b/tests/ui/sized/sized-box-unsized-content.rs
@@ -0,0 +1,10 @@
+//@ run-pass
+
+#![allow(dead_code)]
+// Possibly-dynamic size of typaram should be cleared at pointer boundary.
+
+
+
+fn bar<T: Sized>() { }
+fn foo<T>() { bar::<Box<T>>() }
+pub fn main() { }
diff --git a/tests/ui/sized/sized-reference-to-unsized.rs b/tests/ui/sized/sized-reference-to-unsized.rs
new file mode 100644
index 00000000000..bd213c067db
--- /dev/null
+++ b/tests/ui/sized/sized-reference-to-unsized.rs
@@ -0,0 +1,9 @@
+//@ run-pass
+
+#![allow(dead_code)]
+// Possibly-dynamic size of typaram should be cleared at pointer boundary.
+
+
+fn bar<T: Sized>() { }
+fn foo<T>() { bar::<&T>() }
+pub fn main() { }