summaryrefslogtreecommitdiffstats
path: root/tests/ui/issues/issue-11205.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/ui/issues/issue-11205.rs
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/issues/issue-11205.rs')
-rw-r--r--tests/ui/issues/issue-11205.rs85
1 files changed, 85 insertions, 0 deletions
diff --git a/tests/ui/issues/issue-11205.rs b/tests/ui/issues/issue-11205.rs
new file mode 100644
index 000000000..ce0951eaf
--- /dev/null
+++ b/tests/ui/issues/issue-11205.rs
@@ -0,0 +1,85 @@
+// run-pass
+// pretty-expanded FIXME #23616
+
+#![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
+ };
+}