summaryrefslogtreecommitdiffstats
path: root/tests/ui/where-clauses
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:24 +0000
commit023939b627b7dc93b01471f7d41fb8553ddb4ffa (patch)
tree60fc59477c605c72b0a1051409062ddecc43f877 /tests/ui/where-clauses
parentAdding debian version 1.72.1+dfsg1-1. (diff)
downloadrustc-023939b627b7dc93b01471f7d41fb8553ddb4ffa.tar.xz
rustc-023939b627b7dc93b01471f7d41fb8553ddb4ffa.zip
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/where-clauses')
-rw-r--r--tests/ui/where-clauses/where-clause-bounds-inconsistency.rs1
-rw-r--r--tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.fixed28
-rw-r--r--tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.rs28
-rw-r--r--tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.stderr42
-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.rs11
-rw-r--r--tests/ui/where-clauses/where-clause-placement-type-alias.stderr20
9 files changed, 188 insertions, 1 deletions
diff --git a/tests/ui/where-clauses/where-clause-bounds-inconsistency.rs b/tests/ui/where-clauses/where-clause-bounds-inconsistency.rs
index cf7d06b61..ea60fa708 100644
--- a/tests/ui/where-clauses/where-clause-bounds-inconsistency.rs
+++ b/tests/ui/where-clauses/where-clause-bounds-inconsistency.rs
@@ -14,7 +14,6 @@ trait Trait {
impl Trait for bool {
fn a<T: Bound>(&self, _: T) {}
- //^~ This gets rejected but should be accepted
fn b<T>(&self, _: T) where T: Bound {}
fn c<T: Bound>(&self, _: T) {}
fn d<T>(&self, _: T) where T: Bound {}
diff --git a/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.fixed b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.fixed
new file mode 100644
index 000000000..2f47c0d91
--- /dev/null
+++ b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.fixed
@@ -0,0 +1,28 @@
+// check-pass
+// run-rustfix
+
+trait Trait {
+ // Fine.
+ type Assoc where u32: Copy;
+ // Fine.
+ type Assoc2 where u32: Copy, i32: Copy;
+}
+
+impl Trait for u32 {
+ // 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
+}
+
+impl Trait for i32 {
+ // Fine.
+ type Assoc = () where u32: Copy;
+ // Not fine, suggests moving both.
+ type Assoc2 = () where u32: Copy, i32: Copy;
+ //~^ WARNING where clause not allowed here
+}
+
+fn main() {}
diff --git a/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.rs b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.rs
new file mode 100644
index 000000000..b20aa9398
--- /dev/null
+++ b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.rs
@@ -0,0 +1,28 @@
+// check-pass
+// run-rustfix
+
+trait Trait {
+ // Fine.
+ type Assoc where u32: Copy;
+ // Fine.
+ type Assoc2 where u32: Copy, i32: Copy;
+}
+
+impl Trait for u32 {
+ // 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
+}
+
+impl Trait for i32 {
+ // Fine.
+ type Assoc = () where u32: Copy;
+ // Not fine, suggests moving both.
+ type Assoc2 where u32: Copy, i32: Copy = ();
+ //~^ WARNING where clause not allowed here
+}
+
+fn main() {}
diff --git a/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.stderr b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.stderr
new file mode 100644
index 000000000..b4de05184
--- /dev/null
+++ b/tests/ui/where-clauses/where-clause-placement-assoc-type-in-impl.stderr
@@ -0,0 +1,42 @@
+warning: where clause not allowed here
+ --> $DIR/where-clause-placement-assoc-type-in-impl.rs:13: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-impl.rs:16: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: where clause not allowed here
+ --> $DIR/where-clause-placement-assoc-type-in-impl.rs:24:17
+ |
+LL | type Assoc2 where u32: Copy, 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, i32: Copy = ();
+LL + type Assoc2 = () where u32: Copy, i32: Copy;
+ |
+
+warning: 3 warnings emitted
+
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 000000000..d171eba50
--- /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 000000000..59afee657
--- /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 000000000..a81cb8c8c
--- /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/where-clauses/where-clause-placement-type-alias.rs b/tests/ui/where-clauses/where-clause-placement-type-alias.rs
new file mode 100644
index 000000000..62e301cb4
--- /dev/null
+++ b/tests/ui/where-clauses/where-clause-placement-type-alias.rs
@@ -0,0 +1,11 @@
+// check-fail
+
+// Fine, but lints as unused
+type Foo where u32: Copy = ();
+// Not fine.
+type Bar = () where u32: Copy;
+//~^ ERROR where clauses are not allowed
+type Baz = () where;
+//~^ ERROR where clauses are not allowed
+
+fn main() {}
diff --git a/tests/ui/where-clauses/where-clause-placement-type-alias.stderr b/tests/ui/where-clauses/where-clause-placement-type-alias.stderr
new file mode 100644
index 000000000..d341148b0
--- /dev/null
+++ b/tests/ui/where-clauses/where-clause-placement-type-alias.stderr
@@ -0,0 +1,20 @@
+error: where clauses are not allowed after the type for type aliases
+ --> $DIR/where-clause-placement-type-alias.rs:6:15
+ |
+LL | type Bar = () where u32: Copy;
+ | ^^^^^^^^^^^^^^^
+ |
+ = note: see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information
+ = help: add `#![feature(lazy_type_alias)]` to the crate attributes to enable
+
+error: where clauses are not allowed after the type for type aliases
+ --> $DIR/where-clause-placement-type-alias.rs:8:15
+ |
+LL | type Baz = () where;
+ | ^^^^^
+ |
+ = note: see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information
+ = help: add `#![feature(lazy_type_alias)]` to the crate attributes to enable
+
+error: aborting due to 2 previous errors
+