-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
base: master
Are you sure you want to change the base?
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
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