-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deny some late-bound ty/ct in some positions, add tests
- Loading branch information
1 parent
bd3e324
commit 0162292
Showing
10 changed files
with
205 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// check-pass | ||
// Basic test that show's we can succesfully typeck a `for<T>` where clause. | ||
|
||
#![feature(non_lifetime_binders)] | ||
//~^ WARN the feature `non_lifetime_binders` is incomplete | ||
|
||
trait Trait {} | ||
|
||
impl<T: ?Sized> Trait for T {} | ||
|
||
fn foo() | ||
where | ||
for<T> T: Trait, | ||
{ | ||
} | ||
|
||
fn main() { | ||
foo(); | ||
} |
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,11 @@ | ||
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/basic.rs:4:12 | ||
| | ||
LL | #![feature(non_lifetime_binders)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #1 <https://github.com/rust-lang/rust/issues/1> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
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,23 @@ | ||
// Error reporting for where `for<T> T: Trait` doesn't hold | ||
|
||
#![feature(non_lifetime_binders)] | ||
//~^ WARN the feature `non_lifetime_binders` is incomplete | ||
|
||
trait Trait {} | ||
|
||
fn fail() | ||
where | ||
for<T> T: Trait, | ||
{} | ||
|
||
fn auto_trait() | ||
where | ||
for<T> T: Send, | ||
{} | ||
|
||
fn main() { | ||
fail(); | ||
//~^ ERROR the trait bound `T: Trait` is not satisfied | ||
auto_trait(); | ||
//~^ ERROR `T` cannot be sent between threads safely | ||
} |
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,43 @@ | ||
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/fail.rs:3:12 | ||
| | ||
LL | #![feature(non_lifetime_binders)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #1 <https://github.com/rust-lang/rust/issues/1> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
error[E0277]: the trait bound `T: Trait` is not satisfied | ||
--> $DIR/fail.rs:19:5 | ||
| | ||
LL | fail(); | ||
| ^^^^ the trait `Trait` is not implemented for `T` | ||
| | ||
note: required by a bound in `fail` | ||
--> $DIR/fail.rs:10:15 | ||
| | ||
LL | fn fail() | ||
| ---- required by a bound in this | ||
LL | where | ||
LL | for<T> T: Trait, | ||
| ^^^^^ required by this bound in `fail` | ||
|
||
error[E0277]: `T` cannot be sent between threads safely | ||
--> $DIR/fail.rs:21:5 | ||
| | ||
LL | auto_trait(); | ||
| ^^^^^^^^^^ `T` cannot be sent between threads safely | ||
| | ||
= help: the trait `Send` is not implemented for `T` | ||
note: required by a bound in `auto_trait` | ||
--> $DIR/fail.rs:15:15 | ||
| | ||
LL | fn auto_trait() | ||
| ---------- required by a bound in this | ||
LL | where | ||
LL | for<T> T: Send, | ||
| ^^^^ required by this bound in `auto_trait` | ||
|
||
error: aborting due to 2 previous errors; 1 warning emitted | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Tests to make sure that we reject polymorphic dyn trait. | ||
|
||
#![feature(non_lifetime_binders)] | ||
//~^ WARN the feature `non_lifetime_binders` is incomplete | ||
|
||
trait Test<T> {} | ||
|
||
fn foo() -> &'static dyn for<T> Test<T> { | ||
//~^ ERROR late-bound type parameter not allowed on trait object types | ||
todo!() | ||
} | ||
|
||
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,17 @@ | ||
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/on-dyn.rs:3:12 | ||
| | ||
LL | #![feature(non_lifetime_binders)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #1 <https://github.com/rust-lang/rust/issues/1> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
error: late-bound type parameter not allowed on trait object types | ||
--> $DIR/on-dyn.rs:8:30 | ||
| | ||
LL | fn foo() -> &'static dyn for<T> Test<T> { | ||
| ^ | ||
|
||
error: aborting due to previous error; 1 warning emitted | ||
|
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 @@ | ||
// Tests to make sure that we reject polymorphic fn ptrs. | ||
|
||
#![feature(non_lifetime_binders)] | ||
//~^ WARN the feature `non_lifetime_binders` is incomplete | ||
|
||
fn foo() -> for<T> fn(T) { | ||
//~^ ERROR late-bound type parameter not allowed on function pointer types | ||
todo!() | ||
} | ||
|
||
fn main() { | ||
foo()(1i32); | ||
} |
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,17 @@ | ||
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/on-ptr.rs:3:12 | ||
| | ||
LL | #![feature(non_lifetime_binders)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #1 <https://github.com/rust-lang/rust/issues/1> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
error: late-bound type parameter not allowed on function pointer types | ||
--> $DIR/on-ptr.rs:6:17 | ||
| | ||
LL | fn foo() -> for<T> fn(T) { | ||
| ^ | ||
|
||
error: aborting due to previous error; 1 warning emitted | ||
|