-
-
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
base: main
Are you sure you want to change the base?
constify Iterator, take IV
#151281
Conversation
|
Some changes occurred in compiler/rustc_hir/src/attrs cc @jdonszelmann, @JonathanBrouwer Some changes occurred to the CTFE machinery Some changes occurred in compiler/rustc_passes/src/check_attr.rs cc @jdonszelmann, @JonathanBrouwer Some changes occurred in compiler/rustc_attr_parsing |
This comment has been minimized.
This comment has been minimized.
7bbe4b2 to
c068979
Compare
This comment has been minimized.
This comment has been minimized.
c068979 to
672348d
Compare
| /// ``` | ||
| #[inline] | ||
| #[unstable(feature = "iter_next_chunk", issue = "98326")] | ||
| #[rustc_non_const_trait_method] |
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.
Please also update the dev-guide docs to explain the attribute.
This comment has been minimized.
This comment has been minimized.
| rustc_non_const_trait_method, AttributeType::Normal, template!(Word), | ||
| ErrorFollowing, EncodeCrossCrate::No, | ||
| "`#[rustc_non_const_trait_method]` should only used by the standard library to mark trait methods \ | ||
| as non-const to allow large traits to easier transition to const" |
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.
"traits an easier transition" or "traits to transition more easily"
672348d to
aed44b6
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
The rustc-dev-guide subtree was changed. If this PR only touches the dev guide consider submitting a PR directly to rust-lang/rustc-dev-guide otherwise thank you for updating the dev guide with your changes. |
fa9f21b to
d8c7329
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as off-topic.
This comment was marked as off-topic.
|
r? @oli-obk
|
This comment was marked as resolved.
This comment was marked as resolved.
|
|
||
| impl const A for u8 { | ||
| fn a() {} | ||
| fn b() { println!("hello"); } |
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.
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
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.
r=me with review commits absorbed
Like its predecessors (#92433, #102225, #106541), this PR allows one to make
Iteratorimplementationsconst, and thus enables the ability to haveforloops inconstcontexts. I've also included constifyingOption as IntoIterator,option::IntoIter as Iteratoras a minimal dogfooding example.But unlike its predecessors, it uses a new attribute (not unsound anymore!) that prevents any
Iteratorextension methods from being called. This is intentionally made minimal for an initial approval, the fun stuff like.fold,Range as Iteratorcould be done later.cc @rust-lang/wg-const-eval, cc @oli-obk to review the compiler parts
cc #92476