forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#83935 - SNCPlay42:param-default-impl-trait,…
… r=varkor forbid `impl Trait` in generic param defaults Fixes rust-lang#83929 Forbid using `impl Trait` in the default types of generic parameters, e.g. `struct Foo<T = impl Trait>`. I assume this was never supposed to be allowed - it seems no UI test used it. Note that using `impl Trait` in this position did not hit a feature gate error; however, this *shouldn't* be a breaking change as any attempt to use it should have hit the ICE in rust-lang#83929 and/or failed to provide a defining use of the `impl Trait`.
- 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