about summary refs log tree commit diff
path: root/tests/ui/coercion/trait-object-arrays-11205.rs
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-07-28 08:36:51 +0200
committerGitHub <noreply@github.com>2025-07-28 08:36:51 +0200
commita08ced3856e297b9576a2ec697c5bcb8983a24c4 (patch)
treed2bd04fa247bb98edf7006943d56263598bf4cbc /tests/ui/coercion/trait-object-arrays-11205.rs
parenta9f58bff03969533800491c24b4f538b6b53c609 (diff)
parente9959aa74e23eb340d6c9e9a4eab807be03b028f (diff)
downloadrust-a08ced3856e297b9576a2ec697c5bcb8983a24c4.tar.gz
rust-a08ced3856e297b9576a2ec697c5bcb8983a24c4.zip
Rollup merge of #144151 - Kivooeo:issue1, r=jieyouxu
`tests/ui/issues/`: The Issues Strike Back [1/N]

I believe I’ve finally brought [my program](https://github.com/Kivooeo/test-manager) to life -- it now handles multiple test moves in one go: plain moves first, then a gentle touch on each file depends on given options. The process should be much smoother now.

Of course, I won’t rush through everything in a few days -- that would be unkind to `@Oneirical.` I’ll pace myself. And also I can't have more than one such PR because `issues.txt` will conflict with previous parts after merging them which is not fun as well.

This PR is just that: first commit - moves; second - regression comments and the occasional .stderr reblesses, also issue.txt and tidy changes. Nothing special, but progress nonetheless. This is for the purpose of preserving test file history during restructuring

Part of https://github.com/rust-lang/rust/issues/133895.

r? `@jieyouxu`
Diffstat (limited to 'tests/ui/coercion/trait-object-arrays-11205.rs')
-rw-r--r--tests/ui/coercion/trait-object-arrays-11205.rs86
1 files changed, 86 insertions, 0 deletions
diff --git a/tests/ui/coercion/trait-object-arrays-11205.rs b/tests/ui/coercion/trait-object-arrays-11205.rs
new file mode 100644
index 00000000000..45d69dce323
--- /dev/null
+++ b/tests/ui/coercion/trait-object-arrays-11205.rs
@@ -0,0 +1,86 @@
+//! Regression test for https://github.com/rust-lang/rust/issues/11205
+
+//@ run-pass
+
+#![allow(dead_code)]
+
+trait Foo { fn dummy(&self) { } }
+impl Foo for isize {}
+fn foo(_: [&dyn Foo; 2]) {}
+fn foos(_: &[&dyn Foo]) {}
+fn foog<T>(_: &[T], _: &[T]) {}
+
+fn bar(_: [Box<dyn Foo>; 2]) {}
+fn bars(_: &[Box<dyn Foo+'static>]) {}
+
+fn main() {
+    let x: [&dyn Foo; 2] = [&1, &2];
+    foo(x);
+    foo([&1, &2]);
+
+    let r = &1;
+    let x: [&dyn Foo; 2] = [r; 2];
+    foo(x);
+    foo([&1; 2]);
+
+    let x: &[&dyn Foo] = &[&1, &2];
+    foos(x);
+    foos(&[&1, &2]);
+
+    let x: &[&dyn Foo] = &[&1, &2];
+    let r = &1;
+    foog(x, &[r]);
+
+    let x: [Box<dyn Foo>; 2] = [Box::new(1), Box::new(2)];
+    bar(x);
+    bar([Box::new(1), Box::new(2)]);
+
+    let x: &[Box<dyn Foo+'static>] = &[Box::new(1), Box::new(2)];
+    bars(x);
+    bars(&[Box::new(1), Box::new(2)]);
+
+    let x: &[Box<dyn Foo+'static>] = &[Box::new(1), Box::new(2)];
+    foog(x, &[Box::new(1)]);
+
+    struct T<'a> {
+        t: [&'a (dyn Foo+'a); 2]
+    }
+    let _n = T {
+        t: [&1, &2]
+    };
+    let r = &1;
+    let _n = T {
+        t: [r; 2]
+    };
+    let x: [&dyn Foo; 2] = [&1, &2];
+    let _n = T {
+        t: x
+    };
+
+    struct F<'b> {
+        t: &'b [&'b (dyn Foo+'b)]
+    }
+    let _n = F {
+        t: &[&1, &2]
+    };
+    let r = &1;
+    let r: [&dyn Foo; 2] = [r; 2];
+    let _n = F {
+        t: &r
+    };
+    let x: [&dyn Foo; 2] = [&1, &2];
+    let _n = F {
+        t: &x
+    };
+
+    struct M<'a> {
+        t: &'a [Box<dyn Foo+'static>]
+    }
+    let _n = M {
+        t: &[Box::new(1), Box::new(2)]
+    };
+    let x: [Box<dyn Foo>; 2] = [Box::new(1), Box::new(2)];
+    let _n = M {
+        t: &x
+    };
+}