-
-
Notifications
You must be signed in to change notification settings - Fork 16.4k
reintroduce check RibKind::ConstParamTy did in direct consts #162842
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
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 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 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
38 changes: 0 additions & 38 deletions
38
tests/ui/const-generics/mgca/type_const-generic-param-in-type.gate.stderr
This file was deleted.
Oops, something went wrong.
69 changes: 44 additions & 25 deletions
69
tests/ui/const-generics/mgca/type_const-generic-param-in-type.nogate.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 |
|---|---|---|
| @@ -1,38 +1,57 @@ | ||
| error: anonymous constants referencing generics are not yet supported | ||
| --> $DIR/type_const-generic-param-in-type.rs:8:77 | ||
| error[E0770]: the type of const parameters must not depend on other generic parameters | ||
| --> $DIR/type_const-generic-param-in-type.rs:12:1 | ||
| | | ||
| LL | const FOO<T: core::marker::ConstParamTy_>: [T; 0] = core::direct_const_arg!(const { [] }); | ||
| | ^^^^^^^^^^^^ | ||
| LL | const FOO<T: core::marker::ConstParamTy_>: [T; 0] = core::direct_const_arg!([]); | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `[T; 0]` must not depend on other generic parameter | ||
|
|
||
| error: anonymous constants referencing generics are not yet supported | ||
| --> $DIR/type_const-generic-param-in-type.rs:11:62 | ||
| error[E0770]: the type of const parameters must not depend on other generic parameters | ||
| --> $DIR/type_const-generic-param-in-type.rs:15:1 | ||
| | | ||
| LL | const BAR<const N: usize>: [(); N] = core::direct_const_arg!(const { [] }); | ||
| | ^^^^^^^^^^^^ | ||
| LL | const BAR<const N: usize>: StructWithConstParam<N> = | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `StructWithConstParam<N>` must not depend on other generic parameter | ||
|
|
||
| error: anonymous constants with lifetimes in their type are not yet supported | ||
| --> $DIR/type_const-generic-param-in-type.rs:14:54 | ||
| error[E0770]: the type of const parameters must not depend on other generic parameters | ||
| --> $DIR/type_const-generic-param-in-type.rs:19:1 | ||
| | | ||
| LL | const BAZ<'a>: [&'a (); 0] = core::direct_const_arg!(const { [] }); | ||
| | ^^^^^^^^^^^^ | ||
| LL | const BAZ<'a>: [&'a (); 0] = core::direct_const_arg!([]); | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `[&'a (); 0]` must not depend on other generic parameter | ||
|
|
||
| error: anonymous constants referencing generics are not yet supported | ||
| --> $DIR/type_const-generic-param-in-type.rs:30:83 | ||
| error[E0770]: the type of const parameters must not depend on other generic parameters | ||
| --> $DIR/type_const-generic-param-in-type.rs:37:5 | ||
| | | ||
| LL | const ASSOC<T: core::marker::ConstParamTy_>: [T; 0] = core::direct_const_arg!(const { [] }); | ||
| | ^^^^^^^^^^^^ | ||
| LL | const ASSOC<T: core::marker::ConstParamTy_>: [T; 0] = core::direct_const_arg!([]); | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `[T; 0]` must not depend on other generic parameter | ||
|
|
||
| error: anonymous constants referencing generics are not yet supported | ||
| --> $DIR/type_const-generic-param-in-type.rs:33:74 | ||
| error[E0770]: the type of const parameters must not depend on other generic parameters | ||
| --> $DIR/type_const-generic-param-in-type.rs:40:5 | ||
| | | ||
| LL | const ASSOC_CONST<const N: usize>: [(); N] = core::direct_const_arg!(const { [] }); | ||
| | ^^^^^^^^^^^^ | ||
| LL | const ASSOC_CONST<const N: usize>: StructWithConstParam<N> = | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `StructWithConstParam<N>` must not depend on other generic parameter | ||
|
|
||
| error: anonymous constants with lifetimes in their type are not yet supported | ||
| --> $DIR/type_const-generic-param-in-type.rs:36:63 | ||
| error[E0770]: the type of const parameters must not depend on other generic parameters | ||
| --> $DIR/type_const-generic-param-in-type.rs:44:5 | ||
| | | ||
| LL | const ASSOC_LT<'a>: [&'a (); 0] = core::direct_const_arg!(const { [] }); | ||
| | ^^^^^^^^^^^^ | ||
| LL | const ASSOC_LT<'a>: [&'a (); 0] = core::direct_const_arg!([]); | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `[&'a (); 0]` must not depend on other generic parameter | ||
|
|
||
| error: aborting due to 6 previous errors | ||
| error[E0770]: the type of const parameters must not depend on other generic parameters | ||
| --> $DIR/type_const-generic-param-in-type.rs:24:5 | ||
| | | ||
| LL | const ASSOC<T: core::marker::ConstParamTy_>: [T; 0]; | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `[T; 0]` must not depend on other generic parameter | ||
|
|
||
| error[E0770]: the type of const parameters must not depend on other generic parameters | ||
| --> $DIR/type_const-generic-param-in-type.rs:28:5 | ||
| | | ||
| LL | const ASSOC_CONST<const N: usize>: StructWithConstParam<N>; | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `StructWithConstParam<N>` must not depend on other generic parameter | ||
|
|
||
| error[E0770]: the type of const parameters must not depend on other generic parameters | ||
| --> $DIR/type_const-generic-param-in-type.rs:32:5 | ||
| | | ||
| LL | const ASSOC_LT<'a>: [&'a (); 0]; | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `[&'a (); 0]` must not depend on other generic parameter | ||
|
|
||
| error: aborting due to 9 previous errors | ||
|
|
||
| For more information about this error, try `rustc --explain E0770`. |
40 changes: 24 additions & 16 deletions
40
tests/ui/const-generics/mgca/type_const-generic-param-in-type.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 |
|---|---|---|
| @@ -1,40 +1,48 @@ | ||
| //@ revisions: nogate gate | ||
| //@ [gate] check-fail | ||
| // FIXME(generic_const_parameter_types): this should pass | ||
| //@ [gate] check-pass | ||
| #![expect(incomplete_features)] | ||
| #![feature(adt_const_params, unsized_const_params, min_generic_const_args, generic_const_items)] | ||
| #![cfg_attr(gate, feature(generic_const_parameter_types))] | ||
|
|
||
| const FOO<T: core::marker::ConstParamTy_>: [T; 0] = core::direct_const_arg!(const { [] }); | ||
| //~^ ERROR anonymous constants referencing generics are not yet supported | ||
| use std::marker::ConstParamTy; | ||
|
|
||
| const BAR<const N: usize>: [(); N] = core::direct_const_arg!(const { [] }); | ||
| //~^ ERROR anonymous constants referencing generics are not yet supported | ||
| #[derive(ConstParamTy, PartialEq, Eq, Debug)] | ||
| struct StructWithConstParam<const N: usize>; | ||
|
|
||
| const BAZ<'a>: [&'a (); 0] = core::direct_const_arg!(const { [] }); | ||
| //~^ ERROR anonymous constants with lifetimes in their type are not yet supported | ||
| const FOO<T: core::marker::ConstParamTy_>: [T; 0] = core::direct_const_arg!([]); | ||
| //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters | ||
|
|
||
| const BAR<const N: usize>: StructWithConstParam<N> = | ||
| //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters | ||
| core::direct_const_arg!(StructWithConstParam::<N>); | ||
|
|
||
| const BAZ<'a>: [&'a (); 0] = core::direct_const_arg!([]); | ||
| //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters | ||
|
|
||
| trait Tr { | ||
| // FIXME(min_generic_const_args): These should error under [nogate] | ||
| #[rustc_always_gca] | ||
| const ASSOC<T: core::marker::ConstParamTy_>: [T; 0]; | ||
| //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters | ||
|
|
||
| #[rustc_always_gca] | ||
| const ASSOC_CONST<const N: usize>: [(); N]; | ||
| const ASSOC_CONST<const N: usize>: StructWithConstParam<N>; | ||
| //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters | ||
|
|
||
| #[rustc_always_gca] | ||
| const ASSOC_LT<'a>: [&'a (); 0]; | ||
| //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters | ||
| } | ||
|
|
||
| impl Tr for () { | ||
| const ASSOC<T: core::marker::ConstParamTy_>: [T; 0] = core::direct_const_arg!(const { [] }); | ||
| //~^ ERROR anonymous constants referencing generics are not yet supported | ||
| const ASSOC<T: core::marker::ConstParamTy_>: [T; 0] = core::direct_const_arg!([]); | ||
| //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters | ||
|
|
||
| const ASSOC_CONST<const N: usize>: [(); N] = core::direct_const_arg!(const { [] }); | ||
| //~^ ERROR anonymous constants referencing generics are not yet supported | ||
| const ASSOC_CONST<const N: usize>: StructWithConstParam<N> = | ||
| //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters | ||
| core::direct_const_arg!(StructWithConstParam::<N>); | ||
|
|
||
| const ASSOC_LT<'a>: [&'a (); 0] = core::direct_const_arg!(const { [] }); | ||
| //~^ ERROR anonymous constants with lifetimes in their type are not yet supported | ||
| const ASSOC_LT<'a>: [&'a (); 0] = core::direct_const_arg!([]); | ||
| //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters | ||
| } | ||
|
|
||
| fn main() {} |
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
20 changes: 4 additions & 16 deletions
20
tests/ui/generic-const-items/assoc-const-no-infer-ice-115806.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 |
|---|---|---|
| @@ -1,29 +1,17 @@ | ||
| error: anonymous constants with lifetimes in their type are not yet supported | ||
| --> $DIR/assoc-const-no-infer-ice-115806.rs:22:50 | ||
| | | ||
| LL | T: PinA<USART, A = { core::direct_const_arg!(const { &() }) }>, | ||
| | ^^^^^^^^^^^^^ | ||
|
|
||
| error[E0119]: conflicting implementations of trait `Pins<_>` for type `NoPin` | ||
| --> $DIR/assoc-const-no-infer-ice-115806.rs:19:1 | ||
| --> $DIR/assoc-const-no-infer-ice-115806.rs:18:1 | ||
| | | ||
| LL | impl<TA> Pins<TA> for NoPin {} | ||
| | --------------------------- first implementation here | ||
| ... | ||
| LL | / impl<USART, T> Pins<USART> for T | ||
| LL | | | ||
| LL | | where | ||
| LL | | T: PinA<USART, A = { core::direct_const_arg!(const { &() }) }>, | ||
| | |___________________________________________________________________^ conflicting implementation for `NoPin` | ||
| LL | | T: PinA<USART, A = { core::direct_const_arg!(const { &() }) }> | ||
| | |__________________________________________________________________^ conflicting implementation for `NoPin` | ||
| | | ||
| = note: downstream crates may implement trait `PinA<_>` for type `NoPin` | ||
|
|
||
| error: anonymous constants with lifetimes in their type are not yet supported | ||
| --> $DIR/assoc-const-no-infer-ice-115806.rs:13:52 | ||
| | | ||
| LL | const A: &'static () = core::direct_const_arg!(const { &() }); | ||
| | ^^^^^^^^^^^^^ | ||
|
|
||
| error: aborting due to 3 previous errors | ||
| error: aborting due to 1 previous error | ||
|
|
||
| For more information about this error, try `rustc --explain E0119`. |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a FIXME about how we might want to move this to
type_ofso we can returnErrorfromtype_ofif it references invalid paramsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.