about summary refs log tree commit diff
path: root/tests/ui
diff options
context:
space:
mode:
authorLeón Orell Valerian Liehr <me@fmease.dev>2023-07-11 01:11:21 +0200
committerLeón Orell Valerian Liehr <me@fmease.dev>2023-07-11 01:19:11 +0200
commitb809207dec106b261884daea036fad16eb8a2f89 (patch)
tree959dda04aea3cba6edaae2dd686baa4b7acfd86f /tests/ui
parent71f71a5397c42fec01f5c1045c638d961fa9f7ca (diff)
downloadrust-b809207dec106b261884daea036fad16eb8a2f89.tar.gz
rust-b809207dec106b261884daea036fad16eb8a2f89.zip
Lint against misplaced where-clauses on assoc tys in traits
Diffstat (limited to 'tests/ui')
-rw-r--r--tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.fixed (renamed from tests/ui/parser/type-alias-where-fixable.fixed)0
-rw-r--r--tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.rs (renamed from tests/ui/parser/type-alias-where-fixable.rs)0
-rw-r--r--tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.stderr (renamed from tests/ui/parser/type-alias-where-fixable.stderr)6
-rw-r--r--tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.fixed15
-rw-r--r--tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.rs15
-rw-r--r--tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.stderr29
-rw-r--r--tests/ui/where-clauses/where-clause-placement-type-alias.rs (renamed from tests/ui/parser/type-alias-where.rs)0
-rw-r--r--tests/ui/where-clauses/where-clause-placement-type-alias.stderr (renamed from tests/ui/parser/type-alias-where.stderr)4
8 files changed, 64 insertions, 5 deletions
diff --git a/tests/ui/parser/type-alias-where-fixable.fixed b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.fixed
index 2f47c0d91fa..2f47c0d91fa 100644
--- a/tests/ui/parser/type-alias-where-fixable.fixed
+++ b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.fixed
diff --git a/tests/ui/parser/type-alias-where-fixable.rs b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.rs
index b20aa9398b5..b20aa9398b5 100644
--- a/tests/ui/parser/type-alias-where-fixable.rs
+++ b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.rs
diff --git a/tests/ui/parser/type-alias-where-fixable.stderr b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.stderr
index f0acb388b97..b4de051845f 100644
--- a/tests/ui/parser/type-alias-where-fixable.stderr
+++ b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.stderr
@@ -1,5 +1,5 @@
 warning: where clause not allowed here
-  --> $DIR/type-alias-where-fixable.rs:13:16
+  --> $DIR/where-clause-placement-assoc-type-in-impl.rs:13:16
    |
 LL |     type Assoc where u32: Copy = ();
    |                ^^^^^^^^^^^^^^^
@@ -13,7 +13,7 @@ LL +     type Assoc  = () where u32: Copy;
    |
 
 warning: where clause not allowed here
-  --> $DIR/type-alias-where-fixable.rs:16:17
+  --> $DIR/where-clause-placement-assoc-type-in-impl.rs:16:17
    |
 LL |     type Assoc2 where u32: Copy = () where i32: Copy;
    |                 ^^^^^^^^^^^^^^^
@@ -26,7 +26,7 @@ LL +     type Assoc2  = () where i32: Copy, u32: Copy;
    |
 
 warning: where clause not allowed here
-  --> $DIR/type-alias-where-fixable.rs:24:17
+  --> $DIR/where-clause-placement-assoc-type-in-impl.rs:24:17
    |
 LL |     type Assoc2 where u32: Copy, i32: Copy = ();
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.fixed b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.fixed
new file mode 100644
index 00000000000..d171eba50b7
--- /dev/null
+++ b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.fixed
@@ -0,0 +1,15 @@
+// check-pass
+// run-rustfix
+
+#![feature(associated_type_defaults)]
+
+trait Trait {
+    // Not fine, suggests moving.
+    type Assoc  = () where u32: Copy;
+    //~^ WARNING where clause not allowed here
+    // Not fine, suggests moving `u32: Copy`
+    type Assoc2  = () where i32: Copy, u32: Copy;
+    //~^ WARNING where clause not allowed here
+}
+
+fn main() {}
diff --git a/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.rs b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.rs
new file mode 100644
index 00000000000..59afee65794
--- /dev/null
+++ b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.rs
@@ -0,0 +1,15 @@
+// check-pass
+// run-rustfix
+
+#![feature(associated_type_defaults)]
+
+trait Trait {
+    // Not fine, suggests moving.
+    type Assoc where u32: Copy = ();
+    //~^ WARNING where clause not allowed here
+    // Not fine, suggests moving `u32: Copy`
+    type Assoc2 where u32: Copy = () where i32: Copy;
+    //~^ WARNING where clause not allowed here
+}
+
+fn main() {}
diff --git a/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.stderr b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.stderr
new file mode 100644
index 00000000000..a81cb8c8cd6
--- /dev/null
+++ b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-trait.stderr
@@ -0,0 +1,29 @@
+warning: where clause not allowed here
+  --> $DIR/where-clause-placement-assoc-type-in-trait.rs:8:16
+   |
+LL |     type Assoc where u32: Copy = ();
+   |                ^^^^^^^^^^^^^^^
+   |
+   = note: see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information
+   = note: `#[warn(deprecated_where_clause_location)]` on by default
+help: move it to the end of the type declaration
+   |
+LL -     type Assoc where u32: Copy = ();
+LL +     type Assoc  = () where u32: Copy;
+   |
+
+warning: where clause not allowed here
+  --> $DIR/where-clause-placement-assoc-type-in-trait.rs:11:17
+   |
+LL |     type Assoc2 where u32: Copy = () where i32: Copy;
+   |                 ^^^^^^^^^^^^^^^
+   |
+   = note: see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information
+help: move it to the end of the type declaration
+   |
+LL -     type Assoc2 where u32: Copy = () where i32: Copy;
+LL +     type Assoc2  = () where i32: Copy, u32: Copy;
+   |
+
+warning: 2 warnings emitted
+
diff --git a/tests/ui/parser/type-alias-where.rs b/tests/ui/where-clauses/where-clause-placement-type-alias.rs
index 62e301cb408..62e301cb408 100644
--- a/tests/ui/parser/type-alias-where.rs
+++ b/tests/ui/where-clauses/where-clause-placement-type-alias.rs
diff --git a/tests/ui/parser/type-alias-where.stderr b/tests/ui/where-clauses/where-clause-placement-type-alias.stderr
index fb838179266..b3c155a48dd 100644
--- a/tests/ui/parser/type-alias-where.stderr
+++ b/tests/ui/where-clauses/where-clause-placement-type-alias.stderr
@@ -1,5 +1,5 @@
 error: where clauses are not allowed after the type for type aliases
-  --> $DIR/type-alias-where.rs:6:15
+  --> $DIR/where-clause-placement-type-alias.rs:6:15
    |
 LL | type Bar = () where u32: Copy;
    |               ^^^^^^^^^^^^^^^
@@ -7,7 +7,7 @@ LL | type Bar = () where u32: Copy;
    = note: see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information
 
 error: where clauses are not allowed after the type for type aliases
-  --> $DIR/type-alias-where.rs:8:15
+  --> $DIR/where-clause-placement-type-alias.rs:8:15
    |
 LL | type Baz = () where;
    |               ^^^^^