-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for illegal use bound syntax
- Loading branch information
1 parent
b1efe1a
commit f66558d
Showing
10 changed files
with
122 additions
and
5 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
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,4 @@ | ||
#![feature(precise_capturing)] | ||
|
||
fn dyn() -> &'static dyn use<> { &() } | ||
//~^ ERROR expected one of `!`, `(`, `::`, `<`, `where`, or `{`, found keyword `use` |
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 @@ | ||
error: expected one of `!`, `(`, `::`, `<`, `where`, or `{`, found keyword `use` | ||
--> $DIR/dyn-use.rs:3:26 | ||
| | ||
LL | fn dyn() -> &'static dyn use<> { &() } | ||
| ^^^ expected one of `!`, `(`, `::`, `<`, `where`, or `{` | ||
|
||
error: aborting due to 1 previous error | ||
|
11 changes: 11 additions & 0 deletions
11
tests/ui/impl-trait/precise-capturing/illegal-positions.pre_expansion.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,11 @@ | ||
warning: the feature `precise_capturing` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/illegal-positions.rs:5:12 | ||
| | ||
LL | #![feature(precise_capturing)] | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #123432 <https://github.com/rust-lang/rust/issues/123432> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
66 changes: 66 additions & 0 deletions
66
tests/ui/impl-trait/precise-capturing/illegal-positions.real.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,66 @@ | ||
error: `use<...>` precise capturing syntax not allowed in supertrait bounds | ||
--> $DIR/illegal-positions.rs:9:12 | ||
| | ||
LL | trait Foo: use<> { | ||
| ^^^^^ | ||
|
||
error: `use<...>` precise capturing syntax not allowed in bounds | ||
--> $DIR/illegal-positions.rs:11:33 | ||
| | ||
LL | type Assoc: use<> where (): use<>; | ||
| ^^^^^ | ||
|
||
error: `use<...>` precise capturing syntax not allowed in bounds | ||
--> $DIR/illegal-positions.rs:11:17 | ||
| | ||
LL | type Assoc: use<> where (): use<>; | ||
| ^^^^^ | ||
|
||
error: `use<...>` precise capturing syntax not allowed in bounds | ||
--> $DIR/illegal-positions.rs:17:11 | ||
| | ||
LL | fn fun<T: use<>>(_: impl use<>) where (): use<> {} | ||
| ^^^^^ | ||
|
||
error: `use<...>` precise capturing syntax not allowed in bounds | ||
--> $DIR/illegal-positions.rs:17:43 | ||
| | ||
LL | fn fun<T: use<>>(_: impl use<>) where (): use<> {} | ||
| ^^^^^ | ||
|
||
error: at least one trait must be specified | ||
--> $DIR/illegal-positions.rs:17:21 | ||
| | ||
LL | fn fun<T: use<>>(_: impl use<>) where (): use<> {} | ||
| ^^^^^^^^^^ | ||
|
||
error: `use<...>` precise capturing syntax not allowed in `dyn` trait object bounds | ||
--> $DIR/illegal-positions.rs:24:25 | ||
| | ||
LL | fn dynamic() -> Box<dyn use<>> {} | ||
| ^^^^^ | ||
|
||
warning: the feature `precise_capturing` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/illegal-positions.rs:5:12 | ||
| | ||
LL | #![feature(precise_capturing)] | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #123432 <https://github.com/rust-lang/rust/issues/123432> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
error: `use<...>` precise capturing syntax not allowed in argument-position `impl Trait` | ||
--> $DIR/illegal-positions.rs:17:26 | ||
| | ||
LL | fn fun<T: use<>>(_: impl use<>) where (): use<> {} | ||
| ^^^^^ | ||
|
||
error[E0224]: at least one trait is required for an object type | ||
--> $DIR/illegal-positions.rs:24:21 | ||
| | ||
LL | fn dynamic() -> Box<dyn use<>> {} | ||
| ^^^^^^^^^ | ||
|
||
error: aborting due to 9 previous errors; 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0224`. |
28 changes: 28 additions & 0 deletions
28
tests/ui/impl-trait/precise-capturing/illegal-positions.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,28 @@ | ||
//@ revisions: real pre_expansion | ||
//@[pre_expansion] check-pass | ||
//@ edition: 2021 | ||
|
||
#![feature(precise_capturing)] | ||
//~^ WARN the feature `precise_capturing` is incomplete | ||
|
||
#[cfg(real)] | ||
trait Foo: use<> { | ||
//[real]~^ ERROR `use<...>` precise capturing syntax not allowed | ||
type Assoc: use<> where (): use<>; | ||
//[real]~^ ERROR `use<...>` precise capturing syntax not allowed | ||
//[real]~| ERROR `use<...>` precise capturing syntax not allowed | ||
} | ||
|
||
#[cfg(real)] | ||
fn fun<T: use<>>(_: impl use<>) where (): use<> {} | ||
//[real]~^ ERROR `use<...>` precise capturing syntax not allowed | ||
//[real]~| ERROR `use<...>` precise capturing syntax not allowed | ||
//[real]~| ERROR `use<...>` precise capturing syntax not allowed | ||
//[real]~| ERROR at least one trait must be specified | ||
|
||
#[cfg(real)] | ||
fn dynamic() -> Box<dyn use<>> {} | ||
//[real]~^ ERROR `use<...>` precise capturing syntax not allowed in `dyn` trait object bounds | ||
//[real]~| ERROR at least one trait is required for an object type [E0224] | ||
|
||
fn main() {} |