-
-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Check associated const binding types #161131
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
Open
YUZHEthefool
wants to merge
1
commit into
rust-lang:main
Choose a base branch
from
YUZHEthefool:issue-161100
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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
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
15 changes: 15 additions & 0 deletions
15
tests/ui/const-generics/associated-const-bindings/associated-type-bound-issue-161100.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,15 @@ | ||
| //@ compile-flags: -Znext-solver=globally | ||
|
|
||
| #![feature(generic_const_args, min_generic_const_args)] | ||
| #![allow(incomplete_features)] | ||
|
|
||
| trait Trait { | ||
| const F: fn(); | ||
| } | ||
|
|
||
| trait Nested { | ||
| type Out: Trait<F = { || {} }>; | ||
| //~^ ERROR using function pointers as const generic parameters is forbidden | ||
| } | ||
|
|
||
| fn main() {} |
9 changes: 9 additions & 0 deletions
9
tests/ui/const-generics/associated-const-bindings/associated-type-bound-issue-161100.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,9 @@ | ||
| error[E0741]: using function pointers as const generic parameters is forbidden | ||
| --> $DIR/associated-type-bound-issue-161100.rs:11:21 | ||
| | | ||
| LL | type Out: Trait<F = { || {} }>; | ||
| | ^^^^^^^^^^^^^ | ||
|
|
||
| error: aborting due to 1 previous error | ||
|
|
||
| For more information about this error, try `rustc --explain E0741`. |
15 changes: 15 additions & 0 deletions
15
...-generics/associated-const-bindings/direct-const-item-associated-equality-issue-161100.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,15 @@ | ||
| //@ compile-flags: -Znext-solver=globally | ||
|
|
||
| #![feature(generic_const_args, min_generic_const_args)] | ||
|
|
||
| struct S; | ||
| const C: S = S; | ||
|
|
||
| trait Trait { | ||
| const F: S; | ||
| } | ||
|
|
||
| fn take(_: impl Trait<F = { core::direct_const_arg!(C) }>) {} | ||
| //~^ ERROR `S` must implement `ConstParamTy` | ||
|
|
||
| fn main() {} |
15 changes: 15 additions & 0 deletions
15
...erics/associated-const-bindings/direct-const-item-associated-equality-issue-161100.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,15 @@ | ||
| error[E0741]: `S` must implement `ConstParamTy` to be used as the type of a const generic parameter | ||
| --> $DIR/direct-const-item-associated-equality-issue-161100.rs:12:23 | ||
| | | ||
| LL | fn take(_: impl Trait<F = { core::direct_const_arg!(C) }>) {} | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| help: add `#[derive(ConstParamTy, PartialEq, Eq)]` to the struct | ||
| | | ||
| LL + #[derive(ConstParamTy, PartialEq, Eq)] | ||
| LL | struct S; | ||
| | | ||
|
|
||
| error: aborting due to 1 previous error | ||
|
|
||
| For more information about this error, try `rustc --explain E0741`. |
13 changes: 13 additions & 0 deletions
13
tests/ui/const-generics/associated-const-bindings/fn-ptr-const-param-issue-161100.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,13 @@ | ||
| //@ compile-flags: -Znext-solver=globally | ||
|
|
||
| #![feature(generic_const_args)] | ||
| #![feature(min_generic_const_args)] | ||
|
|
||
| trait Trait { | ||
| const F: fn(); | ||
| } | ||
|
|
||
| fn take(_: impl Trait<F = { || {} }>) {} | ||
| //~^ ERROR using function pointers as const generic parameters is forbidden | ||
|
|
||
| fn main() {} |
9 changes: 9 additions & 0 deletions
9
tests/ui/const-generics/associated-const-bindings/fn-ptr-const-param-issue-161100.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,9 @@ | ||
| error[E0741]: using function pointers as const generic parameters is forbidden | ||
| --> $DIR/fn-ptr-const-param-issue-161100.rs:10:23 | ||
| | | ||
| LL | fn take(_: impl Trait<F = { || {} }>) {} | ||
| | ^^^^^^^^^^^^^ | ||
|
|
||
| error: aborting due to 1 previous error | ||
|
|
||
| For more information about this error, try `rustc --explain E0741`. |
18 changes: 18 additions & 0 deletions
18
...cs/associated-const-bindings/non-const-param-ty-associated-const-equality-issue-161100.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,18 @@ | ||
| //@ compile-flags: -Znext-solver=globally | ||
|
|
||
| #![feature(generic_const_args)] | ||
| #![feature(min_generic_const_args)] | ||
|
|
||
| enum Foo { | ||
| Unit, | ||
| Function(fn()), | ||
| } | ||
|
|
||
| trait Trait { | ||
| const X: Foo; | ||
| } | ||
|
|
||
| fn unit(_: impl Trait<X = { Foo::Unit }>) {} | ||
| //~^ ERROR `Foo` must implement `ConstParamTy` | ||
|
|
||
| fn main() {} |
15 changes: 15 additions & 0 deletions
15
...ssociated-const-bindings/non-const-param-ty-associated-const-equality-issue-161100.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,15 @@ | ||
| error[E0741]: `Foo` must implement `ConstParamTy` to be used as the type of a const generic parameter | ||
| --> $DIR/non-const-param-ty-associated-const-equality-issue-161100.rs:15:23 | ||
| | | ||
| LL | fn unit(_: impl Trait<X = { Foo::Unit }>) {} | ||
| | ^^^^^^^^^^^^^^^^^ | ||
| | | ||
| help: add `#[derive(ConstParamTy, PartialEq, Eq)]` to the enum | ||
| | | ||
| LL + #[derive(ConstParamTy, PartialEq, Eq)] | ||
| LL | enum Foo { | ||
| | | ||
|
|
||
| error: aborting due to 1 previous error | ||
|
|
||
| For more information about this error, try `rustc --explain E0741`. |
12 changes: 12 additions & 0 deletions
12
tests/ui/const-generics/associated-const-bindings/where-clause-issue-161100.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,12 @@ | ||
| //@ compile-flags: -Znext-solver=globally | ||
|
|
||
| #![feature(generic_const_args, min_generic_const_args)] | ||
|
|
||
| trait Trait { | ||
| const F: fn(); | ||
| } | ||
|
|
||
| fn take<T>() where T: Trait<F = { || {} }> {} | ||
| //~^ ERROR using function pointers as const generic parameters is forbidden | ||
|
|
||
| fn main() {} |
9 changes: 9 additions & 0 deletions
9
tests/ui/const-generics/associated-const-bindings/where-clause-issue-161100.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,9 @@ | ||
| error[E0741]: using function pointers as const generic parameters is forbidden | ||
| --> $DIR/where-clause-issue-161100.rs:9:29 | ||
| | | ||
| LL | fn take<T>() where T: Trait<F = { || {} }> {} | ||
| | ^^^^^^^^^^^^^ | ||
|
|
||
| error: aborting due to 1 previous error | ||
|
|
||
| For more information about this error, try `rustc --explain E0741`. |
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.
We can add check for const type here, because we already check for type const in
check_type_constThere 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.
emm... seems this method no name
is_type_constI took a look, and it seems it should now be called
is_direct_const.