-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly check constrainedness of gen params in the presence of weak …
…alias types
- Loading branch information
Showing
9 changed files
with
101 additions
and
17 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
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,27 @@ | ||
// check-pass | ||
|
||
#![feature(lazy_type_alias)] | ||
#![allow(incomplete_features)] | ||
|
||
type Injective<T> = Local<T>; | ||
struct Local<T>(T); | ||
|
||
impl<T> Injective<T> { | ||
fn take(_: T) {} | ||
} | ||
|
||
trait Trait { | ||
type Out; | ||
fn produce() -> Self::Out; | ||
} | ||
|
||
impl<T: Default> Trait for Injective<T> { | ||
type Out = T; | ||
fn produce() -> Self::Out { T::default() } | ||
} | ||
|
||
fn main() { | ||
Injective::take(0); | ||
let _: String = Injective::produce(); | ||
let _: bool = Local::produce(); | ||
} |
8 changes: 8 additions & 0 deletions
8
tests/ui/lazy-type-alias/unconstrained-param-due-to-overflow.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 @@ | ||
#![feature(lazy_type_alias)] | ||
#![allow(incomplete_features)] | ||
|
||
impl<T> Loop<T> {} //~ ERROR the type parameter `T` is not constrained | ||
|
||
type Loop<T> = Loop<T>; | ||
|
||
fn main() {} |
9 changes: 9 additions & 0 deletions
9
tests/ui/lazy-type-alias/unconstrained-param-due-to-overflow.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,9 @@ | ||
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates | ||
--> $DIR/unconstrained-param-due-to-overflow.rs:4:6 | ||
| | ||
LL | impl<T> Loop<T> {} | ||
| ^ unconstrained type parameter | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0207`. |
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,12 @@ | ||
#![feature(lazy_type_alias)] | ||
#![allow(incomplete_features)] | ||
|
||
impl<T> NotInjective<T> {} //~ ERROR the type parameter `T` is not constrained | ||
|
||
type NotInjective<T: ?Sized> = Local<<T as Discard>::Out>; | ||
struct Local<T>(T); | ||
|
||
trait Discard { type Out; } | ||
impl<T: ?Sized> Discard for T { type Out = (); } | ||
|
||
fn main() {} |
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,9 @@ | ||
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates | ||
--> $DIR/unconstrained-params.rs:4:6 | ||
| | ||
LL | impl<T> NotInjective<T> {} | ||
| ^ unconstrained type parameter | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0207`. |