summaryrefslogtreecommitdiff
path: root/tests/ui
diff options
context:
space:
mode:
authorLeón Orell Valerian Liehr <me@fmease.dev>2023-08-09 16:44:06 +0200
committerLeón Orell Valerian Liehr <me@fmease.dev>2023-08-10 16:13:08 +0200
commit051eb7ca7cfe439c2155005937b80219a5e81c49 (patch)
tree7622583db45a9aaef5e40c6a9d549d44c9fc426e /tests/ui
parent617821ab32b7a7563f561812385e2fba7b1d2981 (diff)
Unlock trailing where-clauses for lazy type aliases
Diffstat (limited to 'tests/ui')
-rw-r--r--tests/ui/lazy-type-alias/leading-where-clause.fixed15
-rw-r--r--tests/ui/lazy-type-alias/leading-where-clause.rs16
-rw-r--r--tests/ui/lazy-type-alias/leading-where-clause.stderr16
-rw-r--r--tests/ui/lazy-type-alias/trailing-where-clause.rs13
-rw-r--r--tests/ui/lazy-type-alias/trailing-where-clause.stderr22
-rw-r--r--tests/ui/where-clauses/where-clause-placement-type-alias.stderr6
6 files changed, 86 insertions, 2 deletions
diff --git a/tests/ui/lazy-type-alias/leading-where-clause.fixed b/tests/ui/lazy-type-alias/leading-where-clause.fixed
new file mode 100644
index 00000000000..07ebc09b30e
--- /dev/null
+++ b/tests/ui/lazy-type-alias/leading-where-clause.fixed
@@ -0,0 +1,15 @@
+// run-rustfix
+
+#![feature(lazy_type_alias)]
+#![allow(incomplete_features)]
+
+// Check that we *reject* leading where-clauses on lazy type aliases.
+
+type Alias<T>
+
+= T where String: From<T>;
+//~^^^ ERROR where clauses are not allowed before the type for type aliases
+
+fn main() {
+ let _: Alias<&str>;
+}
diff --git a/tests/ui/lazy-type-alias/leading-where-clause.rs b/tests/ui/lazy-type-alias/leading-where-clause.rs
new file mode 100644
index 00000000000..4a654293472
--- /dev/null
+++ b/tests/ui/lazy-type-alias/leading-where-clause.rs
@@ -0,0 +1,16 @@
+// run-rustfix
+
+#![feature(lazy_type_alias)]
+#![allow(incomplete_features)]
+
+// Check that we *reject* leading where-clauses on lazy type aliases.
+
+type Alias<T>
+where
+ String: From<T>,
+= T;
+//~^^^ ERROR where clauses are not allowed before the type for type aliases
+
+fn main() {
+ let _: Alias<&str>;
+}
diff --git a/tests/ui/lazy-type-alias/leading-where-clause.stderr b/tests/ui/lazy-type-alias/leading-where-clause.stderr
new file mode 100644
index 00000000000..8ddf0ce6c65
--- /dev/null
+++ b/tests/ui/lazy-type-alias/leading-where-clause.stderr
@@ -0,0 +1,16 @@
+error: where clauses are not allowed before the type for type aliases
+ --> $DIR/leading-where-clause.rs:9:1
+ |
+LL | / where
+LL | | String: From<T>,
+ | |____________________^
+ |
+ = 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 +
+LL ~ = T where String: From<T>;
+ |
+
+error: aborting due to previous error
+
diff --git a/tests/ui/lazy-type-alias/trailing-where-clause.rs b/tests/ui/lazy-type-alias/trailing-where-clause.rs
new file mode 100644
index 00000000000..ac9598fe5f6
--- /dev/null
+++ b/tests/ui/lazy-type-alias/trailing-where-clause.rs
@@ -0,0 +1,13 @@
+#![feature(lazy_type_alias)]
+#![allow(incomplete_features)]
+
+// Check that we allow & respect trailing where-clauses on lazy type aliases.
+
+type Alias<T> = T
+where
+ String: From<T>;
+
+fn main() {
+ let _: Alias<&str>;
+ let _: Alias<()>; //~ ERROR the trait bound `String: From<()>` is not satisfied
+}
diff --git a/tests/ui/lazy-type-alias/trailing-where-clause.stderr b/tests/ui/lazy-type-alias/trailing-where-clause.stderr
new file mode 100644
index 00000000000..d7606ba6b2a
--- /dev/null
+++ b/tests/ui/lazy-type-alias/trailing-where-clause.stderr
@@ -0,0 +1,22 @@
+error[E0277]: the trait bound `String: From<()>` is not satisfied
+ --> $DIR/trailing-where-clause.rs:12:12
+ |
+LL | let _: Alias<()>;
+ | ^^^^^^^^^ the trait `From<()>` is not implemented for `String`
+ |
+ = help: the following other types implement trait `From<T>`:
+ <String as From<char>>
+ <String as From<Box<str>>>
+ <String as From<Cow<'a, str>>>
+ <String as From<&str>>
+ <String as From<&mut str>>
+ <String as From<&String>>
+note: required by a bound on the type alias `Alias`
+ --> $DIR/trailing-where-clause.rs:8:13
+ |
+LL | String: From<T>;
+ | ^^^^^^^ required by this bound
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/where-clauses/where-clause-placement-type-alias.stderr b/tests/ui/where-clauses/where-clause-placement-type-alias.stderr
index b3c155a48dd..d341148b04c 100644
--- a/tests/ui/where-clauses/where-clause-placement-type-alias.stderr
+++ b/tests/ui/where-clauses/where-clause-placement-type-alias.stderr
@@ -4,7 +4,8 @@ error: where clauses are not allowed after the type for type aliases
LL | type Bar = () where u32: Copy;
| ^^^^^^^^^^^^^^^
|
- = note: see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information
+ = 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
@@ -12,7 +13,8 @@ error: where clauses are not allowed after the type for type aliases
LL | type Baz = () where;
| ^^^^^
|
- = note: see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information
+ = 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