forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#114662 - fmease:lazy-ty-aliases-unlock-trai…
…ling-wcs, r=oli-obk Unlock trailing where-clauses for lazy type aliases Allows trailing where-clauses on lazy type aliases and forbids[^1] leading ones. Completes rust-lang#89122 (see section *Top-level type aliases*). `@rustbot` label F-lazy_type_alias r? `@oli-obk` [^1]: This is absolutely fine since lazy type aliases are only meant to be stabilized as part of a new edition.
- Loading branch information
Showing
9 changed files
with
175 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters