-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Finalize repeat expr inference behaviour with inferred repeat counts #139635
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
Finalize repeat expr inference behaviour with inferred repeat counts #139635
Conversation
}; | ||
|
||
for (element, element_ty, count) in deferred_repeat_expr_checks { | ||
match count.kind() { |
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 changed this to an explicit match instead of the to_target_usize().is_none_or()
as the is_none_or
felt like somewhat subtle logic given the soundness sensitive nature of how we should be handling each variant 🤔
Background contextI would like to move forwards with stabilizing fn foo(a: &mut [u8; 32]) {
*a = [10; _];
} This introduces some complexities around handling the check that the element type implements
Forbid
|
Team member @BoxyUwU has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
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.
gamer
To my understanding this will not be necessary once we have stable marker traits, will it? At this point we could have #[marker]
trait NonConstValueRepeatExpr {}
impl<T: Copy, const N: usize> ValidRepeatExpr for [T; N] {}
impl<T> ValidRepeatExpr for [T; 0] {}
impl<T> ValidRepeatExpr for [T; 1] {} This would then need some diagnostics handling/ Given that marker traits aren't stable and their stabilization is blocked on the next-generation trait solver, I feel happy with this current approach of deferring them in HIR typeck. @rfcbot reviewed |
Indeed, "add a new obligation for repeat expr checks" can be replaced with "add a lang item'd trait in core" one day. should have put that in the FCP :) |
be56470
to
6296fda
Compare
☔ The latest upstream changes (presumably #140415) made this pull request unmergeable. Please resolve the merge conflicts. |
Reading through the summary (btw @BoxyUwU very nice), I was fairly concerned about special casing deferring Copy. But, given that it seems like the principled solution is marker traits, and I think that's something we will eventually get to, I'm okay with this. I would like a FIXME or an issue opened something so we have some way to know to come back to this with marker traits. But, checking my box. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
I'll make sure to open an issue once the FCP completes 🤔 and probably add a FIXME(#18439339393) in the source where we check the deferred checks |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
6296fda
to
186099c
Compare
Opened an issue to track looking at making inference around repeat expr counts stronger once marker traits are further along #140855. Also rebased. This should be ready now that the FCP is complete. |
186099c
to
def6263
Compare
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 after nits
def6263
to
cc10370
Compare
@bors r=lcnr |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#135562 (Add ignore value suggestion in closure body) - rust-lang#139635 (Finalize repeat expr inference behaviour with inferred repeat counts) - rust-lang#139668 (Handle regions equivalent to 'static in non_local_bounds) - rust-lang#140218 (HIR ty lowering: Clean up & refactor the lowering of type-relative paths) - rust-lang#140435 (use uX::from instead of _ as uX in non - const contexts) - rust-lang#141130 (rustc_on_unimplemented cleanups) - rust-lang#141286 (Querify `coroutine_hidden_types`) Failed merges: - rust-lang#140247 (Don't build `ParamEnv` and do trait solving in `ItemCtxt`s when lowering IATs) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#139635 - BoxyUwU:no_order_dependent_copy_checks, r=lcnr Finalize repeat expr inference behaviour with inferred repeat counts I believe this should be the last change of how repeat exprs are handled before it's finished for `generic_arg_infer`. Assuming we don't wind up deciding to replace this all with a new predicate kind :) This PR has three actual changes: - Always defer the checks to end of typeck even when generic arg infer is not enabled (needs an FCP) - Properly handle element exprs that are constants when the repeat count is inferred - "Isolate" each repeat expr check so that inference constraints from `Copy` goals dont affect other repeat expr checks resulting in weird order-dependent inference The commit history and tests should be relatively helpful for understanding this PR's impl. r? compiler-errors
I believe this should be the last change of how repeat exprs are handled before it's finished for
generic_arg_infer
. Assuming we don't wind up deciding to replace this all with a new predicate kind :)This PR has three actual changes:
Copy
goals dont affect other repeat expr checks resulting in weird order-dependent inferenceThe commit history and tests should be relatively helpful for understanding this PR's impl.
r? compiler-errors