-
-
Notifications
You must be signed in to change notification settings - Fork 15k
fix(mgca): Allow specifying generic args (of enum) on enum itself in unit & tuple variant constructions in (direct) const args #155198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+115
−11
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
19 changes: 19 additions & 0 deletions
19
tests/ui/const-generics/mgca/generic-args-on-enum-variant-segments-fail.rs
This file contains hidden or 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 @@ | ||
| #![feature(min_generic_const_args)] | ||
| #![feature(adt_const_params, unsized_const_params)] | ||
| #[derive(PartialEq, Eq, std::marker::ConstParamTy)] | ||
| pub enum Enum<T> { | ||
| Unit, | ||
| Tuple(), | ||
| Store(T), | ||
| } | ||
| pub mod module { | ||
| pub use super::Enum::Store; | ||
| } | ||
| fn main() { | ||
| type const _: Enum<()> = Enum::<()>::Unit::<()>; | ||
| //~^ ERROR: type arguments are not allowed on unit variant `Unit` [E0109] | ||
| type const _: Enum<()> = Enum::<()>::Tuple::<()>(); | ||
| //~^ ERROR: type arguments are not allowed on tuple variant `Tuple` [E0109] | ||
| type const _: Enum<()> = self::<i32>::Enum::<()>::Store; | ||
| //~^ ERROR: type arguments are not allowed on module `generic_args_on_enum_variant_segments_fail` [E0109] | ||
| } |
41 changes: 41 additions & 0 deletions
41
tests/ui/const-generics/mgca/generic-args-on-enum-variant-segments-fail.stderr
This file contains hidden or 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,41 @@ | ||
| error[E0109]: type arguments are not allowed on unit variant `Unit` | ||
| --> $DIR/generic-args-on-enum-variant-segments-fail.rs:13:49 | ||
| | | ||
| LL | type const _: Enum<()> = Enum::<()>::Unit::<()>; | ||
| | ---- ^^ type argument not allowed | ||
| | | | ||
| | not allowed on unit variant `Unit` | ||
| | | ||
| = note: generic arguments are not allowed on both an enum and its variant's path segments simultaneously; they are only valid in one place or the other | ||
| help: remove the generics arguments from one of the path segments | ||
| | | ||
| LL - type const _: Enum<()> = Enum::<()>::Unit::<()>; | ||
| LL + type const _: Enum<()> = Enum::<()>::Unit; | ||
| | | ||
|
|
||
| error[E0109]: type arguments are not allowed on tuple variant `Tuple` | ||
| --> $DIR/generic-args-on-enum-variant-segments-fail.rs:15:50 | ||
| | | ||
| LL | type const _: Enum<()> = Enum::<()>::Tuple::<()>(); | ||
| | ----- ^^ type argument not allowed | ||
| | | | ||
| | not allowed on tuple variant `Tuple` | ||
| | | ||
| = note: generic arguments are not allowed on both an enum and its variant's path segments simultaneously; they are only valid in one place or the other | ||
| help: remove the generics arguments from one of the path segments | ||
| | | ||
| LL - type const _: Enum<()> = Enum::<()>::Tuple::<()>(); | ||
| LL + type const _: Enum<()> = Enum::<()>::Tuple(); | ||
| | | ||
|
|
||
| error[E0109]: type arguments are not allowed on module `generic_args_on_enum_variant_segments_fail` | ||
| --> $DIR/generic-args-on-enum-variant-segments-fail.rs:17:37 | ||
| | | ||
| LL | type const _: Enum<()> = self::<i32>::Enum::<()>::Store; | ||
| | ---- ^^^ type argument not allowed | ||
| | | | ||
| | not allowed on module `generic_args_on_enum_variant_segments_fail` | ||
|
|
||
| error: aborting due to 3 previous errors | ||
|
|
||
| For more information about this error, try `rustc --explain E0109`. |
16 changes: 16 additions & 0 deletions
16
tests/ui/const-generics/mgca/generic-args-on-enum-variant-segments.rs
|
fmease marked this conversation as resolved.
fmease marked this conversation as resolved.
|
This file contains hidden or 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,16 @@ | ||
| //@ check-pass | ||
|
|
||
| #![feature(min_generic_const_args)] | ||
| #![feature(adt_const_params, unsized_const_params)] | ||
|
|
||
| #[derive(PartialEq, Eq, std::marker::ConstParamTy)] | ||
| enum Enum<T> { | ||
| Unit, | ||
| Tuple(), | ||
| Store(T), | ||
| } | ||
|
|
||
| type const _: Enum<()> = Enum::<()>::Unit; | ||
| type const _: Enum<()> = Enum::<()>::Tuple(); | ||
|
|
||
| fn main() {} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.