diff options
author | León Orell Valerian Liehr <me@fmease.dev> | 2023-08-09 16:44:06 +0200 |
---|---|---|
committer | León Orell Valerian Liehr <me@fmease.dev> | 2023-08-10 16:13:08 +0200 |
commit | 051eb7ca7cfe439c2155005937b80219a5e81c49 (patch) | |
tree | 7622583db45a9aaef5e40c6a9d549d44c9fc426e /tests/ui/lazy-type-alias | |
parent | 617821ab32b7a7563f561812385e2fba7b1d2981 (diff) |
Unlock trailing where-clauses for lazy type aliases
Diffstat (limited to 'tests/ui/lazy-type-alias')
-rw-r--r-- | tests/ui/lazy-type-alias/leading-where-clause.fixed | 15 | ||||
-rw-r--r-- | tests/ui/lazy-type-alias/leading-where-clause.rs | 16 | ||||
-rw-r--r-- | tests/ui/lazy-type-alias/leading-where-clause.stderr | 16 | ||||
-rw-r--r-- | tests/ui/lazy-type-alias/trailing-where-clause.rs | 13 | ||||
-rw-r--r-- | tests/ui/lazy-type-alias/trailing-where-clause.stderr | 22 |
5 files changed, 82 insertions, 0 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`. |