-
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.
forbid
impl Trait
in generic param defaults
- Loading branch information
Showing
5 changed files
with
134 additions
and
66 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
12 changes: 12 additions & 0 deletions
12
src/test/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.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,12 @@ | ||
struct Foo<T = impl Copy>(T); | ||
//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types | ||
|
||
type Result<T, E = impl std::error::Error> = std::result::Result<T, E>; | ||
//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types | ||
|
||
// should not cause ICE | ||
fn x() -> Foo { | ||
Foo(0) | ||
} | ||
|
||
fn main() -> Result<()> {} |
15 changes: 15 additions & 0 deletions
15
src/test/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.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,15 @@ | ||
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types | ||
--> $DIR/issue-83929-impl-trait-in-generic-default.rs:1:16 | ||
| | ||
LL | struct Foo<T = impl Copy>(T); | ||
| ^^^^^^^^^ | ||
|
||
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types | ||
--> $DIR/issue-83929-impl-trait-in-generic-default.rs:4:20 | ||
| | ||
LL | type Result<T, E = impl std::error::Error> = std::result::Result<T, E>; | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0562`. |
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