Check lazy type aliases for well-formedness
This commit is contained in:
parent
2e0136a131
commit
0ca432844c
8 changed files with 55 additions and 11 deletions
18
tests/ui/lazy-type-alias/enum-variant.rs
Normal file
18
tests/ui/lazy-type-alias/enum-variant.rs
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Regression test for issue #113736.
|
||||
// check-pass
|
||||
|
||||
#![feature(lazy_type_alias)]
|
||||
//~^ WARN the feature `lazy_type_alias` is incomplete and may not be safe to use
|
||||
|
||||
enum Enum {
|
||||
Unit,
|
||||
Tuple(),
|
||||
Struct {},
|
||||
}
|
||||
|
||||
fn main() {
|
||||
type Alias = Enum;
|
||||
let _ = Alias::Unit;
|
||||
let _ = Alias::Tuple();
|
||||
let _ = Alias::Struct {};
|
||||
}
|
11
tests/ui/lazy-type-alias/enum-variant.stderr
Normal file
11
tests/ui/lazy-type-alias/enum-variant.stderr
Normal file
|
@ -0,0 +1,11 @@
|
|||
warning: the feature `lazy_type_alias` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/enum-variant.rs:4:12
|
||||
|
|
||||
LL | #![feature(lazy_type_alias)]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
14
tests/ui/lazy-type-alias/type-alias-bounds-are-enforced.rs
Normal file
14
tests/ui/lazy-type-alias/type-alias-bounds-are-enforced.rs
Normal file
|
@ -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() {}
|
|
@ -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() {}
|
|
@ -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`.
|
Loading…
Add table
Add a link
Reference in a new issue