-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 #114228 - fmease:wf-lazy-ty-aliases, r=oli-obk
Check lazy type aliases for well-formedness Previously we didn't check if `T: Mul` holds given lazy `type Alias<T> = <T as Mul>::Output;`. Now we do. It only makes sense. `@rustbot` label F-lazy_type_alias r? `@oli-obk`
- Loading branch information
Showing
8 changed files
with
55 additions
and
11 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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...alias/lazy-type-alias-enum-variant.stderr → tests/ui/lazy-type-alias/enum-variant.stderr
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
14 changes: 14 additions & 0 deletions
14
tests/ui/lazy-type-alias/type-alias-bounds-are-enforced.rs
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,14 @@ | ||
// Check that we don't issue the lint `type_alias_bounds` for | ||
// lazy type aliases since the bounds are indeed enforced. | ||
|
||
// check-pass | ||
|
||
#![feature(lazy_type_alias)] | ||
#![allow(incomplete_features)] | ||
#![deny(type_alias_bounds)] | ||
|
||
use std::ops::Mul; | ||
|
||
type Alias<T: Mul> = <T as Mul>::Output; | ||
|
||
fn main() {} |
8 changes: 8 additions & 0 deletions
8
tests/ui/lazy-type-alias/unsatisfied-bounds-type-alias-body.rs
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,8 @@ | ||
// Test that we check lazy type aliases for well-formedness. | ||
|
||
#![feature(lazy_type_alias)] | ||
#![allow(incomplete_features)] | ||
|
||
type Alias<T> = <T as std::ops::Mul>::Output; //~ ERROR cannot multiply `T` by `T` | ||
|
||
fn main() {} |
14 changes: 14 additions & 0 deletions
14
tests/ui/lazy-type-alias/unsatisfied-bounds-type-alias-body.stderr
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,14 @@ | ||
error[E0277]: cannot multiply `T` by `T` | ||
--> $DIR/unsatisfied-bounds-type-alias-body.rs:6:17 | ||
| | ||
LL | type Alias<T> = <T as std::ops::Mul>::Output; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `T * T` | ||
| | ||
help: consider restricting type parameter `T` | ||
| | ||
LL | type Alias<T: std::ops::Mul> = <T as std::ops::Mul>::Output; | ||
| +++++++++++++++ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |