-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
MGCA: Const constructors support #150704
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
Merged
MGCA: Const constructors support #150704
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
tests/rustdoc/constant/ice-associated-const-equality-105952.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,20 @@ | ||
| //! Regression test for <https://github.com/rust-lang/rust/issues/105952> | ||
|
|
||
| #![crate_name = "foo"] | ||
| #![feature(min_generic_const_args, adt_const_params)] | ||
| #![expect(incomplete_features)] | ||
| use std::marker::ConstParamTy; | ||
|
|
||
| #[derive(PartialEq, Eq, ConstParamTy)] | ||
| pub enum ParseMode { | ||
| Raw, | ||
| } | ||
| pub trait Parse { | ||
| #[type_const] | ||
| const PARSE_MODE: ParseMode; | ||
| } | ||
| pub trait RenderRaw {} | ||
|
|
||
| //@ hasraw foo/trait.RenderRaw.html 'impl' | ||
| //@ hasraw foo/trait.RenderRaw.html 'ParseMode::Raw' | ||
| impl<T: Parse<PARSE_MODE = { ParseMode::Raw }>> RenderRaw for T {} |
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, adt_const_params)] | ||
| #![expect(incomplete_features)] | ||
| use std::marker::ConstParamTy; | ||
|
|
||
| #[derive(ConstParamTy, PartialEq, Eq)] | ||
| struct U; | ||
|
|
||
| #[derive(ConstParamTy, PartialEq, Eq)] | ||
| //~^ ERROR overflow evaluating the requirement `S<U> well-formed` | ||
| //~| ERROR overflow evaluating the requirement `S<U> well-formed` | ||
|
|
||
| struct S<const N: U>() | ||
| where | ||
| S<{ U }>:; | ||
| //~^ ERROR overflow evaluating the requirement `S<U> well-formed` | ||
| //~| ERROR overflow evaluating the requirement `S<U> well-formed` | ||
| //~| ERROR overflow evaluating the requirement `S<U> well-formed` | ||
|
|
||
| fn main() {} |
80 changes: 80 additions & 0 deletions
80
tests/ui/const-generics/mgca/const-ctor-overflow-eval.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,80 @@ | ||
| error[E0275]: overflow evaluating the requirement `S<U> well-formed` | ||
| --> $DIR/const-ctor-overflow-eval.rs:14:5 | ||
| | | ||
| LL | S<{ U }>:; | ||
| | ^^^^^^^^ | ||
| | | ||
| note: required by a bound in `S` | ||
| --> $DIR/const-ctor-overflow-eval.rs:14:5 | ||
| | | ||
| LL | struct S<const N: U>() | ||
| | - required by a bound in this struct | ||
| LL | where | ||
| LL | S<{ U }>:; | ||
| | ^^^^^^^^ required by this bound in `S` | ||
|
|
||
| error[E0275]: overflow evaluating the requirement `S<U> well-formed` | ||
| --> $DIR/const-ctor-overflow-eval.rs:14:5 | ||
| | | ||
| LL | S<{ U }>:; | ||
| | ^^^^^^^^ | ||
| | | ||
| note: required by a bound in `S` | ||
| --> $DIR/const-ctor-overflow-eval.rs:14:5 | ||
| | | ||
| LL | struct S<const N: U>() | ||
| | - required by a bound in this struct | ||
| LL | where | ||
| LL | S<{ U }>:; | ||
| | ^^^^^^^^ required by this bound in `S` | ||
| = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
|
||
| error[E0275]: overflow evaluating the requirement `S<U> well-formed` | ||
| --> $DIR/const-ctor-overflow-eval.rs:14:5 | ||
| | | ||
| LL | S<{ U }>:; | ||
| | ^^^^^^^^ | ||
| | | ||
| note: required by a bound in `S` | ||
| --> $DIR/const-ctor-overflow-eval.rs:14:5 | ||
| | | ||
| LL | struct S<const N: U>() | ||
| | - required by a bound in this struct | ||
| LL | where | ||
| LL | S<{ U }>:; | ||
| | ^^^^^^^^ required by this bound in `S` | ||
| = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
|
||
| error[E0275]: overflow evaluating the requirement `S<U> well-formed` | ||
| --> $DIR/const-ctor-overflow-eval.rs:8:24 | ||
| | | ||
| LL | #[derive(ConstParamTy, PartialEq, Eq)] | ||
| | ^^^^^^^^^ | ||
| | | ||
| note: required by a bound in `S` | ||
| --> $DIR/const-ctor-overflow-eval.rs:14:5 | ||
| | | ||
| LL | struct S<const N: U>() | ||
| | - required by a bound in this struct | ||
| LL | where | ||
| LL | S<{ U }>:; | ||
| | ^^^^^^^^ required by this bound in `S` | ||
|
|
||
| error[E0275]: overflow evaluating the requirement `S<U> well-formed` | ||
| --> $DIR/const-ctor-overflow-eval.rs:8:35 | ||
| | | ||
| LL | #[derive(ConstParamTy, PartialEq, Eq)] | ||
| | ^^ | ||
| | | ||
| note: required by a bound in `S` | ||
| --> $DIR/const-ctor-overflow-eval.rs:14:5 | ||
| | | ||
| LL | struct S<const N: U>() | ||
| | - required by a bound in this struct | ||
| LL | where | ||
| LL | S<{ U }>:; | ||
| | ^^^^^^^^ required by this bound in `S` | ||
|
|
||
| error: aborting due to 5 previous errors | ||
|
|
||
| For more information about this error, try `rustc --explain E0275`. |
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 @@ | ||
| // to ensure it does not ices like before | ||
|
|
||
| #![feature(min_generic_const_args, adt_const_params)] | ||
| #![expect(incomplete_features)] | ||
| use std::marker::ConstParamTy; | ||
|
|
||
| #[derive(ConstParamTy, PartialEq, Eq)] | ||
| enum Option<T> { | ||
| #[allow(dead_code)] | ||
| Some(T), | ||
| None, | ||
| } | ||
|
|
||
| fn pass_enum<const P: Option<u32>>() {} | ||
|
|
||
| fn main() { | ||
| pass_enum::<{ None }>(); | ||
| //~^ ERROR missing generics for enum `std::option::Option` | ||
| } | ||
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,14 @@ | ||
| error[E0107]: missing generics for enum `std::option::Option` | ||
| --> $DIR/const-ctor-with-error.rs:17:19 | ||
| | | ||
| LL | pass_enum::<{ None }>(); | ||
| | ^^^^ expected 1 generic argument | ||
| | | ||
| help: add missing generic argument | ||
| | | ||
| LL | pass_enum::<{ None<T> }>(); | ||
| | +++ | ||
|
|
||
| error: aborting due to 1 previous error | ||
|
|
||
| For more information about this error, try `rustc --explain E0107`. |
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,49 @@ | ||
| //! Regression test for <https://github.com/rust-lang/rust/issues/139596> | ||
| //! <https://github.com/rust-lang/rust/issues/136138> | ||
| //! <https://github.com/rust-lang/rust/issues/132985> | ||
|
|
||
| //@ check-pass | ||
|
|
||
| #![feature( | ||
| min_generic_const_args, | ||
| adt_const_params, | ||
| generic_const_parameter_types, | ||
| unsized_const_params | ||
| )] | ||
| #![expect(incomplete_features)] | ||
| use std::marker::{ConstParamTy, ConstParamTy_}; | ||
| #[derive(ConstParamTy, PartialEq, Eq)] | ||
| struct Colour; | ||
|
|
||
| #[derive(ConstParamTy, PartialEq, Eq)] | ||
| enum A { | ||
| B, | ||
| } | ||
|
|
||
| #[derive(ConstParamTy, PartialEq, Eq)] | ||
| enum MyOption<T> { | ||
| #[allow(dead_code)] | ||
| Some(T), | ||
| None, | ||
| } | ||
|
|
||
| #[derive(ConstParamTy, PartialEq, Eq)] | ||
| struct Led<const C: Colour>; | ||
|
|
||
| #[derive(Eq, PartialEq, ConstParamTy)] | ||
| struct Foo<const N: usize>; | ||
|
|
||
| fn pass_enum<const P: MyOption<u32>>() {} | ||
|
|
||
| fn accepts_foo<const N: usize, const M: Foo<N>>() {} | ||
|
|
||
| fn accepts_bar<T: ConstParamTy_, const B: MyOption<T>>() {} | ||
|
|
||
| fn test<T: ConstParamTy_, const N: usize>() { | ||
| accepts_foo::<N, { Foo::<N> }>(); | ||
| accepts_bar::<T, { MyOption::None::<T> }>(); | ||
| } | ||
|
|
||
| fn main() { | ||
| Led::<{ Colour }>; | ||
| } |
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.