-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Add diagnostic item for std::iter::Iterator::enumerate
#124542
Merged
bors
merged 1 commit into
rust-lang:master
from
CBSpeir:diagnostic-item-enumerate-method
May 1, 2024
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 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 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
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.
Maybe a silly question, but why
not(test)
?A quick
rg rustc_diagnostic_item library
shows lots with, but also lots without, and I don't understand why.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.
The Rust Compiler Development Guide explains, not including
not(test)
can cause compilation errors while running some tests. It goes on to say it's okay to add it as a preventative measure for all diagnostic items.I did not test whether this specific diagnostic item causes any testing compilation errors. I will look into this further to determine if it does.
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.
I ran
./x test
, which I believe runs all tests given my current configuration. There were no failures withnot(test)
removed.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.
The
cfg(not(test))
is required inalloc
andstd
, but not incore
.This is because
alloc
andstd
contain some unit#[test]
s as part of the library crates and the crates therefore have to be compiled twice: Once as a library as a dependency of thetest
crate (which contains the default test runner) and once as an executable that imports thetest
crate.When the crates are compiled twice and the diagnostic items don't have
cfg(not(test))
, then we get an error that the diagnostic items are defined multiple times. (The same also happens for lang items.)The
core
package explicitly doesn't test its library crate and only has integration tests, so thecfg(not(test))
is not required there.rust/library/core/Cargo.toml
Lines 14 to 16 in 20aa2d8
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.
Since
cfg(not(test))
is not required for this diagnostic item, should I remove it? Or is it okay to leave it on as a preventative measure?