about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-05-12 16:41:06 +0200
committerGitHub <noreply@github.com>2022-05-12 16:41:06 +0200
commit5656ea22ada5aae9c6bf9f36c031e55db9b61f79 (patch)
treeec3a2d0b0ebef7636f6089daccb4c91f72586508 /src/test/ui
parent47e4c9efdc369c71920e20f13553d5f7ac791250 (diff)
parentbd41874eeadba20870f49e837babc56e67292b10 (diff)
downloadrust-5656ea22ada5aae9c6bf9f36c031e55db9b61f79.tar.gz
rust-5656ea22ada5aae9c6bf9f36c031e55db9b61f79.zip
Rollup merge of #96968 - cjgillot:codegen-fulfill-nice, r=oli-obk
Add tests for #96806

I messed up the rebase in https://github.com/rust-lang/rust/pull/96806.

I took the opportunity to add an extra mir-opt test from https://github.com/rust-lang/rust/pull/91743.

r? `@oli-obk`
Diffstat (limited to 'src/test/ui')
-rw-r--r--src/test/ui/associated-consts/issue-88599-ref-self.rs24
-rw-r--r--src/test/ui/issues/issue-37725.rs2
-rw-r--r--src/test/ui/trivial-bounds/issue-73021-impossible-inline.inline.stderr46
-rw-r--r--src/test/ui/trivial-bounds/issue-73021-impossible-inline.no-opt.stderr46
-rw-r--r--src/test/ui/trivial-bounds/issue-73021-impossible-inline.rs71
5 files changed, 189 insertions, 0 deletions
diff --git a/src/test/ui/associated-consts/issue-88599-ref-self.rs b/src/test/ui/associated-consts/issue-88599-ref-self.rs
new file mode 100644
index 00000000000..f1144db44ca
--- /dev/null
+++ b/src/test/ui/associated-consts/issue-88599-ref-self.rs
@@ -0,0 +1,24 @@
+// check-pass
+#![feature(generic_const_exprs)]
+#![allow(incomplete_features)]
+
+pub trait First {
+    const CONST: usize;
+}
+pub trait Second {}
+
+impl<'a> First for dyn Second
+where
+    &'a Self: First,
+{
+    const CONST: usize = <&Self>::CONST;
+}
+
+trait Third: First
+where
+    [u8; Self::CONST]:
+{
+    const VAL: [u8; Self::CONST] = [0; Self::CONST];
+}
+
+fn main() {}
diff --git a/src/test/ui/issues/issue-37725.rs b/src/test/ui/issues/issue-37725.rs
index 965ecde6f3c..1c6df0da60c 100644
--- a/src/test/ui/issues/issue-37725.rs
+++ b/src/test/ui/issues/issue-37725.rs
@@ -1,4 +1,6 @@
 // build-pass
+// compiler-opts: -Zmir-opt-level=2
+
 #![allow(dead_code)]
 trait Foo {
     fn foo(&self);
diff --git a/src/test/ui/trivial-bounds/issue-73021-impossible-inline.inline.stderr b/src/test/ui/trivial-bounds/issue-73021-impossible-inline.inline.stderr
new file mode 100644
index 00000000000..40829f53709
--- /dev/null
+++ b/src/test/ui/trivial-bounds/issue-73021-impossible-inline.inline.stderr
@@ -0,0 +1,46 @@
+warning: trait bound for<'any> &'any mut (): Clone does not depend on any type or lifetime parameters
+  --> $DIR/issue-73021-impossible-inline.rs:20:29
+   |
+LL |     for<'any> &'any mut (): Clone,
+   |                             ^^^^^
+   |
+   = note: `#[warn(trivial_bounds)]` on by default
+
+warning: trait bound i32: Foo does not depend on any type or lifetime parameters
+  --> $DIR/issue-73021-impossible-inline.rs:28:21
+   |
+LL | struct S where i32: Foo;
+   |                     ^^^
+
+warning: trait bound i32: Foo does not depend on any type or lifetime parameters
+  --> $DIR/issue-73021-impossible-inline.rs:31:28
+   |
+LL | impl Foo for () where i32: Foo {
+   |                            ^^^
+
+warning: trait bound i32: Foo does not depend on any type or lifetime parameters
+  --> $DIR/issue-73021-impossible-inline.rs:40:19
+   |
+LL | fn f() where i32: Foo {
+   |                   ^^^
+
+warning: trait bound &'static str: Foo does not depend on any type or lifetime parameters
+  --> $DIR/issue-73021-impossible-inline.rs:48:28
+   |
+LL | fn g() where &'static str: Foo {
+   |                            ^^^
+
+warning: trait bound String: Neg does not depend on any type or lifetime parameters
+  --> $DIR/issue-73021-impossible-inline.rs:57:13
+   |
+LL |     String: ::std::ops::Neg<Output = String>,
+   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: trait bound i32: Iterator does not depend on any type or lifetime parameters
+  --> $DIR/issue-73021-impossible-inline.rs:65:10
+   |
+LL |     i32: Iterator,
+   |          ^^^^^^^^
+
+warning: 7 warnings emitted
+
diff --git a/src/test/ui/trivial-bounds/issue-73021-impossible-inline.no-opt.stderr b/src/test/ui/trivial-bounds/issue-73021-impossible-inline.no-opt.stderr
new file mode 100644
index 00000000000..40829f53709
--- /dev/null
+++ b/src/test/ui/trivial-bounds/issue-73021-impossible-inline.no-opt.stderr
@@ -0,0 +1,46 @@
+warning: trait bound for<'any> &'any mut (): Clone does not depend on any type or lifetime parameters
+  --> $DIR/issue-73021-impossible-inline.rs:20:29
+   |
+LL |     for<'any> &'any mut (): Clone,
+   |                             ^^^^^
+   |
+   = note: `#[warn(trivial_bounds)]` on by default
+
+warning: trait bound i32: Foo does not depend on any type or lifetime parameters
+  --> $DIR/issue-73021-impossible-inline.rs:28:21
+   |
+LL | struct S where i32: Foo;
+   |                     ^^^
+
+warning: trait bound i32: Foo does not depend on any type or lifetime parameters
+  --> $DIR/issue-73021-impossible-inline.rs:31:28
+   |
+LL | impl Foo for () where i32: Foo {
+   |                            ^^^
+
+warning: trait bound i32: Foo does not depend on any type or lifetime parameters
+  --> $DIR/issue-73021-impossible-inline.rs:40:19
+   |
+LL | fn f() where i32: Foo {
+   |                   ^^^
+
+warning: trait bound &'static str: Foo does not depend on any type or lifetime parameters
+  --> $DIR/issue-73021-impossible-inline.rs:48:28
+   |
+LL | fn g() where &'static str: Foo {
+   |                            ^^^
+
+warning: trait bound String: Neg does not depend on any type or lifetime parameters
+  --> $DIR/issue-73021-impossible-inline.rs:57:13
+   |
+LL |     String: ::std::ops::Neg<Output = String>,
+   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: trait bound i32: Iterator does not depend on any type or lifetime parameters
+  --> $DIR/issue-73021-impossible-inline.rs:65:10
+   |
+LL |     i32: Iterator,
+   |          ^^^^^^^^
+
+warning: 7 warnings emitted
+
diff --git a/src/test/ui/trivial-bounds/issue-73021-impossible-inline.rs b/src/test/ui/trivial-bounds/issue-73021-impossible-inline.rs
new file mode 100644
index 00000000000..ab6677e911b
--- /dev/null
+++ b/src/test/ui/trivial-bounds/issue-73021-impossible-inline.rs
@@ -0,0 +1,71 @@
+// build-pass
+// revisions: no-opt inline
+// [inline]compile-flags: -Zmir-opt-level=3 --emit=mir
+#![feature(trivial_bounds)]
+#![allow(unused)]
+
+trait Foo {
+    fn test(&self);
+}
+
+fn foo<'a>(s: &'a mut ())
+where
+    &'a mut (): Foo,
+{
+    s.test();
+}
+
+fn clone(it: &mut ()) -> &mut ()
+where
+    for<'any> &'any mut (): Clone,
+    //~^ WARN trait bound for<'any> &'any mut (): Clone does not depend on any type or lifetime parameters
+{
+    it.clone()
+}
+
+fn generic_function<X: Foo>(x: X) {}
+
+struct S where i32: Foo;
+//~^ WARN trait bound i32: Foo does not depend on any type or lifetime parameters
+
+impl Foo for () where i32: Foo {
+//~^ WARN trait bound i32: Foo does not depend on any type or lifetime parameters
+    fn test(&self) {
+        3i32.test();
+        Foo::test(&4i32);
+        generic_function(5i32);
+    }
+}
+
+fn f() where i32: Foo {
+//~^ WARN trait bound i32: Foo does not depend on any type or lifetime parameters
+    let s = S;
+    3i32.test();
+    Foo::test(&4i32);
+    generic_function(5i32);
+}
+
+fn g() where &'static str: Foo {
+//~^ WARN trait bound &'static str: Foo does not depend on any type or lifetime parameters
+    "Foo".test();
+    Foo::test(&"Foo");
+    generic_function("Foo");
+}
+
+fn use_op(s: String) -> String
+where
+    String: ::std::ops::Neg<Output = String>,
+//~^ WARN trait bound String: Neg does not depend on any type or lifetime parameters
+{
+    -s
+}
+
+fn use_for()
+where
+    i32: Iterator,
+//~^ WARN trait bound i32: Iterator does not depend on any type or lifetime parameters
+{
+    for _ in 2i32 {}
+}
+
+fn main() {}