-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
constify Iterator, take IV
#151281
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
fee1-dead
wants to merge
4
commits into
rust-lang:main
Choose a base branch
from
fee1-dead-contrib:push-zmqtzvuvlmuk
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
constify Iterator, take IV
#151281
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,13 +10,22 @@ impl const A for () { | |
| fn a() {} | ||
| } | ||
|
|
||
| impl const A for u8 { | ||
| fn a() {} | ||
| fn b() { println!("hello"); } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs a test for impling the method constly. That's an odd situation, but not a problem since we don't allow stabilizing traits that have such methods |
||
| //~^ ERROR: cannot call non-const function | ||
| } | ||
|
|
||
| const fn foo<T: [const] A>() { | ||
| T::a(); | ||
| T::b(); | ||
| //~^ ERROR: cannot call non-const associated function | ||
| <()>::a(); | ||
| <()>::b(); | ||
| //~^ ERROR: cannot call non-const associated function | ||
| u8::a(); | ||
| u8::b(); | ||
| //~^ ERROR: cannot call non-const associated function | ||
| } | ||
|
|
||
| fn main() {} | ||
25 changes: 22 additions & 3 deletions
25
tests/ui/traits/const-traits/partial/no-const-callers.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,19 +1,38 @@ | ||
| error[E0015]: cannot call non-const function `std::io::_print` in constant functions | ||
| --> $DIR/no-const-callers.rs:15:14 | ||
| | | ||
| LL | fn b() { println!("hello"); } | ||
| | ^^^^^^^^^^^^^^^^^ | ||
| | | ||
| note: function `_print` is not const | ||
| --> $SRC_DIR/std/src/io/stdio.rs:LL:COL | ||
| = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
| = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
|
||
| error[E0015]: cannot call non-const associated function `<T as A>::b` in constant functions | ||
| --> $DIR/no-const-callers.rs:15:5 | ||
| --> $DIR/no-const-callers.rs:21:5 | ||
| | | ||
| LL | T::b(); | ||
| | ^^^^^^ | ||
| | | ||
| = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
|
|
||
| error[E0015]: cannot call non-const associated function `<() as A>::b` in constant functions | ||
| --> $DIR/no-const-callers.rs:18:5 | ||
| --> $DIR/no-const-callers.rs:24:5 | ||
| | | ||
| LL | <()>::b(); | ||
| | ^^^^^^^^^ | ||
| | | ||
| = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
|
|
||
| error: aborting due to 2 previous errors | ||
| error[E0015]: cannot call non-const associated function `<u8 as A>::b` in constant functions | ||
| --> $DIR/no-const-callers.rs:27:5 | ||
| | | ||
| LL | u8::b(); | ||
| | ^^^^^^^ | ||
| | | ||
| = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
|
|
||
| error: aborting due to 4 previous errors | ||
|
|
||
| For more information about this error, try `rustc --explain E0015`. |
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.